/* =====================================================================
 * SI Appearance layer — shared.
 * Attribute-driven theming. Sites map their OWN variables to the --ap-*
 * contract in the per-site sections at the bottom. Never edit a site's
 * own stylesheet for theming; add/extend its map section here.
 *
 * Attributes set on <html> by appearance.js (always all six):
 *   data-theme="light|dark"        (resolved; "system" resolves in JS)
 *   data-accent="gold|teal|plum|forest"
 *   data-text="s|m|l|xl"
 *   data-font="default|dyslexic"
 *   data-contrast="standard|high"
 *   data-motion="full|reduced"
 * ===================================================================== */

/* ---- accent values (light defaults) ---- */
:root {
  --ap-accent: #b98a2f;
  --ap-accent-soft: #f4ead2;
  --ap-accent-ink: #ffffff;
}
html[data-accent="teal"]   { --ap-accent: #2c7a7b; --ap-accent-soft: #ddefef; }
html[data-accent="plum"]   { --ap-accent: #7c4a6e; --ap-accent-soft: #f3e6ef; }
html[data-accent="forest"] { --ap-accent: #3f6b4f; --ap-accent-soft: #e4efe7; }

/* ---- dark mode base ---- */
html[data-theme="dark"] {
  --ap-bg: #10151f;
  --ap-card: #1a2233;
  --ap-ink: #e9ecf4;
  --ap-muted: #9aa5bc;
  --ap-line: #2a3449;
  --ap-head: #eef1f7;
  /* accent stays readable on dark */
  --ap-accent: #d4a94e; --ap-accent-soft: #2b2413;
}
html[data-theme="dark"][data-accent="teal"]   { --ap-accent: #4aa8a9; --ap-accent-soft: #14302f; }
html[data-theme="dark"][data-accent="plum"]   { --ap-accent: #b07fa0; --ap-accent-soft: #2c1e28; }
html[data-theme="dark"][data-accent="forest"] { --ap-accent: #6fa287; --ap-accent-soft: #16281d; }

/* ---- text size (m = site default, untouched) ---- */
html[data-text="s"] body  { font-size: 15px; }
html[data-text="l"] body  { font-size: 19px; }
html[data-text="xl"] body { font-size: 21.5px; }

/* ---- dyslexia-friendly reading font (loaded on demand by appearance.js) ---- */
html[data-font="dyslexic"] body {
  font-family: "Atkinson Hyperlegible", Verdana, Geneva, sans-serif;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
}

/* ---- high contrast ---- */
html[data-contrast="high"] { --ap-ink: #000000; --ap-muted: #2b2b2b; }
html[data-theme="dark"][data-contrast="high"] {
  --ap-ink: #ffffff; --ap-muted: #d5d5d5; --ap-line: #5a5a5a;
}

/* ---- reduced motion ---- */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* =====================================================================
 * Appearance panel (modal). Injected by appearance.js.
 * ===================================================================== */
.si-ap-backdrop {
  position: fixed; inset: 0; background: rgba(10, 14, 22, 0.55);
  z-index: 9990; display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px;
}
.si-ap-panel {
  background: var(--ap-card, #fff); color: var(--ap-ink, #1c2b4a);
  border: 1px solid var(--ap-line, #e2e0d8); border-radius: 14px;
  max-width: 440px; width: 100%; max-height: 84vh; overflow-y: auto;
  padding: 20px 20px 16px; box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.si-ap-panel h3 { margin: 0 0 4px; font-size: 17px; }
.si-ap-panel .si-ap-sub { margin: 0 0 14px; font-size: 13px; color: var(--ap-muted, #5b6472); }
.si-ap-row { margin-bottom: 14px; }
.si-ap-row > span { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ap-muted, #5b6472); }
.si-ap-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.si-ap-seg button {
  font: inherit; font-size: 13.5px; padding: 7px 13px; border-radius: 999px;
  border: 1.5px solid var(--ap-line, #e2e0d8); background: transparent;
  color: var(--ap-ink, #1c2b4a); cursor: pointer;
}
.si-ap-seg button[aria-pressed="true"] {
  border-color: var(--ap-accent, #b98a2f);
  background: var(--ap-accent-soft, #f4ead2);
  font-weight: 700;
}
.si-ap-swatches { display: flex; gap: 10px; }
.si-ap-sw {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; padding: 0;
}
.si-ap-sw[aria-pressed="true"] { border-color: var(--ap-ink, #1c2b4a); }
.si-ap-close {
  float: right; font: inherit; border: none; background: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--ap-muted, #5b6472); padding: 4px;
}
.si-ap-note { font-size: 12.5px; color: var(--ap-muted, #5b6472); margin: 4px 0 0; }

/* =====================================================================
 * PER-SITE VARIABLE MAPS — each site maps its own variables to --ap-*.
 * Add a new section per site/port. Light-mode values must be identical
 * to the site's own :root (verified by the port's before/after check).
 * ===================================================================== */

/* ---- silcme (SI LCME hub) ---- */
html { --gold: var(--ap-accent); --gold-light: var(--ap-accent-soft); }
html[data-theme="dark"] {
  --paper: var(--ap-bg, #10151f);
  --card: var(--ap-card, #1a2233);
  --ink: var(--ap-ink, #e9ecf4);
  --muted: var(--ap-muted, #9aa5bc);
  --line: var(--ap-line, #2a3449);
  --head: var(--ap-head, #eef1f7);
}
