/* READING theme (as-x1xc) -- plain, high-contrast pages that run left to right.

   Colour theme (as-nuqn): dark is the default. The site's dark palette comes
   from the tokens in styles.css; every light value in the READING files sits
   under html[data-theme="light"], which /theme.js sets from localStorage
   'aer_theme' before first paint. Layout rules here are theme-neutral.

   For serious pages (documentation, account, checkout, auth, legal, FAQ,
   support, community lists). Showcase pages (home, products) keep the dark
   animated brand system; they never load this file.

   Opt in:   <body class="... reading">   and   <link rel="stylesheet" href="/reading.css?v=...">
             after styles.css and site-shell.css (specificity here is body.reading,
             so it also wins over the site-shell.css copy app.js appends later).

   What it does
   - Tokens: under data-theme="light" redefines the shared design tokens (--bg-*,
     --text-*, --accent, --air, --border*) to a white page, near-black ink and
     gold used only as an accent. Every rule that already reads var(--token)
     follows with no other change. Dark keeps the styles.css tokens; only
     --border-strong is raised so control edges clear 3:1.
   - Chrome: light variant of the shared site header, footer and menus.
   - No decoration: the aether glow, corner watermark and motion are removed.
   - Layout primitives other READING pages reuse (documented below).

   Dark contrast (against --bg-0 #0A0B12): --text-1 #EFF0F4 17.5:1, --text-2 #B3B7C4 9.9:1,
     --accent #E2A945 9.6:1, --air #9BB2D9 9.0:1, --link #A9BFE6 9.8:1,
     --border-strong #6A7185 4.0:1 (3.5:1 on --bg-2).
   Light contrast (against #FFFFFF; --bg-1/--bg-2 stay above the same thresholds)
     --text-1 #111318 18.6:1   --text-2 #2A2E38 13.6:1   --text-3 #4A4F5C 8.2:1 (all AAA)
     --accent #7A5200 6.9:1    --air #365A92 6.9:1       --link #1C4A94 8.5:1
     --border-strong #767C89 4.2:1 (controls need 3:1); --border is decorative only.
   Gold fills (buttons) carry #111318 text at >= 10:1.

   Layout primitives
     .reading-shell    Full-width page frame: clears the fixed header and applies the
                       fluid side gutter (--shell-gutter). Never a fixed-width column.
     .reading-measure  Caps running text at --reading-measure (80ch). Apply to prose
                       blocks, not to code, tables, forms or grids.
     .reading-flow     Container for sections: one column, and two columns from
                       --reading-2col (1680px) up so wide screens are used.
     .reading-grid     Auto-fitting card/field grid that fills the row.
     .reading-card     Bordered, white, square-ish card with a visible focus state.
     .reading-table-wrap  Horizontal scroll container for wide tables.
   Type scales with the viewport via --reading-size (16px at laptop, 20px at 2560). */

body.reading {
  --border-strong: #6A7185;
  --reading-measure: 80ch;
  --reading-2col: 1680px;
  --reading-size: clamp(16px, .45vw + 9.5px, 20px);

  background: var(--bg-0);
  color: var(--text-1);
}
html[data-theme="light"]:has(body.reading) { color-scheme: light; }
html[data-theme="light"] body.reading {
  --bg-0: #FFFFFF;
  --bg-1: #F5F6F8;
  --bg-2: #ECEEF2;
  --bg-3: #E1E4EA;
  --bg-4: #D3D7DF;

  --text-1: #111318;
  --text-2: #2A2E38;
  --text-3: #4A4F5C;
  --text-4: #4A4F5C;

  --accent: #7A5200;
  --accent-rgb: 122, 82, 0;
  --air: #365A92;
  --air-rgb: 54, 90, 146;
  --link: #1C4A94;
  --gold-fill: #ECBE5E;
  --info: #365A92;
  --success: #1F6B3A;
  --warn: #8A4B0F;
  --danger: #B3261E;

  --border: #D6DAE1;
  --border-strong: #767C89;
  --border-accent: rgba(122, 82, 0, .45);
  --border-hover: #4A4F5C;

  /* Interaction tokens. styles.css declares these on :root, where var(--bg-3),
     var(--bg-4) and var(--air) resolve to the dark values and are inherited as
     already-computed colors, so the background and --air overrides above never reach them.
     Re-declare them here so hover/pressed fills and the keyboard ring follow the
     white page: --text-1 on hover #ECEEF2 is 16.0:1, on pressed #E1E4EA 14.6:1,
     and the ring #365A92 is 6.9:1 on white, 6.0:1 on the hover fill. */
  --control-hover: var(--bg-2);
  --control-press: var(--bg-3);
  --focus-ring: var(--air);

  --shadow-sm: none;
  --shadow-md: 0 1px 3px rgba(17, 19, 24, .12);
  --shadow-card: none;
  --shadow-lg: 0 8px 24px rgba(17, 19, 24, .16);
  --shadow-elevated: 0 8px 24px rgba(17, 19, 24, .16);
  --shadow-modal: 0 16px 40px rgba(17, 19, 24, .24);
  --shadow-glow: none;

  /* Tokens defined for dark in styles.css and read by the shared READING rules. */
  --placeholder: #666B7A;
  --success-bg: #E8F4EC;
  --warn-bg: #FFF3E0;
  --danger-bg: #FBE9E7;
  --selected-bg: #FFF9EA;
  --chip-gold-bg: #FBEBC4;
  --chip-gold-fg: #5C3D00;
  --chip-blue-bg: #E4ECF8;
  --chip-blue-fg: #243F6B;
  --danger-hover-bg: #FBEAE8;
  --danger-hover-fg: #8C1D18;
  --scrim: rgba(17, 19, 24, .6);

  color-scheme: light;
}

