/* SPOT IT — visual identity + feel.
   Palette tokens are DESIGN.md §4 and are load-bearing: no red, no green, and the
   marker yellow appears ONLY on a correct mark at reveal. Depth here comes from
   paper grain, layered ink shadows and type — never from new hues. */

:root {
  /* the five palette values */
  --paper: #DDE0DC;
  --ink: #15181B;
  --bubble-them: #FFFFFF;
  --bubble-you: #C4CAC5;
  --marker: #FFD400;
  --graphite: #6E7479;

  /* derived: the same material under light, not new colours */
  --paper-deep: #CFD3CE;
  /* graphite mixed toward ink for TEXT ONLY — the base graphite fails 4.5:1 on
     paper at small sizes; strokes and fills keep using --graphite */
  --graphite-text: #545B60;
  --hairline: rgba(21, 24, 27, 0.14);
  --lift-1: 0 1px 0 rgba(21, 24, 27, 0.06), 0 2px 6px rgba(21, 24, 27, 0.07);
  --lift-2: 0 1px 0 rgba(21, 24, 27, 0.08), 0 6px 18px rgba(21, 24, 27, 0.12);
  --lift-3: 0 2px 0 rgba(21, 24, 27, 0.10), 0 14px 34px rgba(21, 24, 27, 0.16);

  --ease-out: cubic-bezier(0.22, 0.86, 0.28, 1);
  --ease-spring: cubic-bezier(0.18, 1.30, 0.42, 1);

  --font-display: "Archivo", "Segoe UI", Helvetica, Arial, sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* paper grain — texture, not a gradient, and never tinted. It sits BEHIND the
   content (bubbles, cards, and text render over it crisp); the desk is paper,
   the printed pieces are smooth. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
  mix-blend-mode: multiply;
  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='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 40px;
  position: relative;
  z-index: 1;   /* content above the grain layer */
}

button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

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

/* ---------- persistent chrome: the sound toggle, and nothing else ---------- */

.sound-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  color: var(--graphite);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.sound-toggle.on { color: var(--ink); border-color: var(--ink); }
.sound-toggle svg { width: 18px; height: 18px; display: block; }

/* ---------- cold open ---------- */

.cold-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 26px;
  animation: fadeUp 600ms var(--ease-out) both;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 54px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

/* No marker yellow in the wordmark: the highlighter colour must stay reserved
   for a correct mark, or it stops meaning anything. */

.tagline {
  font-size: 17px;
  line-height: 1.4;
  max-width: 250px;
  color: var(--ink);
  opacity: 0.75;
}

/* ---------- case header ---------- */

.puzzle-head {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--graphite-text);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 10px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.linklike {
  background: none;
  border: none;
  color: var(--graphite-text);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px;
}

.setup {
  font-size: 14px;
  line-height: 1.45;
  color: var(--graphite-text);
  margin-bottom: 18px;
}

/* ---------- conversation ---------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}

.bubble {
  position: relative;
  z-index: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 11px 15px;
  min-height: 44px;
  max-width: 86%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: var(--bubble-them);
  box-shadow: var(--lift-1);
  align-self: flex-start;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.38;
  text-align: left;
  display: block;
  color: var(--ink);
  transition:
    opacity 320ms var(--ease-out),
    box-shadow 240ms var(--ease-out),
    border-color 240ms var(--ease-out),
    transform 240ms var(--ease-spring);
}

.bubble.you {
  background: var(--bubble-you);
  align-self: flex-end;
}

.bubble:not([disabled]):active { transform: scale(0.985); }

/* the highlighter stroke: one gesture, two different payoffs */
.bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 14px;
  transform: scaleX(0);
  transform-origin: left center;
  background: transparent;
  mix-blend-mode: multiply;
  transition:
    transform 420ms var(--ease-out),
    background-color 300ms var(--ease-out);
}

.bubble .speaker,
.bubble .text,
.bubble .tag { position: relative; z-index: 1; }

