/*
  Neuroanaesthesia theme styles.
  Fonts are self-hosted (declared in theme.json), so no requests go to Google and no cookies are set.
  Ink-blue (--trace) is the accent. Red (--alarm) is reserved for emergency material only.
*/

:root {
  --paper: #f5f7f7;
  --surface: #ffffff;
  --ink: #15212b;
  --muted: #586571;
  --rule: #d3dade;
  --trace: #24508c;
  --link: #24508c;
  --alarm: #b3261e;
  --alarm-wash: #fbeceb;
  --focus: #e3a21a;

  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Atkinson Hyperlegible Next', system-ui, sans-serif;

  --measure: 40rem;
  --wide: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f171e;
    --surface: #152029;
    --ink: #e2e8ec;
    --muted: #97a4ae;
    --rule: #2a3741;
    --trace: #8db3e6;
    --link: #a6c4ee;
    --alarm: #f2857c;
    --alarm-wash: #2a1716;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font: 400 clamp(2.4rem, 5.5vw, 3.75rem)/1.05 var(--serif); letter-spacing: -.015em; }
h2 { font: 500 1.625rem/1.2 var(--serif); }
h3 { font: 700 1.0625rem/1.3 var(--sans); }
p { margin: 0 0 1em; }

.wrap { max-width: var(--wide); margin-left: auto; margin-right: auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.measure { max-width: var(--measure); }
.muted { color: var(--muted); }
.lede, .lede p { font-size: 1.1875rem; color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* WordPress's skip link: keep it, restyle it */
.skip-link.screen-reader-text:focus {
  background: var(--surface) !important; color: var(--link) !important;
  font: 600 1rem var(--sans) !important; box-shadow: none !important;
}

/* ---------- Long-form content (pages and guides) ---------- */
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2.25rem 0 .75rem; }
.prose h3 { margin: 1.75rem 0 .5rem; }
.prose ul, .prose ol { padding-left: 1.25rem; margin: 0 0 1em; }
.prose li { margin: .3em 0; }
.prose figure { margin: 0 0 1.5rem; }
.prose .wp-block-table { margin: .5rem 0 1.5rem; overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: .9688rem; }
.prose .wp-block-table thead { border-bottom: 0; }
.prose .wp-block-table th, .prose .wp-block-table td,
.prose th, .prose td {
  text-align: left; vertical-align: top; padding: .55rem .75rem .55rem 0;
  border: 0; border-bottom: 1px solid var(--rule);
}
.prose .wp-block-table th, .prose th { font-weight: 700; border-bottom-color: var(--ink); }
.prose .wp-block-table figcaption { font-size: .875rem; color: var(--muted); }
.prose blockquote {
  margin: 1.5rem 0; padding: .75rem 1rem; border-left: 3px solid var(--alarm);
  background: var(--alarm-wash);
}
.prose blockquote p:last-child { margin: 0; }
.prose blockquote cite { display: block; font-size: .875rem; font-style: normal; color: var(--muted); }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-top: 1.1rem; padding-bottom: 1rem;
}
.site-header .wordmark { margin: 0; font: 500 1.375rem/1 var(--serif); letter-spacing: -.01em; }
.site-header .wordmark a { color: var(--ink); text-decoration: none; }
.site-header .main-nav { font-size: .9688rem; font-weight: 600; }
.site-header .main-nav .wp-block-navigation__container { gap: clamp(1rem, 3vw, 2rem); }
.site-header .main-nav .wp-block-navigation-item__content {
  color: var(--ink); text-decoration: none; padding: 0 0 .2rem; border-bottom: 2px solid transparent;
}
.site-header .main-nav .wp-block-navigation-item__content:hover { border-bottom-color: var(--rule); }
.site-header .main-nav [aria-current='page'] { border-bottom-color: var(--trace); }

main { min-height: 60vh; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 5rem; font-size: .9375rem; }
.site-footer .foot {
  display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  padding-top: 1.75rem; padding-bottom: 2.5rem;
}
.site-footer .foot p { margin: 0; }

/* ---------- Page headers ---------- */
.head { padding-top: clamp(2.5rem, 6vw, 4.5rem); }
.head .lede, .head .wp-block-post-excerpt { margin-top: 1rem; max-width: var(--measure); }
.head .wp-block-post-excerpt__excerpt { margin: 0; }
.page-body { margin-top: 2rem; }

/* ---------- EEG trace ---------- */
.eeg { margin: 0; position: relative; }
.eeg svg { display: block; width: 100%; height: clamp(84px, 11vw, 132px); overflow: visible; }
.eeg-path {
  fill: none;
  stroke: var(--trace);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: na-draw 2.6s cubic-bezier(.45, 0, .2, 1) both;
}
.eeg-divider { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.eeg-labels { position: relative; height: 1.6rem; font-size: .8125rem; color: var(--muted); }
.eeg-labels span { position: absolute; top: .35rem; padding-left: .5rem; white-space: nowrap; }
.eeg-labels span:first-child { padding-left: 0; }
.eeg-labels span:last-child { left: auto !important; right: 0; }
@keyframes na-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .eeg-path { animation: none; } }
@media (max-width: 560px) {
  .eeg-labels span:nth-child(2), .eeg-labels span:nth-child(3) { display: none; }
}

/* ---------- Origami images: straight edges, no shadows, no frames ---------- */
.hero-image, .topic-image { margin: 0; }
.hero-image img, .topic-image img { display: block; width: 100%; height: auto; object-fit: cover; background: var(--rule); }

/* ---------- Home ---------- */
.hero { padding-top: clamp(3rem, 8vw, 6rem); }
.hero h1 { max-width: 15ch; }
.hero .lede { margin-top: 1.25rem; }
.hero-split {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem); align-items: center;
  padding-top: clamp(2rem, 6vw, 4.5rem);
}
.hero-split h1 { max-width: 16ch; }
.hero-split .lede { margin-bottom: 0; }
.hero-image img { aspect-ratio: 1376 / 768; }
@media (max-width: 860px) {
  .hero-split { grid-template-columns: 1fr; }
}
.home-trace { margin-top: clamp(2rem, 5vw, 3.5rem); }

