/* ---------- home hero: a real project, scroll-driven (replaces the .viewport-s2b cathedral animation) ----------
   Default rules are the static layout (no JS, no WebGL2, reduced motion): poster + five steps with stills.
   .scan-live (set by the inline bootstrap before first paint) pins the viewer; as the visitor scrolls into the walkthrough
   the viewer grows to fill the screen and each step's text is shown inside it. */
.hero-scan .scan-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 0 56px; align-items: center; }
.hero-scan .hero-text { grid-column: 1; grid-row: 1; padding-block: 72px 80px; }
.scan-visual { display: contents; }
.viewport-scan { grid-column: 2; grid-row: 1; min-width: 0; height: auto; aspect-ratio: 5 / 4; overflow: hidden; background: var(--ink-0); }
.viewport-scan .scan-poster, .viewport-scan .scan-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewport-scan canvas { opacity: 0; transition: opacity .45s; }
.viewport-scan canvas.is-ready { opacity: 1; }
.viewport-scan .viewport-top, .viewport-scan .viewport-bottom { z-index: 2; align-items: center; }
/* labels sit on their own dark plate: their contrast must not depend on which points happen to be behind them */
.viewport-scan .viewport-top > span, .viewport-scan .s2b-count { padding: 4px 7px; background: rgba(8, 10, 11, .88); }
.viewport-scan .viewport-top > span:first-child { color: var(--soft-d); }
.viewport-scan .viewport-bottom { flex-direction: column; align-items: flex-start; gap: 10px; }
.viewport-scan .s2b-count { color: var(--text-d); text-align: left; white-space: normal; }
.s2b-steps a.scan-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border: 1px solid var(--line-d3); background: rgba(8, 10, 11, .88); color: var(--soft-d); letter-spacing: .06em; text-decoration: none; text-shadow: none; pointer-events: auto; transition: background .3s, color .3s, border-color .3s; }
.s2b-steps a.scan-chip:hover { border-color: var(--text-d); color: var(--text-d); }
.s2b-steps a.scan-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.s2b-steps a.scan-chip.done { color: var(--text-d); }
.scan-dim { position: absolute; left: 0; top: 0; z-index: 3; padding: 7px 10px; background: rgba(8, 10, 11, .9); border: 1px solid var(--accent); font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--soft-d); white-space: nowrap; pointer-events: none; will-change: transform; }
.scan-dim b { display: block; font-size: 15px; font-weight: 500; color: var(--text-d); }
.scan-dim b span { color: var(--accent); }
.viewport-scan .s2b-tree { z-index: 2; top: 46px; }
.scan-fps { position: absolute; right: 12px; top: 40px; z-index: 4; padding: 4px 7px; background: rgba(8, 10, 11, .9); border: 1px solid var(--line-d3); font-family: var(--mono); font-size: 11px; color: var(--text-d); pointer-events: none; }

.scan-story { grid-column: 1 / -1; grid-row: 2; min-width: 0; padding-bottom: 80px; }
.scan-steps { margin: 24px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px; }
.scan-steps-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; padding-top: 24px; border-top: 1px solid var(--line-d); }
.scan-skip { font-family: var(--mono); font-size: 12px; color: var(--soft-d); }
.scan-step { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.scan-step-n { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; color: var(--accent); }
.scan-step .h3 { margin: 0; }
.scan-step p { margin: 0; color: var(--soft-d); font-size: 15px; line-height: 1.55; }
.scan-step .btn-row { margin-top: 8px; }
.scan-still { order: -1; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--ink-1); border: 1px solid var(--line-d); }
.scan-tracks { display: none; }

/* ---------- live ---------- */
.scan-live .scan-grid { align-items: start; }
.scan-live .hero-text { min-height: min(820px, calc(100svh - 74px)); justify-content: center; padding-block: 48px; position: relative; z-index: 1; }
/* the stage: pinned for the whole walkthrough. The viewer keeps its place in the layout (right column) and is grown to the whole
   stage with a transform, so nothing is laid out again while scrolling; its labels are scaled back so they keep their size. */