.bubble .speaker {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite-text);
  margin-bottom: 3px;
}

.bubble .text { display: block; }

/* candidate mark during play: graphite stroke, never the reward yellow */
.bubble.candidate::before {
  transform: scaleX(1);
  background: rgba(110, 116, 121, 0.30);
}
.bubble.candidate {
  border-color: var(--graphite);
  box-shadow: var(--lift-2);
}
.bubble.candidate .text {
  text-decoration: underline;
  text-decoration-color: var(--graphite);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* reveal — the grey stroke turns gold */
.bubble.spotted::before {
  transform: scaleX(1);
  background: var(--marker);
}
.bubble.spotted {
  border-color: var(--ink);
  box-shadow: var(--lift-2);
  animation: bloom 620ms var(--ease-out);
}

.bubble.false-flag::before {
  transform: scaleX(1);
  background: rgba(110, 116, 121, 0.88);
}
.bubble.false-flag { border-color: var(--graphite); }
.bubble.false-flag .text,
.bubble.false-flag .tag { color: var(--paper); }
.bubble.false-flag .speaker { color: rgba(221, 224, 220, 0.7); }
.bubble.false-flag .text { text-decoration: none; }

.bubble.missed {
  border: 2px solid var(--ink);
  box-shadow: var(--lift-2);
  animation: outlinePulse 700ms var(--ease-out);
}

.bubble.dimmed { opacity: 0.42; box-shadow: none; }

.bubble .tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  margin-top: 6px;
  color: var(--ink);
  animation: fadeUp 300ms var(--ease-out) both;
}

.bubble[disabled] { cursor: default; }

/* staggered entrance, first paint of a case only */
.thread.entering .bubble {
  animation: bubbleIn 460ms var(--ease-spring) both;
  animation-delay: calc(var(--i) * 68ms);
}

/* ---------- hint + call bar ---------- */

.callbar {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint {
  text-align: center;
  font-size: 15px;
  min-height: 21px;
  color: var(--ink);
  opacity: 0.8;
}

.hint.strong { font-weight: 600; opacity: 1; }
.hint.nudge { animation: nudge 420ms var(--ease-out); font-weight: 600; opacity: 1; }

.call-buttons { display: flex; gap: 10px; }

/* NOTHING HERE and CALL IT: identical weight, identical size — by design, do not touch */
.call-buttons button {
  flex: 1;
  padding: 17px 8px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: var(--bubble-them);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--lift-1);
  transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.call-buttons button:hover { box-shadow: var(--lift-2); }
.call-buttons button:active { transform: translateY(2px); box-shadow: none; background: var(--paper-deep); }

button.primary {
  padding: 17px 34px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--lift-2);
  transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
button.primary:active { transform: translateY(2px); box-shadow: var(--lift-1); }

/* ---------- reveal ---------- */

.verdict {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-align: center;
  margin: 26px 0 6px;
  animation: stampIn 520ms var(--ease-spring) both;
}

.verdict.small { font-size: 28px; letter-spacing: -0.02em; margin: 22px 0 4px; }

.tactic-card {
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--bubble-them);
  padding: 22px 20px;
  margin-top: 16px;
  text-align: center;
  box-shadow: var(--lift-3);
  animation: cardRise 520ms var(--ease-spring) both;
}

.tactic-card .kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--graphite-text);
}

.tactic-card .tactic-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 8px 0 12px;
}

.tactic-card .tactic-line { font-size: 15px; line-height: 1.45; }

.tactic-card .card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--graphite-text);
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.tactic-card .card-small {
  font-size: 13px;
  color: var(--graphite-text);
  margin-top: 6px;
  line-height: 1.45;
}

.continue-row { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- break ---------- */

.break-list { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }

.break-option {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--bubble-them);
  color: var(--ink);
  padding: 15px 17px;
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.38;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--lift-1);
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out), opacity 300ms var(--ease-out);
}

.break-list.entering .break-option {
  animation: bubbleIn 420ms var(--ease-spring) both;
  animation-delay: calc(var(--i) * 80ms);
}

