/* TraceGrade design system: Warm Light + Warm Dark (amber accent)
   ==========================================================================
   Every colour the app uses is a token in this file. style.css (and the
   standalone practice page) read colours through var() only, so one palette
   swap re-themes the whole app.

   Theme selection (set by the inline script in base.html before paint):
     <html>                    follow the operating system
     <html data-mode="light">  forced light
     <html data-mode="dark">   forced dark
   The light palette lives on :root; the dark one is declared twice, once for
   "system says dark and nothing forced" and once for "forced dark".

   Breakpoints: 768px (phone) and 900px (narrow tablet / collapsed sidebars).
   ========================================================================== */
:root {
  color-scheme: light;

  /* Surfaces */
  --bg-base: #F9F9F7;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FBFBF9;
  --bg-subtle: #F5F5F4;
  --code-bg: #FAFAF9;
  --overlay: rgba(28, 25, 23, 0.45);

  /* Borders */
  --border-color: #E7E5E4;
  --border-subtle: #F5F5F4;
  --border-strong: #D6D3D1;
  --border-focus: #D97706;

  /* Text */
  --text-main: #1C1917;
  --text-muted: #6F6862;
  --text-dim: #8C857F;

  /* Accent: amber */
  --accent: var(--accent-primary);
  /* Fill and text colour: a deeper amber so white labels and amber text both pass AA (4.5:1). */
  --accent-primary: #B45309;
  --accent-primary-hover: #92400E;
  --accent-primary-subtle: rgba(217, 119, 6, 0.12);
  --accent-contrast: #FFFFFF;
  --accent-bg: #FEF3C7;
  --accent-soft: #FFFBEB;
  --accent-border: #FDE68A;
  --accent-text: #92400E;
  --focus-ring: rgba(217, 119, 6, 0.35);

  /* Status */
  --color-success: #16A34A;
  --color-success-bg: rgba(34, 197, 94, 0.12);
  --success-text: #166534;
  --success-bg: #DCFCE7;
  --success-border: #86EFAC;
  --color-warning: #CA8A04;
  --color-warning-bg: rgba(234, 179, 8, 0.12);
  --color-error: #DC2626;
  --color-error-bg: rgba(239, 68, 68, 0.12);
  --error-text: #991B1B;
  --error-bg: #FEE2E2;
  --error-border: #FCA5A5;
  --color-info: #2563EB;
  --on-danger: #FFFFFF;


  /* Aliases kept for older templates */
  --text-primary: #1C1917;
  --text-secondary: var(--text-muted);
  --text-normal: var(--text-main);
  --accent-cyan: var(--accent-primary);
  --accent-cyan-subtle: var(--accent-primary-subtle);
  --warm-bg-base: var(--bg-base);
  --warm-bg-surface: var(--bg-surface);

  /* Typography */
  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;

  /* Spacing */
  --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;
  --space-8: 4rem;

  /* Shape & depth */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(28, 25, 23, 0.06), 0 2px 4px -2px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(28, 25, 23, 0.08), 0 4px 6px -4px rgba(28, 25, 23, 0.04);
}

