/* ==========================================================================
   stages.css: sheet A-01 · "scroll to build"
   Every element of the drawing (svg.bp) knows its own window inside its stage
   (--a start, --d duration) and is styled from one number, --bpt (0 → 1).
   Without the script --bpt derives from the stage defaults --p1 … --p6 = 1, so the
   drawing is simply the finished building; js/stages.js then writes --bpt per
   element from scroll. Stage 6 is the finale after the five stages.
   ========================================================================== */

/* --bpt does not inherit: writing it on a group (a whole render layer) restyles that group only, not the
   hundreds of shapes inside it. (Browsers without @property simply inherit it, which is slower, not wrong.) */
@property --bpt { syntax: "<number>"; inherits: false; initial-value: 1; }

.bp {
  display: block; width: 100%; height: 100%; overflow: hidden; color: var(--ink);
  transform-box: border-box; transform-origin: 50% 50%;   /* the phone's last-frame zoom (js/stages.js) */
  --u: 1.3;                       /* viewBox units per CSS px (set by js/stages.js): hairlines & lettering stay constant */
  --p1: 1; --p2: 1; --p3: 1; --p4: 1; --p5: 1; --p6: 1;

  /* ---- the finished building, by day (light theme): plaster one step below the page's lightest stone ---- */
  --r-pl-top: #EDE5DB; --r-pl-mid: #E8DFD4; --r-pl-bot: #E2D8CC; --r-grain-op: .6;
  --r-ao: rgba(10, 51, 32, .15); --r-hi: rgba(245, 240, 234, .9); --r-sh: rgba(10, 51, 32, .28);
  --r-st-a: #D6CABC; --r-st-b: #C9BBAC; --r-joint: rgba(99, 86, 75, .34);
  --r-slab-top: #E2D8CC; --r-slab-bot: #D6CABC; --r-sill: #F5F0EA;
  --r-gl-top: #A7BBA9; --r-gl-mid: #1A4A34; --r-gl-bot: #0A3320;
  --r-shop-a: #869D8A; --r-shop-b: #103D29; --r-shop-c: #072818;
  --r-sheen: rgba(245, 240, 234, .2); --r-ceil: rgba(5, 28, 17, .3); --r-curtain: rgba(237, 229, 219, .3);
  --r-goods: rgba(5, 28, 17, .32); --r-lamp: rgba(237, 229, 219, .45); --r-room: rgba(5, 28, 17, .3); --r-rev: rgba(5, 28, 17, .28);
  --r-fr: #103D29; --r-rail: #A1742F; --r-bar: #103D29;
  --r-shut-a: #1A4A34; --r-shut-b: #0A3320; --r-groove: rgba(5, 28, 17, .5);
  --r-rf: #0A3320; --r-rf-lo: #072818; --r-rf-mid: #103D29; --r-rf-hi: #1A4A34; --r-rf-edge: rgba(237, 229, 219, .45);
  --r-pipe: #103D29; --r-pipe-hi: #2A6147;
  --r-bal: rgba(63, 125, 94, .26); --r-bal-edge: rgba(245, 240, 234, .75); --r-glint: rgba(245, 240, 234, .3); --r-tb-lo: #A1742F;
  --r-glow: rgba(245, 197, 120, .55); --r-led: #FBE0B4; --r-halo: rgba(245, 197, 120, .5); --r-spill: rgba(245, 197, 120, .5);
  --r-lit-b: #F8CF8E; --r-lit-c: #A1742F; --r-lit-c2: #B88A47; --r-lit-d: #6E4D1B; --r-skyref: rgba(63, 125, 94, .24);
  --r-pave-top: #E2D8CC; --r-pave: #C4B4A5; --r-pave-lo: #A89787; --r-planter: #63564B; --r-trunk: #63564B; --r-trunk-hi: #857567;
  --r-road: #756759; --r-road-hi: rgba(237, 229, 219, .3);
  --r-lf-1: #0A3320; --r-lf-2: #1A4A34; --r-lf-3: #2A6147; --r-lf-4: #3F7D5E; --r-lf-rim: transparent; --r-leaf: rgba(63, 125, 94, .24);
  --r-ppl: rgba(10, 51, 32, .86); --r-ppl-2: rgba(99, 86, 75, .92);
  --r-mk: #F5C578; --r-mk-sh: rgba(99, 86, 75, .5); --r-wm: #0A3320;
}
/* ---- … and at dusk (dark theme): the facade softly lit, the shop open, windows lighting up ---- */
:root[data-theme="dark"]:not([data-vt="light"]) .bp, :root[data-vt="dark"] .bp {
  --r-pl-top: #423A33; --r-pl-mid: #574C42; --r-pl-bot: #7D6D5E; --r-grain-op: .5;
  --r-ao: rgba(3, 14, 9, .36); --r-hi: rgba(237, 229, 219, .2); --r-sh: rgba(3, 14, 9, .42);
  --r-st-a: #5A4F45; --r-st-b: #463D35; --r-joint: rgba(3, 14, 9, .42);
  --r-slab-top: #7A6C5F; --r-slab-bot: #4A4038; --r-sill: #8A7B6D;
  --r-gl-top: #103D29; --r-gl-mid: #072818; --r-gl-bot: #051C11;
  --r-shop-a: #F8CF8E; --r-shop-b: #E5B062; --r-shop-c: #A1742F;
  --r-sheen: rgba(237, 229, 219, .06); --r-ceil: rgba(5, 28, 17, .5); --r-curtain: rgba(245, 197, 120, .16);
  --r-goods: rgba(110, 77, 27, .58); --r-lamp: #FBE0B4; --r-room: rgba(110, 77, 27, .6); --r-rev: rgba(3, 14, 9, .45);
  --r-fr: #072818; --r-rail: #C9954A; --r-bar: #051C11;
  --r-shut-a: #0A2A1C; --r-shut-b: #051C11; --r-groove: rgba(3, 14, 9, .6);
  --r-rf: #051C11; --r-rf-lo: #03150C; --r-rf-mid: #072818; --r-rf-hi: #103D29; --r-rf-edge: rgba(245, 197, 120, .34);
  --r-pipe: #072818; --r-pipe-hi: #1A4A34;
  --r-bal: rgba(63, 125, 94, .2); --r-bal-edge: rgba(245, 197, 120, .45); --r-glint: rgba(237, 229, 219, .08); --r-tb-lo: #6E4D1B;
  --r-glow: rgba(245, 197, 120, .5); --r-halo: rgba(245, 197, 120, .55); --r-spill: rgba(245, 197, 120, .5);
  --r-pave-top: #4E453D; --r-pave: #2E2822; --r-pave-lo: #1A1712; --r-planter: #2E2822; --r-trunk: #2E2822; --r-trunk-hi: #3A322B;
  --r-road: #1A1712; --r-road-hi: rgba(237, 229, 219, .07);
  --r-lf-1: #03150C; --r-lf-2: #072818; --r-lf-3: #0A3320; --r-lf-4: transparent; --r-lf-rim: rgba(63, 125, 94, .16); --r-leaf: rgba(42, 97, 71, .2);
  --r-ppl: rgba(3, 14, 9, .92); --r-ppl-2: rgba(10, 42, 28, .92);
  --r-mk-sh: rgba(3, 14, 9, .6); --r-wm: #072818;
}

