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

[hidden] { display: none !important; }

:root {
  --desk:        #19130c;   /* dark wood desk behind the file */
  --desk-2:      #241a10;
  --folder:      #c6a86a;   /* manila folder */
  --folder-edge: #a98947;
  --paper:       #e4d7b6;   /* aged dossier sheet */
  --paper-2:     #dccbA3;
  --ink:         #2a2118;   /* typed ink */
  --ink-soft:    #6a5b45;   /* faded ink */
  --ink-faint:   rgba(42, 33, 24, 0.22);
  --stamp-red:   #9e2b25;   /* SUSPECT / COMPROMISED */
  --cleared:     #4a5d4a;   /* one muted bottle-green */
  --radius: 2px;            /* paper has barely-there corners */
}

/* magnifying-glass cursor across the file */
body {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="13" cy="13" r="8.5" fill="none" stroke="%232a2118" stroke-width="2.4"/><circle cx="13" cy="13" r="8.5" fill="rgba(255,255,255,0.06)"/><line x1="19.5" y1="19.5" x2="28" y2="28" stroke="%232a2118" stroke-width="3.2" stroke-linecap="round"/></svg>') 13 13, auto;
  font-family: 'Courier Prime', 'Courier New', monospace;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 20%, var(--desk-2), var(--desk) 70%);
  min-height: 100vh;
  line-height: 1.55;
  padding: 2.5rem 1rem;
}

a, button, .btn { cursor: pointer; }

/* ── Atmosphere overlays ───────────────────────────────────────────────────── */

.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.06;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)"/></svg>');
}

.vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
}

/* ── The case file (manila folder) ─────────────────────────────────────────── */

.container {
  position: relative;
  max-width: 880px;
  margin: 0 auto;
  background:
    /* paper fibers */
    repeating-linear-gradient(90deg, rgba(42,33,24,0.018) 0 2px, transparent 2px 4px),
    linear-gradient(160deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid var(--folder-edge);
  border-radius: var(--radius);
  padding: 2.75rem 2.5rem 2.5rem;
  margin-top: 1.6rem;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 22px 50px -12px rgba(0,0,0,0.7),
    0 4px 14px rgba(0,0,0,0.4);
}

/* the protruding folder tab */
.folder-tab {
  position: absolute;
  top: -1.55rem; left: 2rem;
  background: linear-gradient(180deg, var(--folder), var(--folder-edge));
  color: #3a2c12;
  font-family: 'Special Elite', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  padding: 0.5rem 1.4rem 0.7rem;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.25);
}

/* the rotated rubber stamp on the file */
.file-stamp {
  position: absolute;
  top: 1.4rem; right: 1.2rem;
  font-family: 'Special Elite', monospace;
  font-size: 1rem;
  letter-spacing: 0.18em;
  color: var(--stamp-red);
  border: 3px solid var(--stamp-red);
  border-radius: 4px;
  padding: 0.25rem 0.7rem;
  transform: rotate(8deg);
  opacity: 0.72;
  mix-blend-mode: multiply;
  pointer-events: none;
  text-shadow: 0 0 1px rgba(158,43,37,0.4);
}

/* ── Header / masthead ─────────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.1rem;
  margin-bottom: 1.75rem;
  border-bottom: 2px solid var(--ink);
}

.logo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-family: 'Special Elite', monospace;
  font-size: 1.7rem;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.logo-dot {
  width: 11px; height: 11px;
  background: var(--stamp-red);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(158,43,37,0.18);
}

.logo-sub {
  flex-basis: 100%;
  font-family: 'Courier Prime', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.header-actions { display: flex; gap: 0.5rem; }

/* ── Login / setup ─────────────────────────────────────────────────────────── */

#view-login, #view-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56vh;
  text-align: center;
  gap: 1.4rem;
}

#view-login h1, #view-setup h1 {
  font-family: 'Special Elite', monospace;
  font-size: 2.6rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 1px 1px 0 rgba(42,33,24,0.12);
}

#view-login p, #view-setup p {
  color: var(--ink-soft);
  max-width: 460px;
}

.fine-print { font-size: 0.72rem !important; color: var(--ink-faint) !important; }

#view-setup pre {
  background: rgba(42,33,24,0.06);
  border: 1px dashed var(--ink-soft);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: left;
  font-size: 0.82rem;
  max-width: 480px;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ── Loading ───────────────────────────────────────────────────────────────── */

#view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56vh;
  gap: 1.5rem;
}

/* spinner restyled as a sweeping magnifier ring */
.spinner {
  width: 52px; height: 52px;
  border: 3px solid var(--ink-faint);
  border-top-color: var(--stamp-red);
  border-radius: 50%;
  position: relative;
  animation: spin 1s linear infinite;
}
.spinner::after {
  content: '';
  position: absolute;
  bottom: -10px; right: -10px;
  width: 18px; height: 3px;
  background: var(--ink);
  transform: rotate(45deg);
  transform-origin: left center;
  border-radius: 2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: 'Special Elite', monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ''; } 25% { content: '.'; }
  50% { content: '..'; } 75% { content: '...'; }
}

/* ── Results: investigating officer ────────────────────────────────────────── */

