/* tiles.css: round 4, the forest glass language. Floating hero data tiles over the
   3D house (build progress ring, spend sparkline, weeks-to-keys countdown), and the
   same deep tinted glass carried down the page: spec tiles, the process panel,
   project cards, quotes and the contact form, each with an in-view rise.
   Loaded after site.css; driven by js/tiles.js (hero) and js/ui.js (page).
   One warm accent (--acc) on charcoal-forest glass. Reduced motion: drawn, still. */

.fg, .hero-tiles {
  --acc: #e4a66c;
  --acc-rgb: 228 166 108;
  --fg-ink: #f1f0ea;
  --fg-ink-2: rgb(241 240 234 / .74);
  --fg-line: rgb(241 240 234 / .14);
}
.fg {
  --tint: rgb(22 31 27 / .8);
  position: relative; isolation: isolate;
  border: 1px solid transparent; border-radius: 22px;
  background:
    linear-gradient(var(--tint), var(--tint)) padding-box,
    linear-gradient(140deg, rgb(255 255 255 / .38), rgb(255 255 255 / .08) 45%, rgb(var(--acc-rgb) / .3)) border-box;
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .16),
    0 1px 2px rgb(12 18 16 / .12), 0 10px 24px -10px rgb(12 18 16 / .4), 0 44px 80px -36px rgb(12 18 16 / .6);
  color: var(--fg-ink);
}
.fg::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(360px circle at var(--mx, 18%) var(--my, -30%), rgb(255 255 255 / .12), transparent 60%), var(--grain);
  background-size: auto, 160px 160px;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .fg { --tint: rgb(22 31 27 / .95); } }
@media (prefers-reduced-transparency: reduce) {
  .fg { --tint: rgb(22 31 27); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .fg::before { display: none; }
}

/* ---------- hero tiles ---------- */
.hero-tiles { display: flex; gap: 10px; }
.hx {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l c" "v c" "s c";
  column-gap: 12px; align-items: center; padding: 12px 14px 12px 16px; border-radius: 24px; min-width: 0;
}
.hx-l { grid-area: l; display: flex; align-items: center; gap: 7px; font: 500 .7rem/1.1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-ink-2); white-space: nowrap; }
.hx-v { grid-area: v; display: flex; align-items: baseline; gap: 5px; margin-top: 4px; white-space: nowrap; }
.hx-v b { font: 500 2rem/1 var(--display); font-variant-numeric: tabular-nums; color: var(--fg-ink); }
.hx-v small { font: italic 400 .98rem/1 var(--text); color: var(--fg-ink-2); }
.hx-s { grid-area: s; margin-top: 4px; font: italic 400 .95rem/1.15 var(--text); color: var(--fg-ink-2); white-space: nowrap; }
.hx-c { grid-area: c; display: block; }
/* the spend tile's subtitle runs full width under its sparkline, so the riding dot never meets the text */
.hx:has(.hx-spark) { grid-template-areas: "l c" "v c" "s s"; }
.hx-live { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 0 0 rgb(var(--acc-rgb) / .5); flex: none; }
.mo .hx-live { animation: hx-pulse 2.6s ease-out infinite; }
@keyframes hx-pulse { 0% { box-shadow: 0 0 0 0 rgb(var(--acc-rgb) / .55); } 70%, 100% { box-shadow: 0 0 0 8px rgb(var(--acc-rgb) / 0); } }

/* progress ring */
.hx-ring { width: 64px; height: 64px; }
.hx-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.hx-ring circle { fill: none; stroke-width: 7; }
.hx-ring .trk { stroke: var(--fg-line); }
.hx-ring .val { stroke: var(--acc); stroke-linecap: round; stroke-dasharray: 100 200; stroke-dashoffset: calc(100 - var(--p, 0)); transition: stroke-dashoffset 1.5s var(--ease); }

