/* ==========================================================================
   HamLearno — design tokens
   ==========================================================================

   The single source of truth for every value the UI is built from.
   Generated from docs/design.md Parts 1, 2 and 3 (contract completed
   2026-09-12). Every literal below traces to a row in that document.

   THE ONE RULE: token NAMES are locked. They carry 414 usages across 22
   templates, so renaming one is a 414-site refactor. Change a VALUE here
   and the whole app moves together; that is the entire point of this file.
   New names are added only by amending docs/design.md first.

   This file replaced the content-only partial
   backend/templates/shared/_colearn_tokens.html, which was injected inside
   a hand-written `:root {` in each of the three shells. That partial was
   deleted on 2026-09-12 once all three linked this stylesheet instead, so
   there is now exactly one place a token is defined. Do not reintroduce a
   `:root {}` block in a template.

   Load order: this file FIRST, then the component stylesheet. Nothing here
   depends on anything else.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ------------------------------------------------------------------
     Color — core                                      design.md §1.1
     ------------------------------------------------------------------ */
  --color-primary: #15803D;      /* primary buttons, active nav, focus ring */
  --color-primary-ink: #FFFFFF;  /* text ON primary — verified ≥4.5:1        */
  --color-secondary: #16A34A;
  --color-accent: #0284C7;

  --color-bg: #F4FBF6;           /* page ground                              */
  --color-card: #FFFFFF;         /* raised surface                           */

  --color-fg: #14532D;           /* body text                                */
  --color-fg-strong: #0A3319;    /* headings, numbers                        */

  --color-muted: #E8F5ED;        /* subtle fill / hover ground               */
  --color-muted-fg: #466352;     /* secondary text — verified ≥4.5:1 on card */

  --color-border: #D1E7D8;
  --color-hairline: #E5F2E9;     /* softer than border, for large seams.
                                    Pinned to a literal — it was previously
                                    derived via color-mix() from
                                    --color-border. */

  /* ------------------------------------------------------------------
     Color — semantic status                           design.md §1.2
     ------------------------------------------------------------------ */
  --color-destructive: #DC2626;
  --color-destructive-bg: #FEF2F2;

  --status-good: #15803D;        /* risk band LOW                            */
  --status-warning: #B45309;     /* risk band MEDIUM                         */
  --status-critical: #B91C1C;    /* risk band HIGH                           */

  /* ------------------------------------------------------------------
     Color — subject accents                           design.md §1.3
     ------------------------------------------------------------------
     One per broad subject (apps.academics.models.Subject) - ten, then
     nine more with the course catalog on 2026-09-16 - plus CUSTOM for a
     student's own course, which has none. The same subject must read as
     the same color on the planning boards, the dashboard, the profile and
     the course picker, which is the only reason these are global tokens
     rather than page-local values. The course picker's letter squares
     darken each by 15% (color-mix with black) so their white initials
     clear 4.5:1 for every one - PHYSICS and BIOLOGY fall short without it.
     ------------------------------------------------------------------ */
  --subject-MATH: #15803D;
  --subject-PHYSICS: #0284C7;
  --subject-CHEMISTRY: #C2410C;
  --subject-BIOLOGY: #0D9488;
  --subject-LITERATURE: #BE185D;
  --subject-ARABIC: #6D28D9;
  --subject-RELIGIOUS: #78716C;
  --subject-ENGLISH: #0E7490;
  --subject-GEOLOGY: #92400E;
  --subject-GENERAL: #475569;
  --subject-ECONOMICS: #A16207;
  --subject-SOCIOLOGY: #A21CAF;
  --subject-HISTORY: #7F1D1D;
  --subject-GEOGRAPHY: #4D7C0F;
  --subject-LOGIC_PHILOSOPHY: #4338CA;
  --subject-PSYCHOLOGY: #1D4ED8;
  --subject-ISLAMIC: #065F46;
  --subject-TECHNICAL: #3F3F46;
  --subject-ART: #E11D48;
  --subject-CUSTOM: #71717A;

  /* ------------------------------------------------------------------
     Radius                                            design.md §1.4
     ------------------------------------------------------------------ */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* ------------------------------------------------------------------
     Elevation                                         design.md §1.4
     ------------------------------------------------------------------
     Tinted with the deep-green ink (10, 51, 25) rather than neutral grey,
     so a raised surface reads as lifted paper instead of a grey blur.
     ------------------------------------------------------------------ */
  --shadow-xs: 0 1px 2px rgba(10, 51, 25, 0.04);
  --shadow-sm: 0 2px 4px rgba(10, 51, 25, 0.05), 0 1px 2px rgba(10, 51, 25, 0.03);
  --shadow-md: 0 6px 14px -2px rgba(10, 51, 25, 0.07), 0 2px 4px -1px rgba(10, 51, 25, 0.03);
  --shadow-lg: 0 14px 28px -4px rgba(10, 51, 25, 0.09), 0 4px 8px -2px rgba(10, 51, 25, 0.04);
  --shadow-inset: inset 0 1px 2px rgba(10, 51, 25, 0.06);

  /* The app-wide focus ring. §5 law 8: never removed, only restyled, and
     there is exactly one of it — do not introduce a second ring value.

     RESOLVED 2026-09-12. design.md §1.4 originally specified 0.22 alpha
     while §4 wrote every component's focus-visible at 0.28 and §5 law 8
     named 0.28 as the app-wide ring. Same geometry, two alphas. Decided in
     favour of the law: 0.28 everywhere. §1.4 was amended to match, so the
     contract and this file now agree. */
  --shadow-primary: 0 0 0 3px rgba(21, 128, 61, 0.28);

  /* ------------------------------------------------------------------
     Motion                                            design.md §1.4
     ------------------------------------------------------------------
     One easing that settles, one that is slightly springy for toggles and
     things that appear. Every transition in the component library
     references these, so the whole app moves at one tempo.
     ------------------------------------------------------------------ */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  /* ------------------------------------------------------------------
     Typography — NEW                                    design.md §2
     ------------------------------------------------------------------
     Seven steps, four axes each. Before this existed the codebase carried
     28 distinct hardcoded font sizes across 331 declarations and no scale
     at all, which was the mechanical cause of the visual drift.

     Four properties per step rather than a `font:` shorthand: the shorthand
     cannot carry letter-spacing, and it makes overriding a single axis
     impossible. Suffixes are -size / -weight / -lh / -ls throughout.

     PERSIAN CONSTRAINT: Vazirmatn runs a large x-height and its diacritics
     need vertical room, so every step at body size and below holds
     line-height >= 1.5. Dropping below that makes Persian text collide with
     the row beneath it. Verify changes on real Persian text, never on
     Lorem Ipsum.
     ------------------------------------------------------------------ */

  /* KPI numbers, podium hours */
  --text-display-size: 32px;
  --text-display-weight: 800;
  --text-display-lh: 1.25;
  --text-display-ls: -0.02em;

  /* page title in .topbar */
  --text-h1-size: 24px;
  --text-h1-weight: 800;
  --text-h1-lh: 1.35;
  --text-h1-ls: -0.01em;

  /* panel / card title */
  --text-h2-size: 18px;
  --text-h2-weight: 700;
  --text-h2-lh: 1.45;
  --text-h2-ls: 0;

  /* default paragraph, inputs — the floor is 15px, students read on phones */
  --text-body-size: 15px;
  --text-body-weight: 400;
  --text-body-lh: 1.6;
  --text-body-ls: 0;

  /* table cells, list rows, nav */
  --text-sm-size: 13.5px;
  --text-sm-weight: 500;
  --text-sm-lh: 1.55;
  --text-sm-ls: 0;

  /* meta, timestamps, captions */
  --text-xs-size: 12px;
  --text-xs-weight: 500;
  --text-xs-lh: 1.5;
  --text-xs-ls: 0;

  /* badges, chips, pills ONLY — never body copy */
  --text-micro-size: 11px;
  --text-micro-weight: 700;
  --text-micro-lh: 1.5;
  --text-micro-ls: 0.01em;

  /* ------------------------------------------------------------------
     Font                                              design.md §1.4
     ------------------------------------------------------------------ */
  --font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* ------------------------------------------------------------------
     Spacing — 4px-based scale                         design.md §1.4
     ------------------------------------------------------------------ */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  /* ------------------------------------------------------------------
     Layout                                            design.md §1.4
     ------------------------------------------------------------------ */
  --rail-w: 264px;
}

