/* ============================================================
   theme.css — Design Tokens · NIKKENSEI navy · cream theme (recoloured 2026-11-09 from Emerald Cream to match the site)
   ที่มา: Design.md (Single source of truth)
   เด็กทุนมงสอนภาษาญี่ปุ่น — บอสเซนเซ
   ============================================================ */
:root {
  /* --- Surfaces --- */
  --color-bg:            #fffeef;
  --color-bg-alt:        #fdfae0;

  /* --- Text --- */
  --color-ink:           #000000;
  --color-ink-soft:      #2B3A55;
  --color-mute:          #5F6F8C;

  /* --- Accent --- */
  --color-accent:        #0A4088;
  --color-accent-hover:  #083470;

  /* --- Soft fills --- */
  --color-soft-bg:       #E7EDF8;
  --color-card:          #FFFFFF;

  /* --- Lines --- */
  --color-border:        #0A4088;
  --color-rule:          #C9D3E6;

  /* --- Semantic (ส่วนขยายสำหรับระบบข้อสอบ) --- */
  --color-correct:       #0A4088;
  --color-wrong:         #C42B1C;
  --color-wrong-soft:    #FBEAE8;
  --color-gold:          #FF52A2;
  --color-gold-soft:     #FFEAF3;

  /* --- Japanese traditional accents (2026-09 refresh: จังหวะสีแบบโปสเตอร์ญี่ปุ่น) --- */
  --color-shu:           #FF52A2;   /* 朱色 ชาด — จุดเรียกสายตา ใช้น้อยแต่ชัด */
  --color-shu-soft:      #FFEAF3;
  --color-ai:            #0A4088;   /* 藍色 ครามญี่ปุ่น — คู่สุขุมของเขียว */
  --color-ai-soft:       #E7EDF8;

  /* --- Section colors (3 พาร์ทข้อสอบ) --- */
  --sec-goi:             #0A4088;   /* 文字・語彙 */
  --sec-goi-soft:        #E7EDF8;
  --sec-bunpou:          #2F62AE;   /* 文法 */
  --sec-bunpou-soft:     #E9EFF9;
  --sec-dokkai:          #5C86C8;   /* 読解 */
  --sec-dokkai-soft:     #ECF1FA;

  /* --- Type system --- */
  --font-heading-th: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  --font-heading-en: "IBM Plex Sans", "Inter", system-ui, -apple-system, sans-serif;
  --font-heading-jp: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;

  --font-body-th:    "Yves Yvesdrawing", "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --font-body-en:    "Iwata Fukumaru Go Asobu", "IBM Plex Sans", system-ui, sans-serif;
  --font-body-jp:    "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;

  /* --- Type scale --- */
  --fs-action:    clamp(22px, 2vw, 36px);
  --fs-h1:        clamp(36px, 4vw, 56px);
  --fs-h2:        clamp(22px, 2.2vw, 28px);
  --fs-body:      clamp(15px, 1.2vw, 18px);
  --fs-kanji-xl:  clamp(80px, 9vw, 160px);
  --fs-meta:      11px;

  --lh-tight:  1.2;
  --lh-body:   1.7;

  /* --- Spacing (8pt grid) --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;
  --space-8: 96px;

  /* --- Radius --- */
  --radius-card:   16px;
  --radius-chip:   12px;
  --radius-pill:   999px;

  /* --- Shadows --- */
  --shadow-card:   0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-float:  0 4px 16px rgba(10, 64, 136, 0.08);
  --shadow-pop:    0 12px 40px rgba(10, 64, 136, 0.16);

  /* --- Motion --- */
  --ease-out:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap:  cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   180ms;
  --dur-med:    320ms;
  --dur-slow:   560ms;

  color-scheme: light;
}

/* ============================================================
   Dark theme — "Matcha Night" (ครีมเข้ม ไม่ใช่เขียวเข้ม ตามกฎดีไซน์)
   สลับด้วย html[data-theme="dark"] (ปุ่ม 🌙 บนแถบบน · จำใน localStorage)
   ทุกอย่าง override ผ่าน token เดิม — คอมโพเนนต์ไม่ต้องแก้
   ============================================================ */
html[data-theme="dark"] {
  --color-bg:            #101A25;
  --color-bg-alt:        #141D2A;
  --color-ink:           #F4F6F8;
  --color-ink-soft:      #C3CBD6;
  --color-mute:          #9AA6B8;
  --color-accent:        #6A96FF;
  --color-accent-hover:  #8BB0FF;
  --color-soft-bg:       #1C2A3F;
  --color-card:          #182430;
  --color-border:        rgba(254, 252, 234, 0.55);
  --color-rule:          #2B3A52;
  --color-correct:       #6A96FF;
  --color-wrong:         #E26D58;
  --color-wrong-soft:    #3A211C;
  --color-gold:          #FF8DC1;
  --color-gold-soft:     #3A2230;
  --color-shu:           #FF8DC1;
  --color-shu-soft:      #3A2230;
  --color-ai:            #6A96FF;
  --color-ai-soft:       #1C2A3F;
  --sec-goi:             #6A96FF;
  --sec-goi-soft:        #1C2A3F;
  --sec-bunpou:          #8BB0FF;
  --sec-bunpou-soft:     #1C2A3F;
  --sec-dokkai:          #A8C2F5;
  --sec-dokkai-soft:     #1C2A3F;
  --shadow-card:   0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-float:  0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-pop:    0 12px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
html[data-theme="dark"] img.--invertable { filter: brightness(.92); }

/* === Universal Base Reset === */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  background: var(--color-bg);
  color: var(--color-ink-soft);
  font-family: var(--font-body-th);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, .action-title {
  color: var(--color-accent);
  font-family: var(--font-heading-th);
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-3);
}
.ink-feature { color: var(--color-ink); }
.jp { font-family: var(--font-body-jp); }
a { color: var(--color-accent); }
img { max-width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
