/* Theme: Notebook
   A sheet of ruled paper: blue rules, a red margin line and a faint paper grain.
   Headings, reading text and the interface in a book serif (Newsreader); chapter labels
   and the numbers in cards and steps in handwriting (Kalam); addresses in IBM Plex Mono.
   Trust is blue ballpoint; slop is the teacher's red pen. Dark mode is a dark notebook
   page with faint rules.
   Design tokens only. Every value here is documented in DESIGN.md, and
   test/design.test.js keeps the two in sync. Components live in styles.css
   and must use these variables rather than raw values. */

/* Web fonts, served from fonts/ next to this file (self-hosted: no third-party request
   delays the first paint). Latin and Latin Extended only, so other scripts use the system
   fallback. The server preloads the font file marked "preload" (server/pages.js). */
/* Newsreader's stand-in until the font arrives: Times New Roman scaled and re-spaced to
   Newsreader's measurements, so the text barely moves when the real font loads in (a layout
   shift otherwise). Where none of these fonts exist, the stack goes on to Georgia. */
@font-face {
  font-family: "Newsreader Fallback";
  src: local("Times New Roman"), local("Liberation Serif"), local("Tinos");
  size-adjust: 100.7%;
  ascent-override: 73%;
  descent-override: 26.3%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/kalam-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/kalam-400-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/kalam-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/kalam-700-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/newsreader-italic-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/newsreader-italic-var-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/newsreader-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* preload */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/newsreader-var-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  /* Color */
  --color-bg: #fdfcf6;
  --color-surface: #ffffff;
  --color-text: #22283a;
  --color-muted: #5b6275;
  --color-border: #d9d6c8;
  --color-trust: #1f4fbf;
  --color-on-trust: #ffffff;
  --color-trust-soft: #e3ebfb;
  --color-credible: #1e7a3c;
  --color-credible-soft: #e2f3e6;
  --color-on-credible: #ffffff;
  --color-slop: #c0262d;
  --color-slop-soft: #fde4e1;
  --color-on-slop: #ffffff;
  --color-highlight: #fff176;
  --color-topbar: rgba(251, 250, 244, 0.92);
  --color-rule: #a9c6ea;
  --color-margin: #e57373;

  /* Typography */
  --font-display: Newsreader, "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-title: Newsreader, "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-reading: Newsreader, "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-ui: Newsreader, "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-hand: Kalam, "Segoe Print", "Comic Sans MS", cursive;

  --text-2xs: 0.78rem;
  --text-xs: 0.85rem;
  --text-sm: 0.92rem;
  --text-md: 1rem;
  --text-base: 17px;
  --text-lg: 1.18rem;
  --text-xl: 1.6rem;
  --text-h2: clamp(1.6rem, 4.5vw, 2.1rem);
  --text-display: clamp(2.2rem, 6vw, 3rem);

  --weight-medium: 400;
  --weight-semibold: 700;
  --weight-bold: 700;

  --leading-tight: 1.15;
  --leading-body: 1.65;
  --leading-reading: 1.75;

  --tracking-display: -0.01em;
  --tracking-badge: 0.06em;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Shape */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* Borders and decoration */
  --border-width: 1px;
  --accent-bar-width: 0px;
  --card-edge-width: 4px;
  --card-shadow: 0 1px 2px rgba(34, 40, 58, 0.06), 0 2px 8px rgba(34, 40, 58, 0.05);
  --sign-border-style: dashed;
  --focus-ring-width: 2px;
  --topbar-blur: 4px;
  --chapter-rule-opacity: 0.5;
  --marker-stroke-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 10' preserveAspectRatio='none'%3E%3Cpath d='M4 6.2C32 5 70 6.4 116 4.8' fill='none' stroke='%23000' stroke-width='5.5' stroke-linecap='round'/%3E%3C/svg%3E");
  --marker-stroke-height: 0.2em;
  --nav-bar-height: 3px;
  --count-opacity: 0.7;
  --highlight-start: 45%;
  --emphasis-style: italic;
  --rule-gap: 30px;
  --margin-line-width: 2px;
  --paper-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.3 0.1 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --margin-gap: 34px;

  /* Layout */
  --content-width: 920px;
  --list-min-height: 24rem;
  --topbar-width: 1280px;
  --reading-width: 36em;
  --intro-width: 40em;
  --gutter: 16px;
  --step-marker-size: 36px;
  --logo-size: 40px;
  --logo-image: url("/images/logo.svg");
  --icon-size: 18px;
  --search-width: 320px;
  --search-min-width: 220px;
  --control-padding-block: 6px;
  --control-arrow-space: 28px;

  /* Topic map (Directory, Map view) */
  --map-height: 520px;
  --map-node-width: 11.5em;
  --map-column-gap: 48px;
  --map-row-gap: 12px;
  --map-indent: 20px;
  --map-panel-width: 18rem;
  --map-port-size: 7px;
  --map-link-width: 1.5px;
  --map-control-size: 36px;

  /* Motion */
  --duration-state: 120ms;
}

/* Dark is the default (set on <html> in index.html); the switcher toggles data-theme.
   Only colors change between light and dark. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: #161b26;
  --color-surface: #1e2533;
  --color-text: #ece9df;
  --color-muted: #a3a9b8;
  --color-border: #323b4d;
  --color-trust: #8db4ff;
  --color-on-trust: #10141c;
  --color-trust-soft: #1c2a47;
  --color-credible: #6fd08c;
  --color-credible-soft: #173326;
  --color-on-credible: #10141c;
  --color-slop: #ff8a80;
  --color-slop-soft: #41201f;
  --color-on-slop: #10141c;
  --color-highlight: #5a4f12;
  --color-topbar: rgba(22, 27, 38, 0.92);
  --color-rule: #2b3750;
  --color-margin: #6a3038;
}
