/* The homepage as four chapters over three live scenes (see /assets/scenes/stage.js).
   A .world holds a canvas pinned to the top of the view and the sections that scroll over it. Until its scene is live,
   and wherever WebGL 2 is missing, every section keeps a solid ground of its own, so the page reads the same with or
   without the scenes. The room chapter between the second and third world keeps the 2D window wall. */
.worlds { --lvh: 100vh; --canvas-h: max(var(--lvh), var(--stage-h, 0px)); }      /* --stage-h: the tallest view stage.js has seen */
@supports (height: 100lvh) { .worlds { --lvh: 100lvh; } }
/* The page's own background tints a phone's status bar and shows when the page is pulled past its ends. The page opens
   and closes dark, so it is carbon. (Safari reads it once, so it cannot follow the ground.) On touch screens the pinned
   canvases run a little past the bottom of the view, because Safari shows page under its floating bar. */
body.worlds { background: var(--carbon); }
/* the soft shadows behind chapter copy reach past the screen edge on a phone; clip them so the page never scrolls
   sideways (clip, unlike hidden, leaves the sticky scene canvases working) */
body.worlds main { overflow-x: clip; }
@media (pointer: coarse), (max-width: 900px) { .worlds { --canvas-h: calc(max(var(--lvh), var(--stage-h, 0px)) + 72px); } }
#anything-built, #one-home, #every-home, #room-twins { scroll-margin-top: calc(-1 * var(--header-height) - 19px); }   /* chapter links land on the chapter's own first line of pixels */
.worlds main { margin-top: calc(-1 * var(--header-height) - 1px); }          /* the first scene runs under the header */

/* ── the header takes the ground that lies under it ── */
html[data-ground="light"] .worlds .site-header { background: rgba(245, 245, 242, 0.94); border-bottom-color: var(--line); }
html[data-ground="dark"] .worlds .site-header,
html[data-ground="pine"] .worlds .site-header { background: rgba(12, 13, 12, 0.68); border-bottom-color: rgba(245, 245, 242, 0.14); }
html[data-ground="pine"] .worlds .site-header { background: rgba(10, 41, 29, 0.78); }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-header .site-logo img { filter: brightness(0) invert(0.96); }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-nav a { color: rgba(245, 245, 242, 0.86); }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-nav a:hover { background: rgba(245, 245, 242, 0.09); color: #fff; }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-nav .site-nav__signin { border-color: rgba(245, 245, 242, 0.34); color: var(--on-dark); }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-nav .site-nav__signin:hover { background: var(--signal-jade); border-color: var(--signal-jade); color: #fff; }
html:is([data-ground="dark"], [data-ground="pine"]) .worlds .site-menu > summary { color: var(--on-dark); border-color: rgba(245, 245, 242, 0.38); }

/* ── a world: pinned canvas, sections over it ── */
.world { position: relative; background: var(--carbon); }
.world__canvas { position: sticky; top: 0; z-index: 0; display: block; width: 100%; height: var(--canvas-h); opacity: 0; pointer-events: none; transition: opacity 0.9s var(--ease-out); }
.world[data-scene-state="live"] .world__canvas { opacity: 1; }
.world__flow { position: relative; z-index: 2; margin-top: calc(-1 * var(--canvas-h)); }
/* Live WebGL stage: viewport-pinned canvases cross-dissolve in place between worlds with zero sticky unstick */
html.stage-on .world { background: transparent; }
html.stage-on .world__canvas { position: fixed; top: 0; left: 0; z-index: 0; will-change: opacity; }
html.stage-on .world[data-scene-state="live"] .world__canvas { transition: none; }
html.stage-on .world__flow { margin-top: 0; }
html.stage-on .worlds .investment-close,
html.stage-on .worlds .site-footer { position: relative; z-index: 2; }
.world__flow > section > * { transition: opacity 0.35s var(--ease-out); }
.world [data-ground] { position: relative; transition: background-color 0.35s linear 0.9s; }
.world [data-ground="dark"] { color: var(--on-dark); }
.world [data-ground="light"] { background-color: var(--plaster); }
.world [data-ground="pine"] { background-color: var(--pine-lacquer); color: var(--on-dark); }
.world[data-scene-state="live"] [data-ground] { background-color: transparent; border-color: transparent; }
html.scene-copy-hidden .world__flow > section > :not(.world__hud) { opacity: 0; pointer-events: none; }
/* a small instrument line in the corner of each chapter opening: what is being drawn, and two controls for it */
.world__hud { position: absolute; z-index: 2; right: var(--gutter); top: calc(var(--header-height) + 16px); display: none; align-items: center; gap: 10px; }
.world[data-scene-state="live"] .world__hud { display: flex; }
.world__stat { margin: 0 4px 0 0; font: 560 0.6875rem/1.3 var(--display); letter-spacing: 0.1em; text-transform: uppercase; font-variant-numeric: tabular-nums; color: rgba(194, 212, 201, 0.74); }
.world__stat::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--signal-jade); vertical-align: 1px; }
.stage-button { min-height: 30px; padding: 0 12px; border: 1px solid rgba(245, 245, 242, 0.3); border-radius: 999px; background: rgba(12, 13, 12, 0.5); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font: 560 0.6875rem/1 var(--display); letter-spacing: 0.09em; text-transform: uppercase; color: var(--on-dark); cursor: pointer; transition: background-color 0.16s ease, border-color 0.16s ease; }
.stage-button:hover, .stage-button[aria-pressed="true"] { background: var(--viridian); border-color: var(--viridian); }
.stage-button:focus-visible { outline: 2px solid var(--celadon); outline-offset: 2px; }
/* copy over a dark scene sits on a soft shadow of the ground colour, so thin lines never run through the words */
.chapter__copy, .world .home-opening__copy { position: relative; }
.chapter__copy::before, .world .home-opening__copy::before { content: ""; position: absolute; inset: -16% -26% -18% -60%; z-index: -1; pointer-events: none; background: radial-gradient(closest-side, rgba(12, 13, 12, 0.66), rgba(12, 13, 12, 0.4) 58%, rgba(12, 13, 12, 0)); }

