/* ==========================================================================
   Clippings — shared papercraft system
   Two inks on paper. Every game overrides --ink-1 / --ink-2.
   ========================================================================== */

/* Wee Bairn by Raymond Larabie, CC0 (see assets/fonts/wee-bairn-LICENSE.txt).
   Slice-o-Paper: licensed by Rowan. */
@font-face { font-family: 'Wee Bairn'; src: url('../fonts/wee-bairn.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'Slice o Paper'; src: url('../fonts/slice-o-paper-crisp.woff') format('woff'); font-display: swap; }

:root {
  --font-hand: 'Wee Bairn', 'Archivo Black', sans-serif;
  --font-cut: 'Slice o Paper', 'Archivo Black', sans-serif;
  --paper: #f1ead8;
  --paper-card: #f7f1e3;
  --newsprint: #ddd4bd;
  --manila: #e3cf9f;
  --ink-1: #e8333a;          /* accent ink */
  --ink-2: #1d1a1a;          /* key ink */
  --tape: rgba(236, 226, 196, 0.78);
  --shadow: rgba(29, 26, 26, 0.24);

  --font-body: 'Courier Prime', 'Courier New', monospace;
  --font-type: 'Special Elite', 'Courier New', monospace;
  --font-display: 'Archivo Black', 'Arial Black', sans-serif;
  --font-condensed: 'Anton', Impact, sans-serif;

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --fibers: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 0.3' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.25 0 0 0 0 0.15 0 0 0 0.35 -0.08'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  /* content paper: a faint, fine tooth rather than streaks, so cards read as smooth paper */
  --fibers-soft: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5 0.35' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.25 0 0 0 0 0.15 0 0 0 0.12 -0.03'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: var(--fibers), var(--noise);
  background-attachment: fixed;   /* the backdrop stays put, like the scenes and cork board; only the cards scroll */
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* print grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.32;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1000;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

/* ---------- halftone & duotone helpers ---------- */
/* ---------- torn paper sheets ---------- */
/* .sheet gets a jagged clip-path from fx.js (tear()); the wrapper carries the shadow
   because clip-path would cut a box-shadow off. */

.sheet-wrap {
  position: relative;
  filter: drop-shadow(3px 4px 0 var(--shadow));
}
.sheet {
  position: relative;
  background-color: var(--paper-card);
  background-image: var(--fibers-soft);
  padding: 30px 26px 30px;
}
.sheet.newsprint { background-color: var(--newsprint); }
.sheet.manila { background-color: var(--manila); }
.sheet.ink { background-color: var(--ink-2); color: var(--paper); }
.sheet.red { background-color: var(--ink-1); color: var(--paper); }

/* masking tape */
.tape {
  position: absolute;
  width: 96px;
  height: 26px;
  background: var(--tape);
  background-image: linear-gradient(90deg, rgba(255,255,255,0.18), rgba(0,0,0,0.04) 60%, rgba(255,255,255,0.12));
  clip-path: polygon(3% 0, 8% 12%, 4% 25%, 9% 40%, 3% 55%, 8% 72%, 4% 88%, 7% 100%, 94% 100%, 98% 86%, 93% 70%, 97% 55%, 92% 40%, 97% 24%, 93% 10%, 97% 0);
  z-index: 3;
  pointer-events: none;
}
.tape.top { top: -12px; left: 50%; transform: translateX(-50%) rotate(-3deg); }
.tape.tl { top: 6px; left: -34px; transform: rotate(-38deg); }
.tape.tr { top: 6px; right: -34px; transform: rotate(36deg); }

/* ---------- ransom-note lettering ---------- */

.ransom {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.18em 0.42em;
  line-height: 1;
  margin: 0;
  font-weight: normal;
}
.ransom-word {
  display: inline-flex;
  align-items: center;
  filter: drop-shadow(1.5px 2px 0 var(--shadow));
}
.rl {
  display: inline-block;
  padding: 0.1em 0.14em 0.06em;
  margin: 0 0.015em;
  line-height: 1;
}

/* ---------- paper strip labels ---------- */

.strip {
  display: inline-block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
  padding: 5px 12px 4px;
  background: var(--ink-2);
  color: var(--paper);
  transform: rotate(-1.5deg);
}
.strip.red { background: var(--ink-1); }
.strip.paper { background: var(--paper-card); color: var(--ink-2); }

/* ---------- buttons ---------- */

.btn {
  --bg: var(--ink-2);
  --fg: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  border: 0;
  cursor: pointer;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 1rem;
  padding: 14px 26px 12px;
  text-decoration: none;
  white-space: nowrap;
  clip-path: polygon(0 4%, 6% 0, 18% 3%, 34% 0, 52% 4%, 70% 0, 86% 3%, 100% 0, 99% 30%, 100% 62%, 98% 100%, 82% 96%, 64% 100%, 46% 97%, 28% 100%, 12% 96%, 0 100%, 1% 66%, 0 34%);
  transition: transform 0.12s ease, background-color 0.12s ease;
  transform: rotate(-0.6deg);
}
.btn-wrap { display: inline-block; filter: drop-shadow(2px 3px 0 var(--shadow)); }
.btn:hover { transform: rotate(0.4deg) translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px dashed var(--ink-1); outline-offset: 4px; }
.btn.red { --bg: var(--ink-1); }
.btn.paper { --bg: var(--paper-card); --fg: var(--ink-2); }
.btn.small { font-size: 0.8rem; padding: 9px 16px 8px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 2px;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: underline dashed;
  text-underline-offset: 4px;
}

/* ---------- text fields ---------- */

.field-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.field {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--font-type);
  font-size: 1.15rem;
  padding: 13px 14px 11px;
  border: 0;
  background: #fffaf0;
  color: var(--ink-2);
  outline: 2px dashed var(--ink-2);
  outline-offset: -6px;
  box-shadow: inset 0 0 0 2px var(--ink-2);
}
.field:focus { outline-color: var(--ink-1); }
.field::placeholder { color: rgba(29, 26, 26, 0.45); }
input[type=number].field { -moz-appearance: textfield; }
input[type=number].field::-webkit-outer-spin-button,
input[type=number].field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.shake { animation: shake 0.38s ease; }
@keyframes shake {
  20% { transform: translateX(-7px) rotate(-1deg); }
  45% { transform: translateX(6px) rotate(1deg); }
  70% { transform: translateX(-4px); }
}

/* ---------- autocomplete ---------- */

.ac-wrap { position: relative; flex: 1 1 260px; display: flex; min-width: 0; }
.ac-wrap .field { flex: 1; }
.ac-list {
  position: fixed; /* placed under the input by autocomplete.js */
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fffaf0;
  box-shadow: inset 0 0 0 2px var(--ink-2), 4px 5px 0 var(--shadow);
  max-height: min(46vh, 330px);
  overflow-y: auto;
  z-index: 50;
}
.ac-list li {
  padding: 9px 10px 7px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-type);
}
.ac-list li .sub { opacity: 0.6; font-family: var(--font-body); font-size: 0.85em; white-space: nowrap; }
.ac-list li[aria-selected=true] { background: var(--ink-2); color: var(--paper); }
.ac-list li mark { background: none; color: inherit; text-decoration: underline; text-decoration-color: var(--ink-1); text-decoration-thickness: 3px; }
.ac-list li[aria-selected=true] mark { text-decoration-color: var(--ink-1); }
.ac-empty { padding: 9px 10px; opacity: 0.6; font-style: italic; }

/* ---------- stamps ---------- */

.stamp {
  position: absolute;
  top: 30px; right: 16px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.08em;
  padding: 6px 14px 3px;
  color: var(--ink-1);
  border: 4px solid currentColor;
  box-shadow: inset 0 0 0 2px var(--paper-card), inset 0 0 0 4px currentColor;
  transform: rotate(-11deg);
  mix-blend-mode: multiply;
  /* solid ink with speckles knocked out of it */
  -webkit-mask-image: linear-gradient(#000, #000), var(--noise);
  -webkit-mask-composite: source-out;
  mask-image: linear-gradient(#000, #000), var(--noise);
  mask-composite: subtract;
  pointer-events: none;
  animation: stamp-in 0.32s cubic-bezier(.2,1.6,.4,1) both;
  z-index: 4;
}
.stamp.wrong { color: var(--ink-2); transform: rotate(8deg); }
@keyframes stamp-in {
  0% { opacity: 0; transform: scale(2.4) rotate(-20deg); }
  100% { opacity: 1; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}

/* ---------- rubber-stamp ink, everywhere there's a stamp ---------- */
/* fine speckles where the rubber didn't take, and broad patches where it was pressed lighter: one mask for every stamp */
:root {
  --stamp-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3' stitchTiles='stitch' result='f'/%3E%3CfeColorMatrix in='f' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -6 0 0 0 5.3' result='speck'/%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.035' numOctaves='2' seed='8' stitchTiles='stitch' result='l'/%3E%3CfeColorMatrix in='l' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8 0 0 0 0.45' result='press'/%3E%3CfeComposite in='speck' in2='press' operator='arithmetic' k1='1' k2='0' k3='0' k4='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --stamp-ink-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3' stitchTiles='stitch' result='f'/%3E%3CfeColorMatrix in='f' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -5 0 0 0 4.75' result='speck'/%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.035' numOctaves='2' seed='8' stitchTiles='stitch' result='l'/%3E%3CfeColorMatrix in='l' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4 0 0 0 0.72' result='press'/%3E%3CfeComposite in='speck' in2='press' operator='arithmetic' k1='1' k2='0' k3='0' k4='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stamp, .mode-stamp, .cf-archived, .cf-file-status, .cf-stamp-title span, .tab-stamp span, .wl-mark, .cf-findings .res {
  -webkit-mask-image: var(--stamp-ink); mask-image: var(--stamp-ink);
  -webkit-mask-composite: source-over; mask-composite: add;
  -webkit-mask-size: 220px 220px; mask-size: 220px 220px;
  -webkit-mask-repeat: repeat; mask-repeat: repeat;
}

/* the big stamps (verdicts, the case status, the stamped titles) get a lighter wear: same ink, fewer specks */
.stamp, .cf-stamp-title span { -webkit-mask-image: var(--stamp-ink-light); mask-image: var(--stamp-ink-light); }
