/* Layout: a detective's desk. One paper card in the middle (reel style), printable sheets below. */
:root {
  --desk: #e4e6e8;
  --desk-ink: #23272b;
  --desk-muted: #5b636b;
  --paper: #fbfaf7;
  --ink: #1b1b1b;
  --ink-soft: #444;
  --stamp: #b2382c;
  --line: #b9bec3;
  --type: 'Special Elite', 'Courier New', Courier, monospace;
  --hand: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #15171a;
    --desk-ink: #e8e9ea;
    --desk-muted: #9aa1a8;
    --line: #3a3f45;
    --stamp: #d4574a;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
}
body {
  background: var(--desk);
  color: var(--desk-ink);
  font-family: var(--hand);
  font-size: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 48px;
}
.screen {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  gap: 28px;
}
.eyebrow {
  font-family: var(--type);
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--desk-muted);
  text-transform: uppercase;
}
h1,
h2,
h3 {
  font-family: var(--type);
  font-weight: 400;
  margin: 0;
  text-wrap: balance;
}
h1 {
  font-size: clamp(30px, 7vw, 46px);
  letter-spacing: 0.03em;
}
h2 {
  font-size: clamp(24px, 5.5vw, 34px);
  letter-spacing: 0.04em;
}
h3 {
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.masthead,
.doc-title {
  display: grid;
  gap: 6px;
  text-align: center;
}
.hint {
  color: var(--desk-muted);
  margin: 0;
}
.small {
  font-size: 15px;
  text-align: center;
}

/* Upload */
.upload {
  display: grid;
  justify-items: center;
  gap: 12px;
}
.drop {
  width: min(100%, 520px);
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 26px 16px;
  border: 2px dashed var(--desk-muted);
  border-radius: 12px;
  cursor: pointer;
}
.drop:hover,
.drop.over {
  border-color: var(--desk-ink);
}
.drop:focus-within {
  outline: 3px dashed var(--stamp);
  outline-offset: 4px;
}
.drop input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.drop-big {
  font-family: var(--type);
  font-size: 22px;
}
.drop-small {
  color: var(--desk-muted);
  font-size: 15px;
}
.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--desk-muted);
  text-align: center;
}
.status.error {
  color: var(--stamp);
}

/* Buttons */
.btn {
  font-family: var(--type);
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--desk-ink);
  background: transparent;
  border: 1.5px solid var(--desk-ink);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  background: var(--desk-ink);
  color: var(--desk);
}
.btn.solid {
  background: var(--desk-ink);
  color: var(--desk);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:focus-visible,
.chip:focus-visible {
  outline: 3px dashed var(--stamp);
  outline-offset: 3px;
}

/* Checks */
.checks {
  display: grid;
  gap: 8px;
}
.checks .bad,
.checks .ok {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 16px;
}
.checks .bad {
  border: 2px solid var(--stamp);
}
.checks .bad b {
  color: var(--stamp);
  font-family: var(--type);
  font-weight: 400;
}
.checks .ok {
  border: 1.5px solid var(--line);
}
.checks ul {
  margin: 6px 0 0;
  padding-left: 20px;
  color: var(--desk-muted);
}

/* Deck chooser */
.decks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  font-family: var(--hand);
  font-size: 18px;
  color: var(--desk-ink);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.chip[aria-pressed='true'] {
  border-color: var(--desk-ink);
  background: var(--desk-ink);
  color: var(--desk);
}
.chip.done::after {
  content: ' ✓';
}

/* The card */
.stage {
  display: grid;
  justify-items: center;
  gap: 14px;
}
.card {
  width: min(100%, 460px);
  max-width: 100%;
  aspect-ratio: 85 / 55;
  perspective: 1200px;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  display: block;
}
.card:focus-visible {
  outline: 3px dashed var(--stamp);
  outline-offset: 6px;
  border-radius: 10px;
}
.flip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
  transform-style: preserve-3d;
}
.card.flipped .flip {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 10px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.08),
    0 10px 28px rgba(0, 0, 0, 0.18);
}
.back {
  transform: rotateY(180deg);
}
@media (prefers-reduced-motion: reduce) {
  .flip {
    transition: none;
  }
}

