/* ============================================================
   Dossier v4 — stage-driven FBI subject dossier
   All selectors scoped under #dossierV4Overlay to avoid any
   collision with other systems' CSS (metric-bar, folder-tab, etc.)
   ============================================================ */

#dossierV4Overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 50, 56, 0.92);
  z-index: 999999;
  overflow-y: auto;
  display: none;
  font-family: 'Courier New', Courier, monospace;
}
#dossierV4Overlay.open { display: block; }

#dossierV4Overlay .dv4-stage {
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
  /* P2-13 belt: whatever inside still refuses to wrap gets
     clipped by the paper edge, never a page-wide scrollbar. */
  overflow-x: hidden;
}

/* P2-13 — narrow windows: the identity grid's fixed 180px photo
   column plus 2rem gutters overflowed the shrunken paper. */
@media (max-width: 860px) {
  #dossierV4Overlay .pg { grid-template-columns: 130px 1fr; gap: 1rem; }
  #dossierV4Overlay .photo-frame { width: 130px; height: 160px; }
  #dossierV4Overlay .dossier-tab-content { padding: 1rem 1.2rem; }
  #dossierV4Overlay .dossier-tabs,
  #dossierV4Overlay .folder-tabs { padding: 0 1.2rem; }
  #dossierV4Overlay .fl { min-width: 84px; }
}

/* ── Defensive reset ─────────────────────────────────────────
   Other stylesheets (dossier-style.css, fbi-document-style.css,
   betting/property/house-management) define generic class names
   that collide with v4's chrome — e.g. a plain `.folder-tab` with
   `position:absolute`. Those leak in for any property v4 doesn't
   explicitly set, which made the PROFILE/SURVEILLANCE/FILES tabs
   stack on top of each other. This neutralises the leak; every
   v4 rule below is `#dossierV4Overlay .class` (specificity 1,1,0)
   and beats this `#dossierV4Overlay *` reset (1,0,0), so intended
   styles re-apply normally. */
#dossierV4Overlay * {
  position: static;
  float: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  top: auto; right: auto; bottom: auto; left: auto;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes dv4CardReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dv4StampPress {
  0%   { opacity: 0; transform: rotate(12deg) scale(1.6); }
  60%  { opacity: 0.85; transform: rotate(7deg) scale(0.95); }
  100% { opacity: 0.7; transform: rotate(8deg) scale(1); }
}

/* ── Document shell ─────────────────────────────────────── */
#dossierV4Overlay .dossier-document {
  background: #EBE6D8;
  border: 1px solid #8E7F7F;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  position: relative;
  padding-top: 2.5rem;
  opacity: 0;
  animation: dv4CardReveal 0.4s ease-out forwards;
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 28px,
    rgba(142,127,127,0.04) 28px, rgba(142,127,127,0.04) 29px);
}

#dossierV4Overlay .corner-stamp {
  position: absolute;
  top: 1rem; right: 1.5rem;
  border: 2px solid #8B0000;
  color: #8B0000;
  padding: 0.3rem 0.7rem;
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 2px;
  animation: dv4StampPress 0.6s ease-out forwards;
}

/* ── Person tabs (top) ──────────────────────────────────── */
#dossierV4Overlay .dossier-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 2rem;
}
#dossierV4Overlay .dossier-person-tab {
  padding: 0.4rem 1.2rem;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 2px;
  border: 1px solid #8E7F7F;
  border-bottom: none;
  background: #D4C8BE;
  color: #3A3238;
  cursor: pointer;
  position: relative;
  top: 1px;
}
#dossierV4Overlay .dossier-person-tab.active {
  background: #EBE6D8;
  border-bottom: 1px solid #EBE6D8;
  z-index: 1;
}
#dossierV4Overlay .dossier-person-tab.locked {
  color: #8E7F7F;
  font-style: italic;
  cursor: default;
  background: #C9BEB2;
}

/* ── Header ─────────────────────────────────────────────── */
#dossierV4Overlay .header-section {
  text-align: center;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px dashed #8E7F7F;
  background: rgba(212,200,190,0.4);
}
#dossierV4Overlay .classified-banner {
  background: #8B0000;
  color: #EBE6D8;
  padding: 0.3rem 1rem;
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 3px;
  font-weight: bold;
  margin-bottom: 0.8rem;
}
#dossierV4Overlay .page-title {
  margin: 0.3rem 0;
  font-size: 1.6rem;
  color: #3A3238;
  letter-spacing: 4px;
}
#dossierV4Overlay .page-subtitle {
  font-size: 0.75rem;
  color: #8B0000;
  letter-spacing: 3px;
  font-weight: bold;
}

