/* ==========================================================================
   KeelStone Academy: design tokens + base styles (player)
   Owner: Zara (UI) · Sprint 2 · Nov 19, 2026
   Source: departments/education/team/sprint-1/ui/keelstone-brand/keelstone_tokens.md
           departments/education/team/sprint-0/ui/EDUCATION_DESIGN_SYSTEM.md
   Contrast: every text/background pair below is measured in
           departments/education/team/sprint-2/ui/CONTRAST_RESULTS.md
           (run: python3 departments/education/team/sprint-2/ui/contrast_check.py)
   Internal: "KeelStone" name pending trademark clearance. Logo direction not
   chosen: the wordmark is plain text (.ks-wordmark). No external fonts/CDNs.
   Load order: keelstone.css, then components.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Self-hosted fonts: PREPARED, OFF. Waiting on Mark's yes (PLAYER_COMPONENTS §14 Q4).
      To turn on (one step):
        a) put the files below in player/styles/fonts/ together with each
           family's OFL.txt (SIL Open Font License 1.1: free to use, embed and
           redistribute; the license text must travel with the font files;
           the fonts may not be sold on their own; modified versions may not use
           the Reserved Font Names "Charis" / "Charis SIL"),
        b) delete the two comment markers around the block.
      Sources (download once, by hand; nothing is fetched at runtime):
        Charis SIL 6.x  software.sil.org/charis  (v6 ships the family as "Charis";
                        we alias it to the "Charis SIL" name our stacks use)
        Instrument Sans github.com/Instrument/instrument-sans (variable, wdth+wght)
      Check the file names against the download before switching on.
      No CDN, no Google Fonts link. Fallback stacks keep working if a file is missing.
   -------------------------------------------------------------------------- */
/* FONTS-OFF-START
@font-face {
  font-family: "Charis SIL";
  src: url("fonts/Charis-Regular.woff2") format("woff2"), url("fonts/Charis-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Charis SIL";
  src: url("fonts/Charis-Bold.woff2") format("woff2"), url("fonts/Charis-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Charis SIL";
  src: url("fonts/Charis-Italic.woff2") format("woff2"), url("fonts/Charis-Italic.ttf") format("truetype");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/InstrumentSans-VariableFont_wdth,wght.woff2") format("woff2"),
       url("fonts/InstrumentSans-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 400 700; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}
FONTS-OFF-END */