/* spend sparkline: the line is revealed up to this week by a clip; a dot rides its end */
.hx-spark { position: relative; width: 104px; height: 52px; }
.hx-spark svg { width: 100%; height: 100%; overflow: visible; }
.hx-spark .bud { fill: none; stroke: var(--fg-ink-2); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.hx-spark .area { fill: rgb(var(--acc-rgb) / .2); }
.hx-spark .ln { fill: none; stroke: var(--acc); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hx-spark .reveal { clip-path: inset(-6px calc((1 - var(--f, 0)) * 100%) -6px 0); transition: clip-path 1.5s var(--ease); }
.hx-spark .dot {
  position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  left: calc(var(--f, 0) * 100%); top: var(--y, 100%); background: var(--acc); box-shadow: 0 0 0 3px rgb(22 31 27 / .9);
  transition: left 1.5s var(--ease), top 1.5s var(--ease);
}

/* weeks to keys: one bar per two weeks, the ones already built lit */
.hx-cal { display: grid; grid-template-columns: repeat(17, 1fr); gap: 2px; width: 104px; height: 44px; align-items: end; }
.hx-cal i { display: block; height: 40%; border-radius: 2px; background: var(--fg-line); transition: background-color .3s var(--ease) calc(var(--t) * 40ms), height .5s var(--ease) calc(var(--t) * 40ms); }
.hx-cal i.on { height: 100%; background: rgb(var(--acc-rgb) / .9); }
.hx-cal i.key { height: 100%; background: none; box-shadow: inset 0 0 0 1.5px var(--acc); }

/* undrawn until a tile plays (motion only) */
.mo .hx:not(.hx-on) .val { stroke-dashoffset: 100; }
.mo .hx:not(.hx-on) .reveal { clip-path: inset(-6px 100% -6px 0); }
.mo .hx:not(.hx-on) .dot { left: 0; top: 100%; }
.mo .hx:not(.hx-on) .hx-cal i.on { height: 40%; background: var(--fg-line); }

/* entrance, float, and the pointer lean (translate channel, separate from the keyframes) */
.mo .hx {
  animation: hx-in .9s var(--ease) calc(.6s + var(--k) * .15s) both, hx-float 7s ease-in-out calc(1.6s + var(--k) * 1.3s) infinite alternate;
  translate: calc(var(--px, 0) * var(--z, 1) * 1px) calc(var(--py, 0) * var(--z, 1) * 1px);
  transition: translate .6s var(--ease);
}
@keyframes hx-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes hx-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }

/* phones: the week pill gives way to a swipe row of compact tiles, one plus a peek */
@media (max-width: 767px) {
  .hud { display: none; }
  .hero-tiles {
    margin-inline: calc(var(--gutter) * -1); padding: 2px var(--gutter) 4px;
    overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter);
    overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x pan-y;
  }
  .hero-tiles::-webkit-scrollbar { display: none; }
  .hx { flex: 0 0 min(78vw, 320px); scroll-snap-align: start; padding: 10px 14px; border-radius: 20px; }
  .hx-v b { font-size: 1.7rem; }
  .hx-ring { width: 54px; height: 54px; }
  .hx-spark, .hx-cal { width: 92px; height: 42px; }
}
@media (max-width: 767px) and (max-height: 720px) {
  .hx-s { display: none; }
  .hx { padding-block: 9px; }
  .hx-v b { font-size: 1.5rem; }
  .hx-ring { width: 46px; height: 46px; }
  .hx-spark, .hx-cal { height: 36px; }
}
/* tablets: three across between the card and the step bar */
@media (min-width: 768px) and (max-width: 999px) {
  .hero__in { grid-template-rows: 1fr auto auto auto; }
  .hero-tiles { grid-column: 1 / -1; grid-row: 3; }
  .hero__bar { grid-row: 4; }
  .hx { flex: 1 1 0; }
  .hx-s { display: none; }
  /* a third of a tablet is too narrow for "$612k of $612k" beside a chart: the unit wraps
     under the number and the charts slim down, so no figure runs under a sparkline */
  .hx-v { flex-wrap: wrap; row-gap: 2px; }
  .hx-v b { font-size: 1.75rem; }
  .hx-spark, .hx-cal { width: 84px; }
}
/* desktop: a floating column on the right, over the house */
@media (min-width: 1000px) {
  .hero-tiles {
    position: absolute; right: var(--gutter); top: calc(var(--hdr-h) + 56px + 62px); z-index: 2;
    flex-direction: column; align-items: flex-end; gap: 14px; width: 300px;
  }
  /* r7: one aligned 300px column (the 284/292 stagger is gone, per the iOS widget reference) */
  .hx { width: 300px; }
}
@media (min-width: 1000px) and (max-height: 820px) {
  .hero-tiles { gap: 10px; }
  .hx-s { display: none; }
  .hx-ring { width: 54px; height: 54px; }
  .hx-spark, .hx-cal { height: 42px; }
}

