/* Cobbe's Secret Mission — paper.css
 *
 * Paper and print surfaces — notebook, evidence board, certificate (.csm-paper) and the A4 clue sheet (.csm-print).
 *
 * Loaded on every page after components.css (see base.html for the stack).
 * Each screen's rules are scoped under its body class (scr-*) or a screen
 * root class, so they never reach another screen.
 */

/* ═══ Paper surface — Fallmappen: notebook and evidence board. ══════════ */

.scr-casefile .casefile {
  --casefile-alibi-ink: var(--paper-alibi);
  --casefile-alibi-wash: var(--paper-alibi-wash);
  max-width: 1000px;
  margin: 0 auto;
  padding-bottom: var(--space-10);
}

/* ═══ Tabs: notebook dividers ════════════════════════════════════ */

.scr-casefile .casefile__tabs {
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-4);
  margin-top: var(--space-2);
}
.scr-casefile .casefile__tabs .ds-tabs__tab {
  flex: 1 1 0;
  max-width: 280px;
  min-height: var(--tap-large);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-tab);
  border: 2px solid var(--paper-binding);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  text-align: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.scr-casefile .casefile__tabs .ds-tabs__tab:hover { background: var(--paper-tab-hover); transform: translateY(-2px); }
.scr-casefile .casefile__tabs .ds-tabs__tab:focus-visible { outline: 3px solid var(--neon-blue); outline-offset: 2px; }
.scr-casefile .casefile__tabs .ds-tabs__tab.is-current {
  background: var(--grad-notebook-tab);
  border-color: var(--neon-gold-deep);
  color: var(--ink-strong);
  transform: none;
}

/* ═══ Notebook sheet ═════════════════════════════════════════════ */

.scr-casefile .casefile__sheet {
  position: relative;
  padding: var(--space-10);
  background-color: var(--paper);
  background-image: var(--texture-lined-paper);
  background-size: var(--texture-lined-paper-size);
  background-attachment: local;
  border: 2px solid var(--paper-binding);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-pinned);
}

.scr-casefile .casefile__heading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-6);
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--ink-strong);
}
.scr-casefile .casefile__heading + * { margin-top: 0; }
.scr-casefile .casefile__timeline + .casefile__heading,
.scr-casefile .casefile__protocol + .casefile__heading { margin-top: var(--space-10); }
.scr-casefile .casefile__count {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--ink-muted);
  letter-spacing: 0;
}

.scr-casefile .casefile__empty { margin: 0 0 var(--space-8); }

/* ── Pinned notes (the timeline) ────────────────────────────────── */

.scr-casefile .casefile__timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--space-8) var(--space-6);
}
.scr-casefile .casefile__note {
  position: relative;
  padding: var(--space-5);
  background: var(--grad-paper-note);
  border: 2px solid var(--paper-rule);
  box-shadow: var(--shadow-pinned);
  color: var(--ink);
  transform: rotate(-1.2deg);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  animation: casefile-in var(--duration-fade) ease both;
}
/* Opacity only: a transform here would undo the note's tilt. */
@keyframes casefile-in { from { opacity: 0; } }
.scr-casefile .casefile__note:nth-child(even) { transform: rotate(1deg); }
.scr-casefile .casefile__note:hover { transform: rotate(0) scale(1.02); box-shadow: var(--shadow-pinned-hover); }
.scr-casefile .casefile__note::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  width: 16px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: var(--radius-round);
  background: var(--grad-pin-red);
  box-shadow: 0 2px 4px rgba(0,0,0,.3), inset -1px -1px 2px rgba(0,0,0,.2);
}

.scr-casefile .casefile__note-source {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-bold);
  color: var(--ink-strong);
}
.scr-casefile .casefile__note-icon { font-size: 24px; }
.scr-casefile .casefile__note-text { margin: 0 0 var(--space-2); line-height: var(--leading-relaxed); }

.scr-casefile .casefile__postit {
  position: relative;
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  background: linear-gradient(135deg, var(--paper-postit) 0%, var(--paper-postit-2) 100%);
  border-left: 4px solid var(--neon-blue);
  box-shadow: var(--shadow-postit);
  font-size: var(--font-size-sm);
  font-style: italic;
  color: var(--ink-strong);
}
.scr-casefile .casefile__postit::before {
  content: '';
  position: absolute;
  top: -5px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-round);
  background: var(--grad-pin-gold);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.scr-casefile .casefile__note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.scr-casefile .casefile__note-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  background: var(--neon-blue);
  color: var(--ink-on-neon);
  font-size: 12px;
  font-weight: var(--weight-bold);
}