/* --------------------------------------------------------------------------
   1. Tokens: light (default). [data-theme="light"] lets any element force it.
   -------------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  /* Brand palette (keelstone_tokens.md §1). Raw values: do not use for text
     unless the semantic token below says it is measured. */
  --ks-navy: #12324A;
  --ks-teal: #2F6F73;
  --ks-sea: #DCE9EA;
  --ks-stone: #EFE8DC;
  --ks-copper: #C9733C;        /* graphic only, NEVER text */
  --ks-copper-text: #9A4E2E;
  --ks-teal-light: #9CC6C7;
  --ks-copper-light: #E09A68;  /* graphic only on dark */
  --ks-muted: #4F6170;
  --ks-muted-on-dark: #C9D6DE;

  /* Semantic surfaces + text */
  --ks-color-bg: #FAF8F5;            /* page */
  --ks-color-surface: #FFFFFF;       /* cards, checks, tables */
  --ks-color-surface-alt: #EFE8DC;   /* stone: aside, zebra rows */
  --ks-color-tint: #DCE9EA;          /* sea: callouts, table header, selected */
  --ks-color-text: #12324A;          /* body + headings */
  --ks-color-heading: #12324A;
  --ks-color-muted: #4F6170;         /* meta, captions. Never clinical text */
  --ks-color-link: #2F6F73;
  --ks-color-link-hover: #12324A;
  --ks-color-line: #D9D4CC;          /* decorative dividers only */
  --ks-color-border: #6B7A86;        /* control borders (>=3:1 on surfaces) */
  --ks-color-accent: #C9733C;        /* copper rules/marks, decorative only */

  /* Wordmark (plain text placeholder) */
  --ks-color-word-keel: #12324A;
  --ks-color-word-stone: #2F6F73;
  --ks-color-word-sub: #2F6F73;

  /* Actions */
  --ks-color-primary: #2F6F73;
  --ks-color-on-primary: #FFFFFF;
  --ks-color-primary-hover: #12324A;
  --ks-color-on-primary-hover: #FFFFFF;
  --ks-color-secondary-fg: #2F6F73;
  --ks-color-secondary-bg: #FFFFFF;

  /* Progress */
  --ks-color-progress-track: #DCE9EA;
  --ks-color-progress-fill: #2F6F73;

  /* Check feedback (not the safety zone tokens: separate names on purpose) */
  --ks-color-selected-bg: #DCE9EA;
  --ks-color-selected-border: #2F6F73;
  --ks-color-correct-bg: #E6F4EA;
  --ks-color-correct-fg: #1E6B34;
  --ks-color-incorrect-bg: #FDE7E4;
  --ks-color-incorrect-fg: #A61B12;

  /* Status chips (agency report) */
  --ks-color-done-bg: #E6F4EA;
  --ks-color-done-fg: #1E6B34;
  --ks-color-ontrack-bg: #DCE9EA;
  --ks-color-ontrack-fg: #12324A;
  --ks-color-behind-bg: #FFF4CC;
  --ks-color-behind-fg: #7A5A00;
  --ks-color-notstarted-bg: #EFE8DC;
  --ks-color-notstarted-fg: #4F6170;
  /* Admin side (Wave B): attestation + requirement status */
  --ks-color-awaiting-bg: #F1EAF7;   /* Completed, awaiting attestation */
  --ks-color-awaiting-fg: #5B2A86;
  --ks-color-duesoon-bg: #E6EEF9;    /* Due within 30 days */
  --ks-color-duesoon-fg: #1D4E89;
  --ks-color-pastdue-bg: #FDE7E4;    /* Past due date */
  --ks-color-pastdue-fg: #A61B12;

  /* Hours badge */
  --ks-color-hours-bg: #DCE9EA;
  --ks-color-hours-fg: #12324A;

  /* Pending RN review: identical in light, dark and print on purpose */
  --ks-color-pending-bg: #FFD24D;
  --ks-color-pending-fg: #1F1600;
  --ks-color-pending-stripe: #1F1600;

  /* Focus */
  --ks-color-focus: #1A56DB;

  /* Type (keelstone_tokens.md §3; free OFL fonts, system fallbacks.
     @font-face is prepared but commented out in section 0, pending Mark.) */
  --ks-font-head: "Charis SIL", Charter, "Bitstream Charter", Georgia, "Times New Roman", serif;
  --ks-font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --ks-font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --ks-fs-meta: 0.875rem;  /* 14px: chips, stamps. Never clinical/safety text */
  --ks-fs-sm: 1rem;        /* 16px: UI, tables, captions */
  --ks-fs-base: 1.125rem;  /* 18px: lesson body (default) */
  --ks-fs-md: 1.25rem;     /* 20px: banners, check question */
  --ks-fs-lg: 1.5rem;      /* 24px: card titles */
  --ks-fs-xl: 1.875rem;    /* 30px: section headings */
  --ks-fs-2xl: 2.375rem;   /* 38px: lesson title */

  --ks-lh-body: 1.55;
  --ks-lh-head: 1.2;
  --ks-measure: 68ch;
  --ks-fw-regular: 400;
  --ks-fw-semibold: 600;
  --ks-fw-bold: 700;

  /* Spacing (4px base) */
  --ks-space-1: 0.25rem;  /* 4  */
  --ks-space-2: 0.5rem;   /* 8  */
  --ks-space-3: 0.75rem;  /* 12 */
  --ks-space-4: 1rem;     /* 16 */
  --ks-space-5: 1.5rem;   /* 24 */
  --ks-space-6: 2rem;     /* 32 */
  --ks-space-7: 3rem;     /* 48 */
  --ks-space-8: 4rem;     /* 64 */

  /* Shape */
  --ks-radius-control: 6px;
  --ks-radius-card: 10px;
  --ks-radius-panel: 14px;
  --ks-radius-pill: 999px;
  --ks-border-width: 1px;
  --ks-border-width-strong: 2px;

  /* Shadow (subtle; never the only separator: cards also have a border) */
  --ks-shadow-1: 0 1px 2px rgba(18, 50, 74, 0.08);
  --ks-shadow-2: 0 2px 8px rgba(18, 50, 74, 0.12);
  --ks-shadow-focus: 0 0 0 3px var(--ks-color-focus);

  /* Targets + motion */
  --ks-target-min: 48px;
  --ks-transition: 120ms ease-out;

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. Tokens: dark. Reverse set (stone/teal-light on navy). Copper stays
      graphic-only. Pending banner does NOT change.
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --ks-color-bg: #0B1F2E;
  --ks-color-surface: #12324A;
  --ks-color-surface-alt: #163B56;
  --ks-color-tint: #1F4A66;
  --ks-color-text: #EFE8DC;
  --ks-color-heading: #EFE8DC;
  --ks-color-muted: #C9D6DE;
  --ks-color-link: #9CC6C7;
  --ks-color-link-hover: #EFE8DC;
  --ks-color-line: #2E5370;
  --ks-color-border: #7E95A8;
  --ks-color-accent: #E09A68;

  --ks-color-word-keel: #EFE8DC;
  --ks-color-word-stone: #9CC6C7;
  --ks-color-word-sub: #9CC6C7;

  --ks-color-primary: #9CC6C7;
  --ks-color-on-primary: #0B1F2E;
  --ks-color-primary-hover: #EFE8DC;
  --ks-color-on-primary-hover: #0B1F2E;
  --ks-color-secondary-fg: #9CC6C7;
  --ks-color-secondary-bg: #12324A;

  --ks-color-progress-track: #1F4A66;
  --ks-color-progress-fill: #9CC6C7;

  --ks-color-selected-bg: #1F4A66;
  --ks-color-selected-border: #9CC6C7;
  --ks-color-correct-bg: #143826;
  --ks-color-correct-fg: #A8E0B8;
  --ks-color-incorrect-bg: #4A1712;
  --ks-color-incorrect-fg: #FFB4AB;

  --ks-color-done-bg: #143826;
  --ks-color-done-fg: #A8E0B8;
  --ks-color-ontrack-bg: #1F4A66;
  --ks-color-ontrack-fg: #EFE8DC;
  --ks-color-behind-bg: #3D2E00;
  --ks-color-behind-fg: #FFD978;
  --ks-color-notstarted-bg: #163B56;
  --ks-color-notstarted-fg: #C9D6DE;
  --ks-color-awaiting-bg: #33204A;
  --ks-color-awaiting-fg: #E3CCF5;
  --ks-color-duesoon-bg: #15304F;
  --ks-color-duesoon-fg: #B9D3FF;
  --ks-color-pastdue-bg: #4A1712;
  --ks-color-pastdue-fg: #FFB4AB;

  --ks-color-hours-bg: #1F4A66;
  --ks-color-hours-fg: #EFE8DC;

  --ks-color-focus: #8AB4FF;

  --ks-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --ks-shadow-2: 0 2px 8px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* Theme selection (Wave B, Grace default pending Mark: LIGHT for the Dec 2 demo).
   - No data-theme on <html>  -> light, whatever the OS says.
   - <html data-theme="dark"> -> dark (block above).
   - <html data-theme="auto"> -> follow the OS (this block). Values mirror [data-theme="dark"].
   To make "follow the OS" the default again, change the selector below to
   :root:not([data-theme="light"])  (contrast_check.py accepts either). */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --ks-color-bg: #0B1F2E;
    --ks-color-surface: #12324A;
    --ks-color-surface-alt: #163B56;
    --ks-color-tint: #1F4A66;
    --ks-color-text: #EFE8DC;
    --ks-color-heading: #EFE8DC;
    --ks-color-muted: #C9D6DE;
    --ks-color-link: #9CC6C7;
    --ks-color-link-hover: #EFE8DC;
    --ks-color-line: #2E5370;
    --ks-color-border: #7E95A8;
    --ks-color-accent: #E09A68;
    --ks-color-word-keel: #EFE8DC;
    --ks-color-word-stone: #9CC6C7;
    --ks-color-word-sub: #9CC6C7;
    --ks-color-primary: #9CC6C7;
    --ks-color-on-primary: #0B1F2E;
    --ks-color-primary-hover: #EFE8DC;
    --ks-color-on-primary-hover: #0B1F2E;
    --ks-color-secondary-fg: #9CC6C7;
    --ks-color-secondary-bg: #12324A;
    --ks-color-progress-track: #1F4A66;
    --ks-color-progress-fill: #9CC6C7;
    --ks-color-selected-bg: #1F4A66;
    --ks-color-selected-border: #9CC6C7;
    --ks-color-correct-bg: #143826;
    --ks-color-correct-fg: #A8E0B8;
    --ks-color-incorrect-bg: #4A1712;
    --ks-color-incorrect-fg: #FFB4AB;
    --ks-color-done-bg: #143826;
    --ks-color-done-fg: #A8E0B8;
    --ks-color-ontrack-bg: #1F4A66;
    --ks-color-ontrack-fg: #EFE8DC;
    --ks-color-behind-bg: #3D2E00;
    --ks-color-behind-fg: #FFD978;
    --ks-color-notstarted-bg: #163B56;
    --ks-color-notstarted-fg: #C9D6DE;
    --ks-color-awaiting-bg: #33204A;
    --ks-color-awaiting-fg: #E3CCF5;
    --ks-color-duesoon-bg: #15304F;
    --ks-color-duesoon-fg: #B9D3FF;
    --ks-color-pastdue-bg: #4A1712;
    --ks-color-pastdue-fg: #FFB4AB;
    --ks-color-hours-bg: #1F4A66;
    --ks-color-hours-fg: #EFE8DC;
    --ks-color-focus: #8AB4FF;
    --ks-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ks-shadow-2: 0 2px 8px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* Large-print toggle (design system §2.3): root x1.25 */
