/* ─── Fonts ──────────────────────────────────────────────────────────
   Self-hosted. Loading these from Google would send every visitor's IP
   address to a third party for no benefit; served from the same origin
   they are also faster, with no extra DNS lookup or TLS handshake.
   Inter and Sora are both under the SIL Open Font License 1.1.
   ─────────────────────────────────────────────────────────────────── */

@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap;
  src:url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap;
  src:url('/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap;
  src:url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family:'Sora'; font-style:normal; font-weight:500; font-display:swap;
  src:url('/fonts/sora-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family:'Sora'; font-style:normal; font-weight:600; font-display:swap;
  src:url('/fonts/sora-latin-600-normal.woff2') format('woff2'); }

/* ═══ Ethos Monograph ═══════════════════════════════════════════════
   Derived directly from DESIGN.md. No framework, no build step.
   Sharp corners, hairline rules, tonal depth, zero shadows.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --surface:            #f9f9f7;
  --surface-low:        #f4f4f2;
  --surface-container:  #eeeeec;
  --surface-high:       #e8e8e6;
  --surface-lowest:     #ffffff;
  --on-surface:         #1a1c1b;
  --on-surface-variant: #444748;
  --outline:            #6f7373;
  --outline-variant:    #c4c7c7;
  --rule:               #e5e5e3;
  --field-border:       #929595;   /* form controls need 3:1 (WCAG 1.4.11) */
  --primary:            #121212;
  --on-primary:         #ffffff;
  --inverse-surface:    #2f3130;
  --error:              #ba1a1a;

  --font-display: 'Sora', ui-sans-serif, system-ui, sans-serif;
  --font-body:    'Inter', ui-sans-serif, system-ui, sans-serif;

  --baseline: 4px;
  --gutter:   24px;
  --margin:   20px;
  --maxw:     1280px;
  --readw:    72ch;
}

@media (min-width: 900px) { :root { --margin: 64px; } }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── Type scale ─────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}

.t-xl {
  font-size: clamp(28px, 5.5vw, 48px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.t-lg {
  font-size: clamp(24px, 3.6vw, 32px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.t-md { font-size: clamp(19px, 2.2vw, 24px); line-height: 1.3; }

.body-lg { font-size: clamp(16px, 1.6vw, 18px); line-height: 1.7; }
.body-md { font-size: 16px; line-height: 1.6; }
.body-sm { font-size: 14px; line-height: 1.5; color: var(--on-surface-variant); }

.label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.muted  { color: var(--on-surface-variant); }
.serial { font-variant-numeric: tabular-nums; color: var(--outline); }

a { color: inherit; text-decoration: none; }
p  { margin: 0 0 1.2em; }
p:last-child { margin-bottom: 0; }

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

.skip {
  position: absolute; left: -9999px;
  background: var(--primary); color: var(--on-primary);
  padding: 12px 20px; z-index: 100;
}
.skip:focus { left: var(--margin); top: 12px; }

/* ─── Layout ─────────────────────────────────────────────────────── */

.wrap {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--margin);
}

.section { padding-block: clamp(48px, 9vw, 104px); }
.section + .section { border-top: 1px solid var(--rule); }
.section--tint { background: var(--surface-low); }

/* Full-bleed divider, per DESIGN.md: dividers span the container width. */
hr, .rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

.stack > * + * { margin-top: var(--s, 16px); }

/* Two-column editorial split: label rail on the left, content on the right */
.split { display: grid; gap: var(--gutter); }
@media (min-width: 900px) {
  .split { grid-template-columns: 1fr 2fr; gap: calc(var(--gutter) * 2); }
}

.grid-2 { display: grid; gap: clamp(32px, 5vw, 56px) var(--gutter); }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.grid-4 { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.grid-4 > * { background: var(--surface); padding: clamp(20px, 3vw, 32px); }
@media (min-width: 640px)  { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gutter);
  flex-wrap: wrap;
  margin-bottom: clamp(28px, 4vw, 48px);
}

/* ─── Header ─────────────────────────────────────────────────────── */

.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--rule);
}
.masthead__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gutter);
  min-height: 60px;
}
.wordmark {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  white-space: nowrap;
}

