/* SpråkAPP — Unified learner surface tokens.
 *
 * Every learner surface (module overlay, story scene, speech card, flashcard
 * deck, lab playgrounds) reads from the same set of CSS custom properties so
 * the look-and-feel stays consistent across modalities. To switch the entire
 * UI to a different aesthetic, the user picks a theme — that just rewrites
 * the token values on ``html[data-theme="..."]`` and every surface follows.
 *
 *   Default (no attribute) ........ Manuscript (warm cream / ink / serif)
 *   data-theme="manuscript" ....... explicit manuscript (same as default)
 *   data-theme="aurora" ........... cool slate / cyan / inter sans
 *   data-theme="focus" ............ minimal high-contrast mono
 *
 * Tokens are grouped:
 *   --surface-*    paper-style background, borders, shadows
 *   --ink-*        text colors at varying emphasis
 *   --accent-*     CTA / focus highlight
 *   --font-*       typeface stacks
 *   --space-*      consistent spacing rhythm
 *   --radius-*     consistent corner rhythm
 *   --motion-*     animation durations
 */

:root,
:root[data-theme="manuscript"] {
  /* ── Manuscript: warm parchment, serif heads, mono captions ───── */
  --surface-paper: rgba(255, 250, 240, 0.94);
  --surface-paper-soft: rgba(255, 250, 240, 0.6);
  --surface-rule: rgba(60, 45, 30, 0.18);
  --surface-rule-strong: rgba(60, 45, 30, 0.32);
  --surface-shadow: 0 12px 32px rgba(20, 18, 14, 0.1), 0 2px 6px rgba(20, 18, 14, 0.06);
  --surface-shadow-soft: 0 4px 14px rgba(20, 18, 14, 0.06);

  --ink: var(--ds-ink);
  --ink-soft: var(--ds-ink-soft);
  --ink-faint: var(--ds-ink-faint);
  --ink-on-accent: #fffaf0;

  --accent: var(--ds-gold);
  --accent-soft: rgba(184, 146, 42, 0.22);
  --accent-strong: var(--ds-gold-deep);
  --accent-tint: rgba(184, 146, 42, 0.14);

  --ok: var(--ds-green);
  --warn: #b1551a;

  --font-display: "Playfair Display", "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-body: "Iowan Old Style", "Cormorant Garamond", Georgia, serif;
  --font-ui: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius-1: 8px;
  --radius-2: 14px;
  --radius-3: 20px;
  --radius-pill: 999px;

  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-slow: 360ms;
  --motion-feedback: 400ms;
}

html.dark,
html.dark[data-theme="manuscript"] {
  --surface-paper: rgba(28, 22, 18, 0.86);
  --surface-paper-soft: rgba(28, 22, 18, 0.55);
  --surface-rule: rgba(245, 236, 223, 0.16);
  --surface-rule-strong: rgba(245, 236, 223, 0.32);
  --surface-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  --surface-shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.3);

  --ink: #f5ecdf;
  --ink-soft: rgba(245, 236, 223, 0.72);
  --ink-faint: rgba(245, 236, 223, 0.46);

  --accent: #e6c469;
  --accent-soft: rgba(230, 196, 105, 0.22);
  --accent-strong: #f1d27c;
  --accent-tint: rgba(230, 196, 105, 0.14);

  --ok: #7fd4a0;
  --warn: #f0a87a;
}

/* Light-always (2026-06-09): the journey PATH canvas keeps its dark watercolor
 * field deliberately (owner). Re-scoped from html.dark to :root so it stays dark
 * even though the app is now light everywhere else. --wcp-* only affect the path. */
:root {
  --wcp-tint-a: 32, 26, 18 !important;
  --wcp-tint-b: 24, 19, 12 !important;
  --wcp-tint-c: 15, 11, 6 !important;
  --wcp-chip-bg: rgba(32, 25, 15, 0.92) !important;
  --wcp-paper-strong: rgba(26, 20, 12, 0.97) !important;
  --wcp-path-body: #6a5220 !important;
  --wcp-path-dash: #9e7d3a !important;
  --wcp-node-ring: #9e7d3a !important;
  --wcp-node-glow: rgba(158, 125, 58, 0.28) !important;
  --wcp-path-shadow: rgba(0, 0, 0, 0.34) !important;
  --wcp-stage-wash-hi: rgba(0, 0, 0, 0.28) !important;
  --wcp-stage-wash-mid: rgba(0, 0, 0, 0.11) !important;
  --wcp-stage-wash-soft: rgba(0, 0, 0, 0.17) !important;
  --wcp-nav-bg: rgba(12, 9, 5, 0.97) !important;
}

