@font-face {
  font-family: 'OpenDyslexic';
  src: url('/fonts/OpenDyslexic-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

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

:root {
  /* ── Warm teal palette ── */
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.1);

  /* ── Surface tinting (accent wash on chrome) ── */
  --surface-tint: rgba(13, 148, 136, 0.04);
  --surface-tint-strong: rgba(13, 148, 136, 0.07);

  /* ── Surfaces ── */
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --text: #1c1917;
  --text-muted: #57534e;
  --border: #e7e5e4;

  /* ── Highlight (derived from accent) ── */
  --highlight-color: rgba(13, 148, 136, 0.2);
  --highlight-text: var(--text);

  /* ── Typography ── */
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-dyslexic: 'OpenDyslexic', sans-serif;
  --font-size-base: 1.125rem;
  --line-height: 1.75;

  /* ── Sizing ── */
  --touch-target: 48px;
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-full: 999px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 8px 24px rgba(28, 25, 23, 0.12);

  /* ── Safe areas ── */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* ── Transitions ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
}

/* ── Dark theme ── */

[data-theme="dark"] {
  --bg: #1c1917;
  --bg-elevated: #292524;
  --text: #fafaf9;
  --text-muted: #a8a29e;
  --border: #44403c;
  --highlight-color: rgba(13, 148, 136, 0.3);
  --highlight-text: var(--text);
  --primary-soft: rgba(13, 148, 136, 0.15);
  --surface-tint: rgba(13, 148, 136, 0.06);
  --surface-tint-strong: rgba(13, 148, 136, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ── Accent colors ── */

[data-accent="blue"] {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --highlight-color: rgba(37, 99, 235, 0.2);
  --surface-tint: rgba(37, 99, 235, 0.04);
  --surface-tint-strong: rgba(37, 99, 235, 0.07);
}
[data-theme="dark"][data-accent="blue"] {
  --primary-soft: rgba(37, 99, 235, 0.2);
  --highlight-color: rgba(37, 99, 235, 0.3);
  --surface-tint: rgba(37, 99, 235, 0.06);
  --surface-tint-strong: rgba(37, 99, 235, 0.1);
}

[data-accent="amber"] {
  --primary: #92400e;
  --primary-hover: #78350f;
  --primary-soft: rgba(146, 64, 14, 0.1);
  --highlight-color: rgba(146, 64, 14, 0.2);
  --surface-tint: rgba(146, 64, 14, 0.04);
  --surface-tint-strong: rgba(146, 64, 14, 0.07);
}
[data-theme="dark"][data-accent="amber"] {
  --primary-soft: rgba(146, 64, 14, 0.2);
  --highlight-color: rgba(146, 64, 14, 0.3);
  --surface-tint: rgba(146, 64, 14, 0.06);
  --surface-tint-strong: rgba(146, 64, 14, 0.1);
}

[data-accent="rose"] {
  --primary: #be185d;
  --primary-hover: #9f1239;
  --primary-soft: rgba(190, 24, 93, 0.1);
  --highlight-color: rgba(190, 24, 93, 0.2);
  --surface-tint: rgba(190, 24, 93, 0.035);
  --surface-tint-strong: rgba(190, 24, 93, 0.06);
}
[data-theme="dark"][data-accent="rose"] {
  --primary-soft: rgba(190, 24, 93, 0.2);
  --highlight-color: rgba(190, 24, 93, 0.3);
  --surface-tint: rgba(190, 24, 93, 0.06);
  --surface-tint-strong: rgba(190, 24, 93, 0.1);
}

[data-accent="violet"] {
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: rgba(124, 58, 237, 0.1);
  --highlight-color: rgba(124, 58, 237, 0.2);
  --surface-tint: rgba(124, 58, 237, 0.035);
  --surface-tint-strong: rgba(124, 58, 237, 0.06);
}
[data-theme="dark"][data-accent="violet"] {
  --primary-soft: rgba(124, 58, 237, 0.2);
  --highlight-color: rgba(124, 58, 237, 0.3);
  --surface-tint: rgba(124, 58, 237, 0.06);
  --surface-tint-strong: rgba(124, 58, 237, 0.1);
}

[data-accent="contrast"] {
  --primary: #000000;
  --primary-hover: #1a1a1a;
  --primary-soft: rgba(0, 0, 0, 0.08);
  --highlight-color: rgba(0, 0, 0, 0.15);
  --surface-tint: rgba(0, 0, 0, 0.02);
  --surface-tint-strong: rgba(0, 0, 0, 0.04);
}
[data-theme="dark"][data-accent="contrast"] {
  --primary: #ffffff;
  --primary-hover: #e5e5e5;
  --primary-soft: rgba(255, 255, 255, 0.12);
  --highlight-color: rgba(255, 255, 255, 0.2);
  --surface-tint: rgba(255, 255, 255, 0.04);
  --surface-tint-strong: rgba(255, 255, 255, 0.07);
}

/* ── Reading display ── */

[data-reader-size="small"]  { --reader-font-size: 1rem; }
[data-reader-size="medium"] { --reader-font-size: 1.25rem; }
[data-reader-size="large"]  { --reader-font-size: 1.5rem; }
[data-reader-size="xl"]     { --reader-font-size: 1.875rem; }

[data-reader-spacing="compact"] {
  --line-height: 1.5;
  --reader-line-height: 1.5;
  --reader-letter-spacing: normal;
}
[data-reader-spacing="default"] {
  --line-height: 1.75;
  --reader-line-height: 1.8;
  --reader-letter-spacing: normal;
}
[data-reader-spacing="spacious"] {
  --line-height: 2.0;
  --reader-line-height: 2.2;
  --reader-letter-spacing: 0.05em;
  letter-spacing: 0.03em;
}

[data-font="dyslexic"] {
  --font-body: 'OpenDyslexic', sans-serif;
  --font-size-base: 1rem;
}

/* ── Base elements ── */

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Focus styles ── */

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

/* ── Selection ── */

::selection {
  background: var(--primary-soft);
  color: var(--text);
}

/* ── Reduced motion ── */

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

/* ── Screen reader only ── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