/* ── Folder tabs (PROFILE / SURVEILLANCE / FILES) ───────── */
#dossierV4Overlay .folder-tabs {
  display: flex;
  border-bottom: 2px solid #8E7F7F;
  padding: 0 2rem;
  background: rgba(212,200,190,0.2);
}
#dossierV4Overlay .folder-tab {
  padding: 0.8rem 1.5rem;
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #8E7F7F;
  transition: all 0.2s;
}
#dossierV4Overlay .folder-tab:hover { color: #3A3238; }
#dossierV4Overlay .folder-tab.active {
  color: #3A3238;
  border-bottom-color: #8B0000;
}

#dossierV4Overlay .dossier-tab-content { display: none; padding: 1.5rem 2rem; }
#dossierV4Overlay .dossier-tab-content.active { display: block; }

/* ── Profile header (photo + identity) ──────────────────── */
#dossierV4Overlay .pg {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
#dossierV4Overlay .pb {
  width: 180px; height: 220px;
  position: relative;
  border: 1px solid #8E7F7F;
  background: repeating-linear-gradient(45deg, #5F5449, #5F5449 8px, #4a4240 8px, #4a4240 16px);
  display: flex; align-items: center; justify-content: center;
  color: #EBE6D8; font-size: 0.65rem; letter-spacing: 2px;
  text-align: center; line-height: 1.8;
  box-shadow: 2px 3px 6px rgba(0,0,0,0.25);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
/* Hover — the clipped photo lifts off the page, inviting a closer look */
#dossierV4Overlay .pb.has-photo:hover {
  transform: translateY(-6px) rotate(-1.6deg);
  box-shadow: 5px 10px 20px rgba(0,0,0,0.45);
}
#dossierV4Overlay .pb img {
  width: 100%; height: 100%;
  object-fit: cover;
  cursor: pointer;
  /* Aged FBI case-file look — desaturated, warm, slightly contrasty.
     Tweak the four values to taste. */
  filter: grayscale(42%) sepia(30%) contrast(1.08) brightness(0.96);
}
/* "CLOSER LOOK" hint — fades in over the photo on hover */
#dossierV4Overlay .pb-hint {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(58,50,56,0.88);
  color: #EBE6D8;
  font-size: 0.58rem;
  font-weight: bold;
  letter-spacing: 3px;
  text-align: center;
  padding: 5px 0;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
#dossierV4Overlay .pb.has-photo:hover .pb-hint { opacity: 1; }

/* ── Photo lightbox — click a dossier photo to view it full size ──── */
#dossierV4Lightbox {
  position: fixed;
  inset: 0;
  /* ABOVE every window that can open it. It used to sit at
     1000001 — under the Subjects Archive at 1500000 — so a photo
     opened from the gallery rendered BEHIND the gallery and only
     appeared once the gallery was closed on top of it. */
  z-index: 1600000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 16, 18, 0.93);
  cursor: pointer;
}
#dossierV4Lightbox.open {
  display: flex;
  animation: dv4LbFade 0.18s ease;
}
#dossierV4Lightbox img {
  /* The game runs at zoom:1.25 and Chrome multiplies vh/vw by the
     zoom — 86vh was rendering at 107% of the window, so a tall
     photo hung off the top and bottom of the screen. --vh100 /
     --vw100 are the pre-divided units the rest of the game already
     uses for anything that has to FIT the window. */
  max-width: calc(var(--vw100, 100vw) * 0.86);
  max-height: calc(var(--vh100, 100vh) * 0.86);
  object-fit: contain;
  border: 3px solid #8E7F7F;
  background: #3A3238;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75);
}
/* The photo "comes out of the paper clip" — unpins, rotates, settles */
#dossierV4Lightbox.open img {
  animation: dv4PhotoUnpin 0.44s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes dv4LbFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dv4PhotoUnpin {
  0%   { opacity: 0; transform: scale(0.55) rotate(-9deg); }
  70%  { opacity: 1; transform: scale(1.04) rotate(1.6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* Paper clip clamped on the top edge of the subject photo.
   Drawn entirely in CSS via two stacked loops — no image asset. */
#dossierV4Overlay .pb.has-photo::before,
#dossierV4Overlay .pb.has-photo::after {
  content: "";
  position: absolute;
  z-index: 4;
  border-style: solid;
  border-color: #9b9389;
}
#dossierV4Overlay .pb.has-photo::before {
  top: -11px; left: 24px;
  width: 19px; height: 46px;
  border-width: 3px;
  border-radius: 10px;
  filter: drop-shadow(0.5px 1px 1px rgba(0,0,0,0.22));
}
#dossierV4Overlay .pb.has-photo::after {
  top: -4px; left: 30px;
  width: 7px; height: 30px;
  border-width: 3px;
  border-radius: 5px;
}
#dossierV4Overlay .pn {
  font-size: 1.3rem; font-weight: bold; color: #3A3238;
  letter-spacing: 2px; margin-bottom: 0.3rem;
}
#dossierV4Overlay .pa {
  font-size: 0.75rem; color: #8B0000; font-style: italic; margin-bottom: 0.8rem;
}
#dossierV4Overlay .fr {
  display: flex; gap: 0.8rem; padding: 0.3rem 0;
  font-size: 0.82rem; border-bottom: 1px dotted rgba(142,127,127,0.3);
}
#dossierV4Overlay .fl {
  color: #8E7F7F; font-weight: bold; letter-spacing: 1px;
  min-width: 110px; text-transform: uppercase; font-size: 0.7rem;
}
#dossierV4Overlay .fv { color: #3A3238; }