/* Who a clue is about: evidence points (👉, red-brown ink), an alibi clears
   (🛡️, green ink). Shared by the notebook and the board's tags. */
.scr-casefile .casefile__link {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: var(--wash-red-10);
  color: var(--suspect-link);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-bold);
}
.scr-casefile .casefile__link--alibi {
  background: var(--casefile-alibi-wash);
  color: var(--casefile-alibi-ink);
}

/* ── Interrogation protocol ─────────────────────────────────────── */

.scr-casefile .casefile__protocol { display: grid; gap: var(--space-6); }
.scr-casefile .casefile__exchange { display: grid; gap: var(--space-2); }
.scr-casefile .casefile__exchange-who {
  font-weight: var(--weight-bold);
  color: var(--paper-alias);
}
.scr-casefile .casefile__bubble {
  position: relative;
  padding: var(--space-4);
  border-left: 4px solid var(--neon-blue);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bubble-q) 0%, var(--bubble-q-2) 100%);
  color: var(--ink);
}
.scr-casefile .casefile__bubble--a {
  margin-left: var(--space-6);
  border-left-color: var(--neon-orange);
  background: linear-gradient(135deg, var(--bubble-a) 0%, var(--bubble-a-2) 100%);
}
.scr-casefile .casefile__bubble-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--bubble-q-label);
}
.scr-casefile .casefile__bubble--a .casefile__bubble-label { color: var(--bubble-a-label); }
.scr-casefile .casefile__mood { display: inline-block; margin-left: var(--space-2); font-size: 20px; }

/* ── Scratchpad ─────────────────────────────────────────────────── */

.scr-casefile .casefile__scratch {
  margin-top: var(--space-10);
  padding: var(--space-5);
  background: var(--paper-scratch);
  border: 2px dashed var(--paper-binding);
  border-radius: var(--radius);
}
.scr-casefile .casefile__scratch-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.scr-casefile .casefile__heading--scratch { margin: 0; color: var(--ink-brown); }
.scr-casefile .casefile__scratch-status { font-size: var(--font-size-sm); color: var(--ink-brown); }
.scr-casefile .casefile__scratch-field { margin: 0; }
.scr-casefile .casefile__scratch-field .ds-field__input {
  background: var(--paper-field);
  border: 1px solid var(--paper-field-border);
  color: var(--ink);
  resize: vertical;
}
.scr-casefile .casefile__scratch-field .ds-field__input::placeholder { color: var(--ink-muted); }
.scr-casefile .casefile__scratch-field .ds-field__input:focus { border-color: var(--ink-brown); box-shadow: none; }

/* ═══ Evidence board ═════════════════════════════════════════════ */

.scr-casefile .casefile__board {
  position: relative;
  padding: var(--space-8) var(--space-6) var(--space-10);
  background-color: var(--bg-secondary);
  background-image:
    repeating-linear-gradient(0deg, var(--cork-grain) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(90deg, var(--cork-grain) 0 2px, transparent 2px 4px);
  border: 2px solid var(--paper-binding);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow-card);
}
/* Everything on the board sits above the strings. */
.scr-casefile .casefile__board > :not(.casefile__strings) { position: relative; z-index: 1; }

.scr-casefile .casefile__strings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.scr-casefile .casefile__string {
  fill: none;
  stroke: var(--neon-red);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: .85;
  filter: drop-shadow(-1px 2px 1px rgba(0,0,0,.45));
}

.scr-casefile .casefile__stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-5) var(--space-10);
  margin-bottom: var(--space-8);
}

.scr-casefile .casefile__board-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-6);
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-title);
  color: var(--text-primary);
}

/* ── Suspects as polaroids ──────────────────────────────────────── */

.scr-casefile .casefile__suspects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-12);
}
.scr-casefile .casefile__polaroid { width: auto; }
/* Paper-safe ink for the polaroid's coloured text (the component's neon
   versions fail contrast on white; see the README's contrast flags). */
