/* ============ BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -moz-text-size-adjust: none; -webkit-text-size-adjust: none; text-size-adjust: none;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; scroll-behavior: smooth;
  hanging-punctuation: first last; scroll-padding-top: 5rem;
}
body { min-height: 100dvh; line-height: 1.6; font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text); background: var(--color-bg); }
img, svg { display: block; max-width: 100%; }
ul[role='list'] { list-style: none; }
input, button, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; font-family: var(--font-display); }
p, li { text-wrap: pretty; }
::selection { background: color-mix(in oklab, var(--color-primary) 30%, transparent); color: var(--color-text); }
:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; border-radius: 4px; }
button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }
a { color: var(--color-primary); }
[data-theme='dark'] a { color: var(--color-gold); }

/* ============ TOKENS ============ */
:root, [data-theme='light'] {
  --color-bg: #f5f3ec;
  --color-surface: #ffffff;
  --color-surface-2: #fbfaf6;
  --color-surface-offset: #eeece1;
  --color-surface-offset-2: #e6e2d3;
  --color-divider: #e1ddcd;
  --color-border: #d5cfbb;

  --color-text: #1e1c17;
  --color-text-muted: #6c6759;
  --color-text-faint: #a29c88;
  --color-text-inverse: #f7f5ec;

  --color-primary: #1c2e4a;
  --color-primary-hover: #14213a;
  --color-primary-active: #0f1a2d;
  --color-primary-highlight: #dde3ea;

  --color-gold: #a97a1e;
  --color-gold-hover: #8a6217;
  --color-gold-highlight: #efe1bf;

  --status-mandatory: #a4432b;
  --status-mandatory-bg: #f4e2da;
  --status-recommended: #93701a;
  --status-recommended-bg: #f0e6c8;
  --status-conditional: #2b5a82;
  --status-conditional-bg: #dde8f0;
  --status-discretionary: #5a4a8a;
  --status-discretionary-bg: #e6e0f0;
  --status-exempt: #3c7a4e;
  --status-exempt-bg: #dcece0;
  --status-prohibited: #8a2332;
  --status-prohibited-bg: #f2dcdf;
  --status-silent: #7a7669;
  --status-silent-bg: #e9e6db;

  --fmt-structured: #4a3f82;
  --fmt-structured-bg: #e2ddf0;
  --fmt-semi: #2b6b74;
  --fmt-semi-bg: #d9eaec;
  --fmt-freetext: #2b6b52;
  --fmt-freetext-bg: #dceee2;
  --fmt-icon: #93701a;
  --fmt-icon-bg: #f0e6c8;
  --fmt-na: #7a7669;
  --fmt-na-bg: #e9e6db;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem;
  --shadow-sm: 0 1px 2px rgba(30,28,23,0.06);
  --shadow-md: 0 6px 20px rgba(30,28,23,0.08);
  --shadow-lg: 0 16px 40px rgba(30,28,23,0.14);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'General Sans', 'Inter', sans-serif;
}

[data-theme='dark'] {
  --color-bg: #14161c;
  --color-surface: #191c23;
  --color-surface-2: #1d2028;
  --color-surface-offset: #20232b;
  --color-surface-offset-2: #262a33;
  --color-divider: #2b2f39;
  --color-border: #363b47;

  --color-text: #e6e4dc;
  --color-text-muted: #9b9a90;
  --color-text-faint: #6c6a60;
  --color-text-inverse: #191c23;

  --color-primary: #7f9cc4;
  --color-primary-hover: #a1b8d8;
  --color-primary-active: #b8cbe4;
  --color-primary-highlight: #263447;

  --color-gold: #dcb45e;
  --color-gold-hover: #ecc978;
  --color-gold-highlight: #3a3120;

  --status-mandatory: #e08b6e;
  --status-mandatory-bg: #3a2620;
  --status-recommended: #d9bb6a;
  --status-recommended-bg: #3a3120;
  --status-conditional: #8fbadd;
  --status-conditional-bg: #202f3d;
  --status-discretionary: #b8a4e0;
  --status-discretionary-bg: #2a2440;
  --status-exempt: #82c398;
  --status-exempt-bg: #1e3324;
  --status-prohibited: #e2879a;
  --status-prohibited-bg: #3a232a;
  --status-silent: #a8a495;
  --status-silent-bg: #2a2924;

  --fmt-structured: #b3a4e6;
  --fmt-structured-bg: #2a2540;
  --fmt-semi: #8fd0da;
  --fmt-semi-bg: #1c333a;
  --fmt-freetext: #8fd6ab;
  --fmt-freetext-bg: #1c3327;
  --fmt-icon: #d9bb6a;
  --fmt-icon-bg: #3a3120;
  --fmt-na: #a8a495;
  --fmt-na-bg: #2a2924;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.5);
}

