/* dekdaidao.com. Tokens from docs/design/tokens.md ("Calm Paper, Bright Sky"). No raw values below the token block. */

@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/plex-thai-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans Thai";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/plex-thai-600.woff2") format("woff2");
}
@font-face {
  font-family: "Mali";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/mali-700.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  /* primitives (1.1, 1.2) */
  --paper-0: #FFFFFF;
  --paper-50: #FBFAF7;
  --paper-100: #F3F0EA;
  --paper-200: #E8E3DA;
  --stone-500: #8C8478;
  --stone-600: #5D564C;
  --ink-900: #1F1B16;
  --night-950: #14120F;
  --night-900: #1E1B17;
  --night-850: #27231E;
  --night-700: #3A352E;
  --night-500: #7A7266;
  --fog-300: #B8B0A4;
  --fog-50: #F2EEE8;
  --gold: #F2A900;

  /* spacing (1.5) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-14: 3.5rem;

  /* radii (1.6) */
  --radius-xs: 6px;
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* motion (1.8) */
  --dur-fast: 120ms;
  --ease-standard: cubic-bezier(.2, 0, 0, 1);

  /* type (1.4, 2.3) */
  --font-adult: "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-kid: "Mali", "IBM Plex Sans Thai", system-ui, sans-serif;
  --display: 600 2rem/2.75rem var(--font-adult);
  --title-l: 600 1.5rem/2.125rem var(--font-adult);
  --title-m: 600 1.25rem/1.875rem var(--font-adult);
  --title-s: 600 1.0625rem/1.625rem var(--font-adult);
  --body-l: 400 1.0625rem/1.75rem var(--font-adult);
  --body-m: 400 0.9375rem/1.5rem var(--font-adult);
  --label: 600 0.9375rem/1.375rem var(--font-adult);
  --caption: 400 0.8125rem/1.25rem var(--font-adult);
  --kid-title: 700 2rem/2.75rem var(--font-kid);
  --kid-hero: 700 2.75rem/3.5rem var(--font-kid);

  /* sizing (2.4) */
  --touch-min: 3rem;
  --button-h: 3.25rem;
  --icon-l: 2.5rem;
  --icon-feature: 3.5rem;
  --gutter: var(--space-4);
  --measure: 42rem;
  --wide: 66rem;
  --shot-w: 360;
  --shot-h: 780;

  /* semantic, light (2.1) */
  --bg: var(--paper-50);
  --surface: var(--paper-0);
  --surface-alt: var(--paper-100);
  --border: var(--paper-200);
  --border-strong: var(--stone-500);
  --text: var(--ink-900);
  --text-muted: var(--stone-600);
  --primary: #2F5D8A;
  --on-primary: #FFFFFF;
  --focus: #2F5D8A;
  --deed: #2E7D32;
  --oops: #A64B00;
  --reward: #6A45C9;
  --pending: #7A5C00;
  --elev-1: 0 1px 2px rgba(31, 27, 22, .06), 0 2px 8px rgba(31, 27, 22, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--night-950);
    --surface: var(--night-900);
    --surface-alt: var(--night-850);
    --border: var(--night-700);
    --border-strong: var(--night-500);
    --text: var(--fog-50);
    --text-muted: var(--fog-300);
    --primary: #8DB4E0;
    --on-primary: #0E1A26;
    --focus: #8DB4E0;
    --deed: #8FD192;
    --oops: #F5B36B;
    --reward: #B9A3F5;
    --pending: #E8C463;
    --elev-1: none;
  }
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--body-l);
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font: var(--display); }
h2 { font: var(--title-l); }
h3 { font: var(--title-m); }

p,
ul,
ol,
blockquote,
table {
  margin: 0 0 var(--space-4);
}

ul,
ol {
  padding-inline-start: var(--space-6);
}

li + li {
  margin-top: var(--space-1);
}

strong {
  font-weight: 600;
}

a {
  color: var(--primary);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

img {
  max-width: 100%;
  height: auto;
}

code {
  font: inherit;
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
  background: var(--surface-alt);
}

.wrap {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.wrap--prose {
  max-width: calc(var(--measure) + 2 * var(--gutter));
}

.skip {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 1;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--on-primary);
  font: var(--label);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  min-height: 4rem;
  padding-block: var(--space-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-end: auto;
  color: var(--text);
  font: var(--title-m);
  font-family: var(--font-kid);
  text-decoration: none;
}

.brand img {
  width: 1.75rem;
  height: 1.75rem;
}

.lang {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding-inline: var(--space-2);
  font: var(--label);
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--button-h);
  padding: var(--space-2) var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font: var(--label);
  text-align: center;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.button:active {
  transform: scale(.96);
}

.button--primary {
  background: var(--primary);
  color: var(--on-primary);
}

.button--secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button--compact {
  min-height: var(--touch-min);
  padding-inline: var(--space-4);
}

/* ---------- Landing ---------- */
.hero {
  padding-block: var(--space-10) var(--space-14);
}

.hero h1 {
  font: var(--kid-title);
}

.hero .lead {
  max-width: var(--measure);
  font: var(--body-l);
  color: var(--text-muted);
}

.hero .wordmark {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-muted);
  font: var(--label);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block: var(--space-6) var(--space-3);
}

.hint {
  font: var(--caption);
  color: var(--text-muted);
}

.section {
  padding-block: var(--space-10);
  border-top: 1px solid var(--border);
}

.section > .wrap > p,
.section-intro {
  max-width: var(--measure);
}

.cards {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}

.cards li + li {
  margin-top: 0;
}

.card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--elev-1);
}