.scr-casefile .casefile__polaroid .ds-polaroid__alias { color: var(--paper-alias); }
.scr-casefile .casefile__polaroid .ds-polaroid__badge { font-size: 11px; padding: 2px 6px; }
.scr-casefile .casefile__polaroid .ds-polaroid__badge--clue { color: var(--bubble-q-label); }
.scr-casefile .casefile__polaroid .ds-polaroid__badge--interrogated { color: var(--paper-alias); }
.scr-casefile .casefile__polaroid .ds-polaroid__badge--alibi {
  background: var(--casefile-alibi-wash);
  color: var(--casefile-alibi-ink);
}

/* ── Evidence tags ──────────────────────────────────────────────── */

.scr-casefile .casefile__tags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: var(--space-6) var(--space-4);
  align-items: start;
}
.scr-casefile .casefile__tag {
  position: relative;
  padding: var(--space-3) var(--space-4);
  background: var(--paper-note);
  border: 2px solid var(--paper-rule);
  border-radius: 6px;
  box-shadow: var(--shadow-tag), -3px 4px 8px rgba(0,0,0,.25);
  color: var(--ink);
  transform: rotate(-1deg);
  transition: transform var(--transition-normal);
}
.scr-casefile .casefile__tag:nth-child(even) { transform: rotate(1deg); }
.scr-casefile .casefile__tag:hover { transform: rotate(0) scale(1.03); }
.scr-casefile .casefile__tag-pin {
  position: absolute;
  top: -6px;
  left: 16px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-round);
  background: var(--grad-pin-gold);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
/* A tag with a string to a suspect is pinned with a red pin, like the thread. */
.scr-casefile .casefile__tag[data-string-to] .casefile__tag-pin { background: var(--grad-pin-red); }

.scr-casefile .casefile__tag-type {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-strong);
}
.scr-casefile .casefile__tag-text { margin: var(--space-1) 0 0; font-size: var(--font-size-sm); line-height: 1.45; color: var(--ink-soft); }
.scr-casefile .casefile__tag-comment { margin: var(--space-1) 0 0; font-size: 12px; font-style: italic; color: var(--bubble-q-label); }
.scr-casefile .casefile__tag .casefile__link { margin-top: var(--space-2); }

.scr-casefile .casefile__solve { display: flex; justify-content: center; margin-top: var(--space-12); }

/* ── Empty board ────────────────────────────────────────────────── */

.scr-casefile .casefile__board-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-4);
  text-align: center;
}
.scr-casefile .casefile__board-empty-icon { font-size: var(--font-size-mega); }
.scr-casefile .casefile__board-empty-text { margin: 0; font-size: var(--font-size-lg); color: var(--text-primary); }
.scr-casefile .casefile__board-empty .ds-btn { margin-top: var(--space-4); }

/* ═══ Phone ══════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .scr-casefile .casefile__tabs { padding: 0 var(--space-2); }
  .scr-casefile .casefile__tabs .ds-tabs__tab { padding: var(--space-2); font-size: var(--font-size-sm); }
  .scr-casefile .casefile__sheet { padding: var(--space-6) var(--space-4); }
  .scr-casefile .casefile__board { padding: var(--space-6) var(--space-4) var(--space-8); }
  .scr-casefile .casefile__suspects { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--space-5) var(--space-4); }
  .scr-casefile .casefile__bubble--a { margin-left: var(--space-3); }
  .scr-casefile .casefile__stats { gap: var(--space-4) var(--space-6); }
}

/* ═══ Touch and motion ═══════════════════════════════════════════ */

@media (hover: none) {
  .scr-casefile .casefile__note:hover { transform: rotate(-1.2deg); box-shadow: var(--shadow-pinned); }
  .scr-casefile .casefile__note:nth-child(even):hover { transform: rotate(1deg); }
  .scr-casefile .casefile__tag:hover { transform: rotate(-1deg); }
  .scr-casefile .casefile__tag:nth-child(even):hover { transform: rotate(1deg); }
  .scr-casefile .casefile__polaroid:hover { transform: rotate(var(--ds-polaroid-tilt)); box-shadow: var(--shadow-polaroid); }
  .scr-casefile .casefile__tabs .ds-tabs__tab:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .scr-casefile .casefile__note { animation: none; }
  .scr-casefile .casefile__note,
  .scr-casefile .casefile__tag,
  .scr-casefile .casefile__tabs .ds-tabs__tab { transition: none; }
}