.sections { margin-top: clamp(2.5rem, 6vw, 4rem); }
.sections .row:first-child { border-top: 1px solid var(--ink); }
.sections .row {
  display: grid; grid-template-columns: minmax(12rem, 22rem) minmax(0, 40rem); gap: .5rem 3rem;
  padding: 1.5rem 0; border-bottom: 1px solid var(--rule);
}
.sections .row h2 a { color: var(--ink); text-decoration: none; }
.sections .row h2 a:hover { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; }
.sections .row p { margin: 0; color: var(--muted); padding-top: .2rem; }
@media (max-width: 720px) { .sections .row { grid-template-columns: 1fr; } }

.recent { margin-top: 3.5rem; }
.recent .small-head { font: 700 1rem/1.3 var(--sans); }
.recent ul { list-style: none; padding: 0; margin: .75rem 0 0; max-width: var(--measure); }
.recent li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.recent li span { white-space: nowrap; font-size: .9375rem; }

/* ---------- Emergencies list ---------- */
.guide-list { list-style: none; margin-top: 2.5rem; margin-bottom: 0; }
.guide-list > li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 3rem; align-items: baseline;
  border-top: 1px solid var(--rule); padding: 1.25rem 0 1.25rem 1rem; position: relative;
}
.guide-list > li:last-child { border-bottom: 1px solid var(--rule); }
.guide-list > li::before {
  content: ''; position: absolute; left: 0; top: 1.45rem; bottom: 1.45rem; width: 3px; background: var(--alarm);
}
.guide-list a { text-decoration: none; color: var(--ink); display: block; max-width: var(--measure); }
.guide-list .title { display: block; font: 500 1.5rem/1.2 var(--serif); }
.guide-list a:hover .title { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.guide-list .summary { display: block; color: var(--muted); margin-top: .35rem; }
.guide-list .meta { font-size: .875rem; text-align: right; white-space: nowrap; }
.guide-list-empty { margin-top: 2.5rem; }
@media (max-width: 640px) {
  .guide-list > li { grid-template-columns: 1fr; }
  .guide-list .meta { text-align: left; }
}

/* ---------- Emergency guide ---------- */
.sheet { padding-top: 1.75rem; }
.sheet .crumb { font-size: .9375rem; margin: 0 0 1.5rem; }
.sheet .notice {
  max-width: var(--measure); margin: 0 0 1.75rem; padding: .7rem 1rem;
  border: 1px dashed var(--muted); font-size: .9375rem;
}
.sheet-head { border-left: 4px solid var(--alarm); padding-left: 1.1rem; }
.sheet-head .wp-block-post-excerpt { font-size: 1.1875rem; color: var(--muted); margin: .9rem 0 0; max-width: var(--measure); }
.sheet-head .wp-block-post-excerpt__excerpt { margin: 0; }

.sheet .grid {
  display: grid; grid-template-columns: minmax(0, 40rem) minmax(14rem, 18rem); gap: 4rem;
  margin-top: 2.25rem; justify-content: space-between;
}

/* Numbered steps: ordered lists in a guide are its immediate actions */
.sheet .body ol { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.5rem; }
.sheet .body ol > li {
  counter-increment: step; position: relative; padding: .7rem 0 .7rem 3rem; margin: 0;
  border-top: 1px solid var(--rule); font-weight: 600;
}
.sheet .body ol > li:last-child { border-bottom: 1px solid var(--rule); }
.sheet .body ol > li::before {
  content: counter(step); position: absolute; left: 0; top: .32rem;
  font: 500 1.75rem/1 var(--serif); color: var(--alarm); width: 2rem; text-align: right;
}
.sheet .body ol > li p { margin: 0; }
.sheet .body ol li ul { font-weight: 400; margin: .3rem 0 0; }
.sheet .body > h2:first-child { margin-top: 0; }

.guide-meta { font-size: .9375rem; align-self: start; position: sticky; top: 1.5rem; }
.guide-meta dl { margin: 0; border-top: 1px solid var(--ink); }
.guide-meta dl div { padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.guide-meta dt { font-weight: 700; font-size: .8125rem; color: var(--muted); }
.guide-meta dd { margin: .1rem 0 0; }
.guide-meta .overdue { color: var(--alarm); font-weight: 700; }
.guide-meta .print-url { display: none; }
.guide-meta .actions { display: flex; flex-direction: column; gap: .6rem; margin: 1.25rem 0; align-items: flex-start; }
.guide-meta button {
  font: 600 .9375rem var(--sans); color: var(--paper); background: var(--ink);
  border: 0; padding: .6rem 1rem; cursor: pointer; border-radius: 2px;
}
.guide-meta button:hover { background: var(--trace); }
.guide-meta .small { font-size: .875rem; }

@media (max-width: 860px) {
  .sheet .grid { grid-template-columns: 1fr; gap: 2rem; }
  .guide-meta { position: static; }
}

/* ---------- Learning resources ---------- */
.topic-group { margin-top: 2.5rem; }
.topic-group h2 { font: 700 1rem/1.3 var(--sans); padding-bottom: .6rem; border-bottom: 1px solid var(--ink); }
.topic-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0 3rem;
}
.topic-list li { border-bottom: 1px solid var(--rule); }
.topic-list a {
  display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 1.1rem; align-items: start;
  padding: 1rem 0; color: var(--ink); text-decoration: none;
}
.topic-list .thumb img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--rule); }
.topic-list .title { display: block; font: 500 1.375rem/1.2 var(--serif); }
.topic-list a:hover .title { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.topic-list .summary { display: block; color: var(--muted); font-size: .9375rem; margin-top: .3rem; line-height: 1.45; }
@media (max-width: 420px) { .topic-list a { grid-template-columns: 6.5rem minmax(0, 1fr); } }

.elsewhere { margin-top: 3.5rem; }
.elsewhere h2 { font: 700 1rem/1.3 var(--sans); margin-bottom: .75rem; }
.elsewhere .resources { max-width: var(--measure); }

.topic-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem); align-items: start; padding-top: clamp(1.75rem, 5vw, 3rem);
}
.topic-head + .page-body { margin-top: 2.5rem; }
.topic-head .crumb { font-size: .9375rem; margin: 0 0 1.25rem; }
.topic-head .wp-block-post-excerpt { margin: 1rem 0 0; max-width: var(--measure); }
.topic-head .wp-block-post-excerpt__excerpt { margin: 0; }
.topic-image img { aspect-ratio: 16 / 9; }
@media (max-width: 860px) { .topic-head { grid-template-columns: 1fr; } }

