
/* Cold Light — Institutional Archive Design System (v2) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg-primary: #1a1d22;
  --bg-surface: #252a32;
  --text-primary: #dde0e3;
  --text-secondary: #8a9099;
  --text-tertiary: #6c727a;
  --accent: #5b7ca0;
  --accent-soft: #4a6580;
  --hover: #b8bec5;
  --border: #3a414a;
  --border-subtle: #2d333b;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Cascadia Code', monospace;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-body); font-weight: 400; line-height: 1.65; color: var(--text-primary); background-color: var(--bg-primary); min-height: 100vh; }

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; color: var(--text-primary); letter-spacing: -0.01em; }
h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

p { margin-bottom: var(--space-md); max-width: 65ch; }

a { color: var(--text-primary); text-decoration: none; transition: color 150ms ease, border-color 150ms ease; }
a:hover { color: var(--hover); }

.text-mono { font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: 0.02em; }
.text-small-caps { font-variant: small-caps; text-transform: lowercase; letter-spacing: 0.04em; font-weight: 500; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--space-lg); }
.container-narrow { max-width: 720px; }
.container-wide { max-width: 1400px; }

.hairline { height: 1px; background-color: var(--border-subtle); border: none; margin: var(--space-xl) 0; }

.skip-link { position: absolute; top: -100%; left: var(--space-md); z-index: 10000; padding: var(--space-sm) var(--space-md); background: var(--bg-surface); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.875rem; }
.skip-link:focus { top: var(--space-md); }

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

.img-archive { filter: grayscale(100%) contrast(1.05) brightness(0.95); }

.document-card { background: var(--bg-surface); border: 1px solid var(--border); padding: var(--space-xl); transition: border-color 300ms ease; }
.document-card:hover { border-color: var(--accent); }

.classification {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.25rem 0.5rem;
  display: inline-block;
}

.btn { display: inline-flex; align-items: center; gap: var(--space-xs); font-family: var(--font-mono); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; padding: var(--space-sm) var(--space-lg); border: 1px solid var(--border); background: transparent; color: var(--text-primary); cursor: pointer; transition: border-color 200ms ease, color 200ms ease; }
.btn:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); font-weight: 500; }
.btn-primary:hover { background: var(--text-primary); border-color: var(--text-primary); color: var(--bg-primary); }

input { font-family: var(--font-body); font-size: 1rem; padding: var(--space-sm) var(--space-md); background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-primary); width: 100%; transition: border-color 150ms ease; }
input:focus { border-color: var(--accent); outline: none; }
input::placeholder { color: var(--text-secondary); }

blockquote { font-family: var(--font-mono); font-size: 0.9375rem; line-height: 1.6; color: var(--text-secondary); border-left: 2px solid var(--border); padding-left: var(--space-lg); margin: var(--space-xl) 0; font-style: normal; }
blockquote cite { display: block; margin-top: var(--space-sm); font-size: 0.8125rem; color: var(--text-tertiary); font-style: normal; }

::selection { background: var(--accent); color: var(--bg-primary); }

/* ==== HEADER ==== */
.site-header { border-bottom: 1px solid var(--border-subtle); padding: var(--space-md) 0; position: sticky; top: 0; background: rgba(26, 29, 34, 0.92); backdrop-filter: blur(8px); z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); }
.wordmark { display: flex; flex-direction: column; gap: var(--space-xs); text-decoration: none; flex-shrink: 0; }
.wordmark:hover { color: var(--text-primary); }
.wordmark-line { display: block; width: 2rem; height: 1px; background: var(--accent); }
.wordmark-text { font-family: var(--font-display); font-weight: 500; font-size: 1rem; letter-spacing: 0.12em; color: var(--text-primary); line-height: 1; }

.site-nav { display: flex; gap: var(--space-xl); font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.site-nav a { color: var(--text-secondary); transition: color 150ms ease; position: relative; }
.site-nav a::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 1px; background: var(--accent); transition: width 250ms ease; }
.site-nav a:hover { color: var(--text-primary); }
.site-nav a:hover::after { width: 100%; }
.header-date { color: var(--text-tertiary); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; flex-shrink: 0; }

/* ==== FOOTER ==== */
.site-footer { border-top: 1px solid var(--border-subtle); padding: var(--space-3xl) 0 var(--space-xl); margin-top: var(--space-4xl); }
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2xl); }
.footer-col h3 { font-size: 0.75rem; color: var(--text-tertiary); margin-bottom: var(--space-md); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.footer-col ul { list-style: none; margin: 0; }
.footer-col li { margin-bottom: var(--space-xs); }
.footer-col a { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-secondary); }
.footer-col a:hover { color: var(--text-primary); }

.footer-tagline { color: var(--accent); margin-bottom: var(--space-sm); font-size: 0.6875rem; letter-spacing: 0.1em; }
.footer-sister { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: var(--space-sm); }
.footer-sister a { color: var(--text-secondary); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 0.2em; }
.footer-sister a:hover { color: var(--text-primary); text-decoration-color: var(--text-secondary); }
.footer-copyright { font-size: 0.6875rem; color: var(--text-tertiary); letter-spacing: 0.04em; }

/* ==== CATALOGUE ENTRIES — accent pulled back ==== */
.entry-number { color: var(--text-secondary); }
.section-num { color: var(--text-secondary); }
.source-key { color: var(--text-primary); font-weight: 500; }
.source-link { color: var(--text-secondary); border-bottom: 1px solid var(--border); padding-bottom: 0.1em; }
.source-link:hover { color: var(--text-primary); border-bottom-color: var(--text-secondary); }