/* ═══ Paper surface — the certificate (P8). ═════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
 * Screen: Agentdiplom (scr-certificate, on .csm-paper)
 *
 * On screen: a cream sheet on a darker desk, with a back and a print button
 * above it. In print: exactly one A4 page (210×297mm, 14mm margin inside the
 * sheet, the same geometry as the clue sheet), no app chrome, no dark ground,
 * no shadows. Ink colours only — neon on paper fails contrast.
 * ═══════════════════════════════════════════════════════════════════ */

.scr-certificate { background: var(--paper-tab); }
.scr-certificate .app-container { max-width: none; padding: var(--space-4) var(--space-3) var(--space-10); }

/* ── The bar above the sheet (screen only) ──────────────────────── */

.scr-certificate .cert-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  max-width: 210mm;
  margin: 0 auto var(--space-4);
}
.scr-certificate .cert-bar .ds-btn--ghost,
.scr-certificate .cert-copies .ds-btn--ghost { color: var(--ink-strong); }
.scr-certificate .cert-bar .ds-btn--ghost:hover,
.scr-certificate .cert-copies .ds-btn--ghost:hover { background: var(--paper-tab-hover); color: var(--ink); }

/* ── The sheet ──────────────────────────────────────────────────── */

.cert {
  box-sizing: border-box;
  width: 100%;
  max-width: 210mm;
  min-height: min(297mm, 140vw);
  margin: 0 auto;
  padding: clamp(12px, 4vw, 14mm);
  background: var(--print-page);
  color: var(--print-ink);
  box-shadow: var(--shadow-pinned);
  font-family: var(--font-ui);
}

.cert__frame {
  box-sizing: border-box;
  height: 100%;
  min-height: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(16px, 5vw, 16mm) clamp(12px, 4vw, 14mm);
  border: 3px double var(--print-ink-2);
  outline: 1px solid var(--print-rule);
  outline-offset: -10px;
}

.cert__bureau {
  font-family: var(--font-mono);
  font-size: clamp(9px, 2.2vw, 11px);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--print-ink-2);
}

.cert__seal { font-size: clamp(44px, 12vw, 64px); line-height: 1; margin: var(--space-6) 0 var(--space-2); }

.cert__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 10vw, 56px);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-title);
  line-height: 1;
  color: var(--print-ink);
}

.cert__lead {
  margin: var(--space-6) 0 var(--space-2);
  font-size: clamp(15px, 4vw, 18px);
  font-style: italic;
  color: var(--print-ink-2);
}

.cert__name {
  font-size: clamp(28px, 8vw, 44px);
  font-weight: var(--weight-heavy);
  line-height: 1.15;
  color: var(--print-ink);
  padding: 0 var(--space-4) var(--space-2);
  border-bottom: 2px solid var(--print-rule);
  word-break: break-word;
}

.cert__case {
  font-family: var(--font-display);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--paper-alias);
  word-break: break-word;
}

/* ── The facts ──────────────────────────────────────────────────── */

.cert__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-6);
  width: 100%;
  max-width: 150mm;
  /* Shares the sheet's free height with the signature row (also auto), so a
     short certificate is balanced instead of top-heavy. */
  margin: auto 0 0;
  padding-top: var(--space-8);
  text-align: left;
}
.cert__fact { border-top: 1px dotted var(--print-rule); padding-top: var(--space-2); }
.cert__fact dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--print-ink-2);
}
.cert__fact dd {
  margin: 2px 0 0;
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: var(--weight-bold);
  color: var(--print-ink);
  word-break: break-word;
}

/* ── Stamp and signature ────────────────────────────────────────── */

.cert__foot {
  margin-top: auto;
  padding-top: var(--space-8);
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
}

/* A rubber stamp in real ink on paper (the neon red would not print). */
.scr-certificate .cert__stamp {
  border-color: var(--pin-red-deep);
  color: var(--pin-red-deep);
  transform: rotate(-12deg);
  font-size: clamp(20px, 5vw, 28px);
  opacity: .85;
}

.cert__sign { text-align: center; min-width: 45%; }
.cert__signature {
  font-family: var(--font-ui);
  font-size: clamp(28px, 7vw, 40px);
  font-style: italic;
  font-weight: var(--weight-semibold);
  color: var(--bubble-q-label);
  line-height: 1;
  padding: 0 var(--space-4) var(--space-1);
  border-bottom: 1px solid var(--print-ink);
}
.cert__signer {
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--print-ink-2);
}

