/* ============================================================================
   CBSE AI TUTOR — "Warm Scholar" base.css
   FROZEN single-token layer + reset + base elements + layout + decoration.
   Authored by Agent 0 (architect). Consumed verbatim by all downstream agents.
   Tokens here are the source of truth; main.css carries a temporary identical
   safety-duplicate of this token block (§3) — keep the two in lockstep.
   All units rem. Light is the default theme (:root); dark is opt-in.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   TOKENS — LIGHT (default).  WCAG-checked pairs per Appendix C.
   ---------------------------------------------------------------------------- */
:root {
    /* Brand — amber LOCKED (fleet registry). FILL/tint/border/icon; never small text on light. */
    --accent-primary: #f59e0b;
    --accent-primary-hover: #d97706;
    --accent-primary-soft: #fffbeb;
    --accent-primary-text: #b45309;        /* amber-as-text on light = 4.90:1 */
    --accent-secondary: #0d9488;
    --accent-secondary-hover: #0f766e;
    --accent-secondary-soft: #f0fdfa;
    --accent-secondary-text: #0e7c70;       /* teal-as-text on light = 4.96:1 */

    /* Warm neutrals (sand / ink — the "warm" signal) */
    --bg-primary: #fdfcfb;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sunken: #f7f4ef;
    --bg-elevated: #ffffff;

    --text-primary: #1f2430;                 /* 15.1:1 on page */
    --text-secondary: #5b6170;               /* 6.05:1 page / 5.65:1 sunken */
    --text-muted: #646b7a;                   /* 5.20:1 page · 4.88:1 sunken */
    --text-disabled: #8a8f9c;                /* non-text / disabled only */

    --border-color: #e9e2d8;
    --border-subtle: #f0ebe3;
    --focus-ring: #0d9488;                   /* teal, 3.65:1 vs page — passes 3:1 UI */

    /* Semantic: fill = base, text-on-light = *-text */
    --success: #10b981;
    --success-text: #047857;
    --warning: #eab308;
    --warning-text: #a16207;
    --danger: #ef4444;
    --danger-text: #b91c1c;
    --info: #3b82f6;
    --info-text: #2563eb;

    /* Subject coding — FILL/BORDER/ICON ONLY. Chip LABELS use --text-primary (rule 0.8e). */
    --subj-math: #f59e0b;
    --subj-science: #0d9488;
    --subj-physics: #6366f1;
    --subj-chemistry: #e8623d;
    --subj-biology: #16a34a;
    --subj-english: #3b82f6;
    --subj-hindi: #e11d68;
    --subj-social: #8b5cf6;

    /* Spacing scale (Tailwind-aligned — identical rem values) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-24: 6rem;
    --space-32: 8rem;

    /* Typography */
    --font-display: 'Plus Jakarta Sans', sans-serif;   /* headings — weights 600/700/800 */
    --font-body: 'Outfit', sans-serif;                  /* body — 400/500/600 */
    --font-mono: 'JetBrains Mono', monospace;

    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 624.9375rem;

    /* Shadows — soft, low-contrast, warm-tinted */
    --shadow-sm: 0 0.0625rem 0.125rem rgba(31, 36, 48, 0.06);
    --shadow-md: 0 0.25rem 0.75rem rgba(31, 36, 48, 0.07);
    --shadow-lg: 0 0.75rem 2rem rgba(31, 36, 48, 0.08);
    --shadow-glow: 0 0 2rem rgba(245, 158, 11, 0.18);

    /* Motion */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Gradients — SPARING: hero + primary CTA only */
    --gradient-primary: linear-gradient(135deg, #f59e0b 0%, #fb923c 55%, #f97316 100%);
    --gradient-warm: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);

    /* Nav height — MUST equal shared-header height + SHARED_HELP sticky offset + body padding-top */
    --nav-height: 3.75rem;
}

/* ----------------------------------------------------------------------------
   TOKENS — DARK (warmed).  All pairs pass Appendix C.
   Applies whether the page or the shared header sets data-theme, and
   regardless of the .dark class presence (Tailwind sync).
   ---------------------------------------------------------------------------- */
:root[data-theme="dark"],
.dark {
    --bg-primary: #12110f;
    --bg-secondary: #1a1814;
    --bg-card: #1c1a17;
    --bg-sunken: #161410;
    --bg-elevated: #23201b;

    --text-primary: #f5f1ea;
    --text-secondary: #b8b2a7;
    --text-muted: #8a8579;
    --text-disabled: #6f6a5f;

    --border-color: rgba(255, 255, 255, 0.09);
    --border-subtle: rgba(255, 255, 255, 0.05);

    --accent-primary-text: #f59e0b;          /* amber as text on dark = 8.79:1 */
    --accent-secondary-text: #2dd4bf;
    --focus-ring: #2dd4bf;

    --accent-primary-soft: rgba(245, 158, 11, 0.12);
    --accent-secondary-soft: rgba(13, 148, 136, 0.12);

    /* Dark shadows keep the darker rgba(0,0,0,...) scale */
    --shadow-sm: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.30);
    --shadow-md: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 0.75rem 2rem rgba(0, 0, 0, 0.50);
    --shadow-glow: 0 0 2rem rgba(245, 158, 11, 0.22);
}

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

