/* Shared look for all pages — dark noir with brass and paper. */
:root {
  --bg: #0b0907;
  --bg-raise: #17120e;
  --panel: #1e1813;
  --line: rgba(236, 220, 186, 0.14);
  --text: #ede4d1;
  --muted: #a5987f;
  --brass: #c9a35b;
  --brass-hi: #f0d79c;
  --brass-lo: #6f5527;
  --blood: #a01d1d;
  --blood-hi: #d8352c;
  --paper: #efe6d0;
  --paper-dark: #ddcfae;
  --ink: #2a2119;
  --ok: #57c27a;
  --ink-blue: #1f2c78;
  --stamp-blue: #2c3f8c;
  /* Each edition loads the fonts it needs in its pages' <head>; these stacks use whichever is there. */
  --font-ui: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --font-doc: 'Markazi Text', 'Vazirmatn', Georgia, serif;
  --font-hand: 'Gulzar', 'Aref Ruqaa', 'Caveat', 'Markazi Text', cursive;
  --font-lcd: 'Share Tech Mono', ui-monospace, monospace;
  --gutter: 16px;
  /* Patchy-ink mask for rubber stamps, and a deckled edge for old photo prints. */
  --grunge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.09 .45' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3.4 2.6'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --deckle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 112' preserveAspectRatio='none'%3E%3Cpath d='M2 2q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 -2 4 0q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q2 2 0 4q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 2 -4 0q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4q-2 -2 0 -4Z'/%3E%3C/svg%3E");
}

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

html { -webkit-text-size-adjust: 100%; }
html.no-scroll, html.no-scroll body { overflow: hidden; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.75;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* The detective's dark wooden desk under every page, lit from above. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(60, 38, 20, 0.35) 0%, rgba(8, 6, 4, 0) 60%),
    radial-gradient(140% 100% at 50% 40%, rgba(8, 6, 4, 0.55) 30%, rgba(5, 4, 3, 0.92) 100%),
    url('../assets/img/tex/wood.jpg') center / cover,
    var(--bg);
}

/* Film grain over everything (never blocks touches). */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; }
img { max-width: 100%; }
[hidden], .hidden { display: none !important; }

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

/* ---------- Top strip ---------- */
.case-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) 10px;
  font-size: 12.5px;
  color: var(--muted);
  position: relative;
  z-index: 900;
}
.case-bar .badge {
  border: 1px solid var(--brass-lo);
  color: var(--brass);
  border-radius: 4px;
  padding: 1px 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.case-bar > span:not(.badge) { margin-inline-start: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-bar .badge { flex: none; white-space: nowrap; }

/* ---------- Desk button, language button + menu ---------- */
.lang { position: relative; flex: none; }
.desk-btn { flex: none; text-decoration: none; }
.lang-btn, .desk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 15, 11, 0.6);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
}
.lang-btn svg, .desk-btn svg { width: 15px; height: 15px; fill: none; stroke: var(--brass); stroke-width: 1.6; }
.desk-btn:active { border-color: var(--brass-lo); }
/* Phones: the globe alone, so the bar keeps room for the page name and the desk button. */
@media (max-width: 420px) {
  .lang-btn { padding: 0 7px; }
  .lang-btn span { display: none; }
}
.lang-btn[aria-expanded="true"] { border-color: var(--brass-lo); }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 50;
  min-width: 170px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--brass-lo);
  background: rgba(24, 19, 14, 0.98);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  animation: menuIn 0.2s ease both;
}
.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
}
.lang-item small { font-size: 11.5px; font-weight: 600; color: var(--muted); }
a.lang-item:active, a.lang-item:hover { background: rgba(255, 255, 255, 0.06); }
.lang-item.current { color: var(--brass-hi); }
.lang-item.current small { color: var(--brass-hi); }
.lang-item.soon { opacity: 0.5; cursor: default; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Police form on paper (verdict sheet, detective's desk) ---------- */
.sheet {
  position: relative;
  width: min(100%, 540px);
  padding: 28px 22px 24px;
  border-radius: 4px;
  color: var(--ink);
  background: url('../assets/img/tex/paper.jpg') center / cover;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.6);
  animation: sheetIn 0.5s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(16px); } }

