:root {
  --ink: #f2ecdd;          /* cream */
  --bg: #050706;           /* ink black */
  --accent: #17e88f;       /* emerald */
  --accent-dim: rgba(23, 232, 143, 0.55);
  --muted: rgba(242, 236, 221, 0.62);
  --display-latin: "Anton", Impact, sans-serif;
  --display: "Anton", Impact, sans-serif;
  --body: "Space Grotesk", system-ui, sans-serif;
}

/* Thai mode — Apple typography stack: SF Thai on Apple devices,
   Noto Sans Thai as the off-Apple web fallback. Latin runs (brand
   names, numerals) keep their own faces via per-glyph fallback. */
:root[data-lang="th"] {
  --display: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Inter Tight", "Space Grotesk", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Space Grotesk", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow-x: hidden;
}

::selection { background: var(--accent); color: #04150d; }

/* ---------- film grain ---------- */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 90;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(2%, -1%); }
}

/* ---------- fixed chrome ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3em;
  mix-blend-mode: difference;
}
.hud a { color: var(--ink); text-decoration: none; }
.hud-brand .dim { color: var(--accent); margin: 0 3px; }
.hud-mid { color: var(--muted); }
.hud-right { position: relative; }
.hud-right::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}
.hud-right:hover::after { transform: scaleX(1); }
.hud-cluster { display: flex; align-items: center; gap: 24px; }
.lang { display: flex; align-items: center; gap: 8px; }
.lang button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  transition: color 0.3s;
}
.lang button:hover { color: var(--ink); }
.lang button.on { color: var(--accent); }
.lang .sep { color: var(--muted); opacity: 0.5; }

/* ---------- cinematic scrub sections ---------- */
.cinematic { position: relative; }
#hero    { height: 560vh; }
#builder { height: 500vh; }
#closer  { height: 420vh; }

.sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.sticky canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 22%, transparent 72%, rgba(0, 0, 0, 0.78) 100%);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 24px;
  pointer-events: none;
}

/* ---------- hero kinetic type ---------- */
.hero-block { will-change: opacity, transform; }
.hero-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.55em;
  color: var(--accent);
  margin-bottom: 1.4rem;
  opacity: 0;
  animation: rise-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.25s forwards;
}
.hero-title {
  font-family: var(--display-latin);
  font-weight: 400;
  font-size: clamp(4.5rem, 17.5vw, 15.5rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 0 90px rgba(23, 232, 143, 0.25);
}
.hero-title .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.55em) rotate(4deg);
  animation: ch-in 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform;
}
@keyframes ch-in {
  to { opacity: 1; transform: translateY(0) rotate(0deg); }
}
.hero-sub {
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 1.6rem;
  opacity: 0;
  animation: rise-in 0.9s cubic-bezier(0.16, 1, 0.3, 1) 1.15s forwards;
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- scroll-windowed lines ---------- */
.reveal-line {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 92vw;
  opacity: 0;
  will-change: opacity, transform;
}
.reveal-line.act {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 8.5vw, 7.5rem);
  line-height: 0.98;
  letter-spacing: 0.02em;
  text-shadow: 0 6px 60px rgba(0, 0, 0, 0.8);
}
.em { color: var(--accent); }

/* ---------- pillars ---------- */
.pillar { max-width: min(720px, 88vw); }
.pillar-idx {
  display: block;
  font-family: var(--display-latin);
  font-size: clamp(1rem, 2vw, 1.5rem);
  color: var(--accent);
  letter-spacing: 0.3em;
  margin-bottom: 0.8rem;
}
.pillar h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 6vw, 5rem);
  line-height: 1;
  margin-bottom: 1.1rem;
  text-shadow: 0 6px 60px rgba(0, 0, 0, 0.85);
}
.pillar p {
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  color: var(--muted);
  line-height: 1.6;
  max-width: 54ch;
  margin: 0 auto;
}

/* ---------- telemetry / progress ---------- */
.telemetry {
  position: absolute;
  z-index: 12;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--accent-dim);
}
.bl { bottom: 68px; left: 32px; }
.br { bottom: 68px; right: 32px; }
.progress {
  position: absolute;
  left: 32px; right: 32px; bottom: 46px;
  height: 2px;
  background: rgba(242, 236, 221, 0.12);
  z-index: 12;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-dim);
}
.scroll-hint {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.45em;
  color: var(--muted);
  animation: bob 1.8s ease-in-out infinite;
  transition: opacity 0.4s;
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

/* ---------- stats strip ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
  padding: clamp(70px, 12vh, 130px) 6vw;
  border-top: 1px solid rgba(23, 232, 143, 0.18);
  border-bottom: 1px solid rgba(23, 232, 143, 0.18);
  background:
    radial-gradient(60% 120% at 50% 0%, rgba(23, 232, 143, 0.06), transparent 70%),
    var(--bg);
  text-align: center;
}
.stat-num {
  display: block;
  font-family: var(--display-latin);
  font-size: clamp(3rem, 7vw, 5.5rem);
  color: var(--ink);
  line-height: 1;
}
.stat-label {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---------- work cards ---------- */
.work { padding: clamp(80px, 14vh, 160px) 6vw; }
.sec-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5em;
  color: var(--accent);
}
.work-head h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3rem, 9vw, 8rem);
  line-height: 0.95;
  margin: 14px 0 60px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}
