/* ==========================================================================
   Halvard Tonic — template stylesheet
   BRAND SETTINGS: change these first. Everything else reads from them.
   ========================================================================== */
:root {
  --t-ground: #ecebe5;        /* page ground (off-white) */
  --t-ground-2: #e2e1da;      /* panels and swatches */
  --t-ink: #16171a;           /* text */
  --t-muted: #6a6b66;         /* secondary text */
  --t-line: #cbcac2;          /* hairlines */
  --t-night: #121315;         /* dark passage ground */
  --t-night-muted: #9c9d97;   /* secondary text on night */
  --t-night-line: #34352f;

  --t-display: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --t-body: 'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --t-mono: 'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --gutter: clamp(16px, 4vw, 64px);
  --pill: 999px;
  --radius: 18px;
  --nav-h: 64px;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/space-grotesk-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Mono';
  src: url('../fonts/space-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--t-ground);
  color: var(--t-ink);
  font-family: var(--t-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }
h1, h2, h3, p, ul, ol, dl, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
:focus-visible { outline: 2px solid var(--t-ink); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--gutter); top: -40px; z-index: 50; padding: 8px 14px; background: var(--t-ink); color: var(--t-ground); border-radius: var(--pill); }
.skip:focus { top: 12px; }

/* ---------- type ---------- */
.label {
  font-family: var(--t-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t-muted);
}
.display {
  font-family: var(--t-display);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.96;
  text-wrap: balance;
}
.lede { font-size: clamp(16px, 1.25vw, 19px); max-width: 34rem; color: var(--t-ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 22px;
  border-radius: var(--pill);
  background: var(--t-ink); color: var(--t-ground);
  border: 1px solid var(--t-ink);
  font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.4s cubic-bezier(.2,.7,.2,1), background-color 0.4s, color 0.4s, border-color 0.4s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn-ghost { background: transparent; color: var(--t-ink); border-color: var(--t-line); }
.btn-ghost:hover { border-color: var(--t-ink); }
.btn-small { min-height: 38px; padding: 0 16px; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: var(--nav-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 var(--gutter);
  background: transparent;
  transition: color 0.8s, background-color 0.8s;
}
body.nav-solid .nav {
  background: color-mix(in srgb, var(--t-ground) 78%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
body.nav-solid.is-night .nav { background: color-mix(in srgb, var(--t-night) 70%, transparent); }
.nav-brand { font-family: var(--t-display); font-weight: 600; letter-spacing: -0.03em; font-size: 22px; }
.nav-links { display: flex; gap: 28px; font-family: var(--t-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav .btn { justify-self: end; }

/* ---------- 3D canvas layer ---------- */
.stage-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background: var(--t-ground);
  transition: background-color 0.9s;
}
.stage-canvas canvas, .stage-canvas .poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.stage-canvas .poster { object-fit: cover; object-position: 62% 50%; }
html.gl-ready .stage-canvas .poster { display: none; }
html.gl-failed .stage-canvas canvas { display: none; }
@media (max-width: 760px) { .stage-canvas .poster { object-position: 50% 28%; } }

main { position: relative; z-index: 1; }

/* ---------- story (pinned, 4 stages) ---------- */
.story { position: relative; }
.story-pin {
  position: relative; height: 100vh; height: 100svh; overflow: hidden;
  padding: 0 var(--gutter);
}
.rail {
  position: absolute; left: var(--gutter); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 18px;
  font-family: var(--t-mono); font-size: 11px; letter-spacing: 0.08em;
  color: var(--t-muted);
}
.rail li { position: relative; padding-left: 22px; transition: color 0.5s; }
.rail li::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 12px; height: 1px;
  background: currentColor; transform: translateY(-50%) scaleX(0.5); transform-origin: left; transition: transform 0.5s;
}
.story[data-stage="1"] .rail li[data-rail="1"],
.story[data-stage="2"] .rail li[data-rail="2"],
.story[data-stage="3"] .rail li[data-rail="3"],
.story[data-stage="4"] .rail li[data-rail="4"] { color: var(--t-ink); }
.story[data-stage="1"] .rail li[data-rail="1"]::before,
.story[data-stage="2"] .rail li[data-rail="2"]::before,
.story[data-stage="3"] .rail li[data-rail="3"]::before,
.story[data-stage="4"] .rail li[data-rail="4"]::before { transform: translateY(-50%) scaleX(1); }

.stage {
  position: absolute; left: calc(var(--gutter) + 72px); top: 50%; transform: translateY(-50%) translateY(14px);
  width: min(44vw, 620px);
  display: grid; gap: 22px;
  opacity: 0; visibility: hidden;
  transition: opacity 0.7s cubic-bezier(.2,.7,.2,1), transform 0.7s cubic-bezier(.2,.7,.2,1), visibility 0s linear 0.7s;
}
.story[data-stage="1"] .stage[data-stage="1"],
.story[data-stage="2"] .stage[data-stage="2"],
.story[data-stage="3"] .stage[data-stage="3"],
.story[data-stage="4"] .stage[data-stage="4"] {
  opacity: 1; visibility: visible; transform: translateY(-50%);
  transition: opacity 0.7s cubic-bezier(.2,.7,.2,1) 0.15s, transform 0.7s cubic-bezier(.2,.7,.2,1) 0.15s, visibility 0s;
}
.stage .display { font-size: clamp(2.4rem, 5.4vw, 5.6rem); }
.stage h2.display { font-size: clamp(2.1rem, 4.4vw, 4.4rem); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.list { display: grid; max-width: 36rem; border-top: 1px solid var(--t-line); }
.list li { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--t-line); font-size: 15px; }
.list li span:last-child { color: var(--t-muted); }

/* night passage: stage 3 */
.story.is-night { color: var(--t-ground); }
.story.is-night .label, .story.is-night .rail li, .story.is-night .list li span:last-child { color: var(--t-night-muted); }
.story.is-night .rail li.is-on { color: var(--t-ground); }
.story.is-night .list, .story.is-night .list li { border-color: var(--t-night-line); }
.story.is-night .btn { background: var(--t-ground); color: var(--t-ink); border-color: var(--t-ground); }
.story.is-night .btn-ghost { background: transparent; color: var(--t-ground); border-color: var(--t-night-line); }
.story.is-night .lede { color: var(--t-ground); }
body.is-night .nav { color: var(--t-ground); }
body.is-night .nav .btn { background: var(--t-ground); color: var(--t-ink); border-color: var(--t-ground); }
body.is-night .stage-canvas { background: var(--t-night); }

/* ---------- range ---------- */
.range { position: relative; min-height: 100vh; min-height: 100svh; display: flex; align-items: center; padding: clamp(90px, 12vw, 160px) var(--gutter); }
.range-inner { width: min(46vw, 640px); display: grid; gap: 28px; }
.range .display { font-size: clamp(2.1rem, 4.4vw, 4.4rem); }

.variants { display: grid; border-top: 1px solid var(--t-line); }
.variant {
  position: relative; display: grid; grid-template-columns: 28px 1fr auto; grid-template-areas: "sw name price" "sw note price"; column-gap: 16px; align-items: center;
  padding: 16px 0; border-bottom: 1px solid var(--t-line); cursor: pointer;
}
.variant input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.variant-swatch {
  grid-area: sw; width: 28px; height: 28px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0, transparent 40%), var(--liquid);
  box-shadow: inset 0 0 0 1px #0002, 0 0 0 0 var(--t-ink);
  transition: box-shadow 0.4s;
}
.variant-name { grid-area: name; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.variant-note { grid-area: note; font-size: 14px; color: var(--t-muted); }
.variant-price { grid-area: price; font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.04em; }
.variant:has(input:checked) .variant-swatch { box-shadow: inset 0 0 0 1px #0002, 0 0 0 2px var(--t-ground), 0 0 0 3px var(--t-ink); }
.variant:has(input:focus-visible) .variant-name { text-decoration: underline; text-underline-offset: 0.15em; }

.order { display: grid; gap: 14px; max-width: 30rem; }
.order-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--t-line); font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.order-row select {
  font: inherit; font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.04em;
  background: transparent; color: inherit; border: 1px solid var(--t-line); border-radius: var(--pill); padding: 8px 32px 8px 14px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2316171a' stroke-width='1.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.order-total strong { font-family: var(--t-display); font-weight: 500; font-size: 28px; letter-spacing: -0.03em; text-transform: none; }
.order .btn { justify-self: start; }
.order-note { font-size: 13px; color: var(--t-muted); }

/* ---------- process (night) ---------- */
.process {
  position: relative; background: var(--t-night); color: var(--t-ground);
  padding: clamp(90px, 12vw, 160px) var(--gutter);
  display: grid; gap: clamp(40px, 6vw, 80px);
}
.section-head { display: grid; grid-template-columns: 1fr; gap: 16px; }
.section-head .display { font-size: clamp(2.1rem, 4.4vw, 4.4rem); max-width: 18ch; }
.process .label { color: var(--t-night-muted); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; border-top: 1px solid var(--t-night-line); }
.steps li { padding-top: 20px; display: grid; gap: 10px; align-content: start; }
.step-num { font-family: var(--t-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--t-night-muted); }
.steps h3 { font-family: var(--t-display); font-weight: 500; font-size: clamp(1.6rem, 2.6vw, 2.4rem); letter-spacing: -0.03em; line-height: 1; }
.steps p { color: var(--t-night-muted); font-size: 15px; max-width: 28rem; }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 32px; border-top: 1px solid var(--t-night-line); }
.specs div { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--t-night-line); font-size: 15px; }
.specs dt { color: var(--t-night-muted); }
.specs dd { margin: 0; font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.04em; }

/* ---------- stockists ---------- */
.stockists { padding: clamp(90px, 12vw, 160px) var(--gutter); display: grid; gap: clamp(40px, 6vw, 80px); background: var(--t-ground); position: relative; }
.shops { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 48px; border-top: 1px solid var(--t-line); }
.shops li { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--t-line); font-size: clamp(18px, 1.6vw, 24px); font-weight: 500; letter-spacing: -0.02em; }
.shops li span:last-child { font-family: var(--t-mono); font-size: 12px; letter-spacing: 0.06em; font-weight: 400; color: var(--t-muted); text-transform: uppercase; align-self: center; }
.stockists-cta { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px; padding: 24px 0 0; max-width: 60rem; }
.stockists-cta p { font-size: clamp(16px, 1.25vw, 19px); }

/* ---------- footer ---------- */
.footer { position: relative; background: var(--t-night); color: var(--t-ground); padding: clamp(60px, 8vw, 110px) var(--gutter) 40px; display: grid; gap: 48px; }
.footer-brand { font-family: var(--t-display); font-weight: 500; letter-spacing: -0.05em; line-height: 0.9; font-size: clamp(3.2rem, 11vw, 12rem); }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; font-size: 15px; }
.footer-cols .label { color: var(--t-night-muted); margin-bottom: 10px; }
.footer-legal { font-size: 13px; color: var(--t-night-muted); border-top: 1px solid var(--t-night-line); padding-top: 20px; max-width: 60rem; }

/* ---------- poster mode (?poster=1): scene only, for making the fallback image ---------- */
html.poster-mode main, html.poster-mode .nav, html.poster-mode .footer, html.poster-mode .skip { display: none; }

/* ---------- reduced motion ---------- */
html.motion-reduced .story-pin { height: auto; min-height: 100vh; overflow: visible; display: grid; align-content: start; gap: 72px; padding-top: 140px; padding-bottom: 80px; }
html.motion-reduced .rail { display: none; }
html.motion-reduced .story[data-stage] .stage[data-stage] { position: static; transform: none; opacity: 1; visibility: visible; transition: none; }
html.motion-reduced .stage-canvas { position: absolute; height: 100vh; }
html.motion-reduced .range { min-height: 0; }

/* ---------- tablet / phone ---------- */
@media (max-width: 980px) {
  .steps { grid-template-columns: repeat(2, 1fr); }
  .specs { grid-template-columns: repeat(2, 1fr); }
  .shops { grid-template-columns: 1fr; }
  .stockists-cta { grid-template-columns: 1fr; align-items: start; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  :root { --nav-h: 56px; }
  body { font-size: 16px; }
  .nav { grid-template-columns: 1fr auto; }
  .nav-links { display: none; }
  .rail { left: var(--gutter); top: auto; bottom: 22px; transform: none; flex-direction: row; gap: 14px; }
  .rail li { padding-left: 16px; }
  .rail li::before { width: 10px; }
  .stage { left: var(--gutter); right: var(--gutter); width: auto; top: auto; bottom: 64px; transform: translateY(14px); gap: 14px; }
  .story[data-stage="1"] .stage[data-stage="1"],
  .story[data-stage="2"] .stage[data-stage="2"],
  .story[data-stage="3"] .stage[data-stage="3"],
  .story[data-stage="4"] .stage[data-stage="4"] { transform: none; }
  .stage .display { font-size: clamp(2rem, 9.6vw, 2.8rem); }
  .stage h2.display { font-size: clamp(1.8rem, 8.4vw, 2.5rem); }
  .lede { font-size: 15px; }
  .list li { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; font-size: 14px; }
  .range { align-items: flex-end; padding-top: 54vh; }
  .range-inner { width: 100%; }
  .range .display, .section-head .display, .stockists .display { font-size: clamp(1.9rem, 8.6vw, 2.6rem); }
  .variant { grid-template-columns: 24px 1fr; grid-template-areas: "sw name" "sw note" "sw price"; row-gap: 2px; }
  .variant-swatch { width: 24px; height: 24px; align-self: start; margin-top: 4px; }
  .steps { grid-template-columns: 1fr; gap: 20px; }
  .specs { grid-template-columns: 1fr; }
  .footer-cols { grid-template-columns: 1fr; }
  html.motion-reduced .story-pin { padding-top: 46vh; }
}