/* ── Section heading ────────────────────────────────────── */
#dossierV4Overlay hr.d { border: none; border-top: 1px dashed #8E7F7F; margin: 1.5rem 0; }
#dossierV4Overlay .st {
  font-size: 0.85rem; font-weight: bold; color: #3A3238;
  letter-spacing: 3px; text-transform: uppercase; margin-bottom: 0.8rem;
}
#dossierV4Overlay .em {
  color: #8E7F7F; font-style: italic; font-size: 0.8rem;
  padding: 0.5rem 0; letter-spacing: 1px;
}

/* ── Redacted bar ───────────────────────────────────────── */
#dossierV4Overlay .r {
  background: #3A3238; color: #3A3238;
  padding: 0 0.2rem; user-select: none;
  /* QA P2-13 — a redaction is one unbroken run of █: the browser
     treats it as a single 1400px word and the whole modal grows a
     horizontal scrollbar. Redactions are allowed to break. */
  word-break: break-all;
}

/* ── Background paragraphs ──────────────────────────────── */
#dossierV4Overlay .bp {
  font-size: 0.82rem; line-height: 1.65; color: #3A3238; margin-bottom: 0.7rem;
}

/* ── Boxed lists (associations / tells / requirements) ──── */
#dossierV4Overlay .bx { border: 1px solid rgba(142,127,127,0.3); margin-bottom: 1rem; }
#dossierV4Overlay .bxh {
  background: rgba(142,127,127,0.15);
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid rgba(142,127,127,0.3);
  font-size: 0.65rem; font-weight: bold; color: #3A3238; letter-spacing: 2px;
}
#dossierV4Overlay .bxb { padding: 0.5rem 0.7rem; }
#dossierV4Overlay .e {
  padding: 0.35rem 0;
  border-bottom: 1px dotted rgba(142,127,127,0.2);
  font-size: 0.8rem; line-height: 1.5; color: #3A3238;
}
#dossierV4Overlay .e:last-child { border-bottom: none; }
#dossierV4Overlay .el {
  font-size: 0.6rem; color: #8E7F7F; letter-spacing: 1px;
  text-transform: uppercase; font-weight: bold; margin-bottom: 0.1rem;
}

/* ── Requirement tags ───────────────────────────────────── */
#dossierV4Overlay .rt { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
#dossierV4Overlay .t {
  font-size: 0.58rem; font-weight: bold; letter-spacing: 1.5px;
  padding: 0.12rem 0.4rem; border: 1px solid; text-transform: uppercase;
}
#dossierV4Overlay .tm { color: #4a5d4a; border-color: #4a5d4a; background: rgba(74,93,74,0.12); }
#dossierV4Overlay .tu { color: #8E7F7F; border-color: rgba(142,127,127,0.4); background: rgba(142,127,127,0.08); }
#dossierV4Overlay .tf { color: #8B0000; border-color: rgba(139,0,0,0.35); background: rgba(139,0,0,0.06); }
#dossierV4Overlay .tr { color: #6b6040; border-color: rgba(107,96,64,0.5); background: rgba(196,168,122,0.12); font-style: italic; }