.wrap { max-width: 1200px; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 2.5rem); }

/* ============ TYPE SCALE ============ */
:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.84rem + 0.2vw, 0.9375rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.3rem + 1vw, 2.1rem);
  --text-2xl: clamp(2rem, 1.5rem + 2vw, 3.1rem);
}

/* ============ HEADER ============ */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in oklab, var(--color-bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--color-divider); }
.header-row { display: flex; align-items: center; justify-content: space-between; padding-block: 0.85rem; }
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); }
/* AIast: capital-I/lowercase-l are near-identical in the body sans font, reading as "Alast" — the serif display font's I has terminals that disambiguate it. */
.aiast-label { font-family: var(--font-display); letter-spacing: 0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.header-actions { display: flex; align-items: center; gap: 1.25rem; }
.header-link { font-size: var(--text-sm); color: var(--color-text-muted); text-decoration: none; }
.header-link:hover { color: var(--color-primary); }
.theme-toggle { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-full, 999px); border: 1px solid var(--color-border); color: var(--color-text); }
.theme-toggle:hover { background: var(--color-surface-offset); }

/* ============ HERO ============ */
.hero { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 5vw, 3rem); border-bottom: 1px solid var(--color-divider); }
.eyebrow { font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-gold); font-weight: 600; margin-bottom: 0.75rem; }
.hero h1 { font-size: var(--text-2xl); font-weight: 500; max-width: 18ch; margin-bottom: 1.1rem; }
.hero-sub { max-width: 72ch; color: var(--color-text-muted); font-size: var(--text-base); margin-bottom: 2rem; }
.hero-stats { display: flex; gap: clamp(1.5rem, 4vw, 3rem); flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-primary); font-weight: 600; }
[data-theme='dark'] .stat-num { color: var(--color-gold); }
.stat-label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ============ LEGEND ============ */
.legend-section { padding-block: 1.75rem; }
.legend-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm); }
.legend-title { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.9rem; font-family: var(--font-body); font-weight: 600; }
.legend-groups { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; }
.legend-group { display: flex; flex-direction: column; gap: 0.5rem; }
.legend-label { font-size: var(--text-xs); color: var(--color-text-faint); }
.legend-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--text-xs); font-weight: 600; padding: 0.22rem 0.6rem; border-radius: var(--radius-full, 999px); white-space: nowrap; line-height: 1.4; letter-spacing: 0.02em; }
.req-mandatory { color: var(--status-mandatory); background: var(--status-mandatory-bg); }
.req-recommended { color: var(--status-recommended); background: var(--status-recommended-bg); }
.req-conditional { color: var(--status-conditional); background: var(--status-conditional-bg); }
.req-discretionary { color: var(--status-discretionary); background: var(--status-discretionary-bg); }
.req-exempt { color: var(--status-exempt); background: var(--status-exempt-bg); }
.req-prohibited { color: var(--status-prohibited); background: var(--status-prohibited-bg); }
.req-silent { color: var(--status-silent); background: var(--status-silent-bg); }
.fmt-structured { color: var(--fmt-structured); background: var(--fmt-structured-bg); }
.fmt-semi { color: var(--fmt-semi); background: var(--fmt-semi-bg); }
.fmt-freetext { color: var(--fmt-freetext); background: var(--fmt-freetext-bg); }
.fmt-icon { color: var(--fmt-icon); background: var(--fmt-icon-bg); }
.fmt-na { color: var(--fmt-na); background: var(--fmt-na-bg); }

/* ============ SECTION SHARED ============ */
section.wrap { padding-block: clamp(2rem, 5vw, 3.25rem); }
.section-head { margin-bottom: 1.5rem; }
.section-head h2 { font-size: var(--text-xl); font-weight: 500; margin-bottom: 0.4rem; }
.section-sub { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 68ch; }

