/* ============================================================
   Glow Medicinal — Monochrome Aesthetic
   Newsreader display + IBM Plex Sans body + IBM Plex Mono identifiers
   Cool true-white (#FCFCFC) ground, charcoal (#16181C) ink
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --primary:        #16181C;
  --primary-50:     #EBECEE;
  --primary-900:    #0A0B0D;
  --secondary:      #4A4D55;
  --accent:         #16181C;
  --neutral-50:     #FCFCFC;
  --neutral-100:    #F4F4F5;
  --neutral-200:    #E4E5E7;
  --neutral-300:    #D2D4D7;
  --neutral-500:    #6E7178;
  --neutral-700:    #3A3C42;
  --neutral-900:    #16181C;
  --bg:             #FCFCFC;
  --surface:        #FFFFFF;
  --surface-inset:  #F4F4F5;
  --text:           #16181C;
  --text-muted:     #5A5D64;
  --rule:           #16181C;
  --rule-muted:     #E4E5E7;
  --ink-invert:     #FCFCFC;
  --ground-invert:  #16181C;

  --max-width:      74rem;
  --container-px:   clamp(1rem, 3vw, 2.5rem);

  --font-heading:   'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body:      'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:      'IBM Plex Mono', 'Courier New', monospace;

  --radius-button:  0.1875rem;
  --radius-card:    0.1875rem;

  /* Spacing unit: 4px baseline */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-color: currentColor;
}

ul, ol {
  list-style: none;
}

/* ── Typography Scale ──────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  letter-spacing: -0.015em;
  line-height: 1.08;
}

h2 {
  font-size: clamp(1.625rem, 3.25vw, 2.5rem);
}

h3 {
  font-size: 1.375rem;
}

h4 {
  font-size: 1.125rem;
}

p {
  font-size: 1.0625rem;
  line-height: 1.65;
  max-width: 40rem;
}

.lede, .subheadline {
  font-size: 1.25rem;
  line-height: 1.5;
  max-width: 46rem;
}

small {
  font-size: 0.875rem;
  line-height: 1.55;
}

.micro {
  font-size: 0.8125rem;
  line-height: 1.55;
}

.eyebrow, .section-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  display: block;
}

/* Italic serif for pull quotes */
.pull-quote {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  line-height: 1.3;
  max-width: 40rem;
}

/* Mono for identifiers */
code, .mono-id {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9375em;
  background-color: var(--surface-inset);
  border-radius: 0.125rem;
  padding: 0.0625rem 0.25rem;
}

/* ── Container & Grid ──────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--container-px);
}

/* 12-col tight-gutter grid */
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.2rem;
}

/* 8-col reading column + 4-col marginalia */
.reading-col {
  grid-column: 1 / -1;
}

.marginalia-col {
  display: none;
}

@media (min-width: 1024px) {
  .reading-col {
    grid-column: 5 / 13;
  }
  .marginalia-col {
    display: block;
    grid-column: 1 / 5;
  }
}

/* ── Header / Masthead ─────────────────────────────────────── */
.site-header {
  background-color: var(--bg);
  padding-block: var(--sp-5);
  border-bottom: 1px solid var(--rule);
  position: relative;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
}

.site-brand {
  text-decoration: none;
  flex-shrink: 0;
}

.site-brand__name {
  display: block;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: -0.005em;
  color: var(--text);
  line-height: 1.2;
}