/* ── Metric bars ────────────────────────────────────────── */
#dossierV4Overlay .mg { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
#dossierV4Overlay .m { margin-bottom: 0.8rem; }
#dossierV4Overlay .ml { font-size: 0.6rem; color: #8E7F7F; letter-spacing: 2px; font-weight: bold; }
#dossierV4Overlay .mv { font-size: 0.75rem; color: #3A3238; font-weight: bold; margin: 0.15rem 0; }
#dossierV4Overlay .mb {
  height: 12px; width: 100%;
  background: rgba(142,127,127,0.15); border: 1px solid #8E7F7F; position: relative;
}
#dossierV4Overlay .mf { height: 100%; position: absolute; top: 0; left: 0; }
#dossierV4Overlay .me {
  display: flex; justify-content: space-between;
  font-size: 0.55rem; color: #8E7F7F; letter-spacing: 1px; margin-top: 0.15rem;
}
#dossierV4Overlay .pd { background: repeating-linear-gradient(45deg,#4a5d4a,#4a5d4a 10px,#3f4f3f 10px,#3f4f3f 20px); }
#dossierV4Overlay .pc { background: repeating-linear-gradient(45deg,#5d4a4a,#5d4a4a 10px,#4f3f3f 10px,#4f3f3f 20px); }
#dossierV4Overlay .p2 { background: repeating-linear-gradient(45deg,#4a4a5d,#4a4a5d 10px,#3f3f4f 10px,#3f3f4f 20px); }
#dossierV4Overlay .p3 { background: repeating-linear-gradient(45deg,#5d5d4a,#5d5d4a 10px,#4f4f3f 10px,#4f4f3f 20px); }
#dossierV4Overlay .p4 { background: repeating-linear-gradient(45deg,#5d4a5d,#5d4a5d 10px,#4f3f4f 10px,#4f3f4f 20px); }

/* ── Handler override ───────────────────────────────────── */
#dossierV4Overlay .ov { border-top: 2px solid #8B0000; margin-top: 1.5rem; padding: 1rem 0; }
#dossierV4Overlay .ovl { font-size: 0.65rem; font-weight: bold; color: #8B0000; letter-spacing: 2px; margin-bottom: 0.4rem; }
#dossierV4Overlay .ovt { font-size: 0.8rem; line-height: 1.55; color: #3A3238; }

/* ── Footnote + [NEW] marker ────────────────────────────── */
#dossierV4Overlay .fn {
  font-size: 0.68rem; color: #8E7F7F; font-style: italic;
  margin-top: 1.2rem; letter-spacing: 0.5px;
  border-top: 1px dotted #8E7F7F; padding-top: 0.5rem; line-height: 1.5;
}
#dossierV4Overlay .nm {
  font-size: 0.55rem; color: #4a5d4a; font-weight: bold;
  letter-spacing: 1px; margin-left: 0.3rem;
}

/* ── Surveillance schedule ──────────────────────────────── */
#dossierV4Overlay .schedule-day { margin-bottom: 1.5rem; }
#dossierV4Overlay .schedule-day-title {
  font-weight: bold; color: #3A3238; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 0.6rem; padding-bottom: 0.3rem; border-bottom: 1px solid #8E7F7F; font-size: 0.85rem;
}
#dossierV4Overlay .schedule-row {
  display: grid; grid-template-columns: 70px 1fr 180px 110px; gap: 1rem;
  padding: 0.5rem 0.6rem; border-bottom: 1px dashed rgba(142,127,127,0.4);
  font-size: 0.82rem; align-items: center;
}
#dossierV4Overlay .sched-time { font-weight: bold; color: #3A3238; }
#dossierV4Overlay .sched-activity { color: #3A3238; }
#dossierV4Overlay .sched-location { color: #5F5449; font-style: italic; font-size: 0.78rem; }
#dossierV4Overlay .sched-avail {
  font-size: 0.68rem; text-align: center; padding: 0.2rem 0.5rem;
  text-transform: uppercase; letter-spacing: 1px; font-weight: bold; border: 1px solid;
}
#dossierV4Overlay .avail-available   { color: #4a5d4a; border-color: #4a5d4a; background: rgba(74,93,74,0.1); }
#dossierV4Overlay .avail-limited     { color: #c4a87a; border-color: #c4a87a; background: rgba(196,168,122,0.1); }
#dossierV4Overlay .avail-busy        { color: #8B0000; border-color: #8B0000; background: rgba(139,0,0,0.1); }
#dossierV4Overlay .avail-unavailable { color: #8E7F7F; border-color: #8E7F7F; background: rgba(142,127,127,0.15); }