/* ---- Decoration: the dark aether glow stays; light has none ------------- */
body.reading #brand-watermark { display: none !important; }
body.reading a { color: var(--text-1); }
body.reading ::selection { background: rgba(var(--accent-rgb), .35); color: var(--text-1); }
:where(html[data-theme="light"]) body.reading::before { display: none; }
:where(html[data-theme="light"]) body.reading ::selection { background: #FBE3A6; color: #111318; }
body.reading ::-webkit-scrollbar-track { background: var(--bg-0); }
body.reading ::-webkit-scrollbar-thumb { background: var(--bg-4); }
body.reading ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---- Light site header (dark keeps the shared site-shell header) ------ */
:where(html[data-theme="light"]) body.reading .site-header,
:where(html[data-theme="light"]) body.reading.site-frame .site-header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
:where(html[data-theme="light"]) body.reading .nav-links > a,
:where(html[data-theme="light"]) body.reading .nav-auth > a { color: var(--text-2); }
:where(html[data-theme="light"]) body.reading .nav-links a:hover,
:where(html[data-theme="light"]) body.reading .nav-auth a:hover { color: var(--text-1); background: var(--bg-2); }
:where(html[data-theme="light"]) body.reading.site-frame .nav-links > a.is-current:not(.nav-cta),
:where(html[data-theme="light"]) body.reading.site-frame .nav-auth > a.is-current { color: var(--text-1); background: var(--bg-1); }
:where(html[data-theme="light"]) body.reading.site-frame .nav-links > a.is-current:not(.nav-cta)::after,
:where(html[data-theme="light"]) body.reading.site-frame .nav-auth > a.is-current:not(.nav-cta)::after,
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu-btn.is-current::after,
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu a.is-current:not(.nav-cta)::after,
:where(html[data-theme="light"]) body.reading.site-frame .logo.is-current::after { background: var(--accent); }
:where(html[data-theme="light"]) body.reading .nav-cta,
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu .nav-cta {
  background: var(--gold-fill);
  color: #111318 !important;
  box-shadow: none;
}
:where(html[data-theme="light"]) body.reading .nav-cta:hover,
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu .nav-cta:hover {
  background: #F2C14E;
  color: #111318 !important;
  box-shadow: none;
  transform: none;
}
:where(html[data-theme="light"]) body.reading .logo { color: var(--text-1); }
:where(html[data-theme="light"]) body.reading.site-frame .nav-cart-standalone:hover,
:where(html[data-theme="light"]) body.reading.site-frame .nav-cart-standalone.is-current { background: var(--bg-2); }
:where(html[data-theme="light"]) body.reading.site-frame .nav-cart-standalone.is-current { box-shadow: inset 0 -2px var(--accent); }
:where(html[data-theme="light"]) body.reading .mobile-menu-btn:hover { background: var(--bg-2); }
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu { background: var(--bg-0); }
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu a:hover,
:where(html[data-theme="light"]) body.reading.site-frame .mobile-menu a.is-current { background: var(--bg-1); }
:where(html[data-theme="light"]) body.reading .ccy-btn:hover { background: var(--bg-2); }

/* ---- Light footer ------------------------------------------------------ */
:where(html[data-theme="light"]) body.reading.site-frame .site-footer,
:where(html[data-theme="light"]) body.reading .site-footer {
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  color: var(--text-2);
}
:where(html[data-theme="light"]) body.reading .footer-links a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
:where(html[data-theme="light"]) body.reading .footer-links a:hover { color: var(--text-1); }
/* The lockup is a light-on-dark mark; keep it on its own sky plate. */
:where(html[data-theme="light"]) body.reading .footer-brand-mark {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  border-radius: var(--r-md);
  background: #0A0B12;
  opacity: 1;
}
:where(html[data-theme="light"]) body.reading.site-frame .locale-btn:hover,
:where(html[data-theme="light"]) body.reading.site-frame .locale-btn[aria-expanded="true"] { background: var(--bg-2); }
:where(html[data-theme="light"]) body.reading.site-frame .locale-menu { background: #FFFFFF; box-shadow: var(--shadow-lg); }

/* ---- Focus: 2px ring, 6.9:1 on white, never removed ------------------ */
body.reading :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--air);
  outline-offset: 3px;
}

/* ---- Layout primitives ------------------------------------------------ */
.reading-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: calc(var(--header) + clamp(28px, 3vw, 56px)) var(--shell-gutter, 24px) clamp(56px, 6vw, 112px);
}
.reading-measure { max-width: var(--reading-measure); }
.reading-flow { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(28px, 3vw, 56px); }
@media (min-width: 1680px) {
  .reading-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(48px, 5vw, 128px); }
}
.reading-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: clamp(14px, 1.4vw, 28px); }
.reading-card {
  min-width: 0;
  padding: clamp(18px, 1.6vw, 30px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-0);
  color: var(--text-1);
}
a.reading-card { text-decoration: none; }
a.reading-card:hover { background: var(--bg-1); border-color: var(--text-1); }
.reading-table-wrap { max-width: 100%; overflow-x: auto; }
.reading-table-wrap table { width: 100%; border-collapse: collapse; }
.reading-table-wrap :is(th, td) { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.reading-table-wrap th { color: var(--text-1); font-weight: 650; background: var(--bg-1); }

@media (prefers-reduced-motion: reduce) {
  body.reading * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