:root[data-size="large"] { font-size: 125%; }

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body,
[data-theme] {
  color: var(--ks-color-text);
  background-color: var(--ks-color-bg);
}

body {
  margin: 0;
  font-family: var(--ks-font-body);
  font-size: var(--ks-fs-sm);
  line-height: var(--ks-lh-body);
  font-weight: var(--ks-fw-regular);
}

h1, h2, h3, h4 {
  font-family: var(--ks-font-head);
  font-weight: var(--ks-fw-bold);
  line-height: var(--ks-lh-head);
  color: var(--ks-color-heading);
  margin: 0 0 var(--ks-space-3);
}
h1 { font-size: var(--ks-fs-2xl); }
h2 { font-size: var(--ks-fs-xl); margin-top: var(--ks-space-6); }
h3 { font-size: var(--ks-fs-lg); margin-top: var(--ks-space-5); }
h4 { font-size: var(--ks-fs-md); font-family: var(--ks-font-body); font-weight: var(--ks-fw-semibold); }

p, ul, ol, dl, table, figure { margin: 0 0 var(--ks-space-4); }

a { color: var(--ks-color-link); text-decoration: underline; text-underline-offset: 0.15em; }
a:hover { color: var(--ks-color-link-hover); text-decoration-thickness: 2px; }