@media (max-width: 480px) {
  .cert__facts { grid-template-columns: 1fr; }
  .cert__foot { flex-direction: column-reverse; align-items: center; }
}

/* ── Print: one A4 page ─────────────────────────────────────────── */

@media print {
  @page { size: A4; margin: 0; }

  .scr-certificate,
  .scr-certificate .app-container {
    background: var(--print-page);
    margin: 0;
    padding: 0;
    max-width: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .scr-certificate::before { display: none; }

  /* Everything that is the app, not the paper. */
  .scr-certificate .cert-bar,
  .scr-certificate .top-bar,
  .scr-certificate .timer-bar,
  .scr-certificate .console-nav,
  .scr-certificate .live-pause,
  .scr-certificate .live-hint-pop,
  .scr-certificate .live-toast { display: none !important; }

  .cert + .cert { break-before: page; page-break-before: always; }
  .cert-copies { display: none !important; }
  .cert {
    width: 210mm;
    max-width: none;
    height: 297mm;
    min-height: 0;
    padding: 14mm;
    margin: 0;
    box-shadow: none;
    overflow: hidden;
    break-inside: avoid;
    page-break-after: avoid;
  }
  .cert__frame { height: 100%; padding: 16mm 14mm; }

  /* Print sizes are fixed, not viewport-relative. */
  .cert__bureau { font-size: 9pt; }
  .cert__seal { font-size: 48pt; }
  .cert__title { font-size: 40pt; }
  .cert__lead { font-size: 13pt; }
  .cert__name { font-size: 32pt; }
  .cert__case { font-size: 22pt; }
  .cert__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cert__fact dd { font-size: 14pt; }
  .cert__foot { flex-direction: row; align-items: flex-end; }
  .scr-certificate .cert__stamp { font-size: 20pt; }
  .cert__signature { font-size: 28pt; }
}

/* ═══ Paper/print surface — the A4 clue sheet (print_sheet.html). ═══════ */

@page {
  size: A4;
  margin: 0;
}

html:has(> body.csm-print),
body.csm-print {
  margin: 0;
  padding: 0;
  background: var(--print-ink-2);   /* the desk around the sheet, on screen */
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;        /* keep the cream stock when printing */
}
.csm-print {
  font-family: var(--font-ui);
  color: var(--print-ink);
}
.csm-print *, .csm-print *::before, .csm-print *::after { box-sizing: border-box; }
.csm-print p { margin: 0; }

.csm-print .page {
  position: relative;
  width: 210mm;
  height: 297mm;
  padding: 14mm;
  margin: 0 auto;
  background: var(--print-page);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* On screen the sheets sit apart so the parent can see the pagination; in
   print each one is its own page and the gap must not exist. */
.csm-print .page + .page { margin-top: 8mm; }

@media print {
  html:has(> body.csm-print),
  body.csm-print { background: var(--print-page); }
  .csm-print .page + .page { margin-top: 0; }
  .csm-print .page { break-after: page; }
  .csm-print .page:last-child { break-after: auto; }
  .csm-print .no-print { display: none !important; }
}

/* ── Header ─────────────────────────────────────────────────────── */

.csm-print .sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 6mm;
  border-bottom: 2.5px solid var(--print-ink);
  padding-bottom: 3mm;
}
.csm-print .sheet__eyebrow {
  font-family: var(--font-display);
  font-size: 10pt;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--print-ink-2);
}
.csm-print .sheet__title {
  font-family: var(--font-display);
  font-size: 24pt;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 3px;
  line-height: 1.1;
}
.csm-print .sheet__count {
  font-family: var(--font-mono);
  font-size: 16pt;
  font-weight: var(--weight-bold);
  letter-spacing: 2px;
  text-align: right;
}
.csm-print .sheet__count-box { flex-shrink: 0; text-align: right; }

.csm-print .sheet__instruction {
  font-size: 10pt;
  color: var(--print-ink-2);
  margin: 3mm 0 5mm;
  line-height: 1.4;
}

/* ── Note grid — four to a sheet ────────────────────────────────── */

.csm-print .sheet__notes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6mm;
  min-height: 0;   /* let the notes shrink inside the fixed page */
}

/* ClueNote (ds-clue, macro `clue` in components/ds.html). Dashed, because
   the parent cuts along it. The code is the largest thing on the note: the
   parent reads it at arm's length while hiding the note. */