/* ── Files tab ──────────────────────────────────────────── */
/* Media sub-tabs — styled to match the PROFILE/SURVEILLANCE/FILES strip */
#dossierV4Overlay .media-tabs {
  display: flex;
  border-bottom: 2px solid #8E7F7F;
  margin-bottom: 1rem;
}
#dossierV4Overlay .media-tab {
  padding: 0.55rem 1.2rem;
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 1.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #8E7F7F;
  transition: all 0.2s;
}
#dossierV4Overlay .media-tab:hover { color: #3A3238; }
#dossierV4Overlay .media-tab.active {
  color: #3A3238;
  border-bottom-color: #8B0000;
}
#dossierV4Overlay .files-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
/* Self-sufficient reveal — never depend on the legacy sheet's
   unscoped .file-card { opacity: 0; animation: cardReveal } rule. */
@keyframes dv4CardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#dossierV4Overlay .file-card {
  border: 1px solid #8E7F7F;
  position: relative;
  background: #D4C8BE;
  opacity: 1;
  animation: dv4CardIn 0.45s ease both;
}
#dossierV4Overlay .file-card.locked { opacity: 0.6; }
#dossierV4Overlay .file-preview {
  height: 200px;
  position: relative;
  overflow: hidden;
  background: repeating-linear-gradient(45deg,#5F5449,#5F5449 8px,#4a4240 8px,#4a4240 16px);
  display: flex; align-items: center; justify-content: center;
}
#dossierV4Overlay .file-icon-large { font-size: 4rem; line-height: 1; opacity: 0.6; }
/* Grid previews stay BLURRED — no spoilers from the thumbnail wall;
   the lightbox (click) is where a photograph actually gets seen.
   scale hides the blur's edge bleed inside the overflow:hidden card. */
#dossierV4Overlay .file-img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  cursor: pointer;
  filter: grayscale(42%) sepia(30%) contrast(1.08) brightness(0.9) blur(10px);
  transform: scale(1.1);
}
#dossierV4Overlay .file-img:hover {
  filter: grayscale(42%) sepia(30%) contrast(1.08) brightness(0.96) blur(7px);
}
/* Small classified-viewing hint over the blurred preview. */
#dossierV4Overlay .file-preview::after {
  content: '◉ VIEW';
  position: absolute;
  bottom: 0.5rem; right: 0.6rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18rem;
  color: rgba(235, 230, 216, 0.75);
  background: rgba(58, 50, 56, 0.65);
  padding: 0.15rem 0.45rem;
  pointer-events: none;
}
#dossierV4Overlay .file-card.locked .file-preview::after { content: none; }
#dossierV4Overlay .file-info { padding: 0.7rem 0.8rem; background: rgba(212,200,190,0.6); border-top: 1px solid #8E7F7F; }
#dossierV4Overlay .file-title { font-size: 0.95rem; font-weight: bold; color: #3A3238; margin-bottom: 0.4rem; }
#dossierV4Overlay .file-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.72rem; color: #8E7F7F; padding-top: 0.4rem;
  border-top: 1px dotted rgba(142,127,127,0.5);
}
#dossierV4Overlay .file-size { background: #3A3238; color: #EBE6D8; padding: 0.15rem 0.5rem; font-size: 0.65rem; font-weight: bold; }
#dossierV4Overlay .file-lock-badge {
  position: absolute; top: 0.5rem; right: 0.5rem; background: #8B0000; color: #EBE6D8;
  font-size: 0.65rem; padding: 0.15rem 0.4rem; letter-spacing: 1px; font-weight: bold;
}

/* ── Footer controls ────────────────────────────────────── */
#dossierV4Overlay .control-buttons {
  display: flex; justify-content: flex-end; gap: 1rem;
  padding: 1.5rem 2rem; border-top: 1px dashed #8E7F7F; background: rgba(212,200,190,0.2);
}
#dossierV4Overlay .control-button {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase; font-weight: bold;
  padding: 0.7rem 1.5rem; border: 1px solid #8E7F7F;
  background: #D4C8BE; color: #3A3238; cursor: pointer; transition: all 0.2s ease;
}
#dossierV4Overlay .control-button:hover { background: #8E7F7F; color: #EBE6D8; }

/* ── Empty / undiscovered state ─────────────────────────── */
#dossierV4Overlay .dv4-empty {
  text-align: center; color: #8E7F7F; font-style: italic;
  padding: 3rem 2rem; letter-spacing: 1px; font-size: 0.85rem;
}

/* ════════════════════════════════════════════════════════════
   Subjects Archive — main-menu gallery of dossier subjects.
   Case-file photo board in the noir/FBI style.
   ════════════════════════════════════════════════════════════ */
