/* Shared by the buyer page (/) and the contributor page (/vi/contributor/). Light by default, dark when the device
   asks. Each page keeps its own action colour through data-page on <html>: deep teal on the buyer page, a dark
   button with lime text on the contributor page. Every font size on the site is one of the --fs tokens. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eaeef2;
  --line: #d6dde4;
  --ink: #141a21;
  --ink-2: #47525e;
  --muted: #646d78;
  /* data roles: the bright values draw the hand skeletons and legend swatches; the -ink values are for text */
  --task: #1b774d;
  --subgoal: #7a4ecf;
  --action: #0f6f8a;
  --left: #e07a1f;
  --right: #2a8fd6;
  --left-ink: #9d5516;
  --right-ink: #206ea5;
  --accent: #0f6f8a;
  --accent-ink: #ffffff;
  --accent-fg: #0f6f8a;
  --scrim: rgb(10 14 18 / 0.72);

  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-label: 0.75rem;
  --fs-small: 0.875rem;
  --fs-body: 1.0625rem;
  --fs-lead: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --fs-big: 1.375rem;
  --fs-h2: clamp(1.75rem, 1.2rem + 2vw, 2.25rem);
  --fs-h1: clamp(2.2rem, 1.4rem + 3vw, 3.25rem);
  --radius: 12px;
  color-scheme: light;
}
:root[data-page="contributor"] {
  --accent: #15181c;
  --accent-ink: #b6ff5c;
  --accent-fg: #3c7a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #161c23;
    --surface-2: #1f2730;
    --line: #2b3541;
    --ink: #e8edf2;
    --ink-2: #b4bfca;
    --muted: #8c98a3;
    --task: #4ccf8e;
    --subgoal: #b08cff;
    --action: #4fb9d6;
    --left: #ff9f43;
    --right: #4fb3ff;
    --left-ink: #ff9f43;
    --right-ink: #4fb3ff;
    --accent: #4fb9d6;
    --accent-ink: #0b1116;
    --accent-fg: #4fb9d6;
    color-scheme: dark;
  }
  :root[data-page="contributor"] {
    --accent: #b6ff5c;
    --accent-ink: #111316;
    --accent-fg: #b6ff5c;
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body)/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--accent-fg) 24%, transparent); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent-fg); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
a { color: var(--accent-fg); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
h1, h2, h3 { margin: 0; font-family: var(--display); line-height: 1.1; text-wrap: balance; }
h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-body); font-weight: 700; }
p { margin: 0; text-wrap: pretty; }
b, strong { font-weight: 600; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.wrap { width: min(100% - 2 * max(16px, 4vw), 72rem); margin-inline: auto; padding-block: 0 3rem; }

.eyebrow {
  color: var(--muted);
  font: 500 var(--fs-label)/1.3 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.lede { max-width: 62ch; color: var(--ink-2); font-size: var(--fs-lead); }
.lede strong { color: var(--ink); }

/* ---------- header and buttons ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: var(--ink);
  font: 700 var(--fs-big)/1 var(--display);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand .logo { flex: none; display: block; width: auto; height: 2.125rem; aspect-ratio: 498.4 / 200; }
.brand span {
  margin-left: 0.4rem;
  color: var(--muted);
  font: 500 var(--fs-small)/1.2 var(--body);
  letter-spacing: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.25rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 var(--fs-small)/1.2 var(--body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(0.95); }
.btn.large { font-size: var(--fs-body); }

/* ---------- sections ---------- */

section { display: grid; gap: 1.25rem; padding-block: 3.5rem; }
section.rule { border-top: 1px solid var(--line); }
section[id] { scroll-margin-top: 1rem; }
.section-head { display: grid; gap: 0.6rem; max-width: 70ch; }
.section-head .lede { margin-top: 0.2rem; }

/* ---------- clip player (shared) ---------- */

.clip { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.clip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.clip-head > p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; min-width: 0; }
.clip-head b { font-size: var(--fs-body); }
.meta {
  color: var(--muted);
  font: 500 var(--fs-label)/1.4 var(--mono);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.frames { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); }
.frames.single { grid-template-columns: minmax(0, 1fr); background: #000; }
.frame { position: relative; min-width: 0; aspect-ratio: 16 / 9; background: #000; }
.frames.single .frame { width: min(100%, 62rem); margin-inline: auto; }
.frames.single .frame.four3 { width: min(100%, 46rem); aspect-ratio: 4 / 3; }
.frame video, .frame canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.frame video { object-fit: contain; }
.frame canvas { pointer-events: none; }
.frame .tag {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: var(--scrim);
  color: #f2f5f8;
  font: 500 var(--fs-label)/1 var(--mono);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}
.frame .tag.right { left: auto; right: 0.7rem; }
.frame .tag b { font-weight: 600; }
.frame.missing video, .frame.missing canvas { visibility: hidden; }
.frame.missing::after {
  content: "Video didn't load. Reload the page to try again.";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: #aab4bf;
  font: 400 var(--fs-small)/1.5 var(--mono);
  text-align: center;
}
:lang(vi) .frame.missing::after { content: "Video chưa tải được. Tải lại trang để thử lại."; }

/* Caption rows: a level pill, then the page's language with the other language dimmed beside it. */
.labels {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-content: start;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  padding: 1.15rem 1.25rem 0.5rem;
}
.pill {
  justify-self: start;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font: 500 var(--fs-label)/1.1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill.task { color: var(--task); }
.pill.subgoal { color: var(--subgoal); }
.pill.hands { color: var(--action); }
.labels .row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.6rem; min-width: 0; font-size: var(--fs-small); }
.labels .alt { color: var(--muted); }
.labels .alt::before { content: "·"; margin-right: 0.6rem; }
.labels .none { color: var(--muted); }
.hands { display: grid; gap: 0.35rem; }
.hand {
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 var(--fs-label)/1.3 var(--mono);
  letter-spacing: 0.06em;
}
.hand.l { color: var(--left-ink); }
.hand.r { color: var(--right-ink); }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1.25rem 1.1rem;
}
.transport { display: flex; align-items: center; gap: 0.85rem; }
.play {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s;
}
.play:hover { border-color: var(--muted); }
.play svg { width: 14px; height: 14px; }
.play .i-pause, .play[data-state="playing"] .i-play { display: none; }
.play[data-state="playing"] .i-pause { display: block; }
.time { color: var(--muted); font: 500 var(--fs-small)/1 var(--mono); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; color: var(--muted); font-size: var(--fs-small); }
.legend span::before {
  content: "";
  display: inline-block;
  width: 0.9rem;
  height: 3px;
  margin-right: 0.45rem;
  border-radius: 2px;
  background: currentColor;
  vertical-align: middle;
}
.legend .l::before { background: var(--left); }
.legend .r::before { background: var(--right); }
.caption { display: grid; gap: 0.6rem; padding: 1.1rem 1.25rem 1.25rem; border-top: 1px solid var(--line); }

.note { max-width: 70ch; color: var(--muted); font-size: var(--fs-small); }

/* ---------- buyer page ---------- */

.hero { display: grid; gap: 1rem; padding-block: 3.25rem 2.5rem; }
.hero .tagline { color: var(--ink-2); font: 500 clamp(1.125rem, 1rem + 0.6vw, 1.375rem)/1.3 var(--display); }
.hero .kicker { padding-top: 0.4rem; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.9rem; }
.features > div {
  display: grid;
  align-content: start;
  gap: 0.4rem;
  padding: 1.1rem 1.15rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.features .k {
  color: var(--accent-fg);
  font: 500 var(--fs-label)/1.3 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.features p { color: var(--ink-2); font-size: var(--fs-small); }

.survey {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.75rem;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.survey h3 { margin-bottom: 0.75rem; }
.survey ol { display: grid; gap: 0.5rem; margin: 0; padding-left: 1.4rem; color: var(--ink-2); }
.survey ol li::marker { color: var(--accent-fg); font-family: var(--mono); }
.survey aside {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.survey aside .big { font: 700 var(--fs-big)/1.25 var(--display); }
.survey aside p { color: var(--ink-2); }
.survey aside .btn { justify-self: start; }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- contributor page ---------- */

.opening { padding-block: 3.25rem 2.5rem; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cols { display: grid; }
.cols.halves { grid-template-columns: 1fr 1fr; }
.cols.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
ol.cols { margin: 0; padding: 0; list-style: none; counter-reset: step; }
ol.cols > li { counter-increment: step; }
ol.cols h2::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: 0.35rem;
  color: var(--accent-fg);
  font: 500 var(--fs-label)/1 var(--mono);
}
ol.cols p { color: var(--ink-2); }
.col { display: grid; align-content: start; gap: 0.9rem; min-width: 0; padding: 1.25rem 1.3rem; }
.col + .col { border-left: 1px solid var(--line); }
.col h2, .col h3 { font: 600 var(--fs-body)/1.3 var(--body); letter-spacing: 0; }
/* each step spans the same two rows, so headings and text line up across columns even when a heading wraps */
@media (min-width: 1001px) {
  .cols.five { grid-template-rows: auto auto; }
  .cols.five > li { grid-row: span 2; grid-template-rows: subgrid; }
}
.examples { display: grid; gap: 0.25rem; margin: 0; padding-left: 1.2rem; }
.tips {
  display: grid;
  gap: 0.6rem;
  padding: 1rem 1.3rem;
  border: 1px solid color-mix(in srgb, var(--accent-fg) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-fg) 6%, var(--surface));
}
.tips .eyebrow { color: var(--accent-fg); }
.tips ul { display: grid; gap: 0.3rem; margin: 0; padding-left: 1.2rem; }
.facts { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: baseline; gap: 0.75rem 1.25rem; margin: 0; }
.facts dt {
  color: var(--muted);
  font: 500 var(--fs-label)/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.facts dd { margin: 0; }
.closing { padding-block: 3.5rem 1rem; }
.survey-box {
  display: grid;
  gap: 1rem;
  padding: clamp(1.25rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.survey-box .btn { justify-self: start; margin-top: 0.4rem; }

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .cols.five { grid-template-columns: minmax(0, 1fr); }
  .cols.five > .col + .col { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .frames { grid-template-columns: minmax(0, 1fr); }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .survey { grid-template-columns: minmax(0, 1fr); }
  .cols.halves { grid-template-columns: minmax(0, 1fr); }
  .cols.halves > .col + .col { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .top .brand span { display: none; }
  .brand .logo { height: 1.875rem; }
  .btn { padding-inline: 1rem; }
  section { padding-block: 2.5rem; }
  .hero, .opening { padding-block: 2.25rem 1.75rem; }
  .clip-head, .labels, .controls, .caption { padding-inline: 1rem; }
  .labels { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
  .labels .row, .labels .hands { margin-bottom: 0.55rem; }
  .features { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .facts dd { margin-bottom: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .play { transition: none; }
}