#user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}
#user-info::before {
  content: 'OFFICER';
  font-family: 'Special Elite', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 2px;
  object-fit: cover;
  filter: sepia(0.5) contrast(1.05);
  border: 1px solid var(--ink-soft);
}
.user-avatar.placeholder { background: rgba(42,33,24,0.12); }
.user-name { font-weight: 700; }

/* ── Verdict summary ───────────────────────────────────────────────────────── */

.summary-stat {
  position: relative;
  background: rgba(255,255,255,0.18);
  border: 1px solid var(--ink-faint);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  overflow: hidden;
}

.stat-num {
  font-family: 'Special Elite', monospace;
  font-size: 3.2rem;
  line-height: 1;
  color: var(--ink);
}
.has-ai .stat-num { color: var(--stamp-red); }
.clean  .stat-num { color: var(--cleared); }

.stat-label {
  color: var(--ink-soft);
  font-size: 0.92rem;
  flex: 1;
  min-width: 140px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-pct {
  font-family: 'Special Elite', monospace;
  font-size: 1.9rem;
  color: var(--ink-soft);
}

/* the slammed verdict rubber stamp */
.verdict-stamp {
  position: absolute;
  right: 1.2rem; top: 50%;
  font-family: 'Special Elite', monospace;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  padding: 0.2rem 0.7rem;
  border: 3px solid currentColor;
  border-radius: 4px;
  opacity: 0.78;
  mix-blend-mode: multiply;
  pointer-events: none;
  transform: translateY(-50%) rotate(-9deg) scale(1);
  animation: stamp 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.has-ai .verdict-stamp { color: var(--stamp-red); }
.clean  .verdict-stamp { color: var(--cleared); }

@keyframes stamp {
  0%   { transform: translateY(-50%) rotate(-9deg) scale(2.6); opacity: 0; }
  60%  { opacity: 0.78; }
  100% { transform: translateY(-50%) rotate(-9deg) scale(1);   opacity: 0.78; }
}

/* ── Section headers ───────────────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 2rem 0 1rem;
  font-family: 'Special Elite', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.section-header .dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-red   { background: var(--stamp-red); box-shadow: 0 0 0 3px rgba(158,43,37,0.18); }
.dot-green { background: var(--cleared);   box-shadow: 0 0 0 3px rgba(74,93,74,0.18); }
.section-rule { flex: 1; height: 0; border-top: 1px dashed var(--ink-soft); opacity: 0.5; }

/* ── Evidence cards ────────────────────────────────────────────────────────── */

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.7rem;
}

.track-card {
  position: relative;
  background: rgba(255,255,255,0.22);
  border: 1px solid var(--ink-faint);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: fade-in 0.35s ease both;
}
.track-card:hover {
  transform: translateY(-2px) rotate(-0.4deg);
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.4);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.album-art {
  width: 50px; height: 50px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
  filter: sepia(0.55) contrast(1.05) brightness(0.98);
  border: 1px solid var(--ink-soft);
}
.album-art.placeholder { background: rgba(42,33,24,0.12); }

.track-info { min-width: 0; }

.track-name {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
}

.track-artist {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SUSPECT / CLEARED badge stamps — randomly placed per card (see app.js) */
.badge-ai, .badge-clear {
  position: absolute;
  font-family: 'Special Elite', monospace;
  font-size: 0.92rem;
  letter-spacing: 0.1em;
  padding: 0.18em 0.55em;
  border: 2.5px solid currentColor;
  border-radius: 4px;
  mix-blend-mode: multiply;
  opacity: 0.82;
  pointer-events: none;
  z-index: 2;
}
.badge-ai    { color: var(--stamp-red); }
.badge-clear { color: var(--cleared); }

.empty-msg {
  color: var(--ink-soft);
  font-style: italic;
  padding: 0.9rem 0;
}

/* ── Buttons (typed labels) ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  font-family: 'Special Elite', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--ink);
  transition: transform 0.1s, background 0.15s, color 0.15s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--stamp-red); border-color: var(--stamp-red); }

.btn-ghost {
  font-size: 0.72rem;
  padding: 0.45rem 0.9rem;
  border-color: var(--ink-soft);
  color: var(--ink-soft);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ── Footer meta ───────────────────────────────────────────────────────────── */

.data-source-line {
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--ink-soft);
  font-size: 0.72rem;
  color: var(--ink-soft);
  line-height: 2;
}
.data-source-line a { color: var(--ink); text-decoration: underline; }

.case-meta { letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.68rem; }

/* redacted bars — the words are hidden under ink */
.redacted {
  color: transparent;
  background: var(--ink);
  border-radius: 1px;
  padding: 0 0.2em;
  user-select: none;
}

#error-msg {
  color: var(--stamp-red);
  margin-top: 1rem;
  font-size: 0.82rem;
  font-weight: 700;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  body { padding: 1.5rem 0.5rem; }
  .container { padding: 2.5rem 1.25rem 1.75rem; }
  .summary-stat { flex-direction: column; align-items: flex-start; }
  .verdict-stamp { position: static; transform: rotate(-6deg); margin-top: 0.5rem; }
  .stat-pct { display: none; }
  .file-stamp { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