#subjectsArchiveOverlay {
  position: fixed;
  inset: 0;
  z-index: 1500000; /* above scene overlay dialogue (1000200) */
  display: none;
  overflow-y: auto;
  background: rgba(58, 50, 56, 0.96);
  font-family: 'Courier New', Courier, monospace;
}
#subjectsArchiveOverlay.open { display: block; }

#subjectsArchiveOverlay .arch-stage {
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1rem;
}
#subjectsArchiveOverlay .arch-doc {
  background: #EBE6D8;
  border: 1px solid #8E7F7F;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 28px,
    rgba(142,127,127,0.04) 28px, rgba(142,127,127,0.04) 29px);
}

#subjectsArchiveOverlay .arch-header {
  text-align: center;
  padding: 1.8rem 2rem 1.4rem;
  border-bottom: 1px dashed #8E7F7F;
  background: rgba(212, 200, 190, 0.4);
}
#subjectsArchiveOverlay .arch-banner {
  background: #8B0000;
  color: #EBE6D8;
  display: inline-block;
  padding: 0.3rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 3px;
  font-weight: bold;
  margin-bottom: 0.8rem;
}
#subjectsArchiveOverlay .arch-title {
  margin: 0.3rem 0;
  font-size: 1.7rem;
  color: #3A3238;
  letter-spacing: 5px;
}
#subjectsArchiveOverlay .arch-sub {
  font-size: 0.7rem;
  color: #8B0000;
  letter-spacing: 2px;
  font-weight: bold;
}

#subjectsArchiveOverlay .arch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2.2rem 1.6rem;
  padding: 2.6rem 2.2rem;
}
#subjectsArchiveOverlay .arch-card {
  background: #D4C8BE;
  border: 1px solid #8E7F7F;
  padding: 9px 9px 12px;
  box-shadow: 3px 5px 12px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
#subjectsArchiveOverlay .arch-card:hover {
  transform: rotate(0deg) translateY(-7px) scale(1.04) !important;
  box-shadow: 6px 12px 24px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
#subjectsArchiveOverlay .arch-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid #8E7F7F;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #5F5449, #5F5449 8px, #4a4240 8px, #4a4240 16px);
  color: #EBE6D8;
  font-size: 0.6rem;
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.6;
}
#subjectsArchiveOverlay .arch-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(42%) sepia(30%) contrast(1.08) brightness(0.96);
}
#subjectsArchiveOverlay .arch-name {
  margin-top: 9px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #3A3238;
  letter-spacing: 1px;
  text-align: center;
}
#subjectsArchiveOverlay .arch-ref {
  font-size: 0.58rem;
  color: #8E7F7F;
  letter-spacing: 1.5px;
  text-align: center;
  margin-top: 3px;
}

#subjectsArchiveOverlay .arch-controls {
  padding: 1.4rem 2rem;
  border-top: 1px dashed #8E7F7F;
  background: rgba(212, 200, 190, 0.2);
  text-align: center;
}
#subjectsArchiveOverlay .arch-btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: bold;
  padding: 0.7rem 2rem;
  border: 1px solid #8E7F7F;
  background: #D4C8BE;
  color: #3A3238;
  cursor: pointer;
  transition: all 0.2s ease;
}
#subjectsArchiveOverlay .arch-btn:hover {
  background: #8B0000;
  color: #EBE6D8;
  border-color: #8B0000;
}

/* ── Lightbox: video support ─────────────────────────────── */
#dossierV4Lightbox video {
  max-width: calc(var(--vw100, 100vw) * 0.86);
  max-height: calc(var(--vh100, 100vh) * 0.86);
  border: 3px solid #8E7F7F;
  background: #000;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75);
}

/* ── Archive Level 2 — per-subject media gallery ─────────── */
#subjectsArchiveOverlay .arch-mtabs {
  display: flex;
  justify-content: center;
  border-bottom: 2px solid #8E7F7F;
  margin: 0 2.2rem;
}
#subjectsArchiveOverlay .arch-mtab {
  padding: 0.7rem 1.6rem;
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #8E7F7F;
  transition: all 0.2s;
}
#subjectsArchiveOverlay .arch-mtab:hover { color: #3A3238; }
#subjectsArchiveOverlay .arch-mtab.active {
  color: #3A3238;
  border-bottom-color: #8B0000;
}
#subjectsArchiveOverlay .arch-vid {
  font-size: 3.4rem;
}
#subjectsArchiveOverlay .arch-empty {
  text-align: center;
  color: #8E7F7F;
  font-style: italic;
  letter-spacing: 1px;
  font-size: 0.85rem;
  padding: 3rem 2rem;
}