.site-brand__sub {
  display: block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* ── Nav ─────────────────────────────────────────────────────── */
.site-nav {
  display: none;
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

.site-nav a {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--text);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 180ms ease-out;
}

.site-nav a:hover {
  border-bottom-color: var(--rule);
}

.site-nav a[aria-current="page"] {
  border-bottom: 1.5px solid var(--rule);
}

/* Mobile nav toggle */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 1px;
  background-color: var(--text);
  transition: all 180ms ease-out;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.mobile-nav {
  display: none;
  border-top: 1px solid var(--rule-muted);
  padding-block: var(--sp-4);
  background-color: var(--bg);
}

.mobile-nav.is-open {
  display: block;
}

.mobile-nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.mobile-nav a {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
  padding-block: var(--sp-2);
  padding-inline: var(--container-px);
}

.mobile-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (min-width: 768px) {
  .site-nav {
    display: flex;
    align-items: center;
  }
  .nav-toggle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav a,
  .nav-toggle span {
    transition: none;
  }
}

/* ── Main ───────────────────────────────────────────────────── */
main {
  padding-block: var(--sp-16) var(--sp-24);
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  padding-block: var(--sp-16) var(--sp-12);
  max-width: 46rem;
}

.hero .eyebrow {
  margin-bottom: var(--sp-5);
}

.hero h1 {
  margin-bottom: var(--sp-6);
}

.hero .subheadline {
  color: var(--text);
  margin-bottom: var(--sp-6);
}

.hero-rule {
  width: 100%;
  height: 1px;
  background-color: var(--rule);
  margin-block: var(--sp-6);
}

.cta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

/* ── Sections ───────────────────────────────────────────────── */
.page-body > section {
  padding-block: var(--sp-12);
  border-top: 1px solid var(--rule);
}

.page-body > section:first-child {
  border-top: none;
}

.section-header {
  margin-bottom: var(--sp-8);
}

.section-header h2 {
  margin-top: var(--sp-3);
}

section p + p {
  margin-top: var(--sp-5);
}

section h3 {
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-4);
}

section ul, section ol {
  margin-top: var(--sp-4);
  padding-left: var(--sp-6);
}

section ul {
  list-style: disc;
}

section ol {
  list-style: decimal;
}

section li {
  margin-top: var(--sp-2);
  line-height: 1.65;
}

section strong {
  font-weight: 600;
}

section em {
  font-style: italic;
}

/* Subsection rule */
.subsection-rule {
  width: 100%;
  height: 1px;
  background-color: var(--rule-muted);
  margin-block: var(--sp-8);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: 0;
  text-decoration: none;
  padding: 0.75rem 1.375rem;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--ink-invert);
  border: none;
}

.btn-primary:hover {
  background-color: var(--primary-900);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: inset 0 0 0 1px var(--ink-invert);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--rule);
}

.btn-secondary:hover {
  border-width: 1.5px;
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background-color: var(--surface);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-card);
  padding: var(--sp-6);
}

.card-eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.card-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.25rem;
  margin-bottom: var(--sp-3);
}

/* Inverted card — emphasis device */
.card-invert {
  background-color: var(--ground-invert);
  color: var(--ink-invert);
  border-color: var(--ground-invert);
}

.card-invert .card-eyebrow,
.card-invert .card-title,
.card-invert p {
  color: var(--ink-invert);
}

/* Card grid */
.card-grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .card-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .card-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Callouts ───────────────────────────────────────────────── */
.callout {
  border: 1px solid var(--neutral-200);
  border-left: 3px solid var(--rule);
  padding: var(--sp-5) var(--sp-6);
  margin-block: var(--sp-8);
}

.callout-eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.callout p {
  max-width: 100%;
}

/* Inverted callout — highest-priority notice */
.callout-invert {
  background-color: var(--ground-invert);
  border-color: var(--ground-invert);
  border-left-color: var(--ground-invert);
  color: var(--ink-invert);
}

.callout-invert .callout-eyebrow,
.callout-invert p {
  color: var(--ink-invert);
}

/* ── Figures ────────────────────────────────────────────────── */
.figure-block {
  margin-block: var(--sp-12);
}

.figure-block img {
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  display: block;
}

.figure-caption {
  margin-top: var(--sp-3);
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}

.figure-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-block;
  margin-right: var(--sp-2);
  text-transform: uppercase;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-block: var(--sp-8);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead tr {
  border-bottom: 1.5px solid var(--rule);
}

thead th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--rule-muted);
}

tbody td {
  padding: var(--sp-3) var(--sp-4);
  line-height: 1.5;
  vertical-align: top;
}

