/* ═══════════════════════════════════════════════════════════════════════
   Flextstory · "Dossier 1999" — Unified Design System
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Tokens ─── */
:root {
  --ink:           #10030D;
  --ink-soft:      #1a0a16;
  --ink-deep:      #07020a;
  --ink-line:      rgba(16, 3, 13, 0.14);
  --ink-wash:      rgba(16, 3, 13, 0.045);

  --paper:         #f4ead8;
  --paper-light:   #faf2e3;
  --paper-edge:    #e0d4be;
  --white-pure:    #ffffff;

  --on-ink:        rgba(245, 240, 230, 0.92);
  --on-ink-mute:   rgba(245, 240, 230, 0.55);
  --on-paper:      #1a0a16;
  --on-paper-mute: rgba(26, 10, 22, 0.6);
  --muted:         #6b5e63;

  --rust:          #c44a2a;
  --rust-soft:     #d96d4c;
  --rust-deep:     #8d2d18;

  --status-on:     #00dc82;
  --status-on-soft: rgba(0, 220, 130, 0.14);
  --status-off:    #6a6a6a;

  --tape:          rgba(220, 195, 100, 0.62);
  --tape-edge:     rgba(180, 145, 70, 0.7);

  --font-ui:       'Mulish', 'Muli', -apple-system, system-ui, sans-serif;
  --font-body:     'Open Sans', -apple-system, system-ui, sans-serif;
  --font-mono:     'Courier Prime', 'Courier New', Courier, ui-monospace, monospace;
  --font-serif:    'Source Serif 4', 'Source Serif Pro', Georgia, serif;

  --header-h:      88px;
  --grid-max:      1400px;

  --ease:          cubic-bezier(.2, .7, .25, 1);
  --ease-soft:     cubic-bezier(.4, 0, .2, 1);
}

/* ─── Reset-lite ─── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth; background: #10030D; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--on-paper);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
  overflow-x: hidden;
}
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; }

/* ─── Grain ─── */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
  opacity: 0.07; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.0 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
}
.grain--dark { mix-blend-mode: screen; opacity: 0.09; }

/* ─── CRT ─── */
.crt::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0px, transparent 2px, rgba(0,0,0,0.18) 2px, rgba(0,0,0,0.18) 3px);
  pointer-events: none; z-index: 1; mix-blend-mode: multiply; opacity: 0.32;
}

/* ═══════ TYPOGRAPHY ═══════ */
.t-display {
  font-family: var(--font-ui); font-weight: 900;
  font-size: clamp(64px, 9vw, 168px); line-height: 0.86; letter-spacing: -0.038em;
}
.t-display em { font-style: italic; font-weight: 800; letter-spacing: -0.045em; }
.t-h1 { font-family: var(--font-ui); font-weight: 800; font-size: clamp(40px, 4.6vw, 72px); line-height: 0.94; letter-spacing: -0.025em; }
.t-h2 { font-family: var(--font-ui); font-weight: 800; font-size: clamp(28px, 2.6vw, 44px); line-height: 1.05; letter-spacing: -0.015em; }
.t-h3 { font-family: var(--font-ui); font-weight: 700; font-size: 22px; line-height: 1.2; letter-spacing: -0.005em; }
.t-deck { font-family: var(--font-body); font-weight: 300; font-size: 22px; line-height: 1.5; }
.t-body { font-family: var(--font-body); font-weight: 400; font-size: 16px; line-height: 1.65; }
.t-label { font-family: var(--font-ui); font-weight: 800; font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase; }
.t-evidence { font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }
.t-sequence { font-family: var(--font-ui); font-style: italic; font-weight: 800; font-size: clamp(80px, 14vw, 240px); line-height: 1; letter-spacing: -0.05em; }

/* ═══════ HEADER ═══════ */
.fs-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--paper-light);
  border-bottom: 1px solid var(--ink-line);
  display: flex; align-items: center;
  transition: background .3s var(--ease), border-color .3s var(--ease);
}
.fs-header--dark {
  background: rgba(7, 2, 10, 0.97);
  border-bottom: 1px solid rgba(245, 240, 230, 0.08);
}
.fs-header__inner {
  width: 100%; max-width: var(--grid-max);
  margin: 0 auto; padding: 0 32px;
  display: flex; align-items: center; gap: 40px;
}
.fs-header__logo {
  display: flex; align-items: center;
  height: 56px; flex-shrink: 0;
}
.fs-header__logo img { height: 48px; width: auto; }
.fs-header--dark .fs-header__logo img { filter: brightness(0) invert(1); }