.card {
  position: relative;
  display: block;
  padding: 34px 30px 70px;
  border: 1px solid rgba(242, 236, 221, 0.14);
  background: linear-gradient(180deg, rgba(242, 236, 221, 0.03), transparent);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.45s, box-shadow 0.45s;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(23, 232, 143, 0.10) 50%, transparent 70%);
  transform: translateX(-110%);
  transition: transform 0.7s ease;
}
.card:hover {
  transform: translateY(-10px);
  border-color: var(--accent-dim);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(23, 232, 143, 0.12);
}
.card:hover::before { transform: translateX(110%); }
.card-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: var(--accent);
}
.card h3 {
  font-family: var(--display-latin);
  font-weight: 400;
  font-size: clamp(1.9rem, 3.4vw, 2.8rem);
  margin: 16px 0 12px;
}
.card p { color: var(--muted); line-height: 1.6; font-size: 0.98rem; }
.card-arrow {
  position: absolute;
  right: 26px; bottom: 22px;
  font-size: 1.5rem;
  color: var(--accent);
  transform: translateX(-6px);
  opacity: 0.5;
  transition: transform 0.4s, opacity 0.4s;
}
.card:hover .card-arrow { transform: translateX(0); opacity: 1; }

/* ---------- finale ---------- */
.finale {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 100px 6vw 0;
  background:
    radial-gradient(70% 60% at 50% 100%, rgba(23, 232, 143, 0.08), transparent 65%),
    var(--bg);
}
.finale-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.2rem, 11vw, 10rem);
  line-height: 0.95;
  margin: 16px 0 48px;
}
.cta-row {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 18px 44px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.32em;
  text-decoration: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), background 0.35s, color 0.35s, box-shadow 0.35s;
}
.btn-solid {
  background: var(--accent);
  color: #04150d;
}
.btn-solid:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 44px rgba(23, 232, 143, 0.35);
}
.btn-ghost {
  border: 1px solid rgba(242, 236, 221, 0.35);
  color: var(--ink);
}
.btn-ghost:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  color: var(--accent);
}

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 60px 0 34px;
  margin-top: 12vh;
  border-top: 1px solid rgba(242, 236, 221, 0.12);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
}
.foot-links { display: flex; gap: 26px; }
.foot-links a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.3s;
}
.foot-links a:hover { color: var(--accent); }

/* ---------- scroll reveals ---------- */
.reveal {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.in { opacity: 1; transform: translateY(0); }

/* ---------- mobile polish ---------- */
@media (max-width: 600px) {
  .hud { padding: 14px 18px; font-size: 10px; letter-spacing: 0.2em; }
  .hud-mid { display: none; }
  .telemetry { font-size: 9px; letter-spacing: 0.16em; }
  .bl, .br { bottom: 62px; }
  .progress { left: 18px; right: 18px; }
  .card { padding: 28px 22px 64px; }
}

/* ---------- Thai display metrics ----------
   Apple gives Thai display type more air and slightly less size:
   taller glyphs (ascenders/descenders + tone marks) need looser
   line-height, zero tracking, and ~600-700 weight. */
:root[data-lang="th"] .reveal-line.act {
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: 0;
  font-size: clamp(2.1rem, 6.6vw, 5.8rem);
}
:root[data-lang="th"] .pillar h3 {
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: 0;
  font-size: clamp(1.6rem, 4.6vw, 3.8rem);
}
:root[data-lang="th"] .work-head h2 {
  font-weight: 700;
  line-height: 1.18;
  font-size: clamp(2.3rem, 7vw, 6rem);
}
:root[data-lang="th"] .finale-title {
  font-weight: 700;
  line-height: 1.18;
  font-size: clamp(2.4rem, 8.4vw, 7.2rem);
}
:root[data-lang="th"] .hero-sub,
:root[data-lang="th"] .pillar p,
:root[data-lang="th"] .card p {
  line-height: 1.75;
}
:root[data-lang="th"] .hud,
:root[data-lang="th"] .hero-kicker,
:root[data-lang="th"] .sec-kicker,
:root[data-lang="th"] .stat-label,
:root[data-lang="th"] .card-tag,
:root[data-lang="th"] .btn,
:root[data-lang="th"] .scroll-hint {
  letter-spacing: 0.12em;
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .scroll-hint { animation: none; }
}