.scan-live .scan-visual { display: flex; align-items: flex-start; justify-content: flex-end; grid-column: 1 / -1; grid-row: 1 / span 2; align-self: start; position: sticky; top: var(--head-h, 76px); height: calc(100svh - var(--head-h, 76px)); z-index: 2; pointer-events: none; }
/* margin-top centres the viewer on the headline's row (not on the screen: on a tall monitor the row is shorter than the screen) */
.scan-live .viewport-scan { flex: none; width: calc((100% - 56px) * 0.51923); max-height: calc(100svh - var(--head-h, 76px) - 32px); margin-top: max(16px, calc((min(820px, 100svh - 74px) - (100% - 56px) * 0.41538) / 2)); pointer-events: auto; transform-origin: 0 0; transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--sx, 1), var(--sy, 1)); border-width: calc(1px / var(--sy, 1)) calc(1px / var(--sx, 1)); }
/* each label is scaled back to its own size and pulled back to its usual distance from the frame's corner (16 / 14 px), whatever the frame's size */
.scan-live .viewport-scan .viewport-top > span:first-child { transform-origin: 0 0; transform: translate(calc(-16px * (1 - var(--ix, 1))), calc(-14px * (1 - var(--iy, 1)))) scale(var(--ix, 1), var(--iy, 1)); }
.scan-live .viewport-scan .viewport-top > span:last-child { transform-origin: 100% 0; transform: translate(calc(16px * (1 - var(--ix, 1))), calc(-14px * (1 - var(--iy, 1)))) scale(var(--ix, 1), var(--iy, 1)); }
.scan-live .viewport-scan .viewport-bottom { transform-origin: 0 100%; transform: translate(calc(-16px * (1 - var(--ix, 1))), calc(14px * (1 - var(--iy, 1)))) scale(var(--ix, 1), var(--iy, 1)); }
.scan-live .viewport-scan .s2b-tree { transform-origin: 100% 0; transform: translate(calc(14px * (1 - var(--ix, 1))), calc(-46px * (1 - var(--iy, 1)))) scale(var(--ix, 1), var(--iy, 1)); }
.scan-live .viewport-scan .scan-fps { transform-origin: 100% 0; transform: translate(calc(12px * (1 - var(--ix, 1))), calc(-40px * (1 - var(--iy, 1)))) scale(var(--ix, 1), var(--iy, 1)); }
.scan-live .viewport-scan .scan-dim { transform-origin: 0 0; }
/* the step texts live inside the viewer: one stack, the current step visible. Laid out once where the grown viewer's lower left
   corner will be, and carried there with the same transform-only motion */
.scan-live .scan-story { position: absolute; z-index: 3; left: calc(var(--b1x, 0px) + 20px); top: var(--b1b, 100%); width: var(--cw, 340px); transform: translate(var(--stx, 0px), var(--sty, 0px)) translateY(calc(-100% - 100px)); padding: 0; opacity: var(--cap, 0); }
.scan-live .scan-steps-head { padding: 9px 16px; border: 0; background: rgba(8, 10, 11, .92); border-left: 2px solid var(--accent); border-bottom: 1px solid var(--line-d2); pointer-events: var(--cap-pe, none); gap: 6px 16px; }
.scan-live .scan-steps-head .eyebrow { font-size: 11px; }
.scan-live .scan-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 0; }
.scan-live .scan-step { grid-area: 1 / 1; align-self: start; padding: 16px 16px 18px; background: rgba(8, 10, 11, .92); border-left: 2px solid var(--accent); opacity: 0; transition: opacity .3s; }
/* the other steps stay in the page for screen readers and the keyboard; focusing one scrolls the walkthrough to it */
.scan-live .scan-step.is-active { opacity: 1; pointer-events: var(--cap-pe, none); }
.scan-live .scan-step .h3 { font-size: clamp(22px, 1.9vw, 28px); }
.scan-live .scan-step p:not(.scan-step-n) { font-size: 15px; color: var(--text-d); }
.scan-live .scan-step .btn-row { gap: 10px; }
.scan-live .scan-step .btn-lg { min-height: 46px; padding: 0 18px; font-size: 15px; }
.scan-live .scan-still { display: none; }
/* empty sections that give the walkthrough its scroll length: one per step */
.scan-live .scan-tracks { display: block; grid-column: 1 / -1; grid-row: 2; padding-bottom: 30svh; }   /* room to stay on the last step before the next section arrives */
.scan-live .scan-track { height: 92svh; }