html {
    scroll-behavior: smooth;
    font-size: 1rem;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ----------------------------------------------------------------------------
   BASE ELEMENTS
   ---------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.875rem, 4vw, 2.75rem); }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; }
h4 { font-size: clamp(1.25rem, 2vw, 1.5rem); font-weight: 600; }
h5 { font-size: 1.125rem; font-weight: 600; }
h6 { font-size: 1rem; font-weight: 600; }

p { color: var(--text-secondary); line-height: 1.7; }

a {
    color: var(--accent-primary-text);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-primary-hover); }

strong, b { font-weight: 600; color: var(--text-primary); }
small { font-size: 0.875rem; }
code, pre, kbd, samp { font-family: var(--font-mono); }

img, picture, svg, video { max-width: 100%; display: block; }

ul, ol { list-style-position: inside; }

/* Constrained prose measure (65ch max) helper for long-form copy */
.prose { max-width: 65ch; }

/* Scrollbar — warm, restrained */
::-webkit-scrollbar { width: 0.625rem; height: 0.625rem; }
::-webkit-scrollbar-track { background: var(--bg-sunken); }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    border: 0.125rem solid var(--bg-sunken);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }
* { scrollbar-width: thin; scrollbar-color: var(--border-color) var(--bg-sunken); }

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

/* ----------------------------------------------------------------------------
   ACCESSIBILITY — focus + reduced motion (§0.8a / §0.8b)
   ---------------------------------------------------------------------------- */
:focus-visible {
    outline: 0.1875rem solid var(--focus-ring);   /* TEAL — amber fails 3:1 */
    outline-offset: 0.125rem;
}

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

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

/* ----------------------------------------------------------------------------
   LAYOUT COMPONENT CLASSES (load-bearing rhythm — §0.3; NOT retired)
   ---------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}
.container-sm { max-width: 50rem; margin: 0 auto; }
.container-lg { max-width: 90rem; margin: 0 auto; }

.section {
    padding: 6.25rem 0;
    position: relative;
}

.section-header {
    text-align: center;
    max-width: 43.75rem;
    margin: 0 auto 4rem;
}

@media (max-width: 48em) {
    .section { padding: 5rem 0; }
}
@media (max-width: 30em) {
    .container { padding: 0 1rem; }
}

/* ----------------------------------------------------------------------------
   DECORATION HELPERS (§0.7 — enforceable density; max ONE hero decoration)
   ---------------------------------------------------------------------------- */

/* Amber highlighter behind / under a heading — ≤1 per section heading.
   Renders as a soft swept marker stroke under the text baseline. */
.u-underline-mark {
    position: relative;
    display: inline;
    background-image: linear-gradient(
        to top,
        rgba(245, 158, 11, 0.32) 0%,
        rgba(245, 158, 11, 0.32) 0.5rem,
        transparent 0.5rem
    );
    background-repeat: no-repeat;
    background-position: 0 88%;
    background-size: 100% 0.9em;
    padding: 0 0.1em;
}

/* Faint warm notebook grid — HERO-ONLY ambient texture.
   Apply to a hero section/container; sits behind content via ::before. */
.bg-notebook {
    position: relative;
    isolation: isolate;
}
.bg-notebook::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(var(--border-subtle) 0.0625rem, transparent 0.0625rem),
        linear-gradient(90deg, var(--border-subtle) 0.0625rem, transparent 0.0625rem);
    background-size: 1.75rem 1.75rem;
    opacity: 0.7;
    -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 35%, #000 40%, transparent 100%);
            mask-image: radial-gradient(ellipse 75% 60% at 50% 35%, #000 40%, transparent 100%);
}

/* Hero-only gradient text. Solid --accent-primary-text fallback color first,
   so non-supporting / clipped contexts still render legible ink-amber. */
.text-gradient {
    color: var(--accent-primary-text);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Header-embed (SHARED_DASHBOARD) Warm Scholar theme override ──────────────
   /SHARED_DASHBOARD/css/header-embed.css loads AFTER site CSS and ships a
   blue→purple brand tile + guest CTA. Re-skin its guest "Start Free" button,
   its mobile variant, and the brand icon tile to the site's amber primary so
   non-index pages match the index header. !important is required because
   header-embed.css loads later (it uses only normal declarations). */
.he-guest-start,
.he-mobile-start-link {
  background: var(--gradient-primary) !important;
  color: #1f2430 !important;
}
.he-guest-start:hover,
.he-mobile-start-link:hover {
  background: var(--gradient-primary) !important;
  filter: brightness(0.97);
}
.he-brand-icon {
  background: var(--gradient-primary) !important;
  color: #1f2430 !important;
}