/* ============ MATRIX ============ */
.matrix-scroll { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.matrix-grid { display: grid; min-width: 1100px; }
.matrix-row { display: contents; }
.matrix-cell, .matrix-head-cell, .matrix-row-label {
  padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--color-divider); border-right: 1px solid var(--color-divider);
  display: flex; align-items: center; font-size: var(--text-xs);
}
.matrix-head-cell { position: sticky; top: 0; background: var(--color-surface-offset); font-weight: 600; z-index: 2; justify-content: center; text-align: center; font-family: var(--font-body); font-size: var(--text-sm); letter-spacing: 0.015em; }
.matrix-head-cell.corner { position: sticky; left: 0; top: 0; z-index: 3; background: var(--color-surface-offset-2); }
.matrix-row-label { position: sticky; left: 0; background: var(--color-surface-2); font-weight: 600; z-index: 1; color: var(--color-text); border-right: 1px solid var(--color-border); }
.matrix-cell { justify-content: center; cursor: pointer; transition: background 150ms ease; }
.matrix-cell:hover { background: var(--color-surface-offset); }
.matrix-cell:last-child, .matrix-row-label:last-child { border-right: none; }
.cell-pill { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.5rem; border-radius: var(--radius-full,999px); font-weight: 600; font-size: 0.68rem; }
.cell-more { font-size: 0.62rem; color: var(--color-text-faint); margin-left: 0.15rem; }
.cell-empty { color: var(--color-text-faint); font-size: 0.75rem; }

/* ============ PUBLISHER CALLOUT ============ */
.callout-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: clamp(1.5rem, 3vw, 2.25rem); box-shadow: var(--shadow-sm); }
.callout-card h2 { font-size: var(--text-lg); font-weight: 600; margin-bottom: 1.1rem; }
.publisher-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.pub-col { border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 1rem 1.1rem; background: var(--color-surface-2); }
.pub-col h3 { font-size: var(--text-sm); font-weight: 700; margin-bottom: 0.6rem; font-family: var(--font-body); }
.pub-col ul { display: flex; flex-direction: column; gap: 0.5rem; }
.pub-col li { font-size: var(--text-sm); color: var(--color-text-muted); }
.pub-col li strong { color: var(--color-text); font-weight: 600; }

/* ============ TOOLBAR ============ */
.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; box-shadow: var(--shadow-sm); }
.search-field { display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.5rem 0.75rem; background: var(--color-surface-2); flex: 1 1 240px; min-width: 200px; color: var(--color-text-faint); }
.search-field input { border: none; background: none; outline: none; width: 100%; color: var(--color-text); font-size: var(--text-sm); }
.filter-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.filter-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--text-xs); color: var(--color-text-muted); }
.filter-field select { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 0.45rem 0.6rem; background: var(--color-surface-2); font-size: var(--text-sm); min-width: 150px; }
.reset-btn { font-size: var(--text-sm); color: var(--color-primary); font-weight: 600; padding: 0.5rem 0.9rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-2); }
.reset-btn:hover { background: var(--color-surface-offset); }
[data-theme='dark'] .reset-btn { color: var(--color-gold); }

.results-meta { font-size: var(--text-xs); color: var(--color-text-faint); margin-bottom: 0.6rem; }

/* ============ TABLE ============ */
.table-scroll { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.req-table { min-width: 1100px; font-size: var(--text-sm); }
.req-table thead th { position: sticky; top: 0; background: var(--color-surface-offset); text-align: left; padding: 0.7rem 0.85rem; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); cursor: pointer; user-select: none; white-space: nowrap; }
.req-table thead th:hover { color: var(--color-primary); }
.sort-icon::after { content: '↕'; opacity: 0.4; margin-left: 0.2rem; font-size: 0.7em; }
.req-table thead th.sort-asc .sort-icon::after { content: '↑'; opacity: 1; }
.req-table thead th.sort-desc .sort-icon::after { content: '↓'; opacity: 1; }
.req-table tbody tr { border-bottom: 1px solid var(--color-divider); cursor: pointer; }
.req-table tbody tr:hover { background: var(--color-surface-offset); }
.req-table td { padding: 0.7rem 0.85rem; vertical-align: top; }
.td-body { font-weight: 600; white-space: nowrap; }
.td-fields, .td-usecase { max-width: 260px; color: var(--color-text-muted); }
.td-fields { max-width: 220px; }
.td-source a { font-size: var(--text-xs); color: var(--color-primary); text-decoration: none; white-space: nowrap; }
.td-source a:hover { text-decoration: underline; }
[data-theme='dark'] .td-source a { color: var(--color-gold); }
.td-source-note { font-size: var(--text-xs); color: var(--color-text-faint); font-style: italic; white-space: nowrap; cursor: help; }
.empty-state { text-align: center; color: var(--color-text-muted); padding: 2rem; }

/* ============ BODY CARDS ============ */
.body-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.body-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.6rem; }
.body-card h3 { font-size: var(--text-base); font-weight: 700; font-family: var(--font-body); }
.body-card .type-tag { font-size: var(--text-xs); color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.body-card p { font-size: var(--text-sm); color: var(--color-text-muted); }
.body-card .mini-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.2rem; }

