/* ── RESET & TOKENS ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf9;
  --bg-warm: #f5f3f0;
  --bg-subtle: #f0eeeb;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #888;
  --accent: #2c5f6e;
  --accent-light: #e8f0f2;
  --accent-border: #c4d8de;
  --rule: #e0ded9;
  --rule-light: #ece9e4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
          'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-display: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Courier New', Courier, monospace;
  --max-w: 960px;
  --nav-h: 52px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  padding-top: var(--nav-h);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── NAV ─────────────────────────────────────────────────────── */
nav.site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(250,249,249,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 1000;
}

.nav-attribution {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.nav-attribution a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.nav-attribution a:hover { text-decoration: underline; }

/* ── HERO ────────────────────────────────────────────────────── */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 64px 28px 56px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(44px, 8vw, 88px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.0;
  color: var(--text);
  margin-bottom: 52px;
}

.hero-bottom {
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 48px;
  align-items: start;
}

.hero-toc {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hero-toc a {
  display: block;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  line-height: 1.25;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule-light);
  transition: color 0.18s, padding-left 0.18s;
}
.hero-toc a:last-child { border-bottom: none; }
.hero-toc a:hover, .hero-toc a:focus {
  color: var(--accent);
  padding-left: 6px;
  outline: none;
}

.hero-desc { padding-top: 4px; }
.hero-desc p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  text-align: justify;
  margin-bottom: 16px;
  max-width: none;
}
.hero-desc p:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
  .hero-bottom { grid-template-columns: 1fr; gap: 32px; }
  .hero h1 { margin-bottom: 36px; }
}

/* ── MAIN ────────────────────────────────────────────────────── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* ── SECTION ACCORDION ───────────────────────────────────────── */
.section-block {
  border-top: 1px solid var(--rule);
  border-left: 4px solid var(--section-color, var(--rule));
  padding-left: 20px;
  scroll-margin-top: var(--nav-h);
}
.section-block:last-child { border-bottom: 1px solid var(--rule); }

.section-trigger {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 4px 28px 0;
  cursor: pointer;
  text-align: left;
  gap: 16px;
}
.section-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.section-trigger-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.section-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--section-color, var(--text-muted));
  white-space: nowrap;
  flex-shrink: 0;
}

.section-trigger h2 {
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.15;
  transition: color 0.2s;
}

.marks-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.section-chevron {
  width: 22px; height: 22px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.section-trigger[aria-expanded="true"] .section-chevron {
  transform: rotate(180deg);
  color: var(--section-color, var(--accent));
}
.section-trigger[aria-expanded="true"] h2 {
  color: var(--section-color, var(--accent));
}

.section-body { display: none; padding-bottom: 40px; }
.section-body.open { display: block; }

/* ── LISTEN BUTTON ───────────────────────────────────────────── */
.section-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-warm);
  border: 1px solid var(--rule);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 24px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}
.listen-btn:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
}
.listen-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.listen-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.listen-btn.playing {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
}
.listen-btn svg { flex-shrink: 0; }

.section-intro {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 680px;
  margin: 0 0 28px;
  line-height: 1.65;
}

/* ── STRAND NAV ──────────────────────────────────────────────── */
.strand-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.strand-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 7px 15px;
  border: 1px solid var(--rule);
  border-radius: 24px;
  transition: all 0.2s;
  white-space: nowrap;
}
.strand-nav a:hover, .strand-nav a:focus {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-light);
  outline: none;
}
.strand-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 4px;
}

/* ── SUB-SECTION ACCORDION ───────────────────────────────────── */
.sub-section {
  margin-bottom: 0;
  scroll-margin-top: calc(var(--nav-h) + 20px);
}

.sub-trigger {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  cursor: pointer;
  text-align: left;
  gap: 12px;
  border-bottom: 1px solid var(--rule-light);
  transition: border-color 0.2s;
}
.sub-trigger:hover { border-bottom-color: var(--accent-border); }
.sub-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.sub-trigger-left { display: flex; align-items: center; gap: 12px; }
.sub-trigger h3 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  transition: color 0.2s;
}
.sub-trigger[aria-expanded="true"] h3 { color: var(--accent); }

.sub-chevron {
  width: 18px; height: 18px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  color: var(--text-muted);
}
.sub-trigger[aria-expanded="true"] .sub-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.sub-body { display: none; padding: 20px 0 16px; }
.sub-body.open { display: block; }

/* ── EXAMPLE BUTTON ──────────────────────────────────────────── */
.example-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 16px;
  border-radius: 24px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  margin-top: 16px;
}
.example-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-border);
  color: var(--accent);
}
.example-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.example-btn svg { flex-shrink: 0; }

/* ── TYPOGRAPHY ──────────────────────────────────────────────── */
h4 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin: 28px 0 8px;
}
p { margin-bottom: 14px; color: var(--text); max-width: 680px; }
ul, ol { padding-left: 22px; margin-bottom: 14px; max-width: 680px; }
li { margin-bottom: 8px; color: var(--text); }
strong { font-weight: 600; }