/* ─── Nav ─── */
.fs-nav {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: center; gap: 28px;
  margin-left: auto;
}
.fs-nav__link {
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--on-paper); position: relative; padding: 6px 0;
  white-space: nowrap; transition: color .2s var(--ease);
}
.fs-header--dark .fs-nav__link { color: var(--on-ink); }
.fs-nav__link:hover { color: var(--rust); }
.fs-nav__link.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--rust);
}
.fs-nav__chevron::after { content: " ▾"; font-size: 9px; opacity: 0.6; letter-spacing: 0; }

/* ─── Dropdown ─── */
.fs-nav__item { position: relative; }
.fs-dropdown {
  display: none; position: absolute; top: calc(100% + 14px); left: -16px;
  min-width: 260px; background: var(--paper-light); border: 1px solid var(--ink-line);
  box-shadow: 0 16px 40px rgba(16,3,13,0.18), 0 4px 12px rgba(16,3,13,0.08);
  z-index: 200; padding: 8px 0;
}
.fs-header--dark .fs-dropdown { background: var(--ink-soft); border-color: rgba(245,240,230,0.1); }
.fs-nav__item.is-open .fs-dropdown { display: block; }
.fs-dropdown__link {
  display: block; padding: 9px 20px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--on-paper-mute); transition: all .15s var(--ease);
}
.fs-header--dark .fs-dropdown__link { color: var(--on-ink-mute); }
.fs-dropdown__link:hover { color: var(--rust); background: var(--ink-wash); padding-left: 26px; }
.fs-header--dark .fs-dropdown__link:hover { background: rgba(245,240,230,0.05); }
.fs-dropdown__sep { height: 1px; background: var(--ink-line); margin: 6px 16px; }
.fs-header--dark .fs-dropdown__sep { background: rgba(245,240,230,0.08); }
.fs-dropdown__arc {
  display: block; padding: 12px 20px 4px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--rust); font-weight: 700;
}

/* ─── CTA Buttons ─── */
.fs-btn {
  font-family: var(--font-ui); font-size: 11px; font-weight: 800;
  letter-spacing: 0.22em; text-transform: uppercase; padding: 10px 18px;
  display: inline-flex; align-items: center; gap: 10px;
  white-space: nowrap; border-radius: 0; border: 1.5px solid transparent;
  transition: all .2s var(--ease); cursor: pointer;
}
.fs-btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.fs-btn--primary:hover { background: var(--rust); border-color: var(--rust); color: var(--paper); }
.fs-btn--ghost { background: transparent; color: var(--on-paper); border-color: var(--ink); }
.fs-btn--ghost:hover { background: var(--ink); color: var(--paper); }
.fs-header--dark .fs-btn--ghost { color: var(--on-ink); border-color: rgba(245,240,230,0.4); }
.fs-header--dark .fs-btn--ghost:hover { background: var(--paper); color: var(--ink); }
.fs-btn--webtoon { background: var(--status-on); color: var(--ink); border-color: var(--status-on); }
.fs-btn--webtoon:hover { filter: brightness(.9); }
.fs-btn--lg { font-size: 13px; padding: 18px 32px; letter-spacing: 0.24em; }
.fs-btn--rust { background: var(--rust); color: var(--paper); border-color: var(--rust); }
.fs-btn--rust:hover { background: var(--rust-deep); border-color: var(--rust-deep); }

/* ─── Mobile hamburger ─── */
.fs-nav-toggle {
  display: none; flex-direction: column; gap: 5px; padding: 8px;
  background: transparent; cursor: pointer; margin-left: auto;
}
.fs-nav-toggle span {
  display: block; width: 24px; height: 2px;
  background: var(--on-paper); transition: all .3s var(--ease);
}
.fs-header--dark .fs-nav-toggle span { background: var(--on-ink); }
.fs-nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.fs-nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.fs-nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ═══════ FOOTER ═══════ */
.fs-footer {
  background: var(--ink); color: var(--on-ink-mute);
  position: relative; padding: 80px 0 36px;
  border-top: 1px solid rgba(245,240,230,0.06);
}
.fs-footer__inner { max-width: var(--grid-max); margin: 0 auto; padding: 0 32px; }
.fs-footer__top {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 56px; padding-bottom: 56px;
  border-bottom: 1px solid rgba(245,240,230,0.08);
}
.fs-footer__brand h4 {
  font-family: var(--font-ui); font-weight: 900; font-size: 30px;
  letter-spacing: -0.02em; color: var(--on-ink); margin: 0 0 12px;
}
.fs-footer__brand p {
  font-family: var(--font-body); font-size: 14px; line-height: 1.6;
  max-width: 36ch; margin: 0 0 24px; color: var(--on-ink-mute);
}
.fs-footer__col h5 {
  font-family: var(--font-ui); font-size: 11px; font-weight: 800;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--on-ink);
  margin: 0 0 16px;
}
.fs-footer__col ul { list-style: none; margin: 0; padding: 0; }
.fs-footer__col li { margin-bottom: 10px; }
.fs-footer__col a {
  color: var(--on-ink-mute); font-size: 14px; font-family: var(--font-body);
  transition: color .2s var(--ease);
}
.fs-footer__col a:hover { color: var(--rust-soft); }
.fs-footer__bottom {
  margin-top: 32px; display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--on-ink-mute);
}
.fs-footer__sig { display: flex; gap: 24px; align-items: center; }
.fs-footer__sig::before { content: "○"; color: var(--status-on); font-size: 8px; line-height: 1; }

