/* The Women Hidden in π — app.v1.css
   Tokens ported exactly from design/README.md (§Design Tokens) and the prototype.
   Light scheme is the design of record; dark is a conservative remap of the
   neutral tokens in the same warm hue family. */

:root {
  color-scheme: light dark;

  /* surfaces */
  --c-bg: oklch(0.972 0.008 85);
  --c-surface: oklch(0.99 0.005 85);
  --c-surface-2: oklch(0.98 0.005 85);
  --c-surface-3: oklch(0.965 0.008 84);

  /* ink */
  --c-ink: oklch(0.26 0.012 60);
  --c-ink-strong: oklch(0.24 0.012 60);
  --c-body: oklch(0.32 0.012 62);
  --c-ref-ink: oklch(0.3 0.012 62);
  --c-secondary: oklch(0.36 0.012 62);
  --c-tert: oklch(0.52 0.02 72);
  --c-meta2: oklch(0.55 0.02 72);
  --c-muted: oklch(0.5 0.02 70);
  --c-label: oklch(0.58 0.02 74);
  --c-faint: oklch(0.6 0.02 74);
  --c-kicker: oklch(0.56 0.05 72);
  --c-chip-ink: oklch(0.4 0.02 66);
  --c-close-ink: oklch(0.45 0.02 68);

  /* digits + accent */
  --c-ambient: oklch(0.74 0.012 82);
  --c-accent: oklch(0.62 0.09 75);
  --c-accent-strong: oklch(0.5 0.13 64);

  /* hairlines */
  --c-hairline: oklch(0.9 0.012 80);
  --c-hairline-2: oklch(0.88 0.012 80);
  --c-hairline-3: oklch(0.87 0.012 80);
  --c-hairline-4: oklch(0.86 0.012 80);
  --c-divider: oklch(0.84 0.02 78);

  /* components */
  --c-chip-bg: oklch(0.94 0.012 82);
  --c-monogram-bg: oklch(0.9 0.05 82);
  --c-monogram-ink: oklch(0.5 0.07 66);
  --c-disc-bg: oklch(0.91 0.045 82);
  --c-disc-ink: oklch(0.44 0.07 66);
  --c-close-hover: oklch(0.94 0.01 82);
  --c-btn-dark: oklch(0.28 0.012 60);
  --c-btn-dark-hover: oklch(0.2 0.012 60);
  --c-btn-ink-inv: oklch(0.97 0.008 85);
  --c-wiki-hover-border: oklch(0.78 0.02 78);
  --c-wiki-hover-bg: oklch(0.98 0.006 85);
  --c-film-bg: oklch(0.22 0.01 60);
  --c-film-ink: oklch(0.9 0.01 80);
  --c-link: oklch(0.5 0.09 70);
  --c-link-hover: oklch(0.4 0.1 65);
  --c-selection: oklch(0.86 0.06 82);

  --shadow-tip: 0 14px 34px -14px oklch(0.35 0.03 70 / 0.55);
  --shadow-panel: -24px 0 70px -34px oklch(0.32 0.03 70 / 0.5);

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Spectral', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: oklch(0.205 0.012 75);
    --c-surface: oklch(0.24 0.012 75);
    --c-surface-2: oklch(0.27 0.012 75);
    --c-surface-3: oklch(0.26 0.012 75);
    --c-ink: oklch(0.91 0.012 82);
    --c-ink-strong: oklch(0.93 0.012 82);
    --c-body: oklch(0.87 0.012 80);
    --c-ref-ink: oklch(0.86 0.012 80);
    --c-secondary: oklch(0.84 0.012 80);
    --c-tert: oklch(0.7 0.02 76);
    --c-meta2: oklch(0.68 0.02 76);
    --c-muted: oklch(0.7 0.02 74);
    --c-label: oklch(0.62 0.02 74);
    --c-faint: oklch(0.58 0.02 74);
    --c-kicker: oklch(0.68 0.05 74);
    --c-chip-ink: oklch(0.8 0.02 76);
    --c-close-ink: oklch(0.75 0.02 72);
    --c-ambient: oklch(0.42 0.015 78);
    --c-accent: oklch(0.72 0.09 78);
    --c-accent-strong: oklch(0.82 0.11 80);
    --c-hairline: oklch(0.32 0.012 76);
    --c-hairline-2: oklch(0.33 0.012 76);
    --c-hairline-3: oklch(0.34 0.012 76);
    --c-hairline-4: oklch(0.35 0.012 76);
    --c-divider: oklch(0.38 0.02 76);
    --c-chip-bg: oklch(0.28 0.012 76);
    --c-monogram-bg: oklch(0.33 0.05 78);
    --c-monogram-ink: oklch(0.8 0.07 76);
    --c-disc-bg: oklch(0.34 0.045 78);
    --c-disc-ink: oklch(0.82 0.07 74);
    --c-close-hover: oklch(0.3 0.012 76);
    --c-btn-dark: oklch(0.9 0.01 80);
    --c-btn-dark-hover: oklch(0.96 0.01 82);
    --c-btn-ink-inv: oklch(0.22 0.012 60);
    --c-wiki-hover-border: oklch(0.45 0.02 76);
    --c-wiki-hover-bg: oklch(0.29 0.012 76);
    --c-film-bg: oklch(0.16 0.01 60);
    --c-link: oklch(0.75 0.09 74);
    --c-link-hover: oklch(0.85 0.1 76);
    --c-selection: oklch(0.4 0.06 78);
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-body);
  padding: 0 24px 80px;
}
a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-link-hover); }
::selection { background: var(--c-selection); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

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

.site-header { max-width: 840px; margin: 0 auto; padding: 76px 0 26px; text-align: center; }
.kicker {
  margin: 0; font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--c-kicker);
}
.title {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(44px, 7vw, 86px); line-height: 1.02;
  margin: 20px 0 0; letter-spacing: -0.01em;
}
.title em { font-style: italic; font-weight: inherit; }
.subtitle {
  max-width: 620px; margin: 22px auto 0; font-size: 17.5px;
  line-height: 1.6; color: var(--c-secondary); text-wrap: pretty;
}
.legend {
  display: inline-flex; align-items: center; gap: 10px; margin: 26px 0 0;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--c-muted);
}
.legend-digit {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; position: relative;
  color: var(--c-accent); font-weight: 600;
}
.legend-dot {
  position: absolute; top: -3px; left: 50%; width: 4px; height: 4px;
  margin-left: -2px; border-radius: 50%; background: var(--c-accent);
}