.card img {
  display: block;
  width: var(--icon-feature);
  height: var(--icon-feature);
  margin-bottom: var(--space-3);
}

.card h3 {
  font: var(--title-s);
  margin-bottom: var(--space-2);
}

.card p {
  margin: 0;
  font: var(--body-m);
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  margin-inline-start: var(--space-1);
  font: var(--label);
}
.tag--deed { color: var(--deed); }
.tag--oops { color: var(--oops); }
.tag--reward { color: var(--reward); }

/* Screenshots: final images are 360 × 780 CSS px (export 720 × 1560 for 2×). */
.shots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}

.shots li + li {
  margin-top: 0;
}

.shot {
  margin: 0;
}

.shot img,
.shot-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: var(--shot-w) / var(--shot-h);
  border-radius: var(--radius-l);
}

.shot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 2px dashed var(--border-strong);
  background: var(--surface-alt);
  color: var(--text-muted);
  font: var(--caption);
  text-align: center;
}

.shot-placeholder img {
  width: var(--icon-l);
  height: var(--icon-l);
  aspect-ratio: 1;
  border-radius: 0;
}

.shot-placeholder strong {
  color: var(--pending);
}

.shot figcaption {
  margin-top: var(--space-2);
  font: var(--body-m);
}

.split {
  display: grid;
  gap: var(--space-4) var(--space-8);
  align-items: start;
}

.split > img {
  width: var(--icon-feature);
  height: var(--icon-feature);
}

.ticks {
  padding: 0;
  list-style: none;
}

.ticks li {
  position: relative;
  padding-inline-start: var(--space-8);
}

.ticks li::before {
  content: "";
  position: absolute;
  left: var(--space-1);
  top: 0.55em;
  width: 0.75em;
  height: 0.4em;
  border-left: 2px solid var(--deed);
  border-bottom: 2px solid var(--deed);
  transform: rotate(-45deg);
}

/* ---------- Documents (privacy, terms, data deletion) ---------- */
.doc {
  padding-block: var(--space-8) var(--space-14);
}

.doc h2 {
  margin-top: var(--space-10);
  scroll-margin-top: var(--space-4);
}

.doc h3 {
  margin-top: var(--space-6);
  font: var(--title-s);
}

.notice {
  margin: 0 0 var(--space-6);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-strong);
  border-inline-start: 6px solid var(--pending);
  border-radius: var(--radius-m);
  background: var(--surface-alt);
}

.notice p {
  margin: 0;
}

.notice strong {
  color: var(--pending);
}

.toc {
  margin: 0 0 var(--space-6);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
}

.doc .toc h2 {
  margin-top: 0;
  font: var(--title-s);
}

.toc ol {
  margin: 0;
  font: var(--body-m);
}

.meta {
  padding: 0;
  list-style: none;
  font: var(--body-m);
  color: var(--text-muted);
}

.meta strong {
  color: var(--text);
}

.tbd {
  color: var(--pending);
  text-decoration: underline dashed;
  text-underline-offset: 0.25em;
}

.doc blockquote {
  margin-inline: 0;
  padding: var(--space-3) var(--space-5);
  border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.table-wrap {
  margin: 0 0 var(--space-4);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
}

.table-wrap table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font: var(--body-m);
}

th,
td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

th {
  font-weight: 600;
  background: var(--surface-alt);
}

tr:last-child td {
  border-bottom: 0;
}

/* Phones: each row becomes a block, each cell carries its column name. */
@media (max-width: 39.99em) {
  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table-wrap tr,
  .table-wrap td {
    display: block;
  }

  .table-wrap tr {
    padding-block: var(--space-2);
    border-bottom: 1px solid var(--border);
  }

  .table-wrap tr:last-child {
    border-bottom: 0;
  }

  .table-wrap td {
    padding-block: var(--space-1);
    border-bottom: 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    font: var(--caption);
    font-weight: 600;
    color: var(--text-muted);
  }
}

.steps {
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  padding-inline-start: var(--space-10);
  counter-increment: step;
}

.steps > li + li {
  margin-top: var(--space-3);
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  color: var(--text);
  font: var(--label);
  line-height: 1.75rem;
  text-align: center;
}

/* ---------- Language chooser and 404 ---------- */
.chooser {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-8) var(--gutter);
  text-align: center;
}

.chooser img {
  width: var(--icon-feature);
  height: var(--icon-feature);
}

.chooser h1 {
  margin-top: var(--space-4);
  font: var(--kid-title);
}

.chooser .actions {
  justify-content: center;
}

.chooser .button {
  min-width: 10rem;
}

/* ---------- Footer ---------- */
.site-footer {
  padding-block: var(--space-8);
  border-top: 1px solid var(--border);
  background: var(--surface);
  font: var(--body-m);
  color: var(--text-muted);
}

.site-footer nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  padding: 0;
  list-style: none;
}

.site-footer nav li + li {
  margin-top: 0;
}

.site-footer nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
}

.site-footer p {
  margin-bottom: var(--space-2);
}

.site-footer .credits {
  font: var(--caption);
}

/* ---------- Wider screens ---------- */
@media (min-width: 40em) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split {
    grid-template-columns: auto minmax(0, 1fr);
  }
}

@media (min-width: 56em) {
  .hero {
    padding-block: var(--space-14);
  }

  .hero h1 {
    font: var(--kid-hero);
  }

  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .shots {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }

  .button:active {
    transform: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .skip {
    display: none;
  }
}