/* ── shared display type for the chapter pages ── */
.chapter h2, .method h2, .turn h2, .room .home-opening h2 { margin: 0; font: 560 clamp(2.6rem, 4.6vw, 4.7rem)/0.97 var(--display); letter-spacing: -0.046em; color: inherit; text-wrap: balance; }
.chapter h2 em, .method h2 em, .turn h2 em, .room .home-opening h2 em { display: block; margin-top: 0.04em; font: italic 420 1.04em/0.99 var(--serif); letter-spacing: -0.025em; color: var(--celadon); }
.room .home-opening h2 span { display: block; }
.method h2 { color: var(--heading); }
.method h2 em { color: var(--viridian); }

/* ── 01: the opening over the gorge ── */
.world .home-opening { padding: 0; background: transparent; overflow: visible; }
.world .home-opening::after { content: none; }
.world .home-opening__grid { min-height: var(--lvh); grid-template-rows: minmax(0, 1fr) auto; padding-top: calc(var(--header-height) + clamp(20px, 4vh, 56px)); }
.world .home-opening__copy { align-self: center; max-width: 37rem; }
.world .home-opening h1 { font-size: clamp(3rem, 5.6vw, 5.6rem); }
.world .home-opening .lede { max-width: 31rem; }

.method { min-height: var(--lvh); display: grid; align-items: center; padding: clamp(72px, 12vh, 140px) 0; }
.world .method__copy { width: min(100%, 38rem); padding: clamp(26px, 2.8vw, 40px); }
.method__steps { margin: clamp(26px, 3.4vw, 40px) 0 0; padding: 0; list-style: none; counter-reset: step; }
.method__steps li { counter-increment: step; display: grid; grid-template-columns: 3.1rem minmax(0, 1fr); padding: 16px 0; border-top: 1px solid var(--line-strong); }
.method__steps li::before { content: counter(step, decimal-leading-zero); grid-row: 1 / span 2; padding-top: 3px; font: 500 0.9375rem/1.2 var(--serif); font-variant-numeric: lining-nums; color: var(--viridian); }
.method__steps h3 { margin: 0; font: 560 1.25rem/1.22 var(--display); letter-spacing: -0.02em; color: var(--heading); }
.method__steps p { margin: 5px 0 0; font-size: var(--text-small); color: var(--muted); }
.method .provenance { margin-top: 18px; }