.divider { height: 1px; max-width: 120px; margin: 8px auto 36px; background: var(--c-divider); }

/* ---------- pattern switcher ---------- */

.pattern-switcher {
  border: 0; margin: 0 auto 40px; padding: 0;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  font-family: var(--font-mono);
}
.pattern-title {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--c-label); margin-right: 6px;
}
.pattern-switcher label { display: inline-flex; cursor: pointer; }
.pattern-switcher input {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden;
}
.pattern-switcher span {
  font-size: 12px; letter-spacing: 0.02em; padding: 6px 14px;
  border-radius: 100px; border: 1px solid var(--c-hairline-2);
  color: var(--c-chip-ink); background: transparent;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.pattern-switcher input:checked + span {
  border-color: var(--c-accent); color: var(--c-accent-strong);
  background: var(--c-chip-bg); font-weight: 600;
}
.pattern-switcher input:focus-visible + span {
  outline: 2px solid var(--c-accent-strong); outline-offset: 2px;
}

/* ---------- π digit field ---------- */

.field-wrap { max-width: 1220px; margin: 0 auto; overflow-x: auto; }
.pi-field {
  display: grid; grid-template-columns: repeat(32, 1.55rem);
  grid-auto-rows: 1.55rem; gap: 2px;
  width: max-content; margin: 0 auto;
}
.cell {
  font-family: var(--font-mono); font-size: 0.95rem; line-height: 1;
  color: var(--c-ambient); font-weight: 400;
  position: relative; user-select: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.cell.marker {
  color: var(--c-accent); font-weight: 600; cursor: pointer;
  transition: transform 0.18s ease, color 0.18s ease;
}
.cell.marker .dot {
  position: absolute; top: -0.18em; left: 50%; width: 4px; height: 4px;
  margin-left: -2px; border-radius: 50%; background: var(--c-accent); opacity: 0.8;
}
.cell.marker.selected { transform: scale(1.18); color: var(--c-accent-strong); }
.cell.marker.selected .dot { opacity: 1; }
.cell.marker:hover, .cell.marker:focus-visible {
  transform: scale(1.45); color: var(--c-accent-strong); z-index: 5;
}
.cell.marker:focus-visible {
  outline: 2px solid var(--c-accent-strong); outline-offset: 3px; border-radius: 4px;
}

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

.site-footer {
  max-width: 840px; margin: 64px auto 0; text-align: center;
  font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--c-faint);
}
.noscript { text-align: center; font-family: var(--font-mono); color: var(--c-muted); }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed; left: 0; top: 0; opacity: 0; visibility: hidden;
  pointer-events: none; z-index: 80;
  transform: translate(-50%, -118%);
  transition: opacity 0.14s ease;
}
.tooltip.show { opacity: 1; visibility: visible; }
.tooltip-card {
  display: flex; align-items: center; gap: 11px;
  background: var(--c-surface); border: 1px solid var(--c-hairline-3);
  box-shadow: var(--shadow-tip); border-radius: 13px;
  padding: 8px 15px 8px 8px; white-space: nowrap;
}
.tooltip-avatar {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  overflow: hidden; background: var(--c-disc-bg); flex: none;
}
.tooltip-initials {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--c-disc-ink); font-family: var(--font-mono); font-weight: 600; font-size: 13px;
}
.tooltip-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tooltip-name {
  font-family: var(--font-serif); font-size: 19px; font-weight: 500;
  color: var(--c-ink-strong); line-height: 1.05;
}
.tooltip-years {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--c-meta2);
  margin-top: 3px; letter-spacing: 0.02em;
}

