/* ============================================================================
   Gloss Theme
   Interlinear code — as if translated line-by-line.

   Anchored in LokaScript's identity: grammar-aware, multilingual, role-conscious.
   Presents code the way a linguistics journal presents a multilingual text —
   warm vellum paper, deep ink type, doubled hairline rules, and a restrained
   manuscript-pigment palette where colour means semantic role, not decoration.

   - Signature motif: interlinear gloss. Code blocks with data-gloss="..."
     render a muted target-language line beneath the source, separated by a
     dotted hairline — the Leipzig glossing convention in CSS.
   - Five manuscript pigments map 1:1 to LokaScript semantic roles:
       action      → madder red    (rubric, the verb)
       patient     → lapis blue    (object of action)
       destination → verdigris     (where things go)
       source      → ochre         (where things come from)
       event       → mulberry      (the triggering moment)
     These pigments are the *only* chroma in the theme — no decorative colour.
   ============================================================================ */

/* Contrast Audit (WCAG 2.1)
   Light mode (vellum):
     --color-fg (#1F2330) on --color-bg (#F5F1E8): ~14:1 → AAA ✓
     --color-muted (#5B6273) on --color-bg (#F5F1E8): ~5.5:1 → AA ✓
     --color-accent (#2F4A7C) on --color-bg (#F5F1E8): ~7.1:1 → AAA ✓
     --role-action (#A13A2C) on --color-bg (#F5F1E8): ~5.9:1 → AA ✓
     --role-patient (#2F4A7C) on --color-bg (#F5F1E8): ~7.1:1 → AAA ✓
   Dark mode (candlelit):
     --color-fg (#E8DCC8) on --color-bg (#161925): ~12:1 → AAA ✓
     --color-muted (#A59B85) on --color-bg (#161925): ~7:1 → AAA ✓
     --color-accent (#8FA8D4) on --color-bg (#161925): ~7.8:1 → AAA ✓
     Role pigments lifted 15–20 L* for dark-mode AAA.
   Verified: 2026-04-22 */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400;1,8..60,500&family=Instrument+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap");

/* color-scheme on :root only — the theme class is applied to both html and body,
   and a body-level color-scheme would break light-dark() inheritance from <html>. */
html.gloss-theme { color-scheme: light dark; }

/* ============================================
   Theme Activation
   ============================================ */