.turn { min-height: calc(var(--lvh) * 0.94); display: grid; align-items: center; padding: clamp(72px, 12vh, 140px) 0; }
.turn__copy { max-width: 35rem; }
.turn .eyebrow, .chapter .eyebrow { color: var(--celadon); }
.turn .lede { margin-top: 22px; max-width: 30rem; color: var(--on-dark-muted); }
.chapters { display: grid; max-width: 25rem; margin-top: clamp(26px, 3.4vw, 40px); border-top: 1px solid rgba(245, 245, 242, 0.22); }
.chapters a { display: grid; grid-template-columns: 3.1rem minmax(0, 1fr) auto; align-items: center; min-height: 54px; border-bottom: 1px solid rgba(245, 245, 242, 0.22); font: 540 1.125rem/1.2 var(--display); letter-spacing: -0.015em; text-decoration: none; color: var(--on-dark); transition: color 0.16s ease, padding 0.2s var(--ease-out); }
.chapters a span { font: 500 0.9375rem/1 var(--serif); font-variant-numeric: lining-nums; color: var(--celadon); }
.chapters a::after { content: "\2193"; color: var(--celadon); }
.chapters a:hover, .chapters a:focus-visible { color: var(--celadon); padding-left: 6px; }

/* ── 02 and 04: a chapter opens on the dark ground ── */
.chapter { min-height: var(--lvh); display: grid; align-items: center; padding: calc(var(--header-height) + 40px) 0 72px; scroll-margin-top: 0; }
.chapter__copy { max-width: 35rem; }
.chapter .lede { margin-top: 22px; max-width: 31rem; color: rgba(245, 245, 242, 0.82); }

/* ── exhibits: the proven product blocks, set as plates beside the scene ── */
.world .home-app, .world .section.home-teams, .world .section.home-ahead-section { padding: 0 0 clamp(56px, 9vh, 120px); border-top: 0; }
.world .home-head { min-height: calc(var(--lvh) * 0.82); display: grid; align-content: center; max-width: 33rem; margin-bottom: 0;
  background: radial-gradient(ellipse 64% 30% at 34% 50%, rgba(245, 245, 242, 0.96), rgba(245, 245, 242, 0.74) 52%, rgba(245, 245, 242, 0) 100%); }
.world :is(.home-feature, .home-bid, .home-pro, .home-trades-wrap, .home-ahead__grid, .home-store, .method__copy) {
  width: min(100%, 37rem); padding: clamp(22px, 2.3vw, 34px); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: rgba(245, 245, 242, 0.88); -webkit-backdrop-filter: blur(14px) saturate(1.1); backdrop-filter: blur(14px) saturate(1.1);
}
.world :is(.home-feature, .home-bid, .home-pro, .home-trades-wrap, .home-ahead__grid) { display: block; margin: 0 0 clamp(120px, 34vh, 380px); }
.world .home-feature + .home-feature, .world .home-feature + .home-bid { margin-top: 0; }
.world :is(.home-feature--repair, .home-pro) { margin-left: auto; }
.world .home-feature__media { max-width: none; }
.world .home-feature--lite .home-feature__text { margin-top: 24px; max-width: none; }
.world .home-feature--repair { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 24px; align-items: start; width: min(100%, 43rem); }
.world .home-feature--repair .home-feature__text { max-width: none; }
.world .home-repair__media { width: 100%; }
.world .home-repair__media img { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); }
/* the film caption sits on its own dark chip: under the film the floor carries a bright patch of window light */
/* the whole film, caption included, fits under the header on the screen it plays on (1080 x 2340 film) */
.room .twin-story__film {
  width: min(100%, 310px, calc((100vh - var(--header-height) - 88px) * 0.4615));
  width: min(100%, 310px, calc((100svh - var(--header-height) - 88px) * 0.4615)); }
