/* ชาดอย — layout and type. Colours come from tokens.css (generated from data/tokens.json). */
@font-face {
  font-family: 'Noto Sans Thai';
  src: url('../assets/fonts/NotoSansThai-VF.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62.5% 100%;
  font-display: swap;
}

:root {
  --stage: var(--green-bg);
  --hair: color-mix(in oklab, var(--ink) 24%, transparent);
  --gut: 6vw;
  --display: clamp(100px, 25vh, 240px);
  --body: 17px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html {
  background: var(--stage);
  color: var(--ink);
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  margin: 0;
  background: var(--stage);
  color: var(--ink);
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 16px;
  line-height: normal;
}
img { max-width: 100%; }
a { color: inherit; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.sec { --bg: var(--paper); --accent: var(--metal); }
.sec[data-i='0'] { --bg: var(--green-bg); --accent: var(--green-accent); }
.sec[data-i='1'] { --bg: var(--black-bg); --accent: var(--black-accent); }
.sec[data-i='2'] { --bg: var(--oolong-bg); --accent: var(--oolong-accent); }
.sec[data-i='3'] { --bg: var(--paper); --accent: var(--metal); }

/* ---------- type ---------- */
.headline {
  margin: 0;
  font-size: var(--display);
  font-weight: 860;
  font-stretch: 100%;
  line-height: 1.3;
  letter-spacing: -0.012em;
  white-space: nowrap;
}
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  display: flex;
  gap: 1.1em;
  align-items: center;
}
.eyebrow .n { font-variant-numeric: tabular-nums; }
.eyebrow .rule { width: 36px; height: 1px; background: var(--ink); opacity: 0.55; }
.para {
  margin: 0;
  font-size: var(--body);
  line-height: 1.65;
  font-weight: 400;
  max-width: 32ch;
}
.spec {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 450;
}
.spec li { padding: 11px 0 10px; border-bottom: 1px solid var(--hair); }
.spec li:first-child { border-top: 1px solid var(--ink); font-weight: 650; }
.spec .k-ph { display: none; }
.shape svg, .doodle svg, .ridge svg { display: block; width: 100%; height: 100%; overflow: visible; }
.shape path, .shape circle { fill: var(--accent); }
.doodle path, .ridge path { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ridge path { stroke: var(--metal); stroke-width: 1; }
.ridge path.far { opacity: 0.45; }

.contact { list-style: none; margin: 0; padding: 0; font-size: 17px; line-height: 1.5; }
.contact li { padding: 13px 0 12px; border-bottom: 1px solid var(--hair); }
.contact li:first-child { border-top: 1px solid var(--ink); }
.more { display: flex; gap: 28px; font-size: 14px; font-weight: 600; margin: 0; padding: 0; list-style: none; }
.more a { text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 2px; }
.fineprint { margin: 0; font-size: 12px; letter-spacing: 0.04em; opacity: 0.62; }
.hint { margin: 0; font-size: 12px; letter-spacing: 0.08em; display: flex; gap: 10px; align-items: center; opacity: 0.75; }
kbd {
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  border: 1px solid color-mix(in oklab, var(--ink) 40%, transparent); border-radius: 4px; padding: 1px 6px;
}

/* ---------- top bar (layer 2) ---------- */
.bar {
  position: fixed; z-index: 6; left: 0; right: 0; top: 0;
  padding: calc(22px + env(safe-area-inset-top, 0px)) var(--gut) 0;
  display: flex; align-items: center; gap: 28px;
  font-size: 13px;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; margin-right: auto; }
.brand b { font-size: 22px; font-weight: 820; letter-spacing: -0.01em; }
.brand small { font-size: 11px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.7; }
.bar nav ol { list-style: none; display: flex; gap: 22px; margin: 0; padding: 0; }
.bar nav a { text-decoration: none; font-weight: 500; opacity: 0.62; padding: 6px 0; border-bottom: 1px solid transparent; }
.bar nav a[aria-current] { opacity: 1; border-bottom-color: var(--ink); }
.bar nav .n { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; margin-right: 6px; opacity: 0.8; }
.motion {
  font: inherit; font-size: 12px; color: inherit; background: transparent; cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--ink) 30%, transparent); border-radius: 999px; padding: 6px 12px;
}
.motion .motion-state { font-weight: 650; }
.counter { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.counter span { opacity: 0.55; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.skip { position: fixed; z-index: 30; left: 12px; top: -60px; background: var(--paper); padding: 8px 12px; }
.skip:focus { top: 12px; }

/* reading progress: a hairline across the top edge, so every scroll input shows some response */
.progress { display: none; }
html.js .progress {
  display: block; position: fixed; z-index: 7; left: 0; right: 0; top: 0; height: 2px; pointer-events: none;
  background: color-mix(in oklab, var(--ink) 8%, transparent);
}
html.js .progress i { display: block; height: 100%; background: color-mix(in oklab, var(--ink) 55%, transparent); transform: scaleX(0); transform-origin: left; }

/* shown only when the 3D page failed to start and the plain document took over */
.boot-note { display: none; }
html.boot-failed .boot-note {
  display: block; margin: 0; padding: 12px var(--gut); background: var(--ink); color: var(--paper); font-size: 14px;
}

/* ---------- stage layers ---------- */
.stage-bg, canvas.gl, canvas.ghost, .posters, .loader { display: none; }

/* ================= no-JS: plain readable document ================= */
html.no-js .bar { position: static; padding-bottom: 12px; }
html.no-js .motion, html.no-js .counter, html.no-js .hint { display: none; }
html.no-js .sec {
  min-height: 100vh; padding: 14vh var(--gut) 10vh; background: var(--bg);
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px 4vw; align-content: center;
}
html.no-js .sec > * { grid-column: 1; }
html.no-js .still { grid-column: 2; grid-row: 1 / span 8; align-self: center; justify-self: center; max-height: 72vh; width: auto; }
html.no-js .shape, html.no-js .doodle, html.no-js .ridge { display: none; }
html.no-js .headline { font-size: clamp(64px, 16vh, 180px); }

/* ================= JS: layered stage ================= */
html.js body { overflow-x: clip; }
html.js .stage-bg { display: block; position: fixed; inset: 0; z-index: 0; background: var(--stage); }
html.js canvas.gl, html.js canvas.ghost { display: block; position: fixed; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
html.js canvas.ghost { opacity: 0; }
html.js .posters { display: block; position: fixed; inset: 0; z-index: 3; pointer-events: none; }
html.js .posters img { position: absolute; opacity: 0; max-width: none; }
html.js:not(.is-still) .posters { display: none; }
html.js.is-still canvas.gl, html.js.is-still canvas.ghost { display: none; }
html.js .still { display: none; }

html.js .track { position: relative; height: 550vh; margin: 0; }
html.js .sec { position: absolute; left: 0; right: 0; height: 100vh; pointer-events: none; }
html.js .sec[data-i='0'] { top: 45vh; }
html.js .sec[data-i='1'] { top: 180vh; }
html.js .sec[data-i='2'] { top: 315vh; }
html.js .sec[data-i='3'] { top: 450vh; }

/* off-beat leaves stay in the accessibility tree (opacity only) but never take the pointer */
html.js .leaf { position: fixed; margin: 0; opacity: 0; pointer-events: none; }
html.js .leaf.is-on { pointer-events: auto; }
html.js .shape, html.js .ridge { z-index: 1; pointer-events: none !important; }
html.js .headline { z-index: 2; }
html.js .eyebrow, html.js .para, html.js .spec, html.js .doodle, html.js .contact, html.js .more,
html.js .fineprint, html.js .hint { z-index: 4; }
html.js .doodle { pointer-events: none !important; }

/* loader */
html.js .loader {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 20; background: var(--green-bg);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.7s;
}
html.js .loader.is-done { opacity: 0; visibility: hidden; }
.loader-in { display: grid; gap: 14px; justify-items: center; }
.loader-mark { font-size: 44px; font-weight: 820; letter-spacing: -0.01em; }
.loader-bar { width: 168px; height: 1px; background: color-mix(in oklab, var(--ink) 16%, transparent); overflow: hidden; }
.loader-bar i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; }
.loader-pct { font-size: 11px; font-weight: 600; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; opacity: 0.7; }
html.is-reduced .loader { transition-duration: 0.3s; }

/* ---------- desktop composition (1440x900 reference) ---------- */
/* s1 green: headline top-left, tin right of centre catching the last glyph */
html.js .sec[data-i='0'] .eyebrow { left: calc(var(--gut) + 4px); top: 13vh; }
html.js .sec[data-i='0'] .headline { left: var(--gut); top: 15.5vh; }
html.js .sec[data-i='0'] .para { left: calc(var(--gut) + 4px); top: 52vh; }
html.js .sec[data-i='0'] .spec { left: 78vw; top: 66vh; width: 16vw; }
html.js .sec[data-i='0'] .shape { left: calc(var(--tx, 59.5vw) + 2.5vw - 36vh); top: calc(50vh - 36vh); width: 72vh; height: 72vh; }
html.js .sec[data-i='0'] .doodle { left: calc(var(--tx, 59.5vw) + 2.5vw + 24vh); top: 11vh; width: 15vh; height: 17vh; }
html.js .sec[data-i='0'] .hint { left: calc(var(--gut) + 4px); bottom: 6vh; }

/* s2 black: headline across the middle, paragraph top-right, spec bottom-left */
html.js .sec[data-i='1'] .eyebrow { left: calc(var(--gut) + 4px); top: 33vh; }
html.js .sec[data-i='1'] .headline { left: var(--gut); top: 35.5vh; }
html.js .sec[data-i='1'] .para { left: 74vw; top: 13vh; }
html.js .sec[data-i='1'] .spec { left: calc(var(--gut) + 4px); top: 71vh; width: 18vw; }
html.js .sec[data-i='1'] .shape { left: calc(var(--tx, 49.5vw) + 2.5vw - 33vh); top: calc(53vh - 33vh); width: 66vh; height: 66vh; }
html.js .sec[data-i='1'] .doodle { left: calc(var(--tx, 49.5vw) - 10vh); top: 9vh; width: 10vh; height: 14vh; }

/* s3 oolong: headline bottom-left, paragraph and spec top-left */
html.js .sec[data-i='2'] .eyebrow { left: calc(var(--gut) + 4px); top: 59vh; }
html.js .sec[data-i='2'] .headline { left: var(--gut); top: 61.5vh; }
html.js .sec[data-i='2'] .para { left: calc(var(--gut) + 4px); top: 16vh; }
html.js .sec[data-i='2'] .spec { left: calc(var(--gut) + 4px); top: 34vh; width: 18vw; }
html.js .sec[data-i='2'] .shape { left: calc(var(--tx, 67.5vw) + 0.5vw - 33vh); top: calc(46vh - 33vh); width: 66vh; height: 66vh; }
html.js .sec[data-i='2'] .doodle { left: calc(var(--tx, 67.5vw) + 20vh); top: 62vh; width: 13vh; height: 13vh; }

/* s4 contact: calm close, side by side — tin left, text right (the rising s3 text stays clear of it) */
html.js .sec[data-i='3'] .eyebrow { left: calc(58vw + 4px); top: 17vh; }
html.js .sec[data-i='3'] .headline { left: 58vw; top: 19.5vh; font-size: min(calc(var(--display) * 0.6), 10vw); }
html.js .sec[data-i='3'] .para { left: calc(58vw + 4px); top: 41vh; }
html.js .sec[data-i='3'] .contact { left: calc(58vw + 4px); top: 54vh; width: min(480px, 36vw); }
html.js .sec[data-i='3'] .more { left: calc(58vw + 4px); bottom: 6vh; }
html.js .sec[data-i='3'] .fineprint { left: calc(58vw + 4px); bottom: 2.4vh; }
html.js .sec[data-i='3'] .ridge { left: 0; right: 0; bottom: 0; height: 34vh; }

/* ---------- phone (440x750 reference) ---------- */
@media (max-width: 699px), (max-aspect-ratio: 4/5) {
  :root { --gut: 22px; --display: clamp(64px, 20.5vw, 96px); --body: 15px; }
  /* the demo strip sits above the bar on phones (22px), so the bar and the copy start below it */
  .bar { padding-top: calc(38px + env(safe-area-inset-top, 0px)); gap: 8px; }
  html.js .progress { top: calc(22px + env(safe-area-inset-top, 0px)); }
  .bar nav, .hint { display: none !important; }
  .brand b { font-size: 19px; }
  .motion { padding: 5px 10px; font-size: 11px; }
  .spec { font-size: 12.5px; line-height: 1.45; }
  .spec .k, .spec .k-ph { display: block; font-size: 11px; font-weight: 500; opacity: 0.72; }
  .spec .v { display: block; font-weight: 650; white-space: nowrap; }
  .spec li { padding: 8px 0 0; border-bottom: 0; }
  .spec li:first-child { border-top-width: 1px; }
  .contact { font-size: 14px; }
  .contact li { padding: 9px 0 8px; }
  .more { gap: 18px; font-size: 13px; }

  /* whole-pixel offsets: fractional ones rasterise differently after a viewport resize */
  html.js .sec[data-i] .eyebrow { left: calc(var(--gut) + 2px); top: calc(9vh + 22px); top: calc(round(9vh, 1px) + 22px); }
  html.js .sec[data-i] .headline { left: var(--gut); top: calc(12.6vh + 22px); top: calc(round(12.6vh, 1px) + 22px); font-size: var(--display); }
  html.js .sec[data-i] .para { left: calc(var(--gut) + 2px); right: var(--gut); top: auto; bottom: calc(19vh + env(safe-area-inset-bottom, 0px)); bottom: calc(round(19vh, 1px) + env(safe-area-inset-bottom, 0px)); }
  html.js .sec[data-i] .spec { left: calc(var(--gut) + 2px); right: var(--gut); width: auto; top: auto; bottom: calc(2.5vh + env(safe-area-inset-bottom, 0px)); bottom: calc(round(2.5vh, 1px) + env(safe-area-inset-bottom, 0px)); }
  html.js .sec[data-i] .spec li { display: inline-block; width: calc((100% - 2px) / 3); vertical-align: top; padding-right: 8px; border-top: 1px solid var(--ink); }
  html.js .sec[data-i] .spec li + li { border-top-color: var(--hair); }
  html.js .sec[data-i] .shape { left: calc(58vw - 20vh); top: calc(51vh - 20vh); width: 40vh; height: 40vh; }
  html.js .sec[data-i='0'] .doodle { left: auto; right: 4vw; top: 29vh; width: 9vh; height: 10vh; }
  html.js .sec[data-i='1'] .doodle { left: 36vw; top: 28vh; width: 7vh; height: 9vh; }
  html.js .sec[data-i='2'] .doodle { left: auto; right: 5vw; top: 58vh; width: 8vh; height: 8vh; }

  html.js .sec[data-i='3'] .headline { font-size: calc(var(--display) * 0.8); top: calc(14.6vh + 22px); top: calc(round(14.6vh, 1px) + 22px); }
  html.js .sec[data-i='3'] .eyebrow { top: calc(9vh + 22px); top: calc(round(9vh, 1px) + 22px); }
  html.js .sec[data-i='3'] .para { top: calc(27.6vh + 22px); top: calc(round(27.6vh, 1px) + 22px); bottom: auto; }
  html.js .sec[data-i='3'] .contact { top: auto; bottom: calc(10vh + env(safe-area-inset-bottom, 0px)); left: calc(var(--gut) + 2px); right: var(--gut); width: auto; }
  html.js .sec[data-i='3'] .more { left: calc(var(--gut) + 2px); bottom: calc(3.5vh + env(safe-area-inset-bottom, 0px)); }
  html.js .sec[data-i='3'] .fineprint { display: none; }
  html.js .sec[data-i='3'] .ridge { height: 22vh; bottom: 34vh; }
}
