/* C0C00N Unified Chapter Framework - Color variables defined per chapter */

:root {
  /* Colors defined by each chapter - defaults to gold */
  --chapter-primary: #d4a000;
  --chapter-secondary: #c87000;
  --chapter-tertiary: #ffe066;
  --chapter-text: #d1d1d1;
  --cocoon-glitch: #2a1a00;
  --cocoon-gold: #d4a000;       /* fixed book color — never overridden by chapters */
  
  /* Character-specific colors — Book 1 carry-overs (brightened) + Book 2 cast */
  --architect-color: #33bbff;
  --ray-color: #ffffff;
  --marcus-color: #ff44ff;
  --sarah-color: #ff6680;
  --maya-color: #ffff44;
  /* Book 1 carry-overs */
  --melissa-color: #3dda5e;   /* was #2dba4e — brightened */
  --slug-color: #e8944e;      /* was #c87941 — brightened */
  /* Book 2 new cast */
  --merit-color: #90a83a;     /* muted olive — resistance, earthy */
  --mom-color: #c084fc;       /* swapped: soft violet — quiet, precise */
  --nina-color: #e8c97a;      /* swapped: warm amber-gold — grounded authority */
  --rook-color: #94b8d4;      /* steel blue — watchful, detached */
  /* C0c00n Book 2 NPCs */
  --edgar-color: #b8c93a;      /* dying fluorescent — Edgar */
  --maid-color: #7a8fa8;       /* muted steel blue — ornamental NLT staff */
  --nlt-color: #ff8c00;        /* NLT corporate orange — generic staff */
  /* Shared properties */
  --bg-dark: #050505;
  --border-dim: #444;
  --regular-color: #cfc8bf;
  --drunk-color: #d6c07a; /* sick amber for inebriated/rowdy NPCs */
}

/* ===== CORE LAYOUT ===== */
body, html {
  background: var(--bg-dark);
  color: var(--chapter-text);
  font-family: 'Courier New', Courier, monospace;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* CRT Scanlines - fixed overlay */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  z-index: 2;
  background-size: 100% 4px, 3px 100%;
  pointer-events: none;
}

/* Film grain overlay */
body::after {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    url('data:image/svg+xml;utf8,<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="1.5" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)"/></svg>');
  opacity: 0.06;
  pointer-events: none;
  z-index: 10001;
  mix-blend-mode: overlay;
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(212, 160, 0, 0.45);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(10, 7, 0, 0.88), rgba(22, 14, 0, 0.75));
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 18px rgba(212, 160, 0, 0.08);
}

header div {
  color: var(--chapter-primary);
  font-weight: bold;
  letter-spacing: 2px;
  font-size: 0.9rem;
  text-transform: uppercase;
  animation: headerGlitch 0.4s infinite;
}

nav a {
  color: var(--chapter-secondary);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: all 200ms ease;
  position: relative;
  display: inline-block;
}

nav a:hover {
  color: var(--chapter-primary);
  text-shadow: 0 0 12px var(--chapter-primary);
}

/* ===== CORPORATE LINK GLITCH STUB ===== */
/* Make corp links appear like normal text until hovered; hover triggers glitch overlay via JS */
a.corp-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  position: relative;
}

a.corp-link:hover {
  color: var(--chapter-accent);
  text-decoration: none;
  text-shadow: 0 0 6px var(--chapter-accent), 0 0 14px rgba(224, 64, 160, 0.45);
}

/* ===== VIEWPORT ===== */
main {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 0;
  position: relative;
  box-sizing: border-box;
  z-index: 2;
}

main > * { position: relative; z-index: 1; }