/* ── Archive: classified (undiscovered) subject cards ────── */
#subjectsArchiveOverlay .arch-card.arch-locked {
  cursor: default;
  filter: saturate(0.6);
}
#subjectsArchiveOverlay .arch-card.arch-locked:hover {
  transform: none !important;
  box-shadow: 3px 5px 12px rgba(0, 0, 0, 0.35);
}
#subjectsArchiveOverlay .arch-photo-hidden {
  position: relative;
}
#subjectsArchiveOverlay .arch-q {
  font-size: 3.4rem;
  font-weight: bold;
  color: rgba(235, 230, 216, 0.22);
  letter-spacing: 0;
}
#subjectsArchiveOverlay .arch-redact {
  background: #3A3238;
  color: #3A3238;
  letter-spacing: 0;
  padding: 0 0.2rem;
  user-select: none;
}

/* ── Non-emoji media markers ─────────────────────────────── */
/* CSS play triangle for video cards */
#dossierV4Overlay .media-play,
#subjectsArchiveOverlay .media-play {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 20px 0 20px 34px;
  border-color: transparent transparent transparent rgba(235, 230, 216, 0.55);
}
/* "DOC" marker for document cards */
#dossierV4Overlay .media-doc {
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 3px;
  color: rgba(235, 230, 216, 0.55);
  border: 2px solid rgba(235, 230, 216, 0.35);
  padding: 0.4rem 0.7rem;
}

/* ── Archive: per-subject media count badge ──────────────── */
#subjectsArchiveOverlay .arch-card { position: relative; }
#subjectsArchiveOverlay .arch-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #8B0000;
  color: #EBE6D8;
  font-size: 0.62rem;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 0.18rem 0.4rem;
  border: 1px solid #3A3238;
}

/* ── Archive sections: the girls, and everyone else ───────── */
#subjectsArchiveOverlay .arch-section-label {
  margin: 26px auto 2px;
  max-width: 980px;
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 6px;
  color: rgba(196, 168, 122, 0.65);
  text-align: center;
}
#subjectsArchiveOverlay .arch-section-label.arch-section-assoc {
  margin-top: 34px;
  color: rgba(142, 127, 127, 0.75);
}
/* Dossier tab strip: thin divider between the two shelves. */
#dossierV4Overlay .dossier-tab-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 6px;
  background: rgba(196, 168, 122, 0.35);
}

/* ── Gallery player — the projector (js/gallery-player.js) ──
   The lightbox grew a frame: the file, then a paper strip under
   it with where it came from and the four things he can do. */
#dossierV4Lightbox.lbp { cursor: default; }
#dossierV4Lightbox .lbp-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(var(--vw100, 100vw) * 0.9);
}
#dossierV4Lightbox .lbp-stage { display: flex; align-items: center; justify-content: center; }
#dossierV4Lightbox.lbp .lbp-media {
  display: block;
  max-width: calc(var(--vw100, 100vw) * 0.86);
  /* --lbp-cap is set in JS when a scene's dialogue strip is holding
     the bottom of the screen: the file shrinks to the room left
     above it. Unset, it is the usual three quarters of the window. */
  max-height: var(--lbp-cap, calc(var(--vh100, 100vh) * 0.76));
  object-fit: contain;
  border: 3px solid #8E7F7F;
  background: #3A3238;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75);
}
#dossierV4Lightbox .lbp-bar {
  width: 100%;
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  background: #EBE6D8;
  border: 1px solid #8E7F7F;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  padding: 0.5rem 0.8rem;
  font-family: 'Courier New', Courier, monospace;
}
#dossierV4Lightbox .lbp-ref {
  color: #5F5449;
  font-size: 0.7rem;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#dossierV4Lightbox .lbp-pos { color: #8E7F7F; margin-left: 0.4rem; }
#dossierV4Lightbox .lbp-btns { display: flex; gap: 0.4rem; flex: none; }
#dossierV4Lightbox .lbp-btn {
  background: transparent;
  border: 1px solid #8E7F7F;
  color: #3A3238;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 1.5px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