/* TAG CHIPS — were unstyled in v1 */
.tag { display: inline-block; font-family: var(--font-mono); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); background: transparent; border: 1px solid var(--border-subtle); padding: 0.2rem 0.55rem; margin-right: 0.25rem; border-radius: 0; }

/* Filter chips */
.chip { font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.3rem 0.7rem; background: transparent; border: 1px solid var(--border-subtle); color: var(--text-secondary); cursor: pointer; transition: all 150ms ease; }
.chip.active { background: var(--bg-surface); border-color: var(--text-secondary); color: var(--text-primary); }
.chip:hover { border-color: var(--text-primary); color: var(--text-primary); }

.toggle-btn { font-family: var(--font-mono); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; padding: var(--space-xs) var(--space-md); background: transparent; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; transition: all 150ms ease; }
.toggle-btn.active { background: var(--bg-surface); color: var(--text-primary); border-color: var(--text-primary); }
.toggle-btn:hover { border-color: var(--text-primary); color: var(--text-primary); }

@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; gap: var(--space-md); }
  .site-nav { order: 3; width: 100%; gap: var(--space-md); font-size: 0.6875rem; overflow-x: auto; padding-bottom: var(--space-xs); }
  .header-date { display: none; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-xl); }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}


/* ============================================
   CRT TERMINAL FRAME — phosphor green overlay
   Used to wrap any episode image so it appears
   as if displayed on a 1970s-era intelligence
   terminal. Scanlines, drift, flicker, blink.
   ============================================ */

.crt-frame {
  position: relative;
  overflow: hidden;
  background: #050a04;
  border: 1px solid #1f2a18;
  isolation: isolate;
  /* Subtle outer glow as if the CRT casts light into the room */
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 0 32px rgba(159, 205, 142, 0.04);
}

.crt-frame > img,
.crt-frame.crt-frame > img,
.crt-frame > .crt-content {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Phosphor green CRT colour transform. Filter chain in order:
       1. contrast(1.35)  — spread the source luminance range
       2. url(#phosphor)  — map luminance to phosphor green
       3. drop-shadow     — phosphor bloom on bright pixels
       4. brightness(1.4) — overall tube brightness lift
     Works on any source image: photographs, document scans, illustrations. */
  filter:
    contrast(1.35)
    url(#phosphor)
    drop-shadow(0 0 1.5px rgba(159, 205, 142, 0.55))
    brightness(1.4);
  animation: crt-flicker 7.4s infinite;
}

/* Wisner photo is a tall portrait; anchor near the top so his head isn't cropped */
.crt-frame > img[src="img-wisner.jpg"] {
  object-position: center 15%;
}

/* Scanlines — fixed layer, slow vertical drift */
.crt-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.30) 0px,
    rgba(0, 0, 0, 0.30) 1px,
    transparent 1.5px,
    transparent 3px
  );
  animation: crt-drift 14s linear infinite;
}

/* Vignette + gentle inner phosphor glow */
.crt-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    radial-gradient(ellipse at center, rgba(159, 205, 142, 0.05) 0%, transparent 65%);
}

/* Cursor — blinks in the lower-right of every frame */
.crt-cursor {
  position: absolute;
  bottom: 10px;
  right: 12px;
  width: 7px;
  height: 11px;
  background: #9fcd8e;
  z-index: 4;
  pointer-events: none;
  animation: crt-cursor-blink 1.06s steps(2, end) infinite;
  box-shadow: 0 0 3px rgba(159, 205, 142, 0.5);
}

/* Hover: terminal "warms" slightly */
.crt-frame:hover > img,
.crt-frame.crt-frame:hover > img,
.crt-frame:hover > .crt-content {
  filter:
    contrast(1.35)
    url(#phosphor)
    drop-shadow(0 0 3px rgba(159, 205, 142, 0.65))
    brightness(1.55);
  transition: filter 500ms ease;
}

/* One-shot boot-up animation for the hero image */
.crt-frame.boot-up > img,
.crt-frame.boot-up > .crt-content {
  animation:
    crt-boot 1.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both,
    crt-flicker 7.4s 1.7s infinite;
}

@keyframes crt-boot {
  0%   { opacity: 0; filter: contrast(1.35) url(#phosphor) brightness(0); }
  20%  { opacity: 0.5; filter: contrast(1.35) url(#phosphor) brightness(2.0) drop-shadow(0 0 12px rgba(159, 205, 142, 0.6)); }
  60%  { opacity: 1; filter: contrast(1.35) url(#phosphor) brightness(1.6) drop-shadow(0 0 6px rgba(159, 205, 142, 0.45)); }
  100% { opacity: 1; filter: contrast(1.35) url(#phosphor) drop-shadow(0 0 1.5px rgba(159, 205, 142, 0.55)) brightness(1.4); }
}

/* Slow scanline drift — 14s for one row of cycles */
@keyframes crt-drift {
  0%   { background-position: 0 0; }
  100% { background-position: 0 12px; }
}

/* Subtle, infrequent flicker — mostly the image is steady */
@keyframes crt-flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.86; }
  94% { opacity: 1; }
  95% { opacity: 0.94; }
  96% { opacity: 1; }
}

/* Cursor blink */
@keyframes crt-cursor-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .crt-frame > img,
  .crt-frame > .crt-content,
  .crt-frame::before,
  .crt-cursor {
    animation: none !important;
  }
  .crt-frame.boot-up > img {
    animation: none !important;
    opacity: 1;
  }
}