/* Warm Dark: the same palette in stone-900 tones; amber stays the brand colour. */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    color-scheme: dark;
    --bg-base: #100F0E;
    --bg-surface: #1A1917;
    --bg-card: #1A1917;
    --bg-card-hover: #22201E;
    --bg-subtle: #262421;
    --code-bg: #151413;
    --overlay: rgba(0, 0, 0, 0.6);
    --border-color: #322F2B;
    --border-subtle: #262421;
    --border-strong: #48433D;
    --border-focus: #F59E0B;
    --text-main: #F5F5F4;
    --text-muted: #ADA69F;
    --text-dim: #8C857F;
    --accent-primary: #D97706;
    --accent-primary-hover: #F59E0B;
    --accent-contrast: #1C1917;
    --accent-primary-subtle: rgba(245, 158, 11, 0.14);
    --accent-bg: #3A2B12;
    --accent-soft: #2A2116;
    --accent-border: #7A5514;
    --accent-text: #FBBF24;
    --focus-ring: rgba(245, 158, 11, 0.4);
    --color-success: #4ADE80;
    --success-text: #86EFAC;
    --success-bg: #14301F;
    --success-border: #1F6B3A;
    --color-warning: #FACC15;
    --color-error: #F87171;
    --error-text: #FCA5A5;
    --error-bg: #3A1818;
    --error-border: #7F1D1D;
    --color-info: #60A5FA;
    --text-primary: #F5F5F4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  }
}
:root[data-mode="dark"] {
  color-scheme: dark;
  --bg-base: #100F0E;
  --bg-surface: #1A1917;
  --bg-card: #1A1917;
  --bg-card-hover: #22201E;
  --bg-subtle: #262421;
  --code-bg: #151413;
  --overlay: rgba(0, 0, 0, 0.6);
  --border-color: #322F2B;
  --border-subtle: #262421;
  --border-strong: #48433D;
  --border-focus: #F59E0B;
  --text-main: #F5F5F4;
  --text-muted: #ADA69F;
  --text-dim: #8C857F;
  --accent-primary: #D97706;
  --accent-primary-hover: #F59E0B;
  --accent-contrast: #1C1917;
  --accent-primary-subtle: rgba(245, 158, 11, 0.14);
  --accent-bg: #3A2B12;
  --accent-soft: #2A2116;
  --accent-border: #7A5514;
  --accent-text: #FBBF24;
  --focus-ring: rgba(245, 158, 11, 0.4);
  --color-success: #4ADE80;
  --success-text: #86EFAC;
  --success-bg: #14301F;
  --success-border: #1F6B3A;
  --color-warning: #FACC15;
  --color-error: #F87171;
  --error-text: #FCA5A5;
  --error-bg: #3A1818;
  --error-border: #7F1D1D;
  --color-info: #60A5FA;
  --text-primary: #F5F5F4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.45), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* Printing (certificate, reports) always uses the light palette on white paper. */
@media print {
  :root, :root:not([data-mode="light"]), :root[data-mode="dark"] {
    color-scheme: light;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FBFBF9;
    --bg-subtle: #F5F5F4;
    --code-bg: #FAFAF9;
    --overlay: rgba(28, 25, 23, 0.45);
    --border-color: #E7E5E4;
    --border-subtle: #F5F5F4;
    --border-strong: #D6D3D1;
    --border-focus: #D97706;
    --text-main: #1C1917;
    --text-muted: #6F6862;
    --text-dim: #8C857F;
    --accent-primary: #B45309;
    --accent-primary-hover: #92400E;
    --accent-contrast: #FFFFFF;
    --accent-primary-subtle: rgba(217, 119, 6, 0.12);
    --accent-bg: #FEF3C7;
    --accent-soft: #FFFBEB;
    --accent-border: #FDE68A;
    --accent-text: #92400E;
    --focus-ring: rgba(217, 119, 6, 0.35);
    --color-success: #16A34A;
    --success-text: #166534;
    --success-bg: #DCFCE7;
    --success-border: #86EFAC;
    --color-warning: #CA8A04;
    --color-error: #DC2626;
    --error-text: #991B1B;
    --error-bg: #FEE2E2;
    --error-border: #FCA5A5;
    --color-info: #2563EB;
    --text-primary: #1C1917;
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(28, 25, 23, 0.06), 0 2px 4px -2px rgba(28, 25, 23, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(28, 25, 23, 0.08), 0 4px 6px -4px rgba(28, 25, 23, 0.04);
    --bg-base: #FFFFFF;
  }
}

/* Fonts: self-hosted variable Inter + JetBrains Mono (SIL OFL 1.1, see static/fonts/LICENSE-*).
   Split by unicode-range so a page only downloads the subsets it uses (Vietnamese for the vi legal pages). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-vietnamese-var.woff2") format("woff2-variations"), url("/static/fonts/inter-vietnamese-var.woff2") format("woff2");
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-ext-var.woff2") format("woff2-variations"), url("/static/fonts/inter-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/inter-latin-var.woff2") format("woff2-variations"), url("/static/fonts/inter-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/jetbrains-mono-vietnamese-var.woff2") format("woff2-variations"), url("/static/fonts/jetbrains-mono-vietnamese-var.woff2") format("woff2");
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/jetbrains-mono-latin-ext-var.woff2") format("woff2-variations"), url("/static/fonts/jetbrains-mono-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/fonts/jetbrains-mono-latin-var.woff2") format("woff2-variations"), url("/static/fonts/jetbrains-mono-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
