/* A control scene with a floor plan (scripts/lib/story-plan.mjs). Loaded only by stories that use one.
   Base rules: the steps as a list, each with a small static plan, its time, name and line, readable
   without JavaScript or with reduced motion. Under the motion query (.js pages) the track pins, one large
   plan sits beside the words, and lab-geber.js writes each fitting's --l (level) and --w (warmth, 0 cool
   to 1 warm), the sensor's --s, the button's --bo/--bs and each step's --v. Light changes are opacity
   only: a cool and a warm pool per fitting, faded against each other. */

.lab-plan__layout { width: min(100% - 2 * var(--gutter), 1200px); margin-inline: auto; }
.lab-plan__track { padding-bottom: 0; }
/* Static: the key sits under the opening words, above the plans it explains. */
.lab-plan__text { display: flex; flex-direction: column; align-items: center; text-align: center; }
.lab-plan__steps { order: 2; width: 100%; }
.lab-plan__copy { margin-bottom: 0; }
.lab-plan__figure, .lab-plan__rail { display: none; }
.lab-plan__figure { margin: 0; }

.lab-plan__steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(32px, 4vw, 48px) clamp(20px, 3vw, 36px); margin: clamp(36px, 5vw, 64px) 0 0; padding: 0; list-style: none; text-align: left; }
@media (min-width: 700px) { .lab-plan__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .lab-plan__steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.lab-plan__thumb { margin-bottom: 16px; padding: 12px; border: 1px solid rgba(243, 241, 236, 0.08); border-radius: 6px; }
.lab-plan__time { margin: 0 0 4px; font-size: 1rem; font-weight: 500; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; color: #e8c48c; }
.lab-plan__name { margin: 0 0 6px; font-size: clamp(1.35rem, 1.05rem + 1vw, 1.9rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; color: var(--lab-ink); }
.lab-plan__line { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--lab-dim); }

.lab-plan__legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; margin: clamp(24px, 3vw, 36px) 0 0; padding: 0; list-style: none; font-size: 1rem; color: var(--lab-dim); }
.lab-plan__key { display: flex; align-items: center; gap: 8px; }
.lab-plan__key svg { width: 24px; height: 24px; flex: none; }
.lab-plan__key-glow { fill: rgba(255, 214, 160, 0.16); }
.lab-plan__key-mark { fill: #ffe2b4; }
.lab-plan__key-line { stroke: #ffe2b4; stroke-width: 3; stroke-linecap: round; }

.lab-plan__end { padding-block: clamp(32px, 5vw, 56px) clamp(72px, 12vw, 160px); text-align: center; }
.lab-plan__note { max-width: 34rem; margin: 0 auto 1.6rem; font-size: 1rem; line-height: 1.5; color: var(--lab-dim); }

/* The drawing: an architect's plan in warm-white hairlines. */
.lab-plan__svg { display: block; width: 100%; height: auto; overflow: visible; }
.lab-plan__floor .lab-plan__room { fill: rgba(243, 241, 236, 0.022); }
.lab-plan__floor .lab-plan__room--outside { fill: none; }
.lab-plan__walls .lab-plan__room { fill: none; stroke: #9a958b; stroke-width: 3.2; }
.lab-plan__walls .lab-plan__room--outside { stroke: rgba(243, 241, 236, 0.4); stroke-width: 1.4; stroke-dasharray: 7 6; }
.lab-plan__door { stroke: var(--lab-bg); stroke-width: 5; }
.lab-plan__line { fill: none; stroke: rgba(243, 241, 236, 0.36); stroke-width: 1.5; }
.lab-plan__line--dashed { stroke-dasharray: 6 6; }
.lab-plan__label { fill: rgba(243, 241, 236, 0.5); font-family: var(--font); font-size: 19px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; }

/* Light: each fitting's pool, a cool and a warm layer faded against each other. Level 0 is truly off. */
/* --i: how bright the pool reads. Low levels stay visible (a dim light still shows where it falls); 0 is off. */
.lab-plan__pool { --i: calc(clamp(0, var(--l, 0) * 12, 1) * (0.42 + var(--l, 0) * 0.7)); }
.lab-plan__glow--cool { opacity: calc(var(--i) * (1 - var(--w, 1))); }
.lab-plan__glow--warm { opacity: calc(var(--i) * var(--w, 1)); }
.lab-plan__mark { fill: var(--lab-bg); stroke: rgba(243, 241, 236, 0.55); stroke-width: 1.5; }
.lab-plan__mark--line { stroke: rgba(243, 241, 236, 0.3); stroke-width: 3.4; stroke-linecap: round; }
.lab-plan__lit { --on: clamp(0, calc(var(--l, 0) * 3), 1); }
.lab-plan__lit--cool { fill: #f1f5ff; opacity: calc(var(--on) * (1 - var(--w, 1))); }
.lab-plan__lit--warm { fill: #ffe6bf; opacity: calc(var(--on) * var(--w, 1)); }
.lab-plan__lit--line { fill: none; stroke-width: 3.4; stroke-linecap: round; }
.lab-plan__lit--line.lab-plan__lit--cool { stroke: #f1f5ff; }
.lab-plan__lit--line.lab-plan__lit--warm { stroke: #ffe6bf; }

/* The sensor (a blink as someone gets up) and the one large button (a single pulse). */
.lab-plan__sensor-body { fill: var(--lab-bg); stroke: rgba(243, 241, 236, 0.55); stroke-width: 1.4; }
.lab-plan__key-sensor { fill: none; stroke: rgba(243, 241, 236, 0.7); stroke-width: 1.6; }
.lab-plan__key-button { fill: none; stroke: rgba(243, 241, 236, 0.75); stroke-width: 1.8; }
.lab-plan__key-dot { fill: #e8c48c; }
.lab-plan__sensor-dot { fill: #e8c48c; opacity: var(--s, 0); }
.lab-plan__sensor-ring { fill: none; stroke: #e8c48c; stroke-width: 1.4; opacity: calc(var(--s, 0) * 0.7); }
.lab-plan__sensor.is-on { --s: 1; }
.lab-plan__button-body { fill: var(--lab-bg); stroke: rgba(243, 241, 236, 0.7); stroke-width: 2; }
.lab-plan__button-face { fill: #e8c48c; opacity: calc(0.25 + var(--bh, 0) * 0.75); }
.lab-plan__button-ring { fill: none; stroke: #e8c48c; stroke-width: 1.6; opacity: var(--bo, 0); transform-box: fill-box; transform-origin: center; transform: scale(var(--bs, 1)); }
.lab-plan__button.is-on { --bh: 1; --bo: 0.45; --bs: 1.7; }

/* A small plan per step in the static list: labels are too small to read there. */
.lab-plan__thumb .lab-plan__label { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .js .lab-plan__track { height: 600vh; }
  .js .lab-plan .lab-pin__stage { display: flex; align-items: center; }
  .js .lab-plan__layout { display: grid; grid-template-columns: minmax(0, 60fr) minmax(0, 40fr); gap: clamp(32px, 4.5vw, 72px); align-items: center; width: min(100% - 2 * var(--gutter), 1440px); }
  .js .lab-plan__figure { display: block; }
  .js .lab-plan__svg--live { max-height: calc(var(--lab-stage) - 96px); }
  .js .lab-plan__text { display: block; text-align: left; }
  .js .lab-plan__title { font-size: clamp(2rem, 1rem + 2.3vw, 3.3rem); }
  .js .lab-plan__copy { margin: 0; font-size: clamp(1rem, 0.94rem + 0.25vw, 1.15rem); }

  .js .lab-plan__rail { position: relative; display: flex; justify-content: space-between; margin: clamp(22px, 3.4vh, 36px) 0 clamp(16px, 2.6vh, 28px); padding: 0; list-style: none; max-width: 30rem; }
  .js .lab-plan__rail::before { content: ""; position: absolute; left: 4px; right: 4px; top: 4px; height: 1px; background: rgba(243, 241, 236, 0.18); }
  .js .lab-plan__rail li { position: relative; padding-top: 18px; font-size: 1rem; font-variant-numeric: tabular-nums; color: rgba(243, 241, 236, calc(0.42 + var(--v, 0) * 0.58)); }
  .js .lab-plan__rail li::before { content: ""; position: absolute; left: 0; top: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--lab-bg); box-shadow: inset 0 0 0 1.5px rgba(243, 241, 236, 0.45); }
  .js .lab-plan__rail li::after { content: ""; position: absolute; left: 0; top: 0; width: 9px; height: 9px; border-radius: 50%; background: #e8c48c; opacity: var(--v, 0); }
  .js .lab-plan__rail li:last-child { text-align: right; }
  .js .lab-plan__rail li:last-child::before, .js .lab-plan__rail li:last-child::after { left: auto; right: 0; }

  .js .lab-plan__steps { grid-template-columns: minmax(0, 1fr); margin: 0; }
  .js .lab-plan__step { grid-area: 1 / 1; opacity: var(--v, 0); }
  .js .lab-plan__step:first-child { opacity: var(--v, 1); }
  .js .lab-plan__thumb { display: none; }
  .js .lab-plan__name { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.3rem); }
  .js .lab-plan__line { font-size: clamp(1rem, 0.94rem + 0.3vw, 1.2rem); }
  .js .lab-plan__legend { justify-content: flex-start; margin-top: clamp(20px, 3.4vh, 36px); }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 899px) {
  .js .lab-plan .lab-pin__stage { align-items: flex-start; }
  .js .lab-plan__layout { grid-template-columns: minmax(0, 1fr); gap: clamp(12px, 2vh, 22px); padding-top: clamp(10px, 2vh, 24px); }
  .js .lab-plan__svg--live { max-height: 34vh; margin-inline: auto; }
  .js .lab-plan__label { font-size: 25px; letter-spacing: 0.04em; }
  /* Room for everything above the product bar: the eyebrow goes, and the rail keeps its dots (the step shows its time). */
  .js .lab-plan__text .lab-eyebrow { display: none; }
  .js .lab-plan__title { font-size: 1.75rem; }
  .js .lab-plan__copy { font-size: 1rem; }
  .js .lab-plan__rail { margin: 14px 0 12px; }
  .js .lab-plan__rail li { padding-top: 9px; font-size: 0; }
  .js .lab-plan__name { font-size: 1.4rem; }
  .js .lab-plan__line { font-size: 1rem; }
  .js .lab-plan__legend { gap: 4px 18px; margin-top: 14px; }
}