/* ═══════ COMPONENTS ═══════ */

/* Status badge */
.fs-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-size: 10px; font-weight: 800;
  letter-spacing: 0.22em; text-transform: uppercase; padding: 5px 9px;
  background: var(--status-on-soft); color: var(--status-on); border-radius: 0;
}
.fs-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--status-on); }
.fs-status--off { background: rgba(120,120,120,0.18); color: #999; }
.fs-status--off::before { background: #999; }

/* Sticker */
.sticker {
  display: inline-block; background: var(--paper-light); border: 1px solid var(--paper-edge);
  padding: 6px 14px; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--on-paper);
  white-space: nowrap; box-shadow: 0 4px 10px rgba(16,3,13,0.12);
}
.sticker--ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.sticker--rust { background: var(--rust); border-color: var(--rust); color: var(--paper); }

/* Evidence card */
.evidence {
  background: var(--paper); border: 1px solid var(--paper-edge); position: relative;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 14px 28px rgba(16,3,13,0.18), 0 4px 8px rgba(16,3,13,0.08);
}
.evidence--ink { background: var(--ink-soft); border-color: rgba(245,240,230,0.08); color: var(--on-ink); }

/* Tape */
.tape {
  position: absolute; width: 78px; height: 22px;
  background: var(--tape);
  background-image: linear-gradient(90deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.05) 100%);
  border-top: 1px solid var(--tape-edge); border-bottom: 1px solid var(--tape-edge);
  pointer-events: none; z-index: 2; box-shadow: 0 2px 6px rgba(16,3,13,0.18);
}
.tape--tl { top: -8px; left: 24px; transform: rotate(-6deg); }
.tape--tr { top: -8px; right: 24px; transform: rotate(7deg); }

/* Polaroid */
.polaroid {
  background: var(--white-pure); padding: 12px 12px 56px; position: relative;
  box-shadow: 0 16px 36px rgba(16,3,13,0.34), 0 2px 6px rgba(16,3,13,0.12);
}
.polaroid__img { width: 100%; aspect-ratio: 4/5; object-fit: cover; background: var(--paper-edge); display: block; }
.polaroid__caption {
  position: absolute; bottom: 16px; left: 12px; right: 12px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.05em;
  color: #5a4838; text-align: center;
}

/* Redaction */
.redact { display: inline-block; background: var(--ink); color: var(--ink); padding: 0 6px; user-select: none; }

/* Rule */
.rule { border: 0; border-top: 1.5px solid var(--ink); margin: 0; }
.rule--mute { border-top-color: var(--ink-line); }

/* Section header */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); margin-bottom: 48px;
}
.section-head__title {
  font-family: var(--font-ui); font-weight: 900;
  font-size: clamp(32px, 3.4vw, 52px); line-height: 0.96; letter-spacing: -0.02em; margin: 0;
}
.section-head__title em { font-style: italic; font-weight: 800; }
.section-head__meta {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--on-paper-mute); text-align: right; flex-shrink: 0;
}

/* Progress bar */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 99; background: rgba(16,3,13,0.08); }
.progress__bar { height: 100%; background: var(--rust); width: 0%; transition: width 80ms linear; }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Container */
.container { max-width: var(--grid-max); margin: 0 auto; padding: 0 32px; width: 100%; }
.flow > * + * { margin-top: 1em; }

/* ═══════ CHAPTER CARD ═══════ */
.chap-card {
  flex: 0 0 320px; scroll-snap-align: start;
  background: var(--white-pure); color: var(--on-paper); position: relative;
  overflow: hidden; cursor: pointer; text-decoration: none;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  box-shadow: 0 4px 14px rgba(16,3,13,0.08);
}
.chap-card:hover { transform: translateY(-6px); box-shadow: 0 14px 36px rgba(16,3,13,0.18); }
.chap-card__img-wrap { aspect-ratio: 3/4; overflow: hidden; position: relative; }
.chap-card__img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.chap-card:hover .chap-card__img { transform: scale(1.05); }
.chap-card__overlay { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(16,3,13,0.88) 95%); }
.chap-card__index {
  position: absolute; top: 14px; left: 14px;
  font-family: var(--font-ui); font-style: italic; font-weight: 900;
  font-size: 52px; line-height: 1; color: rgba(245,240,230,0.92);
  letter-spacing: -0.04em; text-shadow: 0 4px 18px rgba(0,0,0,0.6);
}
.chap-card__status { position: absolute; top: 16px; right: 14px; }
.chap-card__body { position: absolute; bottom: 0; left: 0; right: 0; padding: 18px 20px 20px; color: var(--paper); }
.chap-card__arc { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(245,240,230,0.6); margin-bottom: 6px; }
.chap-card__label { font-family: var(--font-ui); font-weight: 800; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--rust-soft); margin-bottom: 6px; }
.chap-card__title { font-family: var(--font-ui); font-weight: 800; font-size: 18px; line-height: 1.1; margin: 0 0 10px; color: var(--paper); }
.chap-card__date { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(245,240,230,0.6); }