tbody td.mono-cell {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* ── FAQ ────────────────────────────────────────────────────── */
.faq-list {
  margin-top: var(--sp-8);
}

.faq-item {
  border-top: 1px solid var(--rule-muted);
  padding-block: var(--sp-6);
}

.faq-item:last-child {
  border-bottom: 1px solid var(--rule-muted);
}

.faq-question {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.1875rem;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.faq-answer {
  color: var(--text);
  max-width: 40rem;
}

/* ── References ─────────────────────────────────────────────── */
.references-list {
  margin-top: var(--sp-8);
}

.references-list li {
  padding-block: var(--sp-4);
  border-top: 1px solid var(--rule-muted);
  display: flex;
  gap: var(--sp-4);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.references-list li:last-child {
  border-bottom: 1px solid var(--rule-muted);
}

.ref-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 2rem;
  padding-top: 0.1em;
}

.ref-body {
  flex: 1;
}

.ref-meta {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: block;
  margin-top: var(--sp-1);
}

.ref-link {
  color: var(--text);
  text-underline-offset: 2px;
}

/* ── Citation Chips ─────────────────────────────────────────── */
sup a[data-citation] {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text);
  text-underline-offset: 1px;
  transition: text-decoration-color 180ms ease-out;
}

sup a[data-citation]:hover {
  text-decoration-color: var(--secondary);
}

@media (prefers-reduced-motion: reduce) {
  sup a[data-citation] { transition: none; }
}

/* ── Constituent Cards (index) ──────────────────────────────── */
.constituent-grid {
  display: grid;
  gap: var(--sp-5);
  margin-top: var(--sp-8);
}

@media (min-width: 768px) {
  .constituent-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Contact Form ───────────────────────────────────────────── */
.contact-form {
  margin-top: var(--sp-8);
  max-width: 36rem;
}

.form-group {
  margin-bottom: var(--sp-5);
}

.form-group label {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-button);
  padding: 0.75rem 1rem;
  transition: border-color 180ms ease-out;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 8rem;
  resize: vertical;
}

/* ── Marginalia Rail ────────────────────────────────────────── */
.section-index {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: var(--sp-3);
  display: block;
}

.fig-num-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── 404 ────────────────────────────────────────────────────── */
.error-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  padding-block: var(--sp-24);
}

.error-code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: var(--sp-4);
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--sp-12) var(--sp-8);
  background-color: var(--bg);
}

.footer-disclaimer {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: var(--sp-10);
  max-width: 46rem;
}

.footer-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-8);
  margin-bottom: var(--sp-10);
}

@media (min-width: 640px) {
  .footer-cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

.footer-col-heading {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.footer-col-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.footer-col-links a {
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--text);
  transition: text-decoration-color 180ms ease-out;
}

.footer-col-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-colophon {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  justify-content: space-between;
  align-items: flex-start;
  border-top: 1px solid var(--rule-muted);
  padding-top: var(--sp-5);
}

.footer-colophon-meta {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-copyright {
  font-size: 0.875rem;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .footer-col-links a { transition: none; }
}

/* ── Tippy overrides — monochrome ──────────────────────────── */
.tippy-box[data-theme~="mono"] {
  background-color: var(--surface);
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 24rem;
  box-shadow: none;
}

.tippy-box[data-theme~="mono"] .tippy-arrow::before {
  border-top-color: var(--rule);
}

/* ── DataTables overrides — monochrome ─────────────────────── */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-block: var(--sp-3);
}

.dataTables_wrapper .dataTables_filter input {
  font-family: var(--font-body);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-button);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  color: var(--text);
  margin-left: var(--sp-2);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  font-family: var(--font-body);
  color: var(--text) !important;
  border: 1px solid var(--neutral-200) !important;
  border-radius: var(--radius-button);
  padding: var(--sp-2) var(--sp-3) !important;
  margin-left: var(--sp-1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--primary) !important;
  color: var(--ink-invert) !important;
  border-color: var(--primary) !important;
}

/* ── Reading Progress Bar ──────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--primary);
  z-index: 9999;
  width: 0;
  transition: width 0.1s linear;
}

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

.text-muted { color: var(--text-muted); }
.text-mono  { font-family: var(--font-mono); }
.no-max     { max-width: none; }

.mt-4  { margin-top: var(--sp-4); }
.mt-6  { margin-top: var(--sp-6); }
.mt-8  { margin-top: var(--sp-8); }
.mt-12 { margin-top: var(--sp-12); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-6  { margin-bottom: var(--sp-6); }
.mb-8  { margin-bottom: var(--sp-8); }