/* the box keeps the film's own shape from the start: with the poster's shape it grew by a third when the film
   loaded, and ran off the screen it had just been scrolled into */
.room .twin-story__film video { aspect-ratio: 1080 / 2340; object-fit: cover; }
.room .twin-story__film figcaption { width: fit-content; margin: 12px auto 0; padding: 5px 12px; border-radius: 999px; background: rgba(12, 13, 12, 0.74); color: rgba(214, 228, 219, 0.92); }
.world .home-bid { border-top: 1px solid var(--line); }
.world .home-bid .home-prices { margin-top: 26px; }
.world .home-prices dt { font-size: clamp(2.2rem, 1.6rem + 1.6vw, 3rem); }
.world .home-pro { width: min(100%, 39rem); }
.world .home-pro__line { margin-top: 14px; font-size: var(--text-small); color: var(--muted); }
.world .home-steps { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 26px; }
.world .home-steps li { display: grid; grid-template-columns: 3.1rem minmax(0, 1fr); padding: 14px 0; border-top: 1px solid var(--line-strong); }
.world .home-steps li::before { grid-row: 1 / span 2; margin: 3px 0 0; }
.world .home-steps p { margin-top: 4px; }
.world .home-trades-wrap { margin-top: 0; }
.world .home-ahead__grid { margin-left: auto; }
.world .home-store { display: grid; width: 100%; margin: 0; }
.world .home-band { padding: clamp(96px, 20vh, 220px) 0 clamp(76px, 12vh, 150px); border-bottom: 0; }
.world .home-teams .home-head { min-height: calc(var(--lvh) * 0.7); }

/* ── 03: one room. The window wall stays pinned while the model and the film pass over it ── */
.room.twin-story { padding: 0; overflow: visible; overflow: clip; }
.room.twin-story::after { content: none; }
.room__canvas { position: sticky; top: 0; z-index: 0; display: block; width: 100%; height: var(--canvas-h); opacity: 0.94; pointer-events: none; }
.room__flow { position: relative; z-index: 1; margin-top: calc(-1 * var(--canvas-h)); }
.room .home-opening { display: grid; align-items: center; min-height: var(--lvh); padding: calc(var(--header-height) + 24px) 0 48px; background: transparent; }
.room .home-opening__grid { grid-template-areas: "copy photo"; align-items: center; }
.room .home-opening h2 { font-size: clamp(3rem, 5.4vw, 5.35rem); }
.room .twin-story__grid { position: relative; align-items: center; min-height: var(--lvh); padding-block: clamp(56px, 9vh, 110px); }
.room .twin-story__grid::before { content: ""; position: absolute; inset: 0 calc(50% - 50vw); z-index: -1; pointer-events: none; background: linear-gradient(90deg, rgba(12, 13, 12, 0.9) 0%, rgba(12, 13, 12, 0.76) 40%, rgba(12, 13, 12, 0.2) 60%, rgba(12, 13, 12, 0.12) 100%); }
.room .twin-story__copy h3 { margin: 0; font: 560 clamp(2rem, 1.5rem + 1.9vw, 3rem)/1.04 var(--display); letter-spacing: -0.036em; color: var(--on-dark); text-wrap: balance; }
.room .twin-story__copy h3 em { font: italic 420 1.03em/1 var(--serif); letter-spacing: -0.02em; color: var(--celadon); }