.nav { display: none; gap: 28px; align-items: center; }
@media (min-width: 900px) { .nav { display: flex; } }
.nav a {
  font-size: 14px;
  padding-block: 4px;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.nav a:hover { border-bottom-color: var(--outline-variant); }
.nav a[aria-current='page'] { border-bottom-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 12px 20px;
  border: 1px solid var(--primary);
  border-radius: 0;
  background: var(--primary); color: var(--on-primary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn:hover { background: transparent; color: var(--primary); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--primary); color: var(--on-primary); }
.btn--sm { padding: 9px 14px; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
}
.link-arrow::after { content: '→'; transition: transform .15s; }
.link-arrow:hover::after { transform: translateX(4px); }

/* Mobile drawer */
.burger {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: none; border: 1px solid var(--rule); border-radius: 0;
  cursor: pointer;
}
@media (min-width: 900px) { .burger { display: none; } }
.burger span { display: block; width: 18px; height: 1px; background: var(--on-surface); }
.burger span + span { margin-top: 5px; }

.drawer {
  position: fixed; inset: 0; z-index: 60;
  background: var(--surface);
  padding: var(--margin);
  display: flex; flex-direction: column; gap: 4px;
  transform: translateY(-100%);
  transition: transform .28s ease;
}
.drawer[data-open='true'] { transform: none; }
.drawer a {
  font-family: var(--font-display);
  font-size: 22px;
  padding-block: 14px;
  border-bottom: 1px solid var(--rule);
}
.drawer__close {
  align-self: flex-end; background: none; border: 0;
  font-size: 24px; cursor: pointer; padding: 8px; margin-bottom: 20px;
}

/* ─── Hero ───────────────────────────────────────────────────────── */

.hero { display: grid; align-items: stretch; }
@media (min-width: 900px) {
  .hero--split { grid-template-columns: 1fr 1fr; }
}
.hero__copy {
  padding: clamp(48px, 8vw, 112px) var(--margin);
  max-width: calc(var(--maxw) / 2);
  margin-left: auto; width: 100%;
  align-self: center;
}
.hero__media { background: var(--surface-high); min-height: 320px; }
.hero__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lead {
  border-left: 1px solid var(--rule);
  padding-left: 20px;
  max-width: 46ch;
}

/* The pinned epigraph on Notes. Structural, not part of the notes list. */
.epigraph {
  border-top: 1px solid var(--rule);
  padding-top: 24px;
  margin-top: 32px;
  max-width: 40ch;
}
.epigraph blockquote {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(17px, 2vw, 20px);
  font-style: italic;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

/* ─── Numbered items ─────────────────────────────────────────────── */

.item { border-left: 1px solid var(--rule); padding-left: 20px; }
.item__no {
  display: block;
  font-size: 11px; letter-spacing: 0.1em;
  color: var(--outline);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.item h3 { margin-bottom: 8px; }

/* ─── Index rows (research + notes) ──────────────────────────────── */

.index { border-top: 1px solid var(--rule); }
.row {
  display: grid; gap: 6px var(--gutter);
  padding-block: clamp(24px, 3.5vw, 36px);
  border-bottom: 1px solid var(--rule);
  transition: background .15s;
}
.row:hover { background: #f0f0ee; }
@media (min-width: 820px) {
  .row { grid-template-columns: 200px 1fr; align-items: start; }
  .row--tight { grid-template-columns: 1fr auto; align-items: baseline; }
}
.row__meta { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.row h3 { margin-bottom: 10px; }
.row p { max-width: var(--readw); }

.tag {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 5px 8px;
  border: 1px solid var(--outline-variant);
  color: var(--on-surface-variant);
}

/* ─── Cards, quotes, forms ───────────────────────────────────────── */

.card {
  border: 1px solid var(--rule);
  padding: clamp(24px, 4vw, 40px);
  background: var(--surface);
}

.pullquote {
  border-left: 1px solid var(--primary);
  padding-left: 20px;
  font-family: var(--font-display);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.4;
}

.reflection {
  max-width: 62ch; margin-inline: auto; text-align: left;
}
.reflection blockquote {
  margin: 0 0 20px;
  font-size: clamp(16px, 1.8vw, 19px);
  font-style: italic;
  line-height: 1.7;
}

.field { display: block; margin-bottom: 24px; }
.field > .label { display: block; margin-bottom: 8px; }
.input, .textarea, .select {
  width: 100%;
  font-family: var(--font-body); font-size: 16px;
  color: var(--on-surface);
  background: var(--surface-lowest);
  border: 1px solid var(--field-border);
  border-radius: 0;
  padding: 12px 14px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--primary); border-width: 2px; padding: 11px 13px;
}
.textarea { min-height: 160px; resize: vertical; line-height: 1.6; }
.input[aria-invalid='true'] { border-width: 2px; border-color: var(--primary); }

/* ─── Social icons (render only when links exist) ────────────────── */

.social { display: flex; gap: 8px; flex-wrap: wrap; }
.social a {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--rule);
  transition: background .15s, border-color .15s;
}
.social a:hover { background: var(--primary); border-color: var(--primary); }
.social svg { width: 17px; height: 17px; fill: currentColor; }
.social a:hover svg { fill: var(--on-primary); }

/* ─── Figures in notes ───────────────────────────────────────────── */

figure { margin: 40px 0; }
figure img { width: 100%; height: auto; display: block; background: var(--surface-high); }
figure figcaption {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 13px; color: var(--on-surface-variant);
  max-width: 56ch;
}
.figure--full { margin-inline: calc(var(--margin) * -1); }
@media (min-width: 900px) { .figure--full { margin-inline: -64px; } }
.figure--pair { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

/* ─── Prose (note & manuscript bodies) ───────────────────────────── */

.prose { max-width: var(--readw); font-size: clamp(16px, 1.6vw, 18px); line-height: 1.7; }
.prose h2 { font-size: 24px; margin: 48px 0 16px; }
.prose h3 { font-size: 19px; margin: 36px 0 12px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1.2em; }
.prose li + li { margin-top: 8px; }
.prose blockquote {
  margin: 32px 0; padding-left: 20px;
  border-left: 1px solid var(--primary);
  font-style: italic;
}
.prose a { border-bottom: 1px solid var(--outline-variant); }
.prose a:hover { border-bottom-color: var(--primary); }

/* ─── Footer ─────────────────────────────────────────────────────── */

.footer { border-top: 1px solid var(--rule); padding-block: 40px; }
.footer__inner {
  display: flex; flex-wrap: wrap; gap: 24px;
  align-items: center; justify-content: space-between;
}
.monogram {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600;
  letter-spacing: 0.04em;
  background: none; border: 0; padding: 0;
  color: inherit; cursor: default;
  -webkit-user-select: none; user-select: none;
}
.footer__links { display: flex; flex-wrap: wrap; gap: 20px; }
.footer__links a { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-surface-variant); }
.footer__links a:hover { color: var(--on-surface); }

/* ─── Owner-only hidden-page banner ──────────────────────────────── */

.hidden-banner {
  background: var(--inverse-surface); color: var(--surface);
  padding: 10px var(--margin);
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}
.hidden-banner a { border-bottom: 1px solid currentColor; }

/* ─── Empty states ───────────────────────────────────────────────── */

.empty {
  border: 1px dashed var(--outline-variant);
  padding: 40px 24px;
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 14px;
}


/* ─── Dark palette ───────────────────────────────────────────────────
   The tonal inverse of the ivory system, not a mechanical negation.
   Kept warm (green-grey bias) so it reads as ink-on-paper reversed
   rather than a generic dark theme. Applied via [data-theme] on <html>,
   set server-side from a cookie so there is no flash on load.
   ─────────────────────────────────────────────────────────────────── */

[data-theme='dark'] {
  --surface:            #131413;
  --surface-low:        #181a19;
  --surface-container:  #1e201f;
  --surface-high:       #242625;
  --surface-lowest:     #0d0e0d;
  --on-surface:         #e6e7e4;
  --on-surface-variant: #a4a8a6;
  --outline:            #7d8180;
  --outline-variant:    #3b3e3d;
  --rule:               #2a2d2c;
  --field-border:       #5d605f;
  --primary:            #f2f2ef;
  --on-primary:         #131413;
  --inverse-surface:    #e6e7e4;
  --error:              #ffb4ab;
}

/* Photographs carry more apparent luminance on a dark ground. */
[data-theme='dark'] .hero__media img,
[data-theme='dark'] .identity-photo,
[data-theme='dark'] .about-photo,
[data-theme='dark'] .avatar,
[data-theme='dark'] figure img {
  filter: grayscale(1) brightness(.86) contrast(1.05);
}
[data-theme='dark'] .hero--wash > img { opacity: .16; }
[data-theme='dark'] .logo-panel img { filter: grayscale(1) invert(1) brightness(1.1); opacity: .8; }
[data-theme='dark'] .row:hover { background: var(--surface-high); }
[data-theme='dark'] .masthead {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

/* ─── Theme toggle ───────────────────────────────────────────────── */

.theme-toggle {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: none; border: 1px solid var(--rule);
  border-radius: 0; cursor: pointer; color: inherit;
  transition: border-color .15s;
}
.theme-toggle:hover { border-color: var(--outline); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.25; }
.theme-toggle .moon { display: none; }
[data-theme='dark'] .theme-toggle .sun { display: none; }
[data-theme='dark'] .theme-toggle .moon { display: block; }

/* ─── Direction rows with icons ──────────────────────────────────── */

.icon { flex: none; color: var(--on-surface); }
.row__head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.row__head h3 { margin: 0; }

/* ─── Imagery ────────────────────────────────────────────────────── */

/* Focal point is per-image, set from the dashboard, defaults to centre. */
.hero__media img { object-position: var(--focus, 50% 50%); }

/* Repository masthead: the portrait washed back behind the title. */
.hero--wash { position: relative; overflow: hidden; }
.hero--wash > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 62% 30%;
  opacity: .22;
  filter: grayscale(1) contrast(.85);
  pointer-events: none;
}
.hero--wash > img + * { position: relative; }
.hero--wash::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--surface) 22%, transparent 78%);
  pointer-events: none;
}
.hero--wash > .wrap { position: relative; z-index: 1; }

/* NeuroHue mark, contained rather than cropped. */
.logo-panel {
  display: grid; place-items: center;
  background: var(--surface-container);
  border: 1px solid var(--rule);
  padding: clamp(28px, 5vw, 56px);
  aspect-ratio: 1 / 1;
}
.logo-panel img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: grayscale(1);
  opacity: .9;
}