.bp .s1 { --p: var(--p1); }
.bp .s2 { --p: var(--p2); }
.bp .s3 { --p: var(--p3); }
.bp .s4 { --p: var(--p4); }
.bp .s5 { --p: var(--p5); }
.bp .s6 { --p: var(--p6); }
.bp :is(.ln, .fd, .rs, .gx, .pop, .fo, .dm, .wp, .rn) { --bpt: clamp(0, calc((var(--p) - var(--a)) / var(--d)), 1); }

/* line weights (cut lines heavy, projection lines light) */
.bp-lines :is(path, rect, circle), .bp-notes :is(path, rect, circle), .bp-temp :is(path, rect, circle) { fill: none; stroke: currentColor; stroke-linejoin: round; }
.bp .w1 { stroke-width: calc(var(--u) * .8px); }
.bp .w2 { stroke-width: calc(var(--u) * 1.15px); }
.bp .w3 { stroke-width: calc(var(--u) * 1.6px); }
.bp .w4 { stroke-width: calc(var(--u) * 2.5px); }
.bp .o5 { opacity: .5; } .bp .o6 { opacity: .62; } .bp .o7 { opacity: .74; }
.bp .axis { stroke-dasharray: calc(var(--u) * 11px) calc(var(--u) * 3px) calc(var(--u) * 1.5px) calc(var(--u) * 3px); opacity: .34; }
.bp .dash { stroke-dasharray: calc(var(--u) * 5px) calc(var(--u) * 4px); opacity: .75; }
.bp .bp-ink { fill: currentColor; stroke: none; }