.csm-print .ds-clue {
  border: 1.5px dashed var(--print-rule);
  border-radius: 3mm;
  padding: 7mm;
  background: var(--print-note);
  color: var(--print-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.csm-print .ds-clue__top {
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  font-family: var(--font-display);
  font-size: 10pt;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--print-ink-2);
}
.csm-print .ds-clue__eyebrow {
  font-family: var(--font-display);
  font-size: 10pt;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--print-ink-2);
}
.csm-print .ds-clue__rule { border: 0; border-top: 1.5px solid var(--print-ink); margin: 3mm 0; }
.csm-print .ds-clue__code {
  font-family: var(--font-mono);
  font-size: 32pt;
  font-weight: var(--weight-bold);
  letter-spacing: 6px;
  line-height: 1;
  color: var(--print-ink);
  word-break: break-all;
}
.csm-print .ds-clue__text {
  font-size: 13pt;
  line-height: 1.5;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.csm-print .ds-clue__room {
  margin-top: 3mm;
  font-weight: var(--weight-bold);
  font-size: 12pt;
}
.csm-print .ds-clue__footer {
  border-top: 1px dotted var(--print-rule);
  padding-top: 3mm;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 3mm;
}
.csm-print .ds-clue__hint { font-size: 9pt; color: var(--print-ink-2); }
.csm-print .ds-clue__qr {
  width: 17mm;
  height: 17mm;
  flex-shrink: 0;
  border: 1.5px solid var(--print-ink);
  border-radius: 1.5mm;
  padding: 1mm;
  background: var(--qr-quiet);
}
.csm-print .ds-clue__qr svg { display: block; width: 100%; height: 100%; }

/* ── Page footer ────────────────────────────────────────────────── */

.csm-print .sheet__footer {
  border-top: 1px solid var(--print-rule);
  margin-top: 5mm;
  padding-top: 2.5mm;
  display: flex;
  justify-content: space-between;
  gap: 4mm;
  font-family: var(--font-mono);
  font-size: 8pt;
  letter-spacing: 1px;
  color: var(--print-ink-2);
}

/* ── Nothing to print ───────────────────────────────────────────── */

.csm-print .sheet__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3mm;
  color: var(--print-ink-2);
  font-size: 12pt;
  line-height: 1.5;
}

/* ── On-screen controls ─────────────────────────────────────────── */

.csm-print .sheet__bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  background: var(--print-ink);
}
.csm-print .sheet__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 20px;
  min-height: var(--tap-min);
  border-radius: var(--radius-sm);
  border: 2px solid var(--print-page);
  background: transparent;
  color: var(--print-page);
  text-decoration: none;
  cursor: pointer;
}
.csm-print .sheet__btn--primary { background: var(--print-page); color: var(--print-ink); }

/* On a phone the A4 sheet is wider than the screen. The page's script zooms
   the desk to fit; without script the desk scrolls sideways rather than the
   paper shrinking (the geometry is the point). */
@media screen {
  .csm-print .sheet__desk { padding: 8px 0; overflow-x: auto; }
}


/* ═══ Phase D · P5 · Bevis keypad ═══ */
/* A note with a colour code (sheet__key) shows a swatch dot and the
 * number first, then the code word, so a child who cannot read matches colour
 * and digits on the Bevis keypad. Swatches are literal print-safe colours
 * (the neon tokens are screen hues), named like services/evidence_code.py.
 * Every dot has an ink ring, so white shows and a black-and-white printer
 * still prints a dot. */

.csm-print {
  --swatch-red: #d62828;
  --swatch-blue: #1d4ed8;
  --swatch-green: #1f8a3a;
  --swatch-yellow: #ffd000;
  --swatch-purple: #7b2cbf;
  --swatch-orange: #f77f00;
  --swatch-white: #ffffff;
  --swatch-black: #111111;
  --swatch-pink: #ff6fae;
  --swatch-brown: #7f4f24;
}
.csm-print .sheet-swatch--red    { --swatch: var(--swatch-red); }
.csm-print .sheet-swatch--blue   { --swatch: var(--swatch-blue); }
.csm-print .sheet-swatch--green  { --swatch: var(--swatch-green); }
.csm-print .sheet-swatch--yellow { --swatch: var(--swatch-yellow); }
.csm-print .sheet-swatch--purple { --swatch: var(--swatch-purple); }
.csm-print .sheet-swatch--orange { --swatch: var(--swatch-orange); }
.csm-print .sheet-swatch--white  { --swatch: var(--swatch-white); }
.csm-print .sheet-swatch--black  { --swatch: var(--swatch-black); }
.csm-print .sheet-swatch--pink   { --swatch: var(--swatch-pink); }
.csm-print .sheet-swatch--brown  { --swatch: var(--swatch-brown); }