/* Founder's reflection portrait. */
.avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover; object-position: 50% 22%;
  filter: grayscale(1);
  display: block;
}

/* Sidebar identity portrait in the repository rail. */
.identity-photo {
  width: 100%; aspect-ratio: 4 / 5;
  object-fit: cover; object-position: 50% 18%;
  filter: grayscale(1);
  display: block;
  margin-bottom: 16px;
}

/* About page portrait. */
.about-photo {
  width: 100%; max-width: 280px;
  aspect-ratio: 1 / 1;
  object-fit: cover; object-position: 55% 25%;
  filter: grayscale(1);
  display: block;
}

/* NeuroHue hero: copy beside the mark on wide screens. */
@media (min-width: 900px) {
  .neurohue-hero { grid-template-columns: 1.35fr 1fr; }
}

/* ─── Print ──────────────────────────────────────────────────────────
   Academics print things. A monograph aesthetic that falls apart on
   paper is a contradiction, so this returns the page to a manuscript:
   serif-free body, no chrome, and link destinations spelled out.
   ─────────────────────────────────────────────────────────────────── */

@media print {
  :root {
    --surface: #fff; --surface-low: #fff; --surface-container: #fff;
    --surface-high: #fff; --surface-lowest: #fff;
    --on-surface: #000; --on-surface-variant: #333;
    --rule: #bbb; --outline: #555; --outline-variant: #999;
    --primary: #000; --on-primary: #fff;
  }

  @page { margin: 18mm 16mm; }

  html, body { background: #fff !important; color: #000; font-size: 11pt; }

  /* Navigation, controls and decoration carry nothing onto paper. */
  .masthead, .drawer, .burger, .theme-toggle, .footer__links,
  .hidden-banner, .social, .skip, form, .link-arrow, .btn,
  .hero--wash > img, .hero--wash::after { display: none !important; }

  .section { padding-block: 0 18pt; border-top: 0; }
  .section + .section { border-top: 1px solid var(--rule); padding-top: 18pt; }
  .wrap { max-width: none; padding-inline: 0; }

  /* Single column: side-by-side layouts collapse badly at page width. */
  .split, .grid-2, .grid-4, .hero--split, .neurohue-hero, .figure--pair {
    display: block !important;
  }
  .grid-4 > * { border-bottom: 1px solid var(--rule); padding: 8pt 0; }

  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  .t-xl { font-size: 22pt; }
  .t-lg { font-size: 16pt; }
  .t-md { font-size: 12pt; }
  p, blockquote, figure, .row, .item, .card { break-inside: avoid; page-break-inside: avoid; }

  img { max-width: 100% !important; filter: grayscale(1) !important; }
  .hero__media, .logo-panel { display: none; }
  figure img { max-height: 90mm; object-fit: contain; }

  /* A printed link is useless without its destination. */
  .prose a[href^="http"]::after {
    content: ' <' attr(href) '>';
    font-size: 9pt; color: #555; word-break: break-all;
  }

  /* Identify the source on every printed copy. */
  .footer::before {
    content: attr(data-print-source);
    display: block;
    font-size: 9pt; color: #555;
    padding-top: 8pt; border-top: 1px solid var(--rule);
  }
  .footer { padding-block: 0; }
  .monogram { display: none; }
}

/* Signed in, unpublished pages still appear in the menu so you can reach
   them. The dotted underline marks what the public cannot see. */
.nav a[data-hidden], .drawer a[data-hidden] {
  border-bottom: 1px dotted var(--outline);
  opacity: .7;
}