@media (max-width: 900px) {
  .hero-scan .scan-grid { display: flex; flex-direction: column; align-items: stretch; gap: 20px; padding-block: 28px 0; }
  .hero-scan .hero-text { display: contents; }
  .hero-scan .hero-text > .eyebrow { order: 1; }
  .hero-scan .display { order: 2; }
  .viewport-scan { order: 3; margin-inline: calc(var(--gutter) * -1); aspect-ratio: 4 / 3; border-inline: 0; }
  .hero-scan .btn-row { order: 4; }
  .hero-scan .lead { order: 5; }
  .hero-scan .spec-row { order: 6; }
  .scan-story { order: 7; padding-bottom: 56px; }
  .scan-steps { grid-template-columns: 1fr; gap: 32px; }
  .viewport-scan .s2b-steps, .viewport-scan .s2b-tree { display: none; }
  .scan-dim { font-size: 10px; padding: 5px 8px; }
  .scan-dim b { font-size: 13px; }
  /* live on a phone: the viewer keeps its place in the page, sticks to the top, then grows downwards to the full screen */
  .scan-live .scan-visual { display: block; order: 3; align-self: stretch; top: var(--head-h, 76px); height: auto; aspect-ratio: 4 / 3; margin-inline: calc(var(--gutter) * -1); z-index: 5; }
  .scan-live .viewport-scan { position: absolute; inset: 0; width: auto; height: auto; max-height: none; margin: 0; aspect-ratio: auto; }
  .scan-live .scan-story { left: 12px; right: 12px; width: auto; top: calc(var(--b1b, 100%) + 10px); transform: translate(var(--stx, 0px), var(--sty, 0px)); }
  .scan-live .scan-step .h3 { font-size: 22px; }
  .scan-live .scan-step p:not(.scan-step-n) { font-size: 15px; }
  .scan-live .scan-tracks { order: 7; }
  .scan-live .scan-track { height: 88svh; }
}
@media (max-width: 640px) { .viewport-scan { height: auto; } }
@media (prefers-reduced-motion: reduce) { .viewport-scan canvas, .scan-live .scan-step { transition: none; } }

/* ---------- home services: the project viewer, shown for real ----------
   The four step cards stay as they are and sit on top of the viewer; the viewer is the theme's own component (.viewer-bar,
   .viewer-tabs, .viewer-stage, .viewer-locked, as on a project page) with a capture of the real viewer in each public tab. */