/* the pen: a line is gold while it is being drawn, ink once it is finished */
.bp .ln { stroke-dasharray: 1 1; stroke-dashoffset: calc((1 - var(--bpt)) * 1px); }
.bp :is(.rs, .wp) { transform-box: fill-box; transform-origin: 50% 100%; transform: scaleY(var(--bpt)); }
.bp .wp { transform-origin: 50% 0; }
.bp .gx { transform-box: fill-box; transform-origin: 0 50%; transform: scaleX(var(--bpt)); }
.bp-lines :is(.ln, .rs, .gx) { stroke: color-mix(in srgb, var(--gold-line) calc(clamp(0, calc((1 - var(--bpt)) * 24), 1) * 100%), currentColor); }
.bp .fd { opacity: var(--bpt); }
.bp .fo { opacity: calc(1 - var(--bpt)); }
.bp .dm { opacity: calc(1 - var(--k, .8) * var(--bpt)); }
.bp .pop { opacity: var(--bpt); transform: translateX(calc((1 - var(--bpt)) * var(--u) * -9px)); }
/* temporary works (formwork, props, scaffold, crane): only ever shown by the script, struck in the finished drawing */
.bp .tmp { opacity: 0; }
.bp-temp .bp-scaf { color: var(--ink-2); }
.bp-temp .bp-crane { color: var(--ink-2); }