img, svg, video { max-width: 100%; height: auto; }

small, .ks-meta { font-size: var(--ks-fs-meta); color: var(--ks-color-muted); }

hr { border: 0; border-top: var(--ks-border-width) solid var(--ks-color-line); margin: var(--ks-space-5) 0; }

/* Focus ring: 3px, 2px offset, on every focusable thing */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--ks-color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Browsers without :focus-visible keep a visible ring */
@supports not selector(:focus-visible) {
  :focus { outline: 3px solid var(--ks-color-focus); outline-offset: 2px; }
}

/* Utilities */
.ks-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ks-skip-link {
  position: absolute; left: var(--ks-space-4); top: -100px; z-index: 100;
  padding: var(--ks-space-3) var(--ks-space-4);
  background: var(--ks-color-surface); color: var(--ks-color-link);
  border: var(--ks-border-width-strong) solid var(--ks-color-focus);
  border-radius: var(--ks-radius-control);
}
.ks-skip-link:focus { top: var(--ks-space-4); }

/* Wordmark: plain text placeholder until a logo direction is chosen.
   Always "KeelStone" with capital S. Copper never used for text. */
.ks-wordmark {
  display: inline-flex; flex-direction: column; gap: 2px;
  text-decoration: none; line-height: 1; color: var(--ks-color-word-keel);
}
.ks-wordmark__name {
  font-family: var(--ks-font-head); font-weight: var(--ks-fw-bold);
  font-size: var(--ks-fs-lg); letter-spacing: 0.01em;
}
.ks-wordmark__keel { color: var(--ks-color-word-keel); }
.ks-wordmark__stone { color: var(--ks-color-word-stone); }
.ks-wordmark__academy {
  font-family: var(--ks-font-body); font-weight: var(--ks-fw-semibold);
  font-size: 0.75rem; letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--ks-color-word-sub);
}
a.ks-wordmark:hover { text-decoration: none; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------------------
   4. Print: light tokens, black ink, no chrome. Meaning survives grayscale
      because chips/feedback carry words + icons + borders.
   -------------------------------------------------------------------------- */
@media print {
  /* Doubled selectors out-rank the dark-mode blocks above */
  :root:root:root, [data-theme][data-theme] {
    --ks-color-bg: #FFFFFF;
    --ks-color-surface: #FFFFFF;
    --ks-color-surface-alt: #FFFFFF;
    --ks-color-tint: #FFFFFF;
    --ks-color-text: #000000;
    --ks-color-heading: #000000;
    --ks-color-muted: #333333;
    --ks-color-link: #000000;
    --ks-color-line: #777777;
    --ks-color-border: #000000;
    --ks-color-word-keel: #000000;
    --ks-color-word-stone: #000000;
    --ks-color-word-sub: #000000;
    --ks-shadow-1: none;
    --ks-shadow-2: none;
    color-scheme: light;
  }
  @page { size: letter; margin: 0.5in; }
  html { font-size: 12pt; }
  body { background: #FFFFFF; color: #000000; font-family: Georgia, "Times New Roman", serif; }
  h1, h2, h3, h4 { font-family: Arial, Helvetica, sans-serif; break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  a { text-decoration: underline; }
  .ks-no-print, .ks-skip-link, nav, button, .ks-btn { display: none !important; }
  /* Show link targets for printed lesson text */
  .ks-prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