/* ── CALLOUTS ────────────────────────────────────────────────── */
.callout {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  max-width: 720px;
  font-size: 15px;
}
.callout-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.callout p, .callout ul { font-size: 15px; max-width: none; }

.callout-critical { background: #fdf2f2; border-left: 3px solid #c44; }
.callout-critical .callout-title { color: #c44; }
.callout-critical p, .callout-critical li { color: #5a1a1a; }

.callout-success { background: #f2f7f3; border-left: 3px solid #4a8; }
.callout-success .callout-title { color: #3a8a55; }
.callout-success p, .callout-success li { color: #1a3a1a; }

.callout-warn { background: #fef9f0; border-left: 3px solid #c94; }
.callout-warn .callout-title { color: #a07020; }
.callout-warn p, .callout-warn li { color: #4a2a0a; }

.callout-info { background: #f0f4f8; border-left: 3px solid var(--accent); }
.callout-info .callout-title { color: var(--accent); }
.callout-info p, .callout-info li { color: #1a2a3a; }

/* ── TABLES ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 16px 0; max-width: 760px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 2px solid var(--rule);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--rule-light); color: var(--text); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.marks-cell { font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ── RULES GRID ──────────────────────────────────────────────── */
.rules-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0;
  margin: 12px 0 20px;
  max-width: 800px;
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.rule-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--rule-light);
  border-right: 1px solid var(--rule-light);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  background: var(--bg);
}
.rule-item:last-child { border-bottom: none; }
.rule-icon { color: var(--accent); flex-shrink: 0; font-size: 15px; margin-top: 2px; }

/* ── STRAND SUMMARY CARDS ────────────────────────────────────── */
.strand-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 12px 0 20px;
  max-width: 760px;
}
.strand-card {
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.strand-card h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.strand-card .num { font-size: 10px; font-weight: 700; color: var(--accent); }
.strand-card p { font-size: 13px; color: var(--text-secondary); margin: 0; max-width: none; }

/* ── PAGE RECOMMENDATION TAG ─────────────────────────────────── */
.page-reco {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── COPY BOX ────────────────────────────────────────────────── */
.copy-box {
  margin: 16px 0 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 760px;
  box-shadow: var(--shadow-sm);
}
.copy-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--rule);
  gap: 12px;
}
.copy-box-header h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.copy-btn {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.copy-btn.copied { background: #4a8; border-color: #4a8; color: #fff; }
.copy-box pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  padding: 18px 20px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fcfbf9;
}

/* ── BONUS CONTENT ───────────────────────────────────────────── */
.bonus-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 24px;
  max-width: 680px;
}
.bonus-link-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.bonus-link-item:hover { border-color: var(--accent-border); background: var(--accent-light); }
.bonus-link-title { font-size: 14px; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.bonus-link-desc { font-size: 13px; color: var(--text-secondary); }

.bonus-note {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  padding: 10px 0;
  border-top: 1px dashed var(--rule);
  margin-top: 8px;
  max-width: 680px;
}

/* ── DIALOG ──────────────────────────────────────────────────── */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  border-radius: var(--radius-md);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 40px);
  max-height: 88vh;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
dialog:not([open]) { display: none; }
dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog[open] {
  animation: dialog-in 0.2s ease;
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

dialog::backdrop {
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-subtle);
  gap: 12px;
  flex-shrink: 0;
}
.dialog-header h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.dialog-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.dialog-close:hover { color: var(--text); background: var(--rule-light); }
.dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dialog-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.dialog-body p { font-size: 14px; max-width: none; }
.dialog-body ul { max-width: none; }
.dialog-body li { font-size: 14px; }

/* Placeholder slot for images you add later */
.dialog-img-slot {
  background: var(--bg-subtle);
  border: 2px dashed var(--rule);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.dialog-img-slot img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}
.dialog-img-slot .slot-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Compact table inside dialogs */
.dialog-table { margin: 12px 0; font-size: 13px; }
.dialog-table th { font-size: 10px; padding: 8px 10px; }
.dialog-table td { padding: 8px 10px; font-size: 13px; }
.dialog-table .cell-yes  { color: #3a8a55; font-weight: 700; text-align: center; }
.dialog-table .cell-part { color: #a07020; font-weight: 700; text-align: center; }
.dialog-table .cell-no   { color: #c44;    font-weight: 700; text-align: center; }
.dialog-table tfoot td   { font-weight: 700; background: var(--bg-subtle); border-top: 2px solid var(--rule); }

/* ── FOOTER ──────────────────────────────────────────────────── */
footer {
  background: var(--bg-warm);
  border-top: 1px solid var(--rule);
  padding: 40px 28px;
  text-align: center;
}
footer a { color: var(--accent); text-decoration: none; font-weight: 500; }
footer a:hover { text-decoration: underline; }
.footer-source { font-size: 14px; color: var(--text-muted); max-width: 640px; margin: 0 auto 8px; }
.footer-disclaimer { font-size: 13px; color: #aaa; max-width: 640px; margin: 0 auto; }

/* ── ACCESSIBILITY ───────────────────────────────────────────── */
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus {
  left: 10px; top: 10px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  z-index: 9999;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}