/* ── chapter rail and scene controls: only when the scenes are running ── */
.rail, .stage-tools { display: none; position: fixed; z-index: 55; }
.rail { left: 12px; top: 50%; flex-direction: column; gap: 2px; transform: translateY(-50%); }
.rail a { display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 4px 8px; border-radius: 999px; font: 560 0.6875rem/1 var(--display); letter-spacing: 0.09em; text-transform: uppercase; text-decoration: none; color: rgba(245, 245, 242, 0.5); transition: color 0.16s ease, background-color 0.16s ease; }
.rail a span { font: 500 0.8125rem/1 var(--serif); letter-spacing: 0; font-variant-numeric: lining-nums; }
.rail a b { max-width: 0; overflow: hidden; font-weight: inherit; white-space: nowrap; opacity: 0; transition: max-width 0.25s var(--ease-out), opacity 0.2s ease; }
.rail a:hover b, .rail a:focus-visible b { max-width: 12rem; opacity: 1; }
.rail a[aria-current], .rail a:hover, .rail a:focus-visible { color: var(--on-dark); }
.rail a:hover, .rail a:focus-visible { background: rgba(12, 13, 12, 0.55); }
.rail a[aria-current] span { color: var(--signal-jade); }
html[data-ground="light"] .rail a { color: rgba(17, 21, 19, 0.46); }
html[data-ground="light"] .rail a[aria-current], html[data-ground="light"] .rail a:hover, html[data-ground="light"] .rail a:focus-visible { color: var(--heading); }
html[data-ground="light"] .rail a:hover, html[data-ground="light"] .rail a:focus-visible { background: rgba(245, 245, 242, 0.82); }
html[data-ground="light"] .rail a[aria-current] span { color: var(--viridian); }
.stage-tools { right: 16px; bottom: 14px; }
@media (min-width: 1000px) { html.stage-on.scene-copy-hidden .stage-tools { display: flex; } }
@media (min-width: 1380px) { html.stage-on .rail { display: flex; } }

/* ── narrow screens: plates run full width, with the scene showing between them ── */
@media (max-width: 999px) { .world__hud { display: none !important; } }
@media (max-width: 900px) {
  .chapter { align-items: end; padding-bottom: clamp(112px, 17vh, 168px); }        /* copy low, so the scene stands above it */
  .chapter__copy::before { inset: -22% -12% -30% -12%; background: radial-gradient(closest-side, rgba(12, 13, 12, 0.74), rgba(12, 13, 12, 0.46) 60%, rgba(12, 13, 12, 0)); }
  .room .home-opening::after { background: linear-gradient(180deg, rgba(12, 13, 12, 0.84) 0%, rgba(12, 13, 12, 0.66) 48%, rgba(12, 13, 12, 0.2) 100%); }
  .world :is(.home-feature, .home-bid, .home-pro, .home-trades-wrap, .home-ahead__grid) { width: 100%; margin-bottom: clamp(96px, 26vh, 240px); }
  .world .home-feature--repair { grid-template-columns: minmax(0, 1fr) 150px; gap: 18px; }
  .world .home-head { min-height: calc(var(--lvh) * 0.66); }
  .world .home-opening__grid { padding-top: calc(var(--header-height) + 16px); }
  .room .home-opening__grid { grid-template-areas: "copy" "photo"; }
  .room .twin-story__grid::before { background: rgba(12, 13, 12, 0.78); }
}
@media (max-width: 520px) {
  .world .home-feature--repair { grid-template-columns: minmax(0, 1fr); }
  .world .home-repair__media { order: -1; width: 100%; }                      /* the damage first, as the kitchen picture leads its block */
  .world .home-repair__media img { aspect-ratio: 3 / 2; object-fit: cover; object-position: 50% 48%; }
  .chapter h2, .method h2, .turn h2 { font-size: clamp(2.3rem, 10.5vw, 3rem); }
}
@media (prefers-reduced-motion: reduce) {
  .world__canvas, .world__flow, .world [data-ground] { transition: none; }
}