.pv .flow { border-bottom: 1px solid var(--rule); }
.pv .vtab { border: 0; cursor: pointer; font-family: inherit; transition: background .2s, color .2s; }
.pv .vtab:hover, .pv .vtab[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.pv .vtab:hover .mono-tag, .pv .vtab[aria-pressed="true"] .mono-tag { color: var(--accent-ink); }
.pv .vtab:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.pv .flow-step { transition: box-shadow .2s; }
.pv .flow-step.is-on { box-shadow: inset 0 3px 0 var(--accent); }
.pv-viewer { margin-top: 28px; scroll-margin-top: 16px; border: 1px solid var(--line-d); }
.pv-head { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; align-items: center; gap: 12px 40px; padding: 26px 28px; }
.pv-head .h3-lg { font-size: clamp(26px, 2.6vw, 36px); }
.pv-head p { margin: 0; max-width: 56ch; color: var(--soft-d); font-size: 15px; line-height: 1.55; }
.pv-head .link-arrow { color: var(--accent); text-decoration: none; white-space: nowrap; }
.pv-head .link-arrow:hover { color: var(--accent-hover); }
.pv-frame .viewer-bar { grid-template-columns: minmax(0, 1fr); border-inline: 0; }
.pv-frame .viewer-stage { border-inline: 0; }
/* position: relative keeps each tab's screen-reader-only text inside the scrolling bar; without it that text sits past the
   right edge of a phone screen and makes the whole page wider than the screen */
.pv-frame .viewer-tabs button { position: relative; padding: 0 16px; }
.pv-frame .viewer-tabs button { font-family: inherit; }
.pv-frame .viewer-tabs button .mono-tag { color: var(--muted-d); }
.pv-frame .viewer-tabs button[aria-selected="true"] .mono-tag { color: var(--accent); }
.pv-frame .viewer-panel { height: auto; min-height: 0; }
.pv-shot { display: block; aspect-ratio: var(--ar-d); background: var(--ink-1); }
.pv-shot picture, .pv-shot img { display: block; width: 100%; height: 100%; }
.pv-shot img { object-fit: cover; object-position: 0 0; }
.pv-shot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pv-panel-locked { aspect-ratio: 1824 / 1083; }
.pv-panel-locked .viewer-locked .h3 { color: var(--text-d); font-size: 22px; }
.pv-caption { margin: 0; padding: 12px 28px 14px; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--muted-d); }
/* pointing at a step lights up its tabs */
.services-flow:has(.flow-step[data-s="1"]:hover) .viewer-tabs button[data-s="1"], .services-flow:has(.flow-step[data-s="2"]:hover) .viewer-tabs button[data-s="2"],
.services-flow:has(.flow-step[data-s="3"]:hover) .viewer-tabs button[data-s="3"], .services-flow:has(.flow-step[data-s="4"]:hover) .viewer-tabs button[data-s="4"] { color: var(--text-d); background: var(--ink-3); }
@media (max-width: 1080px) { .pv-head { grid-template-columns: minmax(0, 1fr) auto; } .pv-head p { grid-column: 1 / -1; grid-row: 2; } }
@media (max-width: 700px) {
  .pv-viewer { margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
  .pv-head { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 24px var(--gutter) 18px; }
  .pv-caption { padding-inline: var(--gutter); }
  .pv-head p { grid-row: auto; }
  .pv-shot { aspect-ratio: var(--ar-m); }
  .pv-panel-locked { aspect-ratio: 4 / 5; }
}

/* ---------- the header stays in view on the whole page, the walkthrough included ----------
   Belongs in main.css once ported (it is not specific to the home page). --head-h is the header's height, kept up to date by hero3d.js. */
.site-header { position: sticky; top: 0; z-index: 30; }
html { scroll-padding-top: var(--head-h, 76px); }                       /* in-page links and keyboard focus land below the header */
.nav-open .site-header { max-height: 100svh; overflow-y: auto; }         /* an open phone menu taller than the screen can still be scrolled */

/* ---------- fallback faces sized like Archivo, so text does not reflow when the web font arrives ----------
   Measured against Arial: Archivo regular is 98 % as wide, the condensed headings (font-stretch 76-85 %) 79 %.
   Belongs in fonts.css / main.css once ported (it helps every page, not only the home page). */
@font-face { font-family: "Archivo Fallback"; src: local("Arial"), local("Helvetica Neue"), local("Roboto"), local("Liberation Sans"); font-weight: 100 900; font-stretch: 91% 125%; size-adjust: 98.3%; }
@font-face { font-family: "Archivo Fallback"; src: local("Arial"), local("Helvetica Neue"), local("Roboto"), local("Liberation Sans"); font-weight: 100 900; font-stretch: 62% 90%; size-adjust: 79%; }
:root { --sans: "Archivo", "Archivo Fallback", "Helvetica Neue", Arial, sans-serif; }
