/* AOthman design tokens for learn.aothman.org.
 * Part 1 is copied unchanged from the source of truth, bodmind/frontend/src/design/tokens.css
 * (the live aothman.org design, commit 70cc671 and later); only the page-art URLs point at /brand/.
 * Part 2 holds the shared components, copied from bodmind/frontend/src/styles/tailwind.css with
 * the Tailwind @apply lines written out. Update part 1 by copying the file again. */

/* ---------- Part 1: tokens (bodmind tokens.css) ---------- */
/**
 * CSS custom properties for the design tokens (design/palette.js).
 * Imported once (App). Use the matching Tailwind utilities (bg-surface,
 * text-accent, text-fg, …) in components and these variables in raw CSS.
 * Values follow the AOthman design system (same as the certificates and
 * auth consoles): mist / night canvas, frosted panels, cyan → violet brand.
 *
 * Dark is the default theme; `[data-theme="light"]` (set by ThemeContext)
 * swaps the themed colors. `--rgb-*` hold the same colors as channels so
 * Tailwind opacity modifiers work (bg-surface/60, border-accent/20).
 */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Backgrounds */
  --bg-black: #0a0a0a;
  --bg-dark: #0d0f14;
  --bg-mid: #12141b;
  --surface: #12141b;
  --surface-raised: #1a1d27;
  --panel: rgba(17, 19, 26, 0.88);
  --band: #0e1016; /* alternate section background */
  --page-art: url('/brand/ao-bg-dark.svg');

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-brand: rgba(0, 212, 255, 0.14);

  /* Text */
  --text: #f1f5f9;
  --text-muted: #a3adbf;
  --text-faint: #7b8597;

  /* Accent (cyan) and violet */
  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --accent-muted: rgba(34, 211, 238, 0.10);
  --accent-glow: rgba(34, 211, 238, 0.28);
  --accent-cyan: var(--accent); /* back-compat alias */
  --violet: #a78bfa;

  /* Signals */
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  /* Depth */
  /* Depth: 1 card, 2 hovered card, 3 floating (header, menus, dialogs) */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 28px -12px rgba(0, 0, 0, 0.7);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, 0.5);
  --shadow-panel: var(--shadow-3);
  --shadow-lift: var(--shadow-2);

  /* Channels for Tailwind opacity modifiers */
  --rgb-base: 10 10 10;
  --rgb-surface: 18 20 27;
  --rgb-surface-raised: 26 29 39;
  --rgb-fg: 241 245 249;
  --rgb-accent: 34 211 238;
  --rgb-violet: 167 139 250;
  --rgb-success: 52 211 153;
  --rgb-warning: 251 191 36;
  --rgb-danger: 248 113 113;

  --gradient-text: linear-gradient(95deg, #22d3ee 0%, #818cf8 55%, #a78bfa 100%);
  --gradient-card: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  --gradient-project: linear-gradient(135deg, rgba(34, 211, 238, 0.22) 0%, rgba(124, 58, 237, 0.30) 100%);
}

[data-theme="light"] {
  color-scheme: light;

  --bg-black: #eef1f6;
  --bg-dark: #eef1f7;
  --bg-mid: #e2e8f0;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --panel: rgba(255, 255, 255, 0.9);
  --band: #e4e8f0; /* alternate section background; deeper than the canvas so white cards still pop */
  --page-art: url('/brand/ao-bg-light.svg');

  --border-subtle: rgba(15, 23, 42, 0.11);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-brand: rgba(124, 58, 237, 0.14);

  --text: #0f172a;
  --text-muted: #5b6577;
  --text-faint: #5f6878; /* 4.6:1 on the light canvas (WCAG AA) */

  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-muted: rgba(8, 145, 178, 0.10);
  --accent-glow: rgba(8, 145, 178, 0.25);
  --violet: #7c3aed;

  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  /* Light needs a firmer card edge than dark: white on mist only separates by border and shadow. */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px -6px rgba(15, 23, 42, 0.10);
  --shadow-2: 0 2px 4px rgba(15, 23, 42, 0.05), 0 16px 34px -14px rgba(15, 23, 42, 0.24);
  --shadow-3: 0 18px 50px rgba(15, 23, 42, 0.12);
  --shadow-panel: var(--shadow-3);
  --shadow-lift: var(--shadow-2);

  --rgb-base: 238 241 246;
  --rgb-surface: 255 255 255;
  --rgb-surface-raised: 255 255 255;
  --rgb-fg: 15 23 42;
  --rgb-accent: 8 145 178;
  --rgb-violet: 124 58 237;
  --rgb-success: 5 150 105;
  --rgb-warning: 217 119 6;
  --rgb-danger: 220 38 38;

  --gradient-text: linear-gradient(95deg, #0891b2 0%, #4f46e5 55%, #7c3aed 100%);
  --gradient-card: linear-gradient(160deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.01));
  --gradient-project: linear-gradient(135deg, rgba(8, 145, 178, 0.16) 0%, rgba(124, 58, 237, 0.20) 100%);
}

