/*
 * The Dulles Memo - Shared Styles
 * A noir conspiracy thriller in found-document form
 * v2 - fixed body flex removal
 */

@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Crimson+Pro:ital,wght@0,400;0,600;1,400&display=swap');

/* ============================================
   CSS Custom Properties (Color Palette)
   ============================================ */

:root {
  /* === Backgrounds === */
  --bg-void: #1a1a1a;                /* The darkness surrounding documents */
  --bg-paper-light: #f5f0e6;         /* Aged paper - light end */
  --bg-paper-dark: #e8e0d0;          /* Aged paper - dark end */

  /* === Text on Paper (cream backgrounds) === */
  --text-primary: #2a2a2a;           /* Main prose, body text */
  --text-heading: #1a1a1a;           /* Chapter titles, subject lines */
  --text-meta: #595959;              /* Document metadata, dates, file numbers */
  --text-hint: #4a4a4a;              /* Hints, captions, secondary info */

  /* === Text on Dark Backgrounds === */
  --text-on-dark-primary: #cccccc;   /* Primary text on void */
  --text-on-dark-secondary: #9a9a9a; /* Subtitles, secondary headings */
  --text-on-dark-tertiary: #8a8a8a;  /* Descriptions, author blocks */
  --text-on-dark-ghost: #7a7a7a;     /* Scroll hints, barely-there text */

  /* === Agency Classification Colors === */
  --cia-red: #8b0000;                /* CIA - blood red */
  --cia-olive: #3d4f22;              /* CIA/Army olive - darkened for contrast */
  --cia-olive-light: #556b2f;        /* Original olive for accents */
  --fbi-blue: #1a3a6e;               /* FBI blue */
  --dpd-green: #2d4a2d;              /* Dallas PD green */
  --navy-blue: #1e3a5f;              /* Military/Pentagon */
  --medical-gray: #2d3e50;           /* Autopsy/medical documents */
  --corporate-slate: #2c3e50;        /* Actuarial/legal documents */

  /* === Warning/Alert Colors === */
  --warning-gold: #d4a500;           /* Warning headers, flags */
  --warning-yellow: #d4a500;         /* Alias for warning-gold */
  --alert-red: #c0392b;              /* Critical alerts */

  /* === Borders === */
  --border-dark: #333;               /* Borders on dark backgrounds */

  /* === Annotation Colors === */
  --cdj-red: #8b0000;                /* CDJ margin annotations - red ink */
  --cdj-sepia: #6b4423;              /* Alternative: aged sepia ink */

  /* === Redaction Colors === */
  --redacted-bg: #1a1a1a;            /* Hidden state */
  --redacted-reveal: #8b0000;        /* Revealed state - default red */
  --redacted-reveal-olive: #556b2f;  /* Revealed state - for olive docs */

  /* === Typography === */
  --font-typewriter: 'Special Elite', monospace;
  --font-prose: 'Crimson Pro', Georgia, serif;
  --font-data: 'Courier Prime', monospace;
}


/* ============================================
   Base Styles
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-void);
  min-height: 100vh;
  font-family: var(--font-prose);
}


/* ============================================
   Document Container
   ============================================ */

.document-container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}


/* ============================================
   Classification Headers & Footers
   ============================================ */

.classification-header {
  background: var(--cia-red);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-family: var(--font-typewriter);
  letter-spacing: 4px;
  font-size: 14px;
  margin-bottom: 0;
}

.classification-header.olive,
.classification-header.cia-olive {
  background: var(--cia-olive);
}

.classification-header.fbi {
  background: var(--fbi-blue);
}

.classification-header.dpd {
  background: var(--dpd-green);
}

.classification-header.navy {
  background: var(--navy-blue);
}

.classification-header.medical {
  background: var(--medical-gray);
}

.footer-class {
  background: var(--cia-red);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-family: var(--font-typewriter);
  letter-spacing: 4px;
  font-size: 12px;
}


/* ============================================
   Document (Paper) Styling
   ============================================ */

.document {
  background: linear-gradient(135deg, var(--bg-paper-light) 0%, var(--bg-paper-dark) 100%);
  padding: 50px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  position: relative;
}

/* Paper texture overlay */
.document::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 1;
}


/* ============================================
   Typography
   ============================================ */

p {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: justify;
}

