/* Migraine Meta — one stylesheet, no build step, no dependencies. */

:root {
  --paper: #f7f5f1;
  --surface: #fffefb;
  --ink: #1b1a17;
  --ink-2: #5a564e;
  --ink-3: #5a564e;
  --rule: #e2ded6;
  --accent: #3c5a72;
  --accent-soft: #eef1f4;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14161a;
    --surface: #1b1e24;
    --ink: #e9e6e0;
    --ink-2: #a8a49c;
    --ink-3: #a8a49c;
    --rule: #2b2f36;
    --accent: #9dbdd8;
    --accent-soft: #1f242b;
  }
}

/* Explicit override via the header theme toggle (stored in localStorage).
   Mirrors the two sets above; system preference applies when unset. */
:root[data-theme="light"] {
  --paper: #f7f5f1;
  --surface: #fffefb;
  --ink: #1b1a17;
  --ink-2: #5a564e;
  --ink-3: #5a564e;
  --rule: #e2ded6;
  --accent: #3c5a72;
  --accent-soft: #eef1f4;
}
:root[data-theme="dark"] {
  --paper: #14161a;
  --surface: #1b1e24;
  --ink: #e9e6e0;
  --ink-2: #a8a49c;
  --ink-3: #a8a49c;
  --rule: #2b2f36;
  --accent: #9dbdd8;
  --accent-soft: #1f242b;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

/* Skip link for keyboard users */
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--ink); padding: 0.5rem 1rem; z-index: 100; }
.skip:focus { left: 0.5rem; top: 0.5rem; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 62rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-style: dotted; }

/* Visible keyboard focus on every interactive element. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Theme toggle in the site header. */
.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- header ---------- */

header.site {
  border-bottom: 1px solid var(--rule);
  padding: 1.1rem 0;
  position: sticky;
  top: 0;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  z-index: 10;
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  header.site { background: var(--paper); backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  header.site { backdrop-filter: none; }
}

header.site .wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }

.mark {
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.mark em { font-style: normal; color: var(--ink-3); }

nav.site { margin-left: auto; display: flex; gap: 1.1rem; font-size: 0.86rem; }
nav.site a { color: var(--ink-2); text-decoration: none; }
nav.site a:hover, nav.site a[aria-current="page"] { color: var(--ink); }

/* ---------- type ---------- */

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
}

h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 3rem 0 0.75rem;
}

h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  margin: 2rem 0 0.4rem;
}

p { margin: 0 0 1rem; }
p.lead { font-size: 1.2rem; color: var(--ink-2); line-height: 1.55; }

ul, ol { margin: 0 0 1rem; padding-left: 1.3rem; }
li { margin-bottom: 0.45rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 1rem;
}

.small { font-size: 0.86rem; color: var(--ink-2); }

/* ---------- hero ---------- */

.hero { padding: 5.5rem 0 3.5rem; }
.hero h1 { max-width: 30ch; }

.cta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 2rem; align-items: center; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.primary:hover { color: var(--paper); opacity: 0.9; }

/* ---------- cards ---------- */

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 1.5rem 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.25rem 1.3rem;
}
.card h3 { margin-top: 0; font-family: var(--serif); font-weight: 500; font-size: 1.1rem; letter-spacing: 0; }
.card p { margin: 0; font-size: 0.93rem; color: var(--ink-2); }

/* ---------- notice ---------- */

.notice {
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 2rem 0;
}
.notice p { margin: 0; font-size: 0.93rem; }
.notice p + p { margin-top: 0.6rem; }

/* ---------- legal pages ---------- */

.legal { padding: 3.5rem 0 1rem; }
.legal .updated { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); letter-spacing: 0.04em; }
.legal h2:first-of-type { margin-top: 2rem; }
/* Scroll wrapper owns horizontal overflow so tables keep table layout. */
.table-scroll { overflow-x: auto; margin: 0 0 1rem; }
.table-scroll table { margin: 0; }
.legal table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.legal th, .legal td { text-align: left; padding: 0.5rem 0.8rem 0.5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.legal th { font-weight: 600; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }

.toc { font-size: 0.9rem; columns: 2; column-gap: 2rem; margin: 1.5rem 0 0; padding-left: 1.1rem; }
@media (max-width: 34rem) { .toc { columns: 1; } }

/* ---------- footer ---------- */

footer.site {
  border-top: 1px solid var(--rule);
  margin-top: 5rem;
  padding: 2.5rem 0 3.5rem;
  font-size: 0.86rem;
  color: var(--ink-3);
}
footer.site .links { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
footer.site a { color: var(--ink-2); text-decoration: none; }
footer.site a:hover { color: var(--accent); }