.gloss-theme {
  /* Vellum / ink palette */
  --color-bg:            light-dark(#F5F1E8, #161925);
  --color-fg:            light-dark(#1F2330, #E8DCC8);
  --color-muted:         light-dark(#5B6273, #A59B85);
  --color-faded:         light-dark(#8A8D98, #6F6A5A);
  --color-surface:       light-dark(#FBF8F1, #1F2332);
  --color-surface-hover: light-dark(#F0EBDE, #272B3C);
  --color-border:        light-dark(#D4CBB8, #2C3142);
  --color-rule:          light-dark(#C8BEA8, #353B4D);

  /* Accent = lapis (also the patient role — links = "the thing being pointed at") */
  --color-accent:        light-dark(#2F4A7C, #8FA8D4);
  --color-accent-hover:  light-dark(#1E3460, #B0C2E0);
  --color-accent-light:  light-dark(#E4EAF4, #252B3F);

  /* Semantic-role pigments — the signature colour language of the theme.
     Drawn from traditional manuscript inks (madder, lapis, verdigris, ochre,
     mulberry). Mapped 1:1 to LokaScript semantic roles. */
  --role-action:         light-dark(#A13A2C, #D67A6A);  /* madder — the verb */
  --role-patient:        light-dark(#2F4A7C, #8FA8D4);  /* lapis — object of action */
  --role-destination:    light-dark(#3F6B5C, #7FB09A);  /* verdigris — where */
  --role-source:         light-dark(#A8782A, #D6AE6A);  /* ochre — from where */
  --role-event:          light-dark(#6B3A5C, #B880A0);  /* mulberry — the moment */

  /* Code colours */
  --code-bg:             light-dark(#FBF8F1, #1F2332);
  --code-fg:             light-dark(#1F2330, #E8DCC8);
  --code-border:         light-dark(#D4CBB8, #2C3142);
  --code-gloss-fg:       light-dark(#7A7367, #897E6A);

  /* Typography
     Source Serif 4 — body + display (variable, optical-sized). Chosen for its
     Latin + Cyrillic + Greek + Vietnamese coverage — it can render LokaScript's
     24 languages side-by-side without falling back.
     Instrument Sans — chrome (nav, buttons, chips, badges). Editorial character
     without being another Inter clone.
     JetBrains Mono — code, wide Unicode, ligatures off. */
  --font-display: "Source Serif 4", "Source Serif Pro", "Noto Serif", Georgia, serif;
  --font-body:    "Source Serif 4", "Source Serif Pro", "Noto Serif", Georgia, serif;
  --font-ui:      "Instrument Sans", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    "JetBrains Mono", "IBM Plex Mono", "Source Code Pro", monospace;

  /* Editorial rhythm — wider than Clarity, ranged text */
  --text-base: 1.0625rem;
  --gloss-leading: 1.75;

  --density: 1;

  /* Component tokens */
  --nav-bg: var(--color-bg);
  --nav-border: var(--color-rule);
  --card-bg: var(--color-surface);
  --card-border: var(--color-border);
  --card-radius: 2px;
  --btn-bg: transparent;
  --btn-fg: var(--color-fg);
  --btn-radius: 2px;
  --input-bg: var(--color-surface);
  --input-border: var(--color-border);
  --input-focus-ring: var(--color-accent-light);

  /* Override missing.css font variables */
  --main-font: var(--font-body);
  --secondary-font: var(--font-ui);
  --heading-font: var(--font-display);
  --mono-font: var(--font-mono);

  /* Align navbar inner container with .container width */
  --nav-max: 64rem;

  /* Base */
  background-color: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--gloss-leading);
  font-optical-sizing: auto;
  font-feature-settings: "kern", "liga", "onum";
  transition: var(--theme-transition);
}

/* OKLCH progressive enhancement — warm, low-chroma tuning */
@supports (color: oklch(0% 0 0)) {
  .gloss-theme {
    --color-bg:      light-dark(oklch(95% 0.015 85),  oklch(18% 0.015 265));
    --color-fg:      light-dark(oklch(23% 0.02 260),  oklch(90% 0.015 85));
    --color-surface: light-dark(oklch(98% 0.012 85),  oklch(22% 0.015 265));
    --color-border:  light-dark(oklch(82% 0.02 85),   oklch(28% 0.015 265));
    --color-rule:    light-dark(oklch(78% 0.02 85),   oklch(32% 0.015 265));
    --color-accent:  light-dark(oklch(38% 0.08 260),  oklch(72% 0.08 260));
  }
}

/* ============================================
   Paper grain overlay (light mode only)
   Dark mode uses flat ink — grain reads as noise on dark.
   ============================================ */

html.gloss-theme body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  /* z-index: -1 puts the overlay behind content without touching any body
     child's z-index. Earlier `body > * { z-index: 1 }` clobbered navbar's
     sticky z-index: 1000 and broke mobile drawer clicks past the first item. */
  z-index: -1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}

html.-dark-mode.gloss-theme body::before,
html.gloss-theme.-dark-mode body::before {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  html.gloss-theme body::before { display: none; }
}

/* ============================================
   Layout
   ============================================ */

.gloss-theme .container {
  max-inline-size: 64rem;
  margin-inline: auto;
  padding-inline: var(--space-6, 1.5rem);
}

@media (max-width: 768px) {
  .gloss-theme .container {
    padding-inline: var(--space-4, 1rem);
  }
}

/* ============================================
   Typography
   ============================================ */

.gloss-theme h1,
.gloss-theme h2,
.gloss-theme h3,
.gloss-theme h4,
.gloss-theme h5,
.gloss-theme h6 {
  font-family: var(--font-display);
  color: var(--color-fg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.gloss-theme h1 {
  font-size: 2.75rem;
  font-weight: 700;
  margin-block: calc(var(--space-8, 2rem) * var(--density)) var(--space-5, 1.25rem);
  letter-spacing: -0.02em;
}

.gloss-theme h2 {
  font-size: 1.875rem;
  margin-block: var(--space-8, 2rem) var(--space-3, 0.75rem);
  /* Doubled hairline — scholarly chapter-break motif */
  padding-block-start: var(--space-4, 1rem);
  border-block-start: 1px solid var(--color-rule);
  box-shadow: 0 -3px 0 -2px var(--color-rule);
}

.gloss-theme h3 {
  font-size: 1.375rem;
  margin-block: var(--space-6, 1.5rem) var(--space-3, 0.75rem);
}

.gloss-theme h4 {
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.gloss-theme p {
  line-height: var(--gloss-leading);
  margin-block: var(--space-4, 1rem);
  max-inline-size: 68ch;
}

.gloss-theme em,
.gloss-theme i {
  font-style: italic;
  font-family: var(--font-display);
}

.gloss-theme strong,
.gloss-theme b {
  font-weight: 600;
}

/* Drop-cap for first paragraph of hero (opt-in via .lede class) */
.gloss-theme .lede::first-letter {
  font-family: var(--font-display);
  font-size: 3.5em;
  font-weight: 700;
  float: inline-start;
  line-height: 0.85;
  margin-inline-end: 0.08em;
  margin-block-start: 0.1em;
  color: var(--role-action);
}

/* ============================================
   Links — hairline underline in lapis
   ============================================ */

.gloss-theme a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-thickness 0.12s ease;
}

.gloss-theme a:hover {
  color: var(--color-accent-hover);
  text-decoration-thickness: 2px;
}

.gloss-theme a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  text-decoration: none;
  background: var(--color-accent-light);
}

/* ============================================
   Blockquotes — scholarly, left rule, italic
   ============================================ */

.gloss-theme blockquote {
  margin: var(--space-6, 1.5rem) 0;
  padding: var(--space-2, 0.5rem) var(--space-6, 1.5rem);
  border-inline-start: 1px solid var(--color-rule);
  font-style: italic;
  color: var(--color-muted);
  font-size: 1.05em;
}

.gloss-theme blockquote cite {
  display: block;
  margin-block-start: var(--space-3, 0.75rem);
  font-family: var(--font-ui);
  font-style: normal;
  font-size: 0.85em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: end;
  color: var(--color-faded);
}

/* ============================================
   Code — the heart of the theme
   ============================================ */

.gloss-theme pre,
.gloss-theme pre[class*="language-"] {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-border);
  border-radius: var(--card-radius);
  padding: var(--space-5, 1.25rem);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.65;
  position: relative;
  box-shadow: none;
}

.gloss-theme code,
.gloss-theme code[class*="language-"] {
  font-family: var(--font-mono);
  color: var(--code-fg);
}

/* Override prism-htmx.css's hardcoded #fdfdfd code background and its
   decorative striped gradient — both leak through in dark mode. */
.gloss-theme pre[class*="language-"] > code,
.gloss-theme pre[class*="language-"] > code[class*="language-"] {
  background: var(--code-bg);
  background-image: none;
  box-shadow: none;
}

.gloss-theme :not(pre) > code {
  background: var(--color-accent-light);
  padding: 0.15em 0.4em;
  border-radius: 2px;
  color: var(--color-fg);
  font-size: 0.9em;
  border: 1px solid transparent;
}

/* Language + grammar-type badge in the top-right corner.
   Authored via data-lang="JA · SOV" on the <pre> element.

   Overrides required: prism-htmx.css (upstream Prism Coy theme) sets
   pre[class*=language-]::before with left, width, height, transform, bottom
   for a decorative paper-stack shadow — all of which bleed into and warp
   this label. Explicit resets below pin it to top-right at content size. */
.gloss-theme pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: var(--space-2, 0.5rem);
  right: var(--space-3, 0.75rem);
  bottom: auto;
  left: auto;
  width: auto;
  height: auto;
  transform: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--color-faded);
  background: var(--code-bg);
  padding: 0.1em 0.5em;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  text-transform: uppercase;
}

/* Reserve vertical space at the top of the code block so the badge sits
   in its own band instead of overlapping the first line. */
.gloss-theme pre[data-lang],
.gloss-theme pre[data-lang][class*="language-"] {
  padding-top: calc(var(--space-5, 1.25rem) + 1rem);
}

/* Hide prism-htmx's decorative ::after paper-stack layer — it renders as
   a rotated navy slab below the code content on data-lang blocks. */
.gloss-theme pre[data-lang][class*="language-"]::after {
  display: none;
}

/* ============================================
   Interlinear gloss — signature motif
   ============================================

   Usage (authored, simplest form):

     <pre data-lang="JA · SOV">
       <span class="gloss-line">
         <span class="src">もし ボタン を クリック したら</span>
         <span class="gl">if  button PTCL click    when</span>
       </span>
     </pre>

   The `.gl` line renders below the source in a muted type, separated by a
   dotted hairline — the Leipzig glossing convention. Pure CSS; no JS. */

.gloss-theme .gloss-line {
  display: block;
  padding-block-end: 0.4em;
  margin-block-end: 0.4em;
  border-block-end: 1px dotted var(--color-rule);
}

.gloss-theme .gloss-line:last-child {
  border-block-end: none;
}

.gloss-theme .gloss-line .src {
  display: block;
  color: var(--code-fg);
}

.gloss-theme .gloss-line .gl {
  display: block;
  color: var(--code-gloss-fg);
  font-style: italic;
  font-size: 0.9em;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
  margin-block-start: 0.2em;
}

/* ============================================
   Language-badge strip (row of chips above code blocks)

   Usage: <div class="lang-strip">
            <span class="lang-chip active">EN · SVO</span>
            <span class="lang-chip">JA · SOV</span>
            <span class="lang-chip">AR · VSO</span>
          </div>
   ============================================ */

.gloss-theme .lang-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
  margin-block-end: var(--space-2, 0.5rem);
  padding-block-end: var(--space-2, 0.5rem);
  border-block-end: 1px solid var(--color-rule);
}

.gloss-theme .lang-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2em 0.6em;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  color: var(--color-muted);
  background: transparent;
  cursor: default;
  user-select: none;
}

.gloss-theme .lang-chip.active {
  color: var(--color-bg);
  background: var(--color-fg);
  border-color: var(--color-fg);
}

.gloss-theme button.lang-chip,
.gloss-theme a.lang-chip {
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.gloss-theme button.lang-chip:hover,
.gloss-theme a.lang-chip:hover {
  color: var(--color-fg);
  border-color: var(--color-fg);
}

/* ============================================
   Semantic-role token markers — the doubled underline

   Usage: wrap tokens with <span class="role-action"> etc. inside code blocks.
   Each role gets a doubled underline in its pigment colour. Hovering one
   role dims the others for focused reading (CSS-only via :has).
   ============================================ */

.gloss-theme .role-action,
.gloss-theme .role-patient,
.gloss-theme .role-destination,
.gloss-theme .role-source,
.gloss-theme .role-event {
  text-decoration: underline double;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

.gloss-theme .role-action      { text-decoration-color: var(--role-action);      color: var(--role-action); }
.gloss-theme .role-patient     { text-decoration-color: var(--role-patient);     color: var(--role-patient); }
.gloss-theme .role-destination { text-decoration-color: var(--role-destination); color: var(--role-destination); }
.gloss-theme .role-source      { text-decoration-color: var(--role-source);      color: var(--role-source); }
.gloss-theme .role-event       { text-decoration-color: var(--role-event);       color: var(--role-event); }

/* :has-scoped hover focus — dim non-hovered roles so the hovered one reads */
@supports selector(:has(*)) {
  .gloss-theme pre:has(.role-action:hover) :is(.role-patient, .role-destination, .role-source, .role-event),
  .gloss-theme pre:has(.role-patient:hover) :is(.role-action, .role-destination, .role-source, .role-event),
  .gloss-theme pre:has(.role-destination:hover) :is(.role-action, .role-patient, .role-source, .role-event),
  .gloss-theme pre:has(.role-source:hover) :is(.role-action, .role-patient, .role-destination, .role-event),
  .gloss-theme pre:has(.role-event:hover) :is(.role-action, .role-patient, .role-destination, .role-source) {
    opacity: 0.45;
  }
}

/* ============================================
   Prism syntax tokens — overridden with the five manuscript pigments

   These bypass the luminance-anchor system in prism-tokens.css because Gloss's
   colour identity IS the pigment palette — it shouldn't inherit the generic
   hue map. Keywords (action verbs) = madder; strings (values, the thing acted
   upon) = lapis; functions (calls going somewhere) = verdigris; properties
   (source of a value) = ochre; numbers (moments/amounts) = mulberry.
   ============================================ */

.gloss-theme .token.comment,
.gloss-theme .token.prolog,
.gloss-theme .token.doctype,
.gloss-theme .token.cdata {
  color: var(--color-faded);
  font-style: italic;
}

.gloss-theme .token.keyword,
.gloss-theme .token.tag,
.gloss-theme .token.boolean,
.gloss-theme .token.constant,
.gloss-theme .token.deleted,
.gloss-theme .token.important {
  color: var(--role-action);
  font-weight: 500;
}

.gloss-theme .token.string,
.gloss-theme .token.char,
.gloss-theme .token.attr-value,
.gloss-theme .token.inserted,
.gloss-theme .token.selector,
.gloss-theme .token.regex {
  color: var(--role-patient);
}

.gloss-theme .token.function,
.gloss-theme .token.class-name,
.gloss-theme .token.builtin {
  color: var(--role-destination);
}

.gloss-theme .token.number,
.gloss-theme .token.symbol {
  color: var(--role-event);
}

.gloss-theme .token.property,
.gloss-theme .token.attr-name,
.gloss-theme .token.variable {
  color: var(--role-source);
}

.gloss-theme .token.operator,
.gloss-theme .token.entity,
.gloss-theme .token.url,
.gloss-theme .token.punctuation {
  color: var(--color-muted);
}

.gloss-theme .token.namespace { opacity: 0.7; }

/* ============================================
   Buttons — hairline outline, no shadows
   ============================================ */

.gloss-theme button,
.gloss-theme .btn,
.gloss-theme input[type="submit"],
.gloss-theme input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.125rem;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--color-fg);
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.gloss-theme button:hover,
.gloss-theme .btn:hover,
.gloss-theme input[type="submit"]:hover,
.gloss-theme input[type="button"]:hover {
  background: var(--color-fg);
  color: var(--color-bg);
}

.gloss-theme button:focus-visible,
.gloss-theme .btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.gloss-theme button:active,
.gloss-theme .btn:active {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

/* Primary variant — solid lapis */
.gloss-theme button.primary,
.gloss-theme .btn.primary {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

.gloss-theme button.primary:hover,
.gloss-theme .btn.primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* ============================================
   Forms
   ============================================ */

.gloss-theme input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
.gloss-theme select,
.gloss-theme textarea {
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: 0.5rem 0.75rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--btn-radius);
  color: var(--color-fg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.gloss-theme input:focus,
.gloss-theme select:focus,
.gloss-theme textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}

/* ============================================
   Tables — editorial, ruled not boxed
   ============================================ */

.gloss-theme table {
  width: 100%;
  border-collapse: collapse;
  margin-block: var(--space-5, 1.25rem);
  font-size: 0.95em;
}

.gloss-theme th {
  font-family: var(--font-ui);
  font-weight: 600;
  text-align: start;
  padding: 0.6rem 0.8rem;
  color: var(--color-fg);
  background: transparent;
  border-block-end: 2px solid var(--color-fg);
  letter-spacing: 0.02em;
}

.gloss-theme td {
  padding: 0.55rem 0.8rem;
  border-block-end: 1px solid var(--color-rule);
  vertical-align: top;
}

.gloss-theme tr:last-child td {
  border-block-end: 2px solid var(--color-fg);
}

/* ============================================
   Navigation — quiet, ranged, no shadows
   ============================================ */

.gloss-theme .navbar {
  background: var(--nav-bg);
  border-block-end: 1px solid var(--color-rule);
  box-shadow: 0 2px 0 -1px var(--color-rule); /* doubled rule echo */
}

.gloss-theme .navigation a {
  font-family: var(--font-ui);
  color: var(--color-fg);
  text-decoration: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0.35rem 0.5rem;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.gloss-theme .navigation a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.gloss-theme .navigation select {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: var(--color-bg);
  color: var(--color-fg);
}

/* ============================================
   Cards (generic) — subtle, ranged
   Used by hero sections, feature lists, etc.
   ============================================ */

.gloss-theme .card,
.gloss-theme .intro-card,
.gloss-theme #intro-to-hyperscript,
.gloss-theme #features-list > div {
  background: var(--card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--card-radius);
  padding: var(--space-6, 1.5rem);
  margin-block: var(--space-5, 1.25rem);
  box-shadow: none;
}

.gloss-theme #features-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-inline-size: 64rem;
  margin-inline: auto;
  padding-block: var(--space-4, 1rem);
}

.gloss-theme #features-list h2 {
  text-align: center;
  margin-block: var(--space-6, 1.5rem);
  border-block-start: none;
  box-shadow: none;
}

/* ============================================
   Marginalia — right-column sidenotes on wide screens
   Usage: <aside class="marginalia">...</aside>
   Below 1200px, stacks inline as a blockquote.
   ============================================ */

.gloss-theme aside.marginalia {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.9em;
  color: var(--color-muted);
  border-inline-start: 1px solid var(--color-rule);
  padding: 0 var(--space-4, 1rem);
  margin-block: var(--space-5, 1.25rem);
}

@media (min-width: 1200px) {
  .gloss-theme aside.marginalia {
    float: inline-end;
    inline-size: 14rem;
    margin-inline-start: var(--space-6, 1.5rem);
    margin-inline-end: calc(var(--space-8, 2rem) * -1);
  }
}

/* ============================================
   Warning / info boxes — single-rule, role-coloured
   ============================================ */

.gloss-theme .box.warn,
.gloss-theme .box.warning {
  background: transparent;
  border-inline-start: 3px solid var(--role-action);
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  margin-block: var(--space-4, 1rem);
  border-radius: 0;
  color: var(--color-fg);
}

.gloss-theme .box.info {
  background: transparent;
  border-inline-start: 3px solid var(--role-patient);
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  margin-block: var(--space-4, 1rem);
  border-radius: 0;
  color: var(--color-fg);
}

.gloss-theme .box.ok {
  background: transparent;
  border-inline-start: 3px solid var(--role-destination);
  padding: var(--space-3, 0.75rem) var(--space-5, 1.25rem);
  margin-block: var(--space-4, 1rem);
  border-radius: 0;
  color: var(--color-fg);
}

/* ============================================
   Theme-switcher feedback toast
   ============================================ */

.gloss-theme .shortcut-feedback {
  background: var(--color-surface);
  color: var(--color-fg);
  border: 1px solid var(--color-fg);
  border-radius: 2px;
  font-family: var(--font-ui);
  box-shadow: 2px 2px 0 -1px var(--color-rule);
}

/* ============================================
   High Contrast
   ============================================ */

@media (prefers-contrast: more) {
  .gloss-theme {
    --color-fg:     light-dark(#0D1018, #F5ECD8);
    --color-muted:  light-dark(#3A4050, #C6B898);
    --color-border: light-dark(#A89B82, #4A5066);
    --color-rule:   light-dark(#A89B82, #4A5066);
  }
}

/* ============================================
   Reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .gloss-theme * {
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Print — drop paper grain, flatten to ink-on-white
   ============================================ */

@media print {
  .gloss-theme {
    --color-bg: #ffffff;
    --color-fg: #000000;
    --color-surface: #ffffff;
    --color-border: #000000;
    --color-rule: #666666;
  }

  html.gloss-theme body::before { display: none; }

  .gloss-theme pre,
  .gloss-theme .card,
  .gloss-theme table {
    box-shadow: none;
    border-color: #000000;
  }
}

/* --- Wordmark: hyperfixi ------------------------------------------------
   Rubricated manuscript header: italic madder drop-cap (the "action"
   pigment), small-caps rest in slate. Echoes the theme's interlinear
   gloss vocabulary.
*/
.gloss-theme .wm-hyperfixi .wm-drop {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  font-style: italic;
  color: var(--role-action);
  margin-inline-end: 0.04em;
}

.gloss-theme .wm-hyperfixi .wm-rest {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--color-fg);
}

.gloss-theme .wm-hyperfixi .wm-rest::after {
  background: var(--role-action);
  opacity: 0.5;
}

/* --- Wordmark: lokascript ----------------------------------------------
   Italic madder 'loka' (action pigment) + small-caps slate 'script'.
   Italic + small-caps contrast is the manuscript signature.
*/
.gloss-theme .wm-lokascript .wm-drop {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  font-style: italic;
  color: var(--role-action);
  margin-inline-end: 0.02em;
}

.gloss-theme .wm-lokascript .wm-rest {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--color-fg);
}

.gloss-theme .wm-lokascript .wm-rest::after {
  background: var(--role-action);
  opacity: 0.5;
}