/* ===== TITLE ===== */
.chapter-title {
  color: var(--chapter-primary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 2.5rem;
  font-weight: bold;
  margin: 0 0 2rem 0;
  text-shadow: 0 0 16px var(--chapter-primary), 0 0 32px var(--chapter-primary);
  display: block;
  width: 100%;
  text-align: center;
  position: relative;
  animation: titleGlitch 600ms infinite;
}

/* Chromatic split pseudo-elements */
.chapter-title::before,
.chapter-title::after {
  content: attr(data-glitch);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.9;
}

.chapter-title::before {
  color: var(--chapter-secondary);
  mix-blend-mode: screen;
  animation: titleGlitchBefore 600ms infinite;
}

.chapter-title::after {
  color: var(--chapter-tertiary);
  mix-blend-mode: overlay;
  animation: titleGlitchAfter 600ms infinite;
}

@keyframes titleGlitch {
  0%   { transform: translate(0); }
  2%   { transform: translate(-2px, 1px); }
  4%   { transform: translate(0); }
  100% { transform: translate(0); }
}

@keyframes titleGlitchBefore {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0); }
  20%  { clip-path: inset(10% 0 85% 0); transform: translate(-4px, 4px); }
  40%  { clip-path: inset(0 0 0 0); transform: translate(0); }
  60%  { clip-path: inset(60% 0 25% 0); transform: translate(4px, -4px); }
  80%  { clip-path: inset(0 0 0 0); transform: translate(0); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

@keyframes titleGlitchAfter {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0); }
  15%  { clip-path: inset(80% 0 5% 0); transform: translate(3px, -3px); }
  35%  { clip-path: inset(0 0 0 0); transform: translate(0); }
  55%  { clip-path: inset(20% 0 70% 0); transform: translate(-3px, 2px); }
  75%  { clip-path: inset(0 0 0 0); transform: translate(0); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

@keyframes headerGlitch {
  0%   { opacity: 1; }
  98%  { opacity: 1; }
  99%  { opacity: 0.3; }
  100% { opacity: 1; }
}

/* ===== SCENE CONTAINER ===== */
.scene {
  max-width: 900px;
  margin: 0 auto 4rem;
  padding: 1.5rem;
  border-left: 3px solid var(--chapter-primary);
  background: rgba(212, 160, 0, 0.015);
}

[data-glitch] {
  position: relative;
}

/* ===== GLITCH OVERLAY (hover / spontaneous) ===== */
.maroon-glitch-overlay {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-block;
  white-space: nowrap;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
  font: inherit;
  line-height: inherit;
  color: inherit;
}

@keyframes glitch-flash {
  0%   { opacity: 1; transform: translate(0, 0); }
  15%  { opacity: 0.85; transform: translate(-3px, 1px); }
  30%  { opacity: 1; transform: translate(2px, -2px); }
  50%  { opacity: 0.7; transform: translate(-2px, 2px); }
  70%  { opacity: 1; transform: translate(3px, 0); }
  85%  { opacity: 0.9; transform: translate(-1px, 1px); }
  100% { opacity: 1; transform: translate(0, 0); }
}

.maroon-glitch-overlay.glitch {
  animation: glitch-flash 280ms linear;
  color: var(--cocoon-gold);
  text-shadow: 2px 0 #8b3a00, -2px 0 #ffe066;
}

/* ===== CONTENT ===== */
article {
  line-height: 1.85;
  font-size: 1.05rem;
  color: rgba(220, 220, 220, 0.92);
}

article p {
  margin: 0 0 1.4em 0;
}

/* ===== CHARACTER COLORS ===== */

/* — Book 1 carry-overs — */
.char-architect {
  color: var(--architect-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(51, 187, 255, 0.4);
}

.char-ray {
  color: var(--ray-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.char-marcus {
  color: var(--marcus-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 68, 255, 0.4);
}

.char-sarah {
  color: var(--sarah-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 102, 128, 0.4);
}

.char-maya {
  color: var(--maya-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 255, 68, 0.4);
}

.char-melissa {
  color: var(--melissa-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(61, 218, 94, 0.4);
}

.char-slug {
  color: var(--slug-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(232, 148, 78, 0.4);
}

/* Generic dialogue for ordinary people / NPCs */
.char-regular {
  color: var(--regular-color);
  font-weight: normal;
  text-shadow: 0 0 6px rgba(0,0,0,0.3);
}

/* Dialogue for a drunk/rowdy NPC */
.char-drunk {
  color: var(--drunk-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(214, 192, 122, 0.35);
}

/* Generic dialogue for ordinary NPCs / drunks */
.char-regular {
  color: var(--regular-color);
  font-weight: normal;
  text-shadow: 0 0 6px rgba(0,0,0,0.25);
}

/* — C0c00n NPCs — */
.char-edgar {
  color: var(--edgar-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(184, 201, 58, 0.22);
}

.char-maid {
  color: var(--maid-color);
  font-weight: bold;
  text-shadow: 0 0 6px rgba(122, 143, 168, 0.18);
}

.char-nlt {
  color: var(--nlt-color);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(255, 140, 0, 0.25);
}

/* — Book 2 new cast — */
.char-merit {
  color: var(--merit-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(144, 168, 58, 0.4);
}

.char-mom {
  color: var(--mom-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.4);
}

.char-nina {
  color: var(--nina-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(232, 201, 122, 0.4);
}

.char-rook {
  color: var(--rook-color);
  font-weight: bold;
  text-shadow: 0 0 8px rgba(148, 184, 212, 0.4);
}

.scene-change {
  text-align: center;
  margin: 30px 0 40px 0;
  color: var(--chapter-primary);
  font-weight: bold;
  letter-spacing: 4px;
  font-size: 1.1rem;
  display: inline-block;
  width: 100%;
  animation: titleGlitch 600ms infinite;
}

.center {
  text-align: center;
  margin: 1.8em 0;
}

/* ===== GLITCHING ARROW ===== */
.glitch-arrow {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 60px 0 0 0;
  font-size: 2.8rem;
  letter-spacing: 6px;
  color: var(--chapter-secondary);
  text-shadow: 0 0 10px var(--chapter-secondary);
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  width: 100%;
  animation: arrowConstantGlitch 200ms infinite;
}

/* Layout for chapter navigation arrows (pairs) */
.chapter-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 36px;
}

.chapter-nav .glitch-arrow {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 2.4rem;
}

.glitch-arrow::before,
.glitch-arrow::after {
  content: attr(data-glitch);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.glitch-arrow::before {
  color: var(--chapter-primary);
  z-index: -1;
  text-shadow: -4px 0 var(--chapter-primary), -8px 0 rgba(212, 160, 0, 0.6);
  animation: arrowGlitchBefore 180ms infinite;
}

.glitch-arrow::after {
  color: var(--chapter-tertiary);
  z-index: -2;
  text-shadow: 4px 0 var(--chapter-tertiary), 8px 0 rgba(255, 224, 102, 0.6);
  animation: arrowGlitchAfter 200ms infinite;
}

@keyframes arrowConstantGlitch {
  0% { transform: translate(0); color: var(--chapter-secondary); }
  14% { transform: translate(-3px, 0); }
  28% { transform: translate(3px, 0); }
  42% { transform: translate(-2px, 0); }
  56% { transform: translate(2px, 0); }
  70% { transform: translate(-1px, 0); }
  85% { transform: translate(1px, 0); }
  100% { transform: translate(0); color: var(--chapter-secondary); }
}

@keyframes arrowGlitchBefore {
  0% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
  18% { clip-path: inset(15% 0 80% 0); transform: translateX(-50%) skewX(-5deg); }
  36% { clip-path: inset(50% 0 40% 0); transform: translateX(-50%) skewX(5deg); }
  50% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
  68% { clip-path: inset(60% 0 30% 0); transform: translateX(-50%) skewX(-5deg); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
}

@keyframes arrowGlitchAfter {
  0% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
  20% { clip-path: inset(80% 0 15% 0); transform: translateX(-50%) skewX(5deg); }
  40% { clip-path: inset(35% 0 50% 0); transform: translateX(-50%) skewX(-5deg); }
  55% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
  72% { clip-path: inset(25% 0 65% 0); transform: translateX(-50%) skewX(5deg); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(-50%) skewX(0deg); }
}

.glitch-arrow:hover::before {
  filter: drop-shadow(0 0 10px var(--chapter-primary));
}

.glitch-arrow:hover::after {
  filter: drop-shadow(0 0 10px var(--chapter-tertiary));
}

.glitch-arrow.nuts {
  animation: arrowConstantGlitch 80ms infinite !important;
}

.glitch-arrow.nuts::before {
  animation: arrowGlitchBefore 70ms infinite !important;
}

.glitch-arrow.nuts::after {
  animation: arrowGlitchAfter 75ms infinite !important;
}

/* ===== FOOTER ===== */
footer {
  border-top: 1px solid rgba(127, 127, 127, 0.15);
  margin-top: 6rem;
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  z-index: 50;
  position: relative;
}

footer a {
  color: var(--chapter-secondary);
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 1.2px;
  transition: all 180ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

footer a:hover {
  color: var(--chapter-primary);
  text-shadow: 0 0 8px var(--chapter-primary);
}

.footer-mark,
.maroon-mark {
  font-weight: 900;
  letter-spacing: 2px;
  font-size: 1.6rem;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
  display: inline-block;
  position: relative;
}

.footer-sub {
  display: block;
  letter-spacing: 1px;
  color: #555;
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ===== LOCATION: EAST SIXTH COLLECTIVE ===== */
/* Old newspaper turned resistance safehouse — dim interior, grimy window light, mimeograph ink */
body[data-location="east-sixth"] {
  --chapter-primary: #7a9e7e;       /* faded resistance green */
  --chapter-secondary: #4a5e4c;     /* mimeograph-ink green */
  --chapter-accent: #a8bcaa;        /* worn leaflet grey-green */
  background: #2e3329;              /* dim interior — dark olive-grey, not system-black */
}

/* Faint cool grain */
body[data-location="east-sixth"]::before { display: none; }
body[data-location="east-sixth"]::after {
  display: block;
  opacity: 0.06 !important;
  mix-blend-mode: overlay !important;
}

body[data-location="east-sixth"] main {
  background: linear-gradient(180deg, rgba(52,58,46,0.97) 0%, rgba(44,50,38,0.98) 100%);
}

body[data-location="east-sixth"] .scene {
  border-left-color: rgba(100, 140, 100, 0.4);
  background: rgba(255,255,255,0.03);
}

body[data-location="east-sixth"] .scene p:not([class]) {
  color: #c2cab8; /* desaturated leaflet grey — readable on dark olive */
}

/* Column rule between scenes */
body[data-location="east-sixth"] .scene + .scene {
  border-top: 1px solid rgba(100, 130, 80, 0.12);
  padding-top: 0.5em;
}

/* ===== LOCATION: AUSTIN (Silicon Prairie Network State) ===== */
body[data-location="austin"] {
  --chapter-primary: #c8922a;
  --chapter-secondary: #8b5e1a;
  --chapter-accent: #e0b050;
  background: #0d0805;
}

body[data-location="austin"] main {
  background: radial-gradient(ellipse at 50% 0%, rgba(160, 98, 42, 0.06) 0%, transparent 65%);
}

body[data-location="austin"] .scene {
  border-left-color: #a0622a;
  background: rgba(160, 98, 42, 0.06);
}

body[data-location="austin"] .scene p:not([class]) {
  color: #b06030;
}

/* ===== LOCATION: THE PATCH — Sixth Street dive bar ===== */
body[data-location="the-patch"] {
  --chapter-primary: #4ade6a;        /* sick neon green — neon bleed through the cracks */
  --chapter-secondary: #2a9e48;      /* deeper smoked green */
  --chapter-accent: #e040a0;         /* neon pink — tracer fire accent */
  background: #1a0010;               /* deep bruised pink-black — bar darkness soaked in neon */
}

body[data-location="the-patch"]::after {
  display: block;
  opacity: 0.05 !important;
  mix-blend-mode: overlay !important;
}

body[data-location="the-patch"] main {
  background: radial-gradient(ellipse at 50% 0%, rgba(74, 222, 106, 0.04) 0%, transparent 60%);
}

body[data-location="the-patch"] .scene {
  border-left-color: rgba(74, 222, 106, 0.3);
  background: rgba(74, 222, 106, 0.02);
}

body[data-location="the-patch"] .scene p:not([class]) {
  color: #9ecfa8;  /* smoke-washed green-grey — readable, feels stained */
}

/* ===== LOCATION: EDGAR'S ELECTRONICS — dying fluorescent, salvaged tech junkyard ===== */
body[data-location="edgar-electronics"] {
  background: #041225;   /* deep navy — matches chapter bg-dark */
}

body[data-location="edgar-electronics"] main {
  background: radial-gradient(ellipse at 50% 0%, rgba(184,201,58,0.03) 0%, transparent 70%);
}

body[data-location="edgar-electronics"] .scene {
  border-left-color: rgba(184,201,58,0.25);   /* dying fluorescent green */
  background: rgba(184,201,58,0.012);
}

body[data-location="edgar-electronics"] .scene p:not([class]) {
  color: #e8f7ff;
}

body[data-location="edgar-electronics"] .char-edgar {
  color: #b8c93a;
  text-shadow: 0 0 8px rgba(184,201,58,0.22);
}

/* ===== LOCATION: NLT-HQ — Elias's corporate office, synth frame, metrics wall ===== */
/* Matches Mar00n nlt-hq: cream parchment, dark navy text — corporate authority */
body[data-location="nlt-hq"] {
  --chapter-primary: #1a3d6e;
  --chapter-secondary: #5070a0;
  --chapter-accent: #0a1528;
  background: #e8dcc8;
  color: #1a1e2e;
}

body[data-location="nlt-hq"] main {
  background: linear-gradient(180deg, #e0d4b8 0%, #e8dcc8 60%);
}

body[data-location="nlt-hq"] .scene {
  border-left-color: #a0b0cc;
  background: rgba(26,61,110,0.025);
}

body[data-location="nlt-hq"] .scene p:not([class]) {
  color: #2a2e3e;
}

body[data-location="nlt-hq"] .char-architect {
  color: #1a3d6e;
  text-shadow: none;
  font-weight: bold;
}

body[data-location="nlt-hq"] .char-maid {
  color: #6878a0;
  font-weight: bold;
  text-shadow: none;
}

body[data-location="nlt-hq"] .char-nlt {
  color: #7a5a3a;
  font-weight: 600;
  text-shadow: none;
}

body[data-location="nlt-hq"] .broadcast-text {
  color: #1a3d6e;
  text-shadow: none;
  opacity: 0.75;
}

body[data-location="nlt-hq"] .system-command code {
  background: rgba(0,255,102,0.08);
  border-color: rgba(0,200,80,0.3);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  main {
    padding: 40px 24px 0;
  }

  .chapter-title {
    font-size: 1.8rem;
  }

  article {
    font-size: 1rem;
  }

  nav a {
    margin-left: 10px;
    font-size: 0.65rem;
  }
}

/* In-body links inside scenes: keep paragraph color, remove underline */
.scene a.in-body-link,
.scene a.in-body-link:visited {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
  box-shadow: none;
}
.scene a.in-body-link:hover,
.scene a.in-body-link:active {
  color: inherit;
  text-decoration: none;
}


@media (max-width: 640px) {
  .glitch-arrow {
    font-size: 2.2rem;
    margin: 40px 0 0 0;
  }

  main {
    padding: 40px 18px 0;
  }

  .chapter-title {
    font-size: 1.6rem;
    margin-bottom: 30px;
  }

  article {
    font-size: 0.95rem;
    line-height: 1.75;
  }
}