.sheet-head { text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 22px; }
.sh-crest { width: 54px; margin: 0 auto 4px; color: #2a2119; }
.sh-crest > svg { display: block; width: 100%; height: auto; }
.sh-dept { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; color: #5c4f3c; text-align: center; }
.sheet-head h1 { margin: 4px 0 0; font-family: var(--font-doc); font-size: 34px; font-weight: 700; line-height: 1.3; }
.sh-meta { margin: 2px 0 0; font-size: 13px; color: #6b5d48; }
.sheet-stamp { width: 92px; flex: none; }

/* ---------- Official-document parts (crest, ink stamp, signature) ---------- */
.ink-stamp { display: block; width: 100%; height: auto; color: var(--stamp-blue); opacity: 0.8; transform: rotate(-11deg); mix-blend-mode: multiply; overflow: visible; }
.ink-stamp-text { font: 700 17px var(--font-ui); }
.signature {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink-blue);
  font-family: var(--font-hand);
  line-height: 1.2;
  transform: rotate(-6deg);
}
.signature svg { width: 2.4em; height: auto; margin-top: -0.35em; }
.blood {
  position: absolute;
  pointer-events: none;
  background: no-repeat center / contain;
  mix-blend-mode: multiply;
}
.blood.b1 { background-image: url('../assets/img/fx/blood-1.png'); aspect-ratio: 252 / 700; }
.blood.b2 { background-image: url('../assets/img/fx/blood-2.png'); aspect-ratio: 700 / 671; }
.blood.b3 { background-image: url('../assets/img/fx/blood-3.png'); aspect-ratio: 360 / 201; }

/* ---------- Buttons ---------- */
.btn-brass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 52px;
  padding: 0 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f5dfa6 0%, #cfa95e 45%, #8f6d2f 100%);
  color: #22180c;
  font-weight: 800;
  font-size: 17px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25),
    0 10px 26px rgba(201, 163, 91, 0.22);
  transition: transform 0.12s ease, filter 0.2s;
}
.btn-brass:active { transform: translateY(1px) scale(0.98); filter: brightness(0.95); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.btn-ghost:active { background: rgba(255, 255, 255, 0.08); }

/* ---------- Rubber stamp ---------- */
.stamp {
  display: inline-block;
  color: var(--blood-hi);
  border: 3px double currentColor;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
  transform: rotate(-7deg);
  opacity: 0.88;
  text-shadow: 0 0 1px currentColor;
}

/* ---------- Feedback ---------- */
.shake { animation: shake 0.45s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 30px);
  opacity: 0;
  z-index: 1500;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(30, 24, 19, 0.96);
  border: 1px solid var(--brass-lo);
  color: var(--brass-hi);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.35s ease, opacity 0.35s ease;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Viewer (documents & photos) ---------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: rgba(6, 5, 4, 0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.viewer.open { opacity: 1; pointer-events: auto; }
.viewer-top, .viewer-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter);
  position: relative;
  z-index: 2;
}
.viewer-top { padding-top: max(10px, env(safe-area-inset-top)); }
.viewer-bottom { justify-content: center; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.viewer-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }
.viewer-count { min-width: 44px; text-align: left; color: var(--muted); font-size: 14px; }
.viewer-tip { font-size: 12px; color: var(--muted); text-align: center; flex: 0 1 auto; }
.viewer-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.viewer-btn:disabled { opacity: 0.25; }
.viewer-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  display: grid;
  place-items: center;
}
.viewer-content {
  display: grid;
  place-items: center;
  transform-origin: center center;
  will-change: transform;
}
.viewer-content img {
  display: block;
  max-width: calc(100vw - 20px);
  max-height: calc(100svh - 150px);
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
}
.viewer-content .doc {
  width: min(calc(100vw - 20px), calc((100svh - 150px) / var(--ratio, 1.414)), 640px);
}
.viewer-loading { color: var(--muted); font-size: 28px; }

/* ---------- Placeholder documents (shown until the designed image exists) ---------- */
.doc {
  --ratio: 1.414;
  position: relative;
  aspect-ratio: 1 / var(--ratio);
  container-type: inline-size;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(255, 252, 240, 0.7), rgba(255, 252, 240, 0) 70%),
    radial-gradient(circle at 85% 12%, rgba(140, 100, 40, 0.18), transparent 25%),
    linear-gradient(180deg, #f1e8d2, #e3d5b3);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-select: none;
}
/* Text lives in .doc-in so its cqw units measure the document itself. */
.doc > .doc-in { position: absolute; inset: 0; }