/* ═══════ COMIC READER (used in comic/ pages) ═══════ */
.immersive-overlay {
  display: none; position: fixed; inset: 0;
  background: #000; z-index: 9999;
  flex-direction: column; align-items: center; justify-content: center;
}
.immersive-overlay.active { display: flex; }
.immersive-container { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; position: relative; }
.immersive-comic-image { max-width: 98%; max-height: 85%; object-fit: contain; user-select: none; cursor: grab; transition: transform 0.2s ease; }
.immersive-comic-image:active { cursor: grabbing; }
.immersive-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px; background: rgba(0,0,0,0.7); z-index: 100; flex-wrap: wrap;
}
.immersive-btn {
  background: #1a0a16; color: var(--on-ink); border: 1px solid rgba(245,240,230,0.2);
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  transition: all .15s var(--ease); font-size: 20px;
}
.immersive-btn:hover { background: var(--rust); border-color: var(--rust); }
.immersive-close-btn {
  position: absolute; top: 20px; right: 20px;
  background: transparent; border: none; color: var(--on-ink);
  width: 60px; height: 60px; font-size: 48px;
  display: flex; align-items: center; justify-content: center; z-index: 101;
}
.immersive-page-indicator { color: var(--on-ink); font-size: 14px; font-weight: 600; min-width: 60px; text-align: center; }

.comic-reader-section { background: var(--ink); padding: 60px 0 80px; }
.comic-reader-section .container { max-width: 900px; }
.comic-page-title { font-family: var(--font-ui); font-weight: 800; font-size: 18px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-ink); margin-bottom: 24px; text-align: center; }
.comic-display { position: relative; }
.comic-page-image { width: 100%; height: auto; display: block; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.comic-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 28px;
}
.comic-header-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px;
}
.comic-btn, .comic-btn-top {
  background: transparent; border: 1.5px solid rgba(245,240,230,0.25); color: var(--on-ink);
  padding: 10px 16px; font-family: var(--font-ui); font-size: 11px; font-weight: 800;
  letter-spacing: 0.22em; text-transform: uppercase; transition: all .15s var(--ease);
  display: inline-flex; align-items: center; gap: 4px;
}
.comic-btn:hover, .comic-btn-top:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.page-indicator { font-family: var(--font-mono); font-size: 14px; color: var(--on-ink); padding: 0 16px; min-width: 80px; text-align: center; }
.btn-icon { font-size: 16px; }
.btn-text { display: none; }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 1024px) {
  .fs-footer__top { grid-template-columns: 1fr 1fr; gap: 40px; }
}

@media (max-width: 900px) {
  .fs-nav-toggle { display: flex; }
  .fs-nav {
    display: none; position: fixed; inset: var(--header-h) 0 0 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper-light); padding: 24px 32px; overflow-y: auto;
    z-index: 99; border-top: 1px solid var(--ink-line);
  }
  .fs-header--dark .fs-nav { background: var(--ink-soft); border-top-color: rgba(245,240,230,0.08); }
  .fs-nav.is-open { display: flex; }
  .fs-nav li { width: 100%; }
  .fs-nav__link { font-size: 14px; padding: 14px 0; display: block; border-bottom: 1px solid var(--ink-line); }
  .fs-header--dark .fs-nav__link { border-bottom-color: rgba(245,240,230,0.06); }
  .fs-btn { width: 100%; justify-content: center; margin-top: 8px; }
  .fs-dropdown { display: none !important; }
  .fs-nav__item--dropdown .fs-nav__link { pointer-events: none; }
  .container { padding: 0 20px; }
  .fs-footer__top { grid-template-columns: 1fr; gap: 32px; }
  .fs-footer__bottom { flex-direction: column; gap: 12px; text-align: center; }
}

@media (max-width: 480px) {
  :root { --header-h: 72px; }
  .fs-header__logo img { height: 36px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Page transitions — overlay noire
   ═══════════════════════════════════════════════════════════════════════ */

#fs-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  opacity: 1;
  pointer-events: all;
}