.chapter-num {
  font-family: var(--font-typewriter);
  font-size: 12px;
  color: var(--cia-red);
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.chapter-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 25px;
  font-style: italic;
}


/* ============================================
   Document Header
   ============================================ */

.doc-header {
  border-bottom: 2px solid #333;
  padding-bottom: 20px;
  margin-bottom: 30px;
}

.doc-title {
  font-family: var(--font-typewriter);
  font-size: 13px;
  color: #444;
  margin-bottom: 10px;
}

.doc-subject {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 5px;
}

.doc-meta {
  font-family: var(--font-typewriter);
  font-size: 12px;
  color: var(--text-meta);
}


/* ============================================
   Redactions
   ============================================ */

.redacted {
  background: var(--redacted-bg);
  color: var(--redacted-bg);
  padding: 0 4px;
  border-radius: 2px;
  user-select: none;
  cursor: help;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.redacted.revealed {
  background: var(--redacted-reveal);
  color: #fff;
  outline: none;
}

/* Desktop: hover to reveal */
@media (hover: hover) and (pointer: fine) {
  .redacted:hover,
  .redacted:focus {
    background: var(--redacted-reveal);
    color: #fff;
    outline: none;
  }
}

/* Olive variant for CIA/Army documents */
.redacted-olive.revealed,
.document-olive .redacted.revealed {
  background: var(--redacted-reveal-olive);
}

@media (hover: hover) and (pointer: fine) {
  .redacted-olive:hover,
  .redacted-olive:focus,
  .document-olive .redacted:hover,
  .document-olive .redacted:focus {
    background: var(--redacted-reveal-olive);
    color: #fff;
  }
}


/* ============================================
   Section Breaks
   ============================================ */

.ellroy-break {
  text-align: center;
  margin: 30px 0;
  font-family: var(--font-typewriter);
  color: var(--cia-red);
  letter-spacing: 8px;
}


/* ============================================
   CDJ Margin Annotations
   ============================================ */

.margin-annotation {
  background: var(--bg-void);
  color: var(--text-on-dark-secondary);
  padding: 20px 25px;
  margin: 25px 0;
  font-family: var(--font-prose);
  font-size: 15px;
  font-style: italic;
  line-height: 1.7;
  border-left: 3px solid var(--cdj-red);
}

.margin-annotation em {
  color: var(--text-on-dark-primary);
}


/* ============================================
   Annotation (Editor's Notes)
   ============================================ */

.annotation {
  background: rgba(0,0,0,0.03);
  border-left: 3px solid var(--cia-red);
  padding: 20px;
  margin: 25px 0;
  font-style: italic;
  color: var(--text-meta);
}


/* ============================================
   Hints
   ============================================ */

.hint {
  text-align: center;
  font-family: var(--font-typewriter);
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 30px;
  letter-spacing: 2px;
}


/* ============================================
   Dialogue
   ============================================ */

.dialogue {
  margin: 25px 0;
  padding-left: 10px;
}

.dialogue .speaker {
  font-family: var(--font-typewriter);
  font-size: 12px;
  color: var(--cia-red);
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.dialogue .speech {
  font-size: 16px;
  font-style: italic;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 15px;
}


/* ============================================
   Document Boxes (FBI, CIA, Surveillance)
   ============================================ */

.memo-box,
.surveillance-box {
  background: #fff;
  border: 1px solid #333;
  padding: 20px;
  margin: 25px 0;
  font-family: var(--font-typewriter);
  font-size: 12px;
  line-height: 1.9;
  position: relative;
}

.surveillance-header,
.memo-header {
  background: #333;
  color: #fff;
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 2px;
  margin: -20px -20px 15px -20px;
}

.surveillance-box p,
.memo-box p {
  font-family: var(--font-typewriter);
  font-size: 12px;
  text-align: left;
  margin-bottom: 12px;
  line-height: 1.8;
}

.transcript-line {
  display: block;
  margin-bottom: 10px;
  padding-left: 15px;
  text-indent: -15px;
}

.fbi-box {
  background: #f8f5e6;
  border: 2px solid var(--fbi-blue);
  padding: 20px;
  margin: 25px 0;
  font-family: var(--font-typewriter);
  font-size: 12px;
  line-height: 1.9;
}

.fbi-header {
  background: var(--fbi-blue);
  color: #fff;
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 2px;
  margin: -20px -20px 15px -20px;
  display: flex;
  justify-content: space-between;
}

.fbi-box p {
  font-family: var(--font-typewriter);
  font-size: 12px;
  text-align: left;
  margin-bottom: 12px;
}

.cia-box {
  background: rgba(139, 0, 0, 0.06);
  border: 1px solid var(--cia-red);
  padding: 20px;
  margin: 25px 0;
  font-family: var(--font-typewriter);
  font-size: 12px;
  line-height: 1.9;
}

.cia-header {
  background: var(--cia-red);
  color: #fff;
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 2px;
  margin: -20px -20px 15px -20px;
}

.cia-box p {
  font-family: var(--font-typewriter);
  font-size: 12px;
  text-align: left;
  margin-bottom: 12px;
}


/* ============================================
   Location & Timeline Stamps
   ============================================ */

.location-stamp {
  font-family: var(--font-typewriter);
  font-size: 11px;
  color: var(--text-meta);
  text-align: center;
  margin: 30px 0;
  letter-spacing: 2px;
}

.timeline-note {
  font-family: var(--font-typewriter);
  font-size: 10px;
  color: #999;
  text-align: right;
  margin-top: -15px;
  margin-bottom: 20px;
}


/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 600px) {
  .document {
    padding: 30px 20px;
  }

  p {
    font-size: 16px;
  }

  .chapter-title {
    font-size: 18px;
  }
}


/* ============================================
   High Contrast Mode (WCAG AAA)
   Toggle via Alt+Shift+C or footer button
   ============================================ */

body.high-contrast {
  /* Deeper void for maximum contrast */
  --bg-void: #0a0a0a;

  /* Text on dark: all AAA compliant (7:1+) */
  --text-on-dark-primary: #ffffff;     /* 21:1 */
  --text-on-dark-secondary: #e0e0e0;   /* 14.9:1 */
  --text-on-dark-tertiary: #d0d0d0;    /* 12.6:1 */
  --text-on-dark-ghost: #c0c0c0;       /* 10.7:1 */

  /* Paper: maximum contrast */
  --bg-paper-light: #ffffff;
  --bg-paper-dark: #f5f5f5;
  --text-primary: #000000;
  --text-heading: #000000;
  --text-meta: #333333;
  --text-hint: #444444;

  /* Agency colors: lightened for AAA on dark backgrounds */
  --cia-red: #ff6b6b;                  /* 7.2:1 on #0a0a0a */
  --cia-olive: #8fbc8f;                /* 8.5:1 - dark sea green */
  --fbi-blue: #6db3f2;                 /* 7.8:1 */
  --warning-gold: #ffd700;             /* 12.8:1 */

  /* Redactions: visible affordance */
  --redacted-bg: #000000;
  --redacted-reveal: #ff6b6b;

  /* Borders */
  --border-dark: #555;

  /* Focus indicators */
  --focus-ring: #ffcc00;
}

/* High contrast: redactions */
body.high-contrast .redacted.revealed,
body.high-contrast .redacted:hover,
body.high-contrast .redacted:focus {
  background: var(--redacted-reveal);
  color: #000000;
}

/* High contrast: document borders more defined */
body.high-contrast .document {
  border: 2px solid #000000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

/* High contrast: classification headers */
body.high-contrast .classification-header,
body.high-contrast .footer-class {
  background: var(--cia-red);
  color: #000000;
  font-weight: bold;
}

body.high-contrast .classification-header.olive,
body.high-contrast .classification-header.cia-olive {
  background: var(--cia-olive);
  color: #000000;
}

body.high-contrast .classification-header.fbi {
  background: var(--fbi-blue);
  color: #000000;
}

/* High contrast: margin annotations */
body.high-contrast .margin-annotation {
  border-left: 4px solid var(--cia-red);
}


/* ============================================
   Contrast Toggle Button
   ============================================ */

.contrast-toggle {
  font-family: var(--font-typewriter);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: transparent;
  border: 1px dashed var(--text-on-dark-ghost);
  color: var(--text-on-dark-ghost);
  padding: 6px 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.contrast-toggle:hover,
.contrast-toggle:focus {
  opacity: 1;
  border-style: solid;
  color: var(--text-on-dark-secondary);
  border-color: var(--text-on-dark-secondary);
}

body.high-contrast .contrast-toggle {
  border-color: var(--focus-ring);
  color: var(--focus-ring);
  opacity: 1;
}


/* ============================================
   Screen Reader Only
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