/* hatches */
.bp pattern .pl { fill: none; stroke: currentColor; stroke-width: .8; }
.bp pattern .pf { fill: currentColor; }
.bp-fills :is(path, rect) { stroke: none; }
.bp-fills .w1, .bp-fills .w2 { fill: none; stroke: currentColor; }
.bp .bp-conc { fill: url(#bp-conc); }
.bp .bp-bond { fill: url(#bp-bond); opacity: .9; }
.bp .bp-soil path, .bp .bp-soilfill { fill: url(#bp-soil); }
.bp .bp-wp, .bp .bp-rebar { stroke-linecap: square; }
.bp .bp-mesh { stroke-width: calc(var(--u) * 2.2px); stroke-dasharray: 0 16; stroke-linecap: round; }   /* bars in section, every 0.4 m */
.bp .bp-fig :is(path, circle) { fill: var(--ink-3); stroke-width: calc(var(--u) * .8px); }
.bp .bp-bub circle { fill: var(--bg); stroke-width: calc(var(--u) * .9px); }
.bp .bp-bub { opacity: .85; }

/* ---------- the render (dev/drawing-render.mjs): plain fills, one opacity per layer ---------- */
.bp .rn { opacity: var(--bpt); }
.bp-render :is(path, rect, ellipse), .bp .rn-sky ellipse { stroke: none; }
.bp .rn-grain { opacity: var(--r-grain-op); }
.bp .rn-gr { fill: var(--r-ao); }
.bp .rn-gr2 { fill: var(--r-hi); }
.bp .rn-joint { fill: none; stroke: var(--r-joint); stroke-width: .9; }
.bp .rn-groove { fill: none; stroke: var(--r-groove); stroke-width: 1.3; }
.bp .rn-leaf { fill: var(--r-leaf); }
.bp .rn-limb { fill: none; stroke: var(--r-ppl); stroke-linecap: round; stroke-linejoin: round; }
.bp .rn-limb2 { stroke: var(--r-ppl-2); }
.bp .rn-rod { fill: none; stroke: var(--r-fr); stroke-width: 1.6px; stroke-linecap: round; }
.bp .rn-pipe { fill: none; stroke: var(--r-pipe); stroke-width: 3.6px; stroke-linejoin: round; }
.bp .rn-pipe-hi { fill: none; stroke: var(--r-pipe-hi); stroke-width: 1px; stroke-linejoin: round; transform: translate(-1px, 0); }
.bp .rn-pipe-sh { fill: none; stroke: var(--r-sh); stroke-width: 3.6px; stroke-linejoin: round; opacity: .55; transform: translate(3px, 2.5px); }
.bp .rn-mk path { fill: var(--r-mk); }
.bp .rn-mk use { fill: var(--r-wm); }
.bp .rn-mksh :is(path, use) { fill: var(--r-mk-sh); }
/* day / evening variants */
.bp :is(.rn-dusk, .rn-lit) { display: none; }
:root[data-theme="dark"]:not([data-vt="light"]) .bp :is(.rn-dusk, .rn-lit), :root[data-vt="dark"] .bp :is(.rn-dusk, .rn-lit) { display: inline; }
:root[data-theme="dark"]:not([data-vt="light"]) .bp .rn-day, :root[data-vt="dark"] .bp .rn-day { display: none; }

/* lettering: 12 px on screen on every sheet (--u turns CSS px into viewBox units) */
.bp text { font: 500 calc(var(--u) * 12px)/1 var(--font-mono); letter-spacing: .04em; fill: currentColor; stroke: none; font-variant-numeric: tabular-nums; }
.bp .bp-t2 { letter-spacing: .14em; }
/* level marks: the triangle stays about 8 px whatever the drawing's scale; the label starts 10 px after its tip
   and sits 3 px clear of its line (it is placed at the tip in the drawing) */
.bp .bp-lvtri { transform-box: fill-box; transform-origin: 50% 100%; transform: scale(calc(var(--u) * .7)); }
.bp .bp-lv text { transform: translate(calc(var(--u) * 10px), calc(var(--u) * -3px)); }
/* compact sheet (phones, narrow columns): the big tree, the scale figure, the title, the section marks, the
   vertical chain and the column-grid chain stay on the wide sheet; a slim tree frames the building's left side */
.bp.is-compact :is(.bp-wide, .bp-dimv, .bp-grid) { display: none; }
.bp:not(.is-compact) .bp-cpt { display: none; }
.bp.is-compact .bp-bub circle { r: calc(var(--u) * 8.5px); }
/* the compact sheet's last frame (and the static drawing on a phone): the finished building alone */
.bp.is-fin .bp-notes { display: none; }

/* the sky behind the finished building: an HTML layer under the drawing, so the frame never cuts it */
.build { --sky-a: rgba(214, 202, 188, .55); --sky-b: rgba(214, 202, 188, .2); --sky-h: rgba(251, 224, 180, .24); }
:root[data-theme="dark"]:not([data-vt="light"]) .build, :root[data-vt="dark"] .build { --sky-a: rgba(42, 97, 71, .5); --sky-b: rgba(16, 61, 41, .34); --sky-h: rgba(201, 149, 74, .2); }
/* Painted under the drawing with z-index -1 inside the figure's own stacking context; the svg itself stays
   unpositioned. (A positioned svg over a sky that switches on, or a fading sky, makes the browser re-rasterise
   the whole drawing from scratch: seconds of stalled frames on a slow phone.) The sky ends at the ground line
   (--gy, measured by js/stages.js), so no glow shows below the street; on a phone it zooms with the drawing. */
.build__sky {
  position: absolute; left: 0; right: 0; top: 0; height: var(--gy, 100%); z-index: -1; pointer-events: none; opacity: 0;
  transform-origin: var(--zo, 50% 50%);
  background:
    radial-gradient(ellipse 48% 32% at 50% 98%, var(--sky-h), transparent 72%),
    radial-gradient(ellipse 62% 66% at 50% 52%, var(--sky-a), var(--sky-b) 48%, transparent 76%);
}
html:not(.js-build) .build__sky, .build.is-sky .build__sky { opacity: 1; }

/* ---------- layout: static version (no script / reduced motion / short screens) ---------- */
.stages > .stages__top { padding-bottom: 0; }
.build__in { display: grid; padding-bottom: var(--sec-y); }
.build__dwg { position: relative; padding: 8px 0 20px; aspect-ratio: 860 / 864; }
.build__side { position: relative; }
.build__ruler, .build__read, .stage__big { display: none; }
.build__list { display: grid; }
.stage { position: relative; display: grid; justify-items: start; gap: 14px; padding: 26px 0 28px; border-top: 1px solid var(--line); }
.stage__meta { display: flex; gap: 12px; color: var(--ink-2); }
.stage__name { font: 800 clamp(1.8rem, 1.2rem + 2.3vw, 2.9rem)/1 var(--font-display); font-stretch: 80%; text-transform: uppercase; overflow-wrap: break-word; }
.stage__text { font-size: var(--fs-lead); line-height: 1.5; color: var(--ink-2); max-width: 34ch; text-wrap: pretty; }
.stage__cta { margin-top: 2px; }
.stage--end { border-top-color: var(--line-2); }
.stage--end .stage__meta { color: var(--gold-text); }
.stage__go { margin-top: 6px; }

@media (min-width: 900px) {
  .build__in { grid-template-columns: minmax(0, 7.7fr) minmax(0, 4.3fr); }
  .build__dwg { position: sticky; top: calc(var(--hdr) + 24px); align-self: start; aspect-ratio: 1000 / 940; padding: 24px var(--pad); }
  .build__side { border-left: 1px solid var(--line); }
  .stage { padding: 40px clamp(24px, 3vw, 44px); }
  .stage:first-child { border-top: 0; }
}

/* ---------- pinned, scroll-driven version ---------- */
html.js-build .build { height: calc(100vh - var(--hdr) - var(--abar) + var(--build-len, 560vh)); height: calc(100svh - var(--hdr) - var(--abar) + var(--build-len, 560vh)); }
html.js-build .build__pin { position: sticky; top: var(--hdr); height: calc(100vh - var(--hdr) - var(--abar)); height: calc(100svh - var(--hdr) - var(--abar)); overflow: hidden; }
html.js-build .build__in { height: 100%; padding-bottom: 0; grid-template-rows: minmax(0, 47fr) minmax(0, 53fr); }
html.js-build .build__dwg { position: relative; top: auto; align-self: stretch; aspect-ratio: auto; min-height: 0; padding: 10px 0 6px; overflow: hidden; }
html.js-build .build__side { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-top: 1px solid var(--line-2); }

/* the stage ruler: 5 ticks, a slab travels along it */
html.js-build .build__ruler {
  position: relative; display: block; height: 45px; border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 8px) 0 100% / 100% 5px no-repeat;
}
.build__bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.build__bar i { display: block; height: 100%; background: var(--hl); transform-origin: 0 50%; transform: scaleX(var(--bp, 0)); }
.build__tick {
  position: absolute; left: calc(var(--i) * 20%); bottom: 0; top: 0; min-width: 44px; padding: 0 0 0 9px; text-align: left;
  font: 500 var(--fs-ann)/1 var(--font-mono); letter-spacing: .1em; color: var(--ink-2); border-left: 1px solid var(--line-2); transition: color .3s;
}
.build__tick[aria-current="step"], .build__tick.is-done { color: var(--ink); }
.build__tick[aria-current="step"] .build__n { box-shadow: 0 2px 0 var(--hl); }
.build__tick:focus-visible { outline-offset: -3px; }

html.js-build .build__list { position: relative; display: block; min-height: 0; }
html.js-build .stage {
  position: absolute; inset: 0; align-content: start; gap: 10px; padding: clamp(14px, 3.4vh, 44px) 0 14px; border: 0;
  opacity: 0; pointer-events: none; transform: translateY(22px);     /* the other sheets stay readable for assistive tech; */
  transition: opacity .4s var(--ease), transform .6s var(--ease);    /* focusing one scrolls the drawing to it (js/stages.js) */
}
html.js-build .stage.is-past { transform: translateY(-22px); }
html.js-build .stage.is-active { opacity: 1; pointer-events: auto; transform: none; transition: opacity .5s var(--ease) .12s, transform .7s var(--ease) .1s; }
html.js-build .stage__name { font-size: clamp(1.7rem, 8.6vw, 2.4rem); }
html.js-build .stage__text { font-size: .9375rem; line-height: 1.45; }
html.js-build .stage__chips { gap: 6px; }
html.js-build .stage__chips li { padding: 5px 9px 5px 8px; font-size: .75rem; }
html.js-build .stage__cta { min-height: 44px; padding-top: 4px; }
html.js-build .stage--end .stage__name { font-size: clamp(2rem, 10.4vw, 3rem); }
html.js-build .stage--end { align-content: center; padding-bottom: clamp(14px, 3.4vh, 44px); }   /* the closing sheet sits balanced, no empty foot */
html.js-build .build__read { display: block; position: absolute; right: 0; top: 50px; color: var(--ink-2); transition: opacity .3s; }
html.js-build .build.is-final .build__read { opacity: 0; }
/* short phones: the sheet gets the larger share and sets a size smaller, so its price link is never cut */
@media (max-height: 620px) and (max-width: 899.98px) {
  html.js-build .build__in { grid-template-rows: minmax(0, 40fr) minmax(0, 60fr); }
  html.js-build .build__ruler { height: 40px; }
  html.js-build .stage { gap: 8px; padding-top: 12px; }
  html.js-build .stage__text { font-size: .875rem; line-height: 1.4; }
  html.js-build .build__read { top: 44px; }
}
@media (max-height: 680px) and (max-width: 899.98px) {
  html.js-build .stage__chips { display: none; }
  /* little room for the drawing: the setting-out bubbles and the column-grid chain give way to the building */
  .bp.is-compact :is(.bp-grid, .bp-bub) { display: none; }
}

@media (min-width: 600px) and (max-width: 899.98px) {
  html.js-build .build__in { grid-template-rows: minmax(0, 58fr) minmax(0, 42fr); }
}
@media (min-width: 900px) {
  html.js-build .build__in { grid-template-rows: minmax(0, 1fr); }
  html.js-build .build__dwg { padding: clamp(14px, 2.6vh, 30px) var(--pad); }
  html.js-build .build__in { grid-template-columns: minmax(0, 1fr) clamp(380px, 31%, 440px); }
  html.js-build .build__side { grid-template-rows: none; grid-template-columns: 58px minmax(0, 1fr); border-top: 0; }
  html.js-build .build__ruler {
    height: auto; border-bottom: 0; border-right: 1px solid var(--line-2);
    background:
      repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 8px) 100% 0 / 5px 100% no-repeat;
  }
  .build__bar { left: auto; right: -2px; top: 0; bottom: 0; width: 3px; height: auto; }
  .build__bar i { transform-origin: 50% 0; transform: scaleY(var(--bp, 0)); }
  .build__tick { left: 0; right: 0; top: calc(var(--i) * 20%); bottom: auto; height: 44px; padding: 9px 0 0; text-align: center; border-left: 0; border-top: 1px solid var(--line-2); }
  html.js-build .stage { align-content: center; gap: 16px; padding: 24px; }
  html.js-build .stage__name { font-size: clamp(1.6rem, 2.9vw, 2.6rem); }
  html.js-build .stage--end .stage__name { font-size: clamp(2.2rem, 3.9vw, 3.6rem); }
  html.js-build .stage__text { font-size: var(--fs-lead); line-height: 1.5; }
  html.js-build .stage__chips { gap: 8px; }
  html.js-build .stage__chips li { padding: 7px 12px 7px 10px; font-size: .8125rem; }
  html.js-build .stage__cta { min-height: 44px; margin-top: 6px; }
  html.js-build .stage__big {
    display: block; position: absolute; right: 22px; top: clamp(20px, 3.4vh, 40px);
    font: 500 clamp(4rem, 7vw, 6.5rem)/.8 var(--font-mono); letter-spacing: -.04em; color: transparent; -webkit-text-stroke: 1px var(--line-2);
  }
  html.js-build .build__read { right: 24px; top: auto; bottom: clamp(20px, 3.4vh, 40px); }
}
