/* layout.css (foundation, F-C, frozen after the foundation): themes, sections, tracks, seams, gutters.
   The --sc table below is the ONLY place a section's scroll length is set. A track is (1 + --sc) x 100svh of
   sticky travel. Never 100vh. A scene that needs a new atom defines it in its own prefixed stylesheet. */

:root {
  --gutter: clamp(16px, 4vw, 64px);
  --seam: 4vw;
  --pad-block: clamp(72px, 10vw, 160px);
  --sc: 0;
}

/* Worlds: razor-cut bands. Nav, rail, cursor and the swarm read these. html[data-theme] follows the section under the probe line. */
[data-theme=bone]   { --bg: var(--bone);   --fg: var(--on-bone); --mut: var(--on-bone-dim); --line: var(--line-bone); --acc: var(--signal); }
[data-theme=ink]    { --bg: var(--ink);    --fg: var(--on-ink);  --mut: var(--on-ink-dim);  --line: var(--line-ink);  --acc: var(--signal); }
[data-theme=signal] { --bg: var(--signal); --fg: var(--on-signal); --mut: rgb(255 255 255 / .78); --line: rgb(255 255 255 / .3); --acc: var(--ink); }

.sec, .site-footer { position: relative; background: var(--bg); color: var(--fg); overflow-x: clip; }
.sec--page { min-height: 100svh; }

/* Padding lives on the stage for tracked sections, and on the section itself for flow sections. */
.sec:not(:has(> .track)) { padding-block: var(--pad-block); padding-inline: var(--gutter); }
.stage { padding-inline: var(--gutter); padding-block: var(--pad-block); }
.site-footer { padding-block: clamp(48px, 6vw, 96px); padding-inline: var(--gutter); }

/* Content sits above the canvas. :where keeps specificity at zero so any scene rule wins. */
:where(.stage) > *, :where(.sec:not(:has(> .track))) > *, :where(.site-footer) > * { position: relative; z-index: 2; }

/* Default (no-JS, static, fx-fail): natural flow, nothing sticky. */
.track { height: auto; }
.stage { position: static; height: auto; }

/* Cinematic: tall tracks, sticky 100svh stages. Applied from first paint (the head guard adds .js before CSS evaluates). */
html.js:not(.fx-fail):not(.static) .track { height: calc((1 + var(--sc)) * 100svh); }
html.js:not(.fx-fail):not(.static) .track > .stage { position: sticky; top: 0; z-index: 2; height: 100svh; overflow: clip; padding-block: 0; }

/* Scroll length per section: desktop, then phone. Beats are track fractions, so trimming a track keeps every scene's order. */
#hero      { --sc: 1.2; }
#where     { --sc: 3.0; }
/* The flat tier (T0/T1 desktop) shows all six industries at once: ring.mjs sets html.where-flat, no long pin. */
html.where-flat #where { --sc: .6; }
#build     { --sc: 2.2; }
#two-weeks { --sc: 1.9; }
#pipeline  { --sc: 2.6; }
#process   { --sc: 1.6; }
#start     { --sc: 1.0; }

/* Layering (spec 3.3): section backgrounds < canvas (z1) < content (z2). A sticky stage and a clip-path each create a
   stacking context at z-index:auto, which would paint everything inside BELOW the fixed canvas. So the stage carries
   z-index:2 itself, and a tilted section clips a ::before background layer (z-index:0) instead of clipping itself.
   .sec must never get a z-index or clip-path of its own. */
.sec--tilt, .site-footer.sec--tilt { background: none; margin-top: calc(var(--seam) * -1); }
.sec--tilt::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: var(--bg);
  clip-path: polygon(0 var(--seam), 100% 0, 100% 100%, 0 100%);
}
.sec--tilt[data-theme=bone]::before { background: var(--fibre), var(--bg); }
.sec--tilt:not(:has(> .track)) { padding-top: calc(var(--seam) + var(--pad-block)); }
.site-footer.sec--tilt { padding-top: calc(var(--seam) + clamp(48px, 6vw, 96px)); }

/* Seam slot: a zero-height strip on a section's top edge for a seam-owned mark. Neutral by default; never a stripe. */
.seam { position: absolute; left: 0; right: 0; top: 0; height: 0; z-index: 6; overflow-x: clip; overflow-y: visible; pointer-events: none; }

@media (max-width: 900px) {
  :root { --gutter: 16px; --seam: 8vw; }
  #hero      { --sc: 1.0; }
  #where     { --sc: 3.7; }
  #build     { --sc: 1.1; }
  #two-weeks { --sc: 1.5; }
  #pipeline  { --sc: 2.2; }
  #process   { --sc: 1.4; }
  #start     { --sc: 1.0; }
}