/* ==========================================================================
   Bento v2 — the student workspace                          design.md §1.5
   ==========================================================================

   student/_base.html puts data-ui="bento" on <body>; nothing else does. The
   values below therefore apply to every student page and to nothing in the
   advisor workspace or the pre-authentication pages, which keep :root.

   Custom properties are inherited, so redefining them on <body> reaches
   every descendant, native <dialog> elements included. <body>'s own
   background reads --color-bg from this same block.

   Locked names first (new values), then the names that exist only in this
   scope. Every literal traces to design.md §1.5, which records where in the
   Stitch export (docs/design-refs/bento-dashboard/) it came from.
   ========================================================================== */

[data-ui="bento"] {
  /* -- locked names, bento values ------------------------------------- */
  --color-primary: #137A4B;      /* white text on it: 5.37:1                 */
  --shadow-primary: 0 0 0 3px rgba(19, 122, 75, 0.28);

  /* The export's rendered ground (code.html's <html>/<body> background-color),
     not DESIGN.md's lighter #F2F7F4: the 0.18 grid lines read faint on that
     one (2026-09-15, fidelity pass 3). */
  --color-bg: #E3EFE7;
  --color-muted: #ECFDF5;

  --color-fg-strong: #0F172A;
  --color-fg: #131B2E;
  --color-muted-fg: #3F4941;     /* 9.37:1 on white, 8.65:1 on the canvas    */

  --radius-xs: 8px;
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 32px;

  /* design.md §2: three sizes follow the export; line-heights do not. */
  --text-display-size: 36px;
  --text-h1-size: 26px;
  --text-h1-weight: 700;
  --text-sm-size: 14px;

  /* -- names that exist only in this scope ---------------------------- */
  --color-lime: #ACF847;
  --color-lime-ink: #102000;     /* 13.24:1 on lime                          */
  --color-mint: #34D399;
  --color-card-tint: #F0FDF4;
  --color-streak-from: #FB923C;
  --color-streak-to: #EA580C;
  --color-peste: #EAB308;

  --bg-grid-line: rgba(19, 122, 75, 0.18);

  /* Corrected 2026-09-15 (polish pass, design.md section 6): these two
     carried the DUAL-inset formula DESIGN.md's prose describes, but every
     card in the actual Stitch export (docs/design-refs/bento-dashboard/
     code.html) renders a plainer two-layer shadow - one inset highlight,
     one drop shadow, no bottom inset, no second dark drop layer. Pulled
     from the rendered markup (`shadow-[...]` on .card/.panel and on the
     hero/league gradient tiles), not the prose, so cards "pop" the way the
     reference actually does rather than the way it says it does. */
  --shadow-clay: inset 0 2px 4px 0 rgba(255, 255, 255, 0.9), 0 12px 28px -6px rgba(19, 122, 75, 0.08);
  --shadow-clay-hero: inset 0 3px 5px 0 rgba(255, 255, 255, 0.25), 0 18px 36px -8px rgba(19, 122, 75, 0.35);
  /* Three-stop, matching the export's from/via/to exactly (was a flatter
     two-stop guess). */
  --gradient-hero: linear-gradient(135deg, #137A4B, #0E633D, #084529);
  --shadow-push: 0 4px 0 0 rgba(0, 0, 0, 0.08);
  --shadow-push-pressed: 0 2px 0 0 rgba(0, 0, 0, 0.08);

  --space-7: 1.75rem;

  /* -- the dark nav shell (polish pass, 2026-09-15): the floating desktop
     sidebar, its off-canvas mobile-drawer form, and the mobile bottom
     capsule nav all share this one dark-green surface, so a control looks
     identical wherever it appears. Values are the export's own literals
     (`#claySidebar`, `#mobile-menu-drawer`, the bottom `<nav>`). */
  --color-nav-bg: #072C1A;
  --color-nav-text: rgba(209, 250, 229, 0.75);   /* emerald-100/75         */
  --color-nav-text-hover: #FFFFFF;
  --gradient-nav-active: linear-gradient(90deg, #137A4B, #005F38);
  --gradient-mascot: linear-gradient(155deg, #137A4B, #0B482B);
  --shadow-nav: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 16px 36px -6px rgba(3, 25, 14, 0.55), 0 0 0 1px rgba(153, 246, 188, 0.12);
  --shadow-nav-drawer: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.2);
  --shadow-nav-bottom: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 12px 32px rgba(3, 25, 14, 0.5), 0 0 0 1px rgba(153, 246, 188, 0.15);
  --shadow-nav-active: inset 0 1px 2px rgba(255, 255, 255, 0.25), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-mascot: inset 0 2px 3px rgba(255, 255, 255, 0.35), 0 4px 10px rgba(0, 0, 0, 0.3);
  --rail-w-collapsed: 76px;
  --rail-w-expanded: 240px;
}

/* The export's mobile type sizes, at the 640px content tier. */
@media (max-width: 640px) {
  [data-ui="bento"] {
    --text-display-size: 28px;
    --text-h1-size: 22px;
  }
}

/* ==========================================================================
   Breakpoints — documentation only, deliberately NOT tokens
   ==========================================================================

   These cannot be custom properties. `@media (max-width: var(--bp-mobile))`
   is invalid CSS — the media-query prelude is evaluated before custom
   properties are substituted, so the spec does not allow it. Every media
   query therefore repeats the literal, and this block is the canonical
   record of what those literals mean.

   Corrected 2026-09-14: this block described a three-tier draft (767 /
   1023 / a tablet rail rendered icons-only) that design.md §3 replaced with
   two tiers on 2026-09-12, because no icons-only rail exists. The two
   values answer different questions and are not to be merged:

     1023px    the SHELL tier: at or below it the rail becomes the
               .mobile-nav-bar drawer and shell-level grids fold
     640px     the CONTENT tier: a card grid that has run out of room for a
               second column reflows to one

   Student surfaces are mobile-first (the PWA audience); advisor surfaces are
   desktop-first. Where the two conflict, mobile-first wins for shared
   components and advisor views stay locked to the desktop layout.
   ========================================================================== */

/* ==========================================================================
   Reduced motion                                            design.md §5.10
   ==========================================================================
   Law 10 requires one app-wide block rather than a per-component opt-out.
   Zeroing the duration tokens is the cheapest correct place to honour it:
   every transition in the component library already reads these three
   values, so this single block disarms all of them at once.

   Transforms are NOT handled here — they are not token-driven, so the
   `translateY` nudges specified in §4 are suppressed in the component
   stylesheet, under this same media query.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
}