.csm-print .sheet__key {
  display: flex;
  align-items: center;
  gap: 4mm;
  margin-bottom: 2mm;
}
.csm-print .sheet__dot {
  flex-shrink: 0;
  width: 13mm;
  height: 13mm;
  border-radius: var(--radius-round);
  background: var(--swatch);
  border: 1.2mm solid var(--print-ink);
}
.csm-print .sheet__digits {
  font-size: 34pt;
  letter-spacing: 4px;
}
.csm-print .sheet__word {
  display: block;
  font-size: 18pt;
  letter-spacing: 4px;
}


/* ═══ Phase D · P7 · Team play ═══ */
/* The certificate names every agent and what each found. Up to four names
 * share the name line, so it steps down a size; the finds are one short
 * wrapping row under it. Still exactly one A4 page in print. */

.cert .cert__name--team { font-size: clamp(24px, 6.5vw, 36px); }
.cert .cert__team {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1) var(--space-5);
}
.cert .cert__agent {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(14px, 3.6vw, 17px);
  color: var(--print-ink-2);
}
.cert .cert__agent-name { font-weight: var(--weight-bold); color: var(--print-ink); }

@media print {
  .cert .cert__name--team { font-size: 26pt; }
  .cert .cert__team { margin-top: 3mm; }
  .cert .cert__agent { font-size: 12pt; }
}


/* ═══ Phase G · The kit sheet: six notes to an A4 ═══ */
/* A 2×3 grid; each note is smaller than the four-up live note, so the code
 * and padding step down. The legend line (which note goes on which thing) is
 * for the grown-up and sits above the notes, never on them. */

.csm-print .sheet__notes--six { grid-template-rows: repeat(3, 1fr); gap: 5mm; }
.csm-print .sheet__notes--six .ds-clue { padding: 5mm; }
.csm-print .sheet__notes--six .ds-clue__rule { margin: 2mm 0; }
.csm-print .sheet__notes--six .ds-clue__text { font-size: 10pt; line-height: 1.35; }
/* A third of a page: the dot and the word already say it is a code, and the
   QR still scans at 14mm, so the teaser gets its two lines. */
.csm-print .sheet__notes--six .ds-clue__eyebrow { display: none; }
.csm-print .sheet__notes--six .ds-clue__footer { padding-top: 2mm; }
.csm-print .sheet__notes--six .ds-clue__qr { width: 14mm; height: 14mm; }
.csm-print .sheet__notes--six .sheet__dot { width: 11mm; height: 11mm; }
.csm-print .sheet__notes--six .sheet__digits { font-size: 30pt; }
.csm-print .sheet__notes--six .sheet__word { font-size: 14pt; }

.csm-print .sheet__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2mm 6mm;
  margin: -2mm 0 4mm;
  font-size: 10pt;
  color: var(--print-ink-2);
}
.csm-print .sheet__legend b { color: var(--print-ink); }

/* ── One certificate per child (plan 2026-11-24, §7 decision 3) ──── */

.scr-certificate .cert-copies {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  max-width: 210mm;
  margin: 0 auto var(--space-4);
  color: var(--ink-strong);
  font-size: var(--font-size-sm);
}
.scr-certificate .cert-copies input {
  width: 5em;
  padding: var(--space-2);
  border: 1px solid var(--print-rule);
  border-radius: var(--radius-sm, 6px);
  font: inherit;
}
.scr-certificate .cert-copies small { flex-basis: 100%; color: var(--ink); }
.scr-certificate .cert-copies__one { color: var(--ink-strong); }
.scr-certificate .cert + .cert { margin-top: var(--space-6); }
/* "Agent" and room to write a name, on the name's own underline. */
.cert .cert__name--blank {
  display: flex;
  align-items: flex-end;
  gap: 3mm;
  min-width: 75%;
  white-space: nowrap;
}
.cert .cert__line { flex: 1; height: 1.1em; }