/* ── Aurora: cool slate + cyan/violet accents, modern Inter sans ── */
:root[data-theme="aurora"] {
  --surface-paper: rgba(244, 248, 252, 0.96);
  --surface-paper-soft: rgba(244, 248, 252, 0.62);
  --surface-rule: rgba(56, 80, 110, 0.14);
  --surface-rule-strong: rgba(56, 80, 110, 0.3);
  --surface-shadow: 0 18px 44px rgba(34, 56, 96, 0.12), 0 2px 6px rgba(34, 56, 96, 0.08);
  --surface-shadow-soft: 0 4px 14px rgba(34, 56, 96, 0.06);

  --ink: #1f2a44;
  --ink-soft: rgba(31, 42, 68, 0.66);
  --ink-faint: rgba(31, 42, 68, 0.42);
  --ink-on-accent: #ffffff;

  --accent: #3a6df0;
  --accent-soft: rgba(58, 109, 240, 0.18);
  --accent-strong: #2a4fb8;
  --accent-tint: rgba(58, 109, 240, 0.1);

  --ok: #0e8f6a;
  --warn: #d97a4a;

  --font-display: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --font-body: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --font-ui: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --radius-1: 10px;
  --radius-2: 16px;
  --radius-3: 22px;
}

html.dark[data-theme="aurora"] {
  --surface-paper: rgba(20, 28, 44, 0.92);
  --surface-paper-soft: rgba(20, 28, 44, 0.58);
  --surface-rule: rgba(174, 198, 232, 0.14);
  --surface-rule-strong: rgba(174, 198, 232, 0.3);
  --surface-shadow: 0 18px 44px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --surface-shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.3);

  --ink: #e5edff;
  --ink-soft: rgba(229, 237, 255, 0.7);
  --ink-faint: rgba(229, 237, 255, 0.42);

  --accent: #7da7ff;
  --accent-soft: rgba(125, 167, 255, 0.22);
  --accent-strong: #a8c1ff;
  --accent-tint: rgba(125, 167, 255, 0.12);

  --ok: #5dd1a8;
  --warn: #ffae7d;
}

/* ── Focus: minimal mono, high-contrast, distraction-free ───────── */
:root[data-theme="focus"] {
  --surface-paper: #ffffff;
  --surface-paper-soft: rgba(255, 255, 255, 0.85);
  --surface-rule: rgba(15, 18, 22, 0.16);
  --surface-rule-strong: rgba(15, 18, 22, 0.4);
  --surface-shadow: 0 1px 0 rgba(15, 18, 22, 0.08);
  --surface-shadow-soft: 0 1px 0 rgba(15, 18, 22, 0.06);

  --ink: #0f1216;
  --ink-soft: rgba(15, 18, 22, 0.7);
  --ink-faint: rgba(15, 18, 22, 0.45);
  --ink-on-accent: #ffffff;

  --accent: #0f1216;
  --accent-soft: rgba(15, 18, 22, 0.08);
  --accent-strong: #000000;
  --accent-tint: rgba(15, 18, 22, 0.04);

  --ok: #0d6d3d;
  --warn: #a14a14;

  --font-display: "JetBrains Mono", ui-monospace, monospace;
  --font-body: "Inter", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius-1: 4px;
  --radius-2: 6px;
  --radius-3: 10px;
  --radius-pill: 4px;
}

html.dark[data-theme="focus"] {
  --surface-paper: #14171b;
  --surface-paper-soft: rgba(20, 23, 27, 0.85);
  --surface-rule: rgba(245, 245, 245, 0.16);
  --surface-rule-strong: rgba(245, 245, 245, 0.42);
  --surface-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  --surface-shadow-soft: 0 1px 0 rgba(0, 0, 0, 0.45);

  --ink: #f5f5f5;
  --ink-soft: rgba(245, 245, 245, 0.7);
  --ink-faint: rgba(245, 245, 245, 0.42);

  --accent: #f5f5f5;
  --accent-soft: rgba(245, 245, 245, 0.1);
  --accent-strong: #ffffff;
  --accent-tint: rgba(245, 245, 245, 0.06);
}

/* Honor the user's system reduced-motion preference globally. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
    --motion-base: 0ms;
    --motion-slow: 0ms;
    --motion-feedback: 0ms;
  }
}

/* ── Shared "card" surface used across modules / story / speech ─── */
.surface,
.surface.surface--manuscript.module-card {
  background: var(--surface-paper);
  color: var(--ink);
  border: 1px solid var(--surface-rule);
  border-radius: var(--radius-2);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-body);
  box-shadow: var(--surface-shadow);
  transition:
    background var(--motion-base) ease,
    border-color var(--motion-base) ease,
    box-shadow var(--motion-base) ease,
    color var(--motion-base) ease;
}

.surface__title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 var(--space-3);
}

.surface__actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Theme switcher control (placed in dashboard header) ─────────── */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  border: 1px solid var(--surface-rule);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: background var(--motion-base) ease, border-color var(--motion-base) ease;
}

.theme-switcher__btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0.32rem 0.7rem;
  font: inherit;
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    background var(--motion-base) ease,
    color var(--motion-base) ease,
    transform var(--motion-fast) ease;
}

.theme-switcher__btn:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.theme-switcher__btn[aria-pressed="true"] {
  background: var(--surface-paper);
  color: var(--ink);
  box-shadow: var(--surface-shadow-soft);
}

.theme-switcher__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