/* ---------- through the page ---------- */
/* spec tiles over the configurator */
.tile.fg .tile__k, .tile.fg .tile__v small, .tile.fg .tile__f { color: var(--fg-ink-2); }
.tile.fg .phases i:nth-child(1) { background: #6f7c66; }
.tile.fg .phases i:nth-child(2) { background: #94a083; }
.tile.fg .phases i:nth-child(3) { background: #c2c7ad; }
.tile.fg .phases i:nth-child(4) { background: var(--acc); }
.tile.fg .gauge__trk { stroke: var(--fg-line); }
.tile.fg .gauge__val { stroke: var(--acc); }
@media (hover: hover) and (pointer: fine) {
  .tile.fg:hover { box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 14px 30px -10px rgb(12 18 16 / .5), 0 48px 84px -34px rgb(12 18 16 / .7); }
}

/* process panel, with a five-step meter */
.ppanel.fg { background:
    linear-gradient(var(--tint), var(--tint)) padding-box,
    linear-gradient(140deg, rgb(255 255 255 / .38), rgb(255 255 255 / .08) 45%, rgb(var(--acc-rgb) / .3)) border-box;
  border: 1px solid transparent; border-radius: 28px; --tint: rgb(29 43 37 / .94); }
.ppanel.fg .ppanel__k { color: var(--acc); }
.ppanel.fg p:not(.ppanel__k) { color: var(--fg-ink); }
.ppanel.fg .ppanel__list li { color: var(--fg-ink-2); }
.ppanel.fg .ppanel__list li::before { background: var(--acc); border-radius: 2px; }
.pmeter { display: flex; align-items: center; gap: 12px; margin-top: 26px; }
.pmeter span { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; flex: 1; max-width: 260px; }
.pmeter i { height: 8px; border-radius: 4px; background: var(--fg-line); overflow: hidden; }
.pmeter i::after { content: ""; display: block; height: 100%; background: var(--acc); transform: scaleX(0); transform-origin: 0 50%; }
.pmeter i.on::after { transform: scaleX(1); }
.pmeter i.now::after { animation: pm-grow .9s var(--ease) .2s both; }
@keyframes pm-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.pmeter b { font: 500 .78rem/1 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-ink-2); white-space: nowrap; }

/* project cards */
.proj.fg { padding: 10px 10px 16px; border-radius: 24px; }
.proj.fg img { border-radius: 16px; }
.proj.fg .proj__txt { padding: 14px 8px 0; }
.proj.fg p { color: var(--fg-ink-2); }
.proj.fg h3 { color: var(--fg-ink); }

/* quotes */
.quote.fg { border-radius: 26px; }
.quote.fg blockquote p { color: var(--fg-ink); }
.quote.fg blockquote p::before { color: var(--acc); }
.quote.fg .quote__who { color: var(--fg-ink); }
.quote.fg .quote__who span { color: var(--acc); }

/* contact form */
.form.fg { border-radius: 28px; }
.form.fg label { color: var(--fg-ink-2); }
.form.fg input, .form.fg textarea { background: rgb(246 245 240 / .97); border-color: transparent; }
.form.fg input:focus, .form.fg textarea:focus { outline-color: var(--acc); }
.form.fg .btn { background: var(--acc); color: #17201c; }
.form.fg .btn:hover { background: #efb986; }
.form.fg .form__status { color: var(--acc); }
.form.fg :focus-visible { outline-color: var(--acc); }

/* the shared in-view rise (only once JS has armed it) */
.io-on .io { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease) calc(var(--k, 0) * 90ms), transform .9s var(--ease) calc(var(--k, 0) * 90ms); }
.io-on .io.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .mo .hx, .mo .hx-live, .pmeter i.now::after { animation: none; translate: none; }
  .hx-ring .val, .hx-spark .reveal, .hx-spark .dot, .hx-cal i { transition: none; }
}