#dossierV4Lightbox .lbp-btn:hover { background: #3A3238; color: #EBE6D8; }
#dossierV4Lightbox .lbp-btn.on { border-color: #8B0000; color: #8B0000; }
#dossierV4Lightbox .lbp-btn.on:hover { background: #8B0000; color: #EBE6D8; }
#dossierV4Lightbox .lbp-dead {
  color: #c4a87a;
  font-family: 'Courier New', monospace;
  text-align: center;
  padding: 3rem 2rem;
  letter-spacing: 2px;
  border: 3px solid #8E7F7F;
  background: #3A3238;
}
#dossierV4Lightbox .lbp-dead span { font-size: 0.8em; opacity: 0.75; letter-spacing: 1px; }

/* ── the shelf: a star on a card, and whose folder it came from ── */
#subjectsArchiveOverlay .arch-fav-mark {
  position: absolute;
  top: 6px;
  left: 8px;
  color: #8B0000;
  font-size: 1rem;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
#subjectsArchiveOverlay .arch-fav-subj {
  font-size: 0.58rem;
  letter-spacing: 1.2px;
  color: #8E7F7F;
  margin-top: 0.2rem;
}
#subjectsArchiveOverlay .arch-card-fav .arch-photo-evidence { background: #efe7d2; }

/* A source's folder — footage that belongs to a place. */
#subjectsArchiveOverlay .arch-section-label.arch-section-src {
  margin-top: 2rem;
}
#subjectsArchiveOverlay .arch-card-source .arch-photo { background: #2a2428; }

/* A reel's own first frame as its thumbnail (dossier-system
   _videoFace) — the play mark rides on top of it. */
#subjectsArchiveOverlay .arch-vidface,
#dossierV4Overlay .arch-vidface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #2a2428;
  pointer-events: none;
}
#subjectsArchiveOverlay .arch-photo,
#subjectsArchiveOverlay .arch-vid,
#dossierV4Overlay .file-preview { position: relative; }
#subjectsArchiveOverlay .arch-vid .media-play,
#dossierV4Overlay .file-preview .media-play {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.7));
}

/* ── Archive: a reel is not a print ─────────────────────────
   Video cards used to wear the photo's polaroid (3:4). A reel is
   wider — its own frame: two columns of the grid, a 16:9 face,
   sprocket holes down both edges, a REEL stamp in the corner.
   The play mark and the first-frame thumbnail stay as they were. */
#subjectsArchiveOverlay .arch-card[data-mvid="1"] {
  grid-column: span 2;
  background: #2f2a2e;
  border-color: #5a5150;
  padding: 10px 26px 12px;
  position: relative;
}
#subjectsArchiveOverlay .arch-card[data-mvid="1"]::before,
#subjectsArchiveOverlay .arch-card[data-mvid="1"]::after {
  content: "";
  position: absolute;
  top: 6px; bottom: 6px;
  width: 12px;
  background: repeating-linear-gradient(180deg,
    transparent 0 6px, #EBE6D8 6px 14px, transparent 14px 22px);
  opacity: 0.55;
  pointer-events: none;
}
#subjectsArchiveOverlay .arch-card[data-mvid="1"]::before { left: 7px; }
#subjectsArchiveOverlay .arch-card[data-mvid="1"]::after  { right: 7px; }
#subjectsArchiveOverlay .arch-card[data-mvid="1"] .arch-vid {
  aspect-ratio: 16 / 9;
  border-color: #1a1618;
  background: #1a1618;
}
#subjectsArchiveOverlay .arch-card[data-mvid="1"] .arch-ref {
  color: #c4b8a8;
}
#subjectsArchiveOverlay .arch-card[data-mvid="1"] .arch-ref::before {
  content: "REEL · ";
  color: #c4a87a;
  letter-spacing: 2px;
}
#subjectsArchiveOverlay .arch-card[data-mvid="1"] .arch-new {
  right: 30px;
}

/* ── Section labels you can read (2026-10-03 — the author: "sources,
   associates і верхнє поганенько читається"). Pale gold 11px on cream
   paper was a whisper; now each shelf is announced like a file divider:
   dark ink on a paper tab, a ruled line running out to both sides. ── */
#subjectsArchiveOverlay .arch-section-label,
#subjectsArchiveOverlay .arch-section-label.arch-section-assoc,
#subjectsArchiveOverlay .arch-section-label.arch-section-src {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; letter-spacing: 5px; font-weight: bold;
  color: #3A3238;
}
#subjectsArchiveOverlay .arch-section-label::before,
#subjectsArchiveOverlay .arch-section-label::after {
  content: ''; flex: 1; height: 0; border-top: 1px solid rgba(58, 50, 56, 0.45);
}
#subjectsArchiveOverlay .arch-section-label {
  text-indent: 5px;   /* the letter-spacing hangs after the last letter */
}