/* Reading lists: title (linked), source in italics shown as a quiet second line */
.resources { list-style: none; padding: 0 !important; margin: 0 0 1.5rem; border-top: 1px solid var(--rule); }
.resources li { margin: 0 !important; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.resources em { display: block; font-style: normal; font-size: .875rem; color: var(--muted); margin-top: .15rem; }
.suggest { margin-top: 2.5rem; color: var(--muted); }

/* ---------- pEEG ---------- */
.sim { margin-top: 2.5rem; margin-bottom: 3rem; }
.sim .frame { border: 1px solid var(--rule); background: var(--surface); padding: 1.5rem; }
.sim .frame p { margin: 1rem 0 0; font-size: .9375rem; }

/* ---------- Print: every guide on one A4 page ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  html { margin-top: 0 !important; }
  #wpadminbar, .site-header, .site-footer, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }

  .single-emergency_guide { --paper: #fff; --ink: #000; --muted: #444; --rule: #bbb; --alarm: #b3261e; --alarm-wash: #fbeceb; --link: #000; }
  .sheet .crumb, .guide-meta .actions, .guide-meta .small, .sheet .notice { display: none; }
  .sheet { padding: 0; max-width: none; }
  .sheet .grid { display: block; margin-top: 1rem; }
  .guide-meta { position: static; margin-top: 1rem; font-size: 8.5pt; max-width: var(--measure); break-inside: avoid; }
  .guide-meta dl { display: flex; flex-wrap: wrap; gap: 0 1.5rem; border-top: 1px solid #000; }
  .guide-meta dl div { border: 0; padding: .3rem 0; }
  .guide-meta .print-url { display: block; margin: .3rem 0 0; }
  .sheet h1 { font-size: 22pt; }
  .sheet-head .wp-block-post-excerpt { font-size: 11pt; margin-top: .3rem; }
  .sheet .body h2 { font-size: 14pt; margin: 1rem 0 .4rem; }
  .sheet .body ol > li { padding: .3rem 0 .3rem 2.4rem; }
  .sheet .body ol > li::before { font-size: 1.3rem; top: .2rem; }
  .sheet .body li { margin: .15em 0; }
  .sheet .body .wp-block-table { margin-bottom: .5rem; }
  .sheet .body th, .sheet .body td { padding: .3rem .75rem .3rem 0; }
  .sheet .body blockquote { margin: .75rem 0; padding: .4rem .8rem; }
}