/* ============ CONVERGENCE / SOURCES ============ */
.convergence .callout-card p { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 78ch; }
.convergence .callout-card a { color: var(--color-primary); font-weight: 600; }
[data-theme='dark'] .convergence .callout-card a { color: var(--color-gold); }
.sources-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.6rem 2rem; margin-bottom: 1.5rem; }
.sources-list li { font-size: var(--text-sm); border-bottom: 1px dashed var(--color-divider); padding-bottom: 0.5rem; }
.sources-list a { color: var(--color-primary); text-decoration: none; }
.sources-list a:hover { text-decoration: underline; }
[data-theme='dark'] .sources-list a { color: var(--color-gold); }
.source-no-url { color: var(--color-text-faint); font-style: italic; cursor: help; }
.disclaimer { font-size: var(--text-xs); color: var(--color-text-faint); max-width: 80ch; border-top: 1px solid var(--color-divider); padding-top: 1.25rem; }

/* ============ FOOTER ============ */
.site-footer { border-top: 1px solid var(--color-divider); padding-block: 1.5rem; }
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; font-size: var(--text-xs); color: var(--color-text-faint); }
.footer-row a { color: var(--color-text-faint); }

/* ============ DRAWER ============ */
.drawer { position: fixed; inset: 0; z-index: 100; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(10,10,10,0.45); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(480px, 92vw); background: var(--color-surface); box-shadow: var(--shadow-lg); padding: 2rem 1.75rem; overflow-y: auto; animation: slideIn 220ms ease; }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-close { position: absolute; top: 1.25rem; right: 1.25rem; font-size: 1.5rem; width: 32px; height: 32px; border-radius: var(--radius-full,999px); border: 1px solid var(--color-border); display: flex; align-items: center; justify-content: center; line-height: 1; }
.drawer-close:hover { background: var(--color-surface-offset); }
#drawer-content h3 { font-size: var(--text-lg); margin-bottom: 0.25rem; margin-top: 1rem; padding-right: 2.5rem; line-height: 1.3; }
#drawer-content h3:first-child { margin-top: 0; }
#drawer-content .drawer-meta { font-size: var(--text-xs); color: var(--color-text-faint); margin-bottom: 1rem; }
#drawer-content .drawer-quote { background: var(--color-surface-offset); border-left: 3px solid var(--color-gold); padding: 0.85rem 1rem; margin: 0.75rem 0; font-style: italic; font-size: var(--text-sm); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
#drawer-content .drawer-row { margin-bottom: 0.5rem; font-size: var(--text-sm); }
#drawer-content .drawer-row strong { color: var(--color-text-muted); font-weight: 600; display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.1rem; }
#drawer-content .drawer-source-link { display: inline-block; margin-top: 0.5rem; font-size: var(--text-sm); font-weight: 600; }
#drawer-content .drawer-source-note { color: var(--color-text-faint); font-weight: 500; font-style: italic; }
#drawer-content .drawer-item { padding-block: 0.75rem; border-bottom: 1px solid var(--color-divider); }
#drawer-content .drawer-item:last-child { border-bottom: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
  .header-row { flex-wrap: wrap; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-field { flex: 0 0 auto; width: 100%; }
  .filter-controls { justify-content: space-between; }
  .filter-field select { min-width: 0; width: 100%; }
}

.et-sub { font-size: 0.82em; font-weight: 400; opacity: 0.85; margin-left: 0.35em; }

/* ---- Version-check + self-disclosure + corrections (added 29 Jul 2026) ---- */
.version-check,
.self-disclosure,
.corrections {
  border: 1px solid var(--color-border, #d9d4c8);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  margin: 1.5rem 0 0;
  background: var(--color-surface, #fff);
}
.version-check h3,
.self-disclosure h3,
.corrections h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  line-height: 1.3;
}
.version-check > p,
.self-disclosure p,
.corrections p {
  margin: 0 0 0.9rem;
  font-size: 0.94rem;
  line-height: 1.6;
}
.self-disclosure { border-left: 3px solid var(--color-gold, #e8b64a); }
.corrections     { border-left: 3px solid var(--color-primary, #1c2e4a); }
.version-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) 1fr;
  gap: 0.45rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.55;
}
.version-list dt { font-weight: 600; margin: 0; }
.version-list dd { margin: 0; }
.convergence-sources {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  line-height: 1.6;
  opacity: 0.85;
}
@media (max-width: 640px) {
  .version-list { grid-template-columns: 1fr; gap: 0.15rem; }
  .version-list dt { margin-top: 0.6rem; }
}