.break-option:hover { box-shadow: var(--lift-2); }
.break-option:active { transform: translateY(2px); box-shadow: none; }
.break-option[disabled] { cursor: default; }
.break-option.chosen { box-shadow: var(--lift-3); border-width: 3px; }
.break-option.faded { opacity: 0.38; box-shadow: none; }

.break-option .tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  margin-top: 8px;
  color: var(--graphite-text);
}
.break-option.chosen .tag { color: var(--ink); }

.break-note {
  text-align: center;
  font-size: 14px;
  color: var(--graphite-text);
  margin-top: 18px;
  line-height: 1.45;
  animation: fadeUp 420ms var(--ease-out) both;
  animation-delay: 140ms;
}

/* ---------- receipt ---------- */

.receipt {
  position: relative;
  background: var(--bubble-them);
  padding: 26px 22px 30px;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: var(--lift-3);
  animation: printOut 720ms var(--ease-out) both;
  /* torn top and bottom edge */
  -webkit-mask:
    radial-gradient(6px at 6px 50%, transparent 98%, #000) repeat-x top left / 12px 10px,
    radial-gradient(6px at 6px 50%, transparent 98%, #000) repeat-x bottom left / 12px 10px,
    linear-gradient(#000, #000) no-repeat center / 100% calc(100% - 20px);
  mask:
    radial-gradient(6px at 6px 50%, transparent 98%, #000) repeat-x top left / 12px 10px,
    radial-gradient(6px at 6px 50%, transparent 98%, #000) repeat-x bottom left / 12px 10px,
    linear-gradient(#000, #000) no-repeat center / 100% calc(100% - 20px);
}

.receipt hr {
  border: none;
  border-top: 1px dashed var(--graphite);
  margin: 14px 0;
  opacity: 0.6;
}

.receipt-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.26em;
}

.receipt-line { color: var(--graphite-text); margin-top: 4px; font-size: 12px; letter-spacing: 0.18em; }

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.receipt-row span:first-child { color: var(--graphite-text); }
.receipt-row span:last-child { font-weight: 500; text-align: right; }

.countdown {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--graphite-text);
  margin-top: 18px;
}

.psyoptin-line {
  text-align: center;
  font-size: 13px;
  color: var(--ink);
  opacity: 0.6;
  margin-top: 22px;
}

.share-status {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-top: 12px;
  min-height: 18px;
}

.share-fallback {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--graphite);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: all;
}

/* ---------- test harness (removed before launch) ---------- */

.dev-harness {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px dashed var(--hairline);
  text-align: center;
}

.dev-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--graphite-text);
  margin-bottom: 12px;
}

.dev-next-btn {
  width: 100%;
  padding: 15px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--paper);
  color: var(--ink);
  border: 2px dashed var(--graphite);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.dev-next-btn:active { transform: translateY(2px); background: var(--paper-deep); }

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

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes stampIn {
  0%   { opacity: 0; transform: scale(1.45); }
  60%  { opacity: 1; transform: scale(0.97); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bloom {
  0%   { box-shadow: var(--lift-2); }
  35%  { box-shadow: 0 0 0 6px rgba(255, 212, 0, 0.42), var(--lift-2); }
  100% { box-shadow: var(--lift-2); }
}

@keyframes outlinePulse {
  0%   { box-shadow: 0 0 0 0 rgba(21, 24, 27, 0.30), var(--lift-2); }
  60%  { box-shadow: 0 0 0 7px rgba(21, 24, 27, 0), var(--lift-2); }
  100% { box-shadow: var(--lift-2); }
}

@keyframes printOut {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

/* Reduced motion: every animation collapses to a plain fade, transitions off.
   Final visual states are unchanged. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .thread.entering .bubble,
  .break-list.entering .break-option { animation-delay: 0ms !important; }
  .verdict, .tactic-card, .receipt { animation: fadeIn 160ms linear both !important; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
}