:root {
  /* Brand colors (same in both themes) */
  --purple: #7c3aed;
  --purple-hover: #8b5cf6;
  --blue: #2563eb;
  --rgb-purple: 124 58 237;
  --rgb-blue: 37 99 235;

  /* Brand gradient: buttons, active marks. White text reads on both ends. */
  --gradient-brand: linear-gradient(90deg, #0891b2 0%, #7c3aed 100%);
  --gradient-primary: var(--gradient-brand);
  --gradient-button: var(--gradient-brand);
  --gradient-hero: var(--gradient-brand);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html {
  background-color: var(--bg-black);
  /* Keep focused and anchored elements clear of the sticky header (WCAG 2.4.11). */
  scroll-padding-top: 96px;
}

/* High-contrast mode: when the system asks for more contrast, secondary text
   and hairlines step up and decoration steps back. */
@media (prefers-contrast: more) {
  :root,
  [data-theme] {
    --text-muted: var(--text);
    --border-subtle: var(--border-strong);
  }
  [data-theme="light"] {
    --text-faint: #3f4756;
    --border-strong: rgba(15, 23, 42, 0.45);
  }
  [data-theme="dark"],
  :root:not([data-theme="light"]) {
    --text-faint: #c3cad6;
    --border-strong: rgba(255, 255, 255, 0.4);
  }
  body::before {
    display: none;
  }
}

/* Wide screens: scale rem-based type and spacing up so the page fills the
   view instead of sitting small in the middle. */
@media (min-width: 1800px) {
  html { font-size: 17px; }
}
@media (min-width: 2300px) {
  html { font-size: 18.5px; }
}

body {
  position: relative;
  min-height: 100vh;
  /* Canvas colour lives on html, so the art layer below can sit under content. */
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* The brand art is atmosphere for the top of a page, not a texture under
   the reading area: it fades into the plain canvas before the content. */
body::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: min(820px, 100vh);
  background: var(--page-art) center top / cover no-repeat;
  opacity: 0.5;
  -webkit-mask-image: linear-gradient(to bottom, #000 25%, transparent 85%);
  mask-image: linear-gradient(to bottom, #000 25%, transparent 85%);
  pointer-events: none;
  z-index: -1;
}

/* ---------- Part 2: components (bodmind tailwind.css, written out) ---------- */
:root { --link: var(--accent); --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace; }
[data-theme="light"] { --link: var(--accent-hover); } /* small cyan text on mist needs the darker step (AA) */
::selection { background: rgb(var(--rgb-violet) / 0.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.surface { background: var(--surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-1); }
.glass { background: var(--panel); border: 1px solid var(--border-brand); box-shadow: var(--shadow-3);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); }
.lift { transition: transform .2s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow .2s, border-color .2s; }
.lift:hover { transform: translateY(-2px); border-color: rgb(var(--rgb-violet) / 0.3); box-shadow: var(--shadow-2); }
.text-gradient { background: var(--gradient-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--accent); }
[data-theme="light"] .eyebrow { color: var(--accent-hover); }
.eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--gradient-brand); }
.btn-cta, .btn-outline { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px;
  font: 600 14px/1.2 var(--font-sans); padding: 9px 18px; cursor: pointer; text-decoration: none; transition: all .2s; }
.btn-cta { color: #fff; border: 0; background: var(--gradient-brand); box-shadow: 0 10px 24px -10px rgb(var(--rgb-violet) / 0.55); }
.btn-cta:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -10px rgb(var(--rgb-violet) / 0.7); filter: brightness(1.06); }
.btn-outline { color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); }
.btn-outline:hover { transform: translateY(-1px); border-color: rgb(var(--rgb-violet) / 0.35); box-shadow: 0 8px 20px -10px rgb(var(--rgb-fg) / 0.25); }
.btn-cta:disabled, .btn-outline:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.nav-pill { border-radius: 999px; padding: 7px 14px; font-size: .95rem; font-weight: 500; color: var(--text-muted); text-decoration: none; transition: color .2s, background-color .2s; }
.nav-pill:hover { color: var(--text); background: rgb(var(--rgb-fg) / 0.05); text-decoration: none; }
.nav-pill[aria-current="page"] { color: var(--text); background: linear-gradient(90deg, rgb(var(--rgb-accent) / 0.16), rgb(var(--rgb-violet) / 0.16)); }
.ao-mark { filter: drop-shadow(0 0 14px var(--accent-glow)); display: block; }
.theme-btn { border: 0; background: transparent; color: var(--text-muted); border-radius: 999px; width: 38px; height: 38px;
  display: inline-grid; place-items: center; cursor: pointer; }
.theme-btn:hover { color: var(--text); background: rgb(var(--rgb-fg) / 0.05); }
.theme-btn svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .lift:hover, .btn-cta:hover, .btn-outline:hover { transform: none; } }