/* Card faces: shared by screen and print. Sized in container units so the card looks the same at any size. */
.face,
.cell {
  background: var(--paper);
  color: var(--ink);
  container-type: size;
  overflow: hidden;
}
.cardface {
  position: absolute;
  inset: 0;
  display: grid;
}
.cardface.f {
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 3cqh 3cqw 4cqh;
}
.cardface.b {
  align-content: center;
  justify-items: center;
  gap: 3cqh;
  padding: 6cqh 7cqw;
  text-align: center;
}
.cardface .pic {
  min-height: 0;
  display: grid;
}
.cardface .pic svg {
  width: 100%;
  height: 100%;
}
.cardface .pic:has(.photo) {
  position: relative;
  overflow: hidden;
}
.cardface .photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(1) contrast(1.1);
}
.cardface .clue {
  display: grid;
  gap: 1cqh;
  text-align: center;
  font-size: 7.4cqh;
  line-height: 1.15;
  padding-top: 1cqh;
}
.cardface .clue b {
  font-family: var(--type);
  font-weight: 400;
  font-size: 7cqh;
  letter-spacing: 0.05em;
}
.cardface .link {
  font-size: 5.8cqh;
  line-height: 1.15;
  color: var(--ink-soft);
}
.cardface .hint {
  font-family: var(--type);
  font-size: 5.6cqh;
  letter-spacing: 0.14em;
  color: #6b6b6b;
}
.cardface .blank {
  display: inline-block;
  width: 16cqw;
  border-bottom: 0.5cqh solid currentColor;
  margin: 0 0.6cqw;
  vertical-align: baseline;
}
.cardface .tag {
  position: absolute;
  left: 3cqw;
  top: 3cqh;
  font-family: var(--type);
  font-size: 5.4cqh;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cardface .star {
  position: absolute;
  right: 3.4cqw;
  top: 2.4cqh;
  font-size: 7cqh;
}
.cardface .answer {
  font-family: var(--type);
  font-size: 11cqh;
  line-height: 1.12;
  text-wrap: balance;
}
.cardface .answer.long {
  font-size: 8cqh;
}
.cardface .exact {
  font-size: 7.6cqh;
  line-height: 1.22;
  color: var(--ink-soft);
  text-wrap: balance;
}
.cardface .exact::first-letter {
  text-transform: uppercase;
}
.cardface .also {
  font-size: 6.4cqh;
  border: 0.4cqh dashed #777;
  border-radius: 4px;
  padding: 0.6cqh 2cqw;
}
.cardface .tip {
  font-size: 6cqh;
  line-height: 1.2;
  color: var(--ink-soft);
  border-top: 0.3cqh solid #bbb;
  padding-top: 1.6cqh;
  max-width: 92%;
  text-wrap: balance;
}
.cardface .tip b {
  font-family: var(--type);
  font-weight: 400;
  font-size: 5cqh;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 1cqw;
}
.cardface .lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1.6cqh;
  font-size: 6.6cqh;
  line-height: 1.15;
  text-align: left;
  justify-self: stretch;
}
.cardface .pic .lines {
  align-self: center;
  font-size: 6.4cqh;
  gap: 2.2cqh;
}
.cardface .lines li::before {
  content: '▸ ';
}
.cardface .identity {
  font-size: 5.6cqh;
  line-height: 1.2;
  color: var(--ink-soft);
  font-style: italic;
  max-width: 92%;
  text-wrap: balance;
}
.cardface .src {
  position: absolute;
  right: 3cqw;
  bottom: 2.4cqh;
  font-family: var(--type);
  font-size: 4.4cqh;
  color: #8a8a8a;
  letter-spacing: 0.05em;
}

.dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 460px;
}
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--desk-muted);
}
.dot.seen {
  background: var(--desk-ink);
  border-color: var(--desk-ink);
}
.dot.here {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.closed {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  justify-items: center;
  text-align: center;
}
.stampbox {
  font-family: var(--type);
  color: var(--stamp);
  border: 3px solid var(--stamp);
  border-radius: 6px;
  padding: 6px 18px;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: 0.12em;
  transform: rotate(-6deg);
}
@media (prefers-reduced-motion: no-preference) {
  .stampbox {
    animation: thump 0.35s ease-out;
  }
}
@keyframes thump {
  from {
    transform: rotate(-6deg) scale(1.6);
    opacity: 0;
  }
  to {
    transform: rotate(-6deg) scale(1);
    opacity: 1;
  }
}

/* Print sheets (preview on screen, real pages when printing) */
.print-area {
  display: grid;
  gap: 10px;
  border-top: 1.5px dashed var(--line);
  padding-top: 22px;
}
.print-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sheets {
  display: grid;
  gap: 18px;
}
.sheet-label {
  font-family: var(--type);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--desk-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sheet {
  background: var(--paper);
  padding: 10px;
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cell {
  position: relative;
  aspect-ratio: 85 / 55;
  outline: 1px dashed #9a9a9a;
}
.cell.empty {
  outline-color: transparent;
}

.foot a {
  color: inherit;
}
.foot {
  font-size: 14px;
  color: var(--desk-muted);
  text-align: center;
  max-width: 62ch;
  margin: 0 auto;
}

@page {
  size: A4 portrait;
  margin: 0;
}
@media print {
  body {
    background: #fff;
    padding: 0;
  }
  .masthead,
  .upload,
  .doc-title,
  .checks,
  .decks,
  .stage,
  .closed,
  .print-head,
  .print-area > .hint,
  .foot,
  .sheet-label {
    display: none !important;
  }
  .screen,
  .print-area,
  .sheets {
    display: block;
    max-width: none;
    border: 0;
    padding: 0;
    margin: 0;
  }
  .sheet {
    width: 210mm;
    height: 297mm;
    padding: 11mm 20mm;
    border-radius: 0;
    background: #fff;
    grid-template-columns: repeat(2, 85mm);
    grid-auto-rows: 55mm;
    break-after: page;
  }
  .cell {
    aspect-ratio: auto;
    width: 85mm;
    height: 55mm;
    background: #fff;
    outline: 0.2mm dashed #888;
  }
  .cell.empty {
    outline-color: transparent;
  }
  .sheet-wrap {
    break-inside: avoid;
  }
}