/* ---------- detail panel (dialog) ---------- */

.detail {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(452px, 96vw); overflow-y: auto;
  background: var(--c-surface); border-left: 1px solid var(--c-hairline-2);
  box-shadow: var(--shadow-panel);
  padding: 40px 34px 52px; z-index: 70;
  animation: fadeUp 0.32s ease;
}
.detail[hidden] { display: none; }

.detail-close {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--c-hairline-3);
  background: var(--c-surface-2); color: var(--c-close-ink);
  font-size: 19px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 3;
}
.detail-close:hover { background: var(--c-close-hover); }
.detail-close:focus-visible { outline: 2px solid var(--c-accent-strong); outline-offset: 2px; }

.portrait {
  position: relative; width: 100%; height: 288px; border-radius: 13px;
  overflow: hidden; background: var(--c-monogram-bg);
  display: flex; align-items: center; justify-content: center;
}
.portrait-monogram {
  font-family: var(--font-serif); font-size: 76px; font-weight: 500;
  color: var(--c-monogram-ink);
}
.portrait-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
}

.detail-kicker {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--c-accent); margin: 22px 0 8px;
}
.detail-name {
  font-family: var(--font-serif); font-weight: 500; font-size: 39px;
  line-height: 1.04; margin: 0; letter-spacing: -0.01em;
}
.detail-meta {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--c-tert);
  margin: 8px 0 0; letter-spacing: 0.03em;
}
.detail-tags {
  display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 0;
  padding: 0; list-style: none;
}
.detail-tags li {
  font-family: var(--font-mono); font-size: 11px; padding: 5px 10px;
  border-radius: 100px; background: var(--c-chip-bg);
  border: 1px solid var(--c-hairline-2); color: var(--c-chip-ink);
  letter-spacing: 0.02em;
}
.detail-bio {
  font-size: 16.5px; line-height: 1.62; color: var(--c-body);
  margin: 20px 0 0; text-wrap: pretty;
}
.detail-label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--c-label); margin: 28px 0 12px;
}

.film {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: #000;
}
.film iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.film.empty {
  background: var(--c-film-bg);
  display: flex; align-items: center; justify-content: center;
}
.film .poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0.28;
}
.film .no-film {
  position: relative; text-align: center; color: var(--c-film-ink);
  font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.08em; padding: 0 24px;
}
.film .no-film span { opacity: 0.6; }

.refs { display: flex; flex-direction: column; border-top: 1px solid var(--c-hairline); }
.refs a {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--c-hairline);
  color: var(--c-ref-ink);
}
.refs a:hover { color: var(--c-link); }
.refs .ref-label { font-family: var(--font-body); font-size: 14.5px; }
.refs .ref-sub {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em;
  color: var(--c-faint); white-space: nowrap;
}
.credit {
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.5;
  color: var(--c-label); margin: 10px 0 0;
}

.actions { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px; border-radius: 11px;
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.btn:focus-visible { outline: 2px solid var(--c-accent-strong); outline-offset: 2px; }
.btn-share { background: var(--c-btn-dark); color: var(--c-btn-ink-inv); }
.btn-share:hover { background: var(--c-btn-dark-hover); color: var(--c-btn-ink-inv); }
.x-glyph { font-weight: 700; font-size: 14px; font-family: Georgia, serif; }
.btn-wiki {
  background: var(--c-surface-3); border: 1px solid var(--c-hairline-4);
  color: var(--c-ref-ink);
}
.btn-wiki:hover {
  border-color: var(--c-wiki-hover-border); background: var(--c-wiki-hover-bg);
  color: var(--c-ref-ink);
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .detail { animation: none; }
  .tooltip { transition: none; }
  .cell.marker { transition: none; }
  .cell.marker:hover, .cell.marker:focus-visible { transform: none; }
  .cell.marker.selected { transform: none; }
  .pattern-switcher span { transition: none; }
}
