/* ==========================================================================
   Fake sau Real — design tokens & shared atoms
   Aesthetic: forensic dossier. Evidence tags, rubber stamps, monospace
   metadata, warm paper on the phone, deep black on the projector.
   ========================================================================== */

:root {
  --red: #d2232a;
  --red-deep: #a81a20;
  --red-wash: #fdf0f0;
  --green: #1e7a46;
  --green-deep: #165c35;
  --green-wash: #eef7f1;
  --ink: #1d1d1f;
  --gray: #6f6f6f;
  --paper: #fbfaf7;
  --paper-2: #f2efe9;
  --line: #e0dbd2;
  --stage: #0c0c0e;
  --stage-2: #17171b;
  --stage-line: #2c2c33;

  /* Per-quiz accent. REAL/FAKE keep their fixed semantic colours above — only
     brand chrome (primary buttons, rules, progress) follows this. */
  --accent: #d2232a;
  --accent-deep: color-mix(in srgb, var(--accent) 80%, #000);
  --accent-wash: color-mix(in srgb, var(--accent) 8%, transparent);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;

  --tap: 64px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --slam: cubic-bezier(0.2, 1.5, 0.4, 1);

  /* Self-contained film grain — no network request, survives an offline venue. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

html, body {
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
img, video { max-width: 100%; display: block; }

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

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

/* -------------------------------------------------- connection indicator */
/* Shared by every page's header (join, admin), so it lives here — not in a
   page stylesheet where the other pages would render it unstyled. */

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 0.62rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray);
}
.link__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gray);
  transition: background 0.3s;
}
.link.is-live .link__dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.link.is-polling .link__dot { background: #c8901a; }

/* ------------------------------------------------------------ evidence tag */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  font: 600 0.68rem/1 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gray);
}
.tag::before {
  content: "";
  width: 1.7em;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}
.tag--bare::before { display: none; }

/* --------------------------------------------------------------- wordmark */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: 800 0.88rem/1 var(--sans);
  letter-spacing: -0.01em;
  text-decoration: none;
  color: inherit;
}
/* A miniature of the reveal stamp doubles as the logo. */
.wordmark b {
  font: 900 0.6rem/1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--red);
  border: 2px solid currentColor;
  border-radius: 3px;
  padding: 2px 4px;
  transform: rotate(-6deg);
}
.wordmark span { font-weight: 800; }

/* ------------------------------------------------------- the signature move */

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: clamp(2rem, 9vw, 4.5rem);
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.16em 0.36em;
  border: 0.085em solid currentColor;
  border-radius: 8px;
  box-shadow: inset 0 0 0 0.028em currentColor;
  transform: rotate(-8deg);
  opacity: 0.94;
  position: relative;
  isolation: isolate;
}
/* Ink-bleed: the grain eats into the letterforms like a real rubber stamp. */
.stamp::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: var(--grain);
  mix-blend-mode: screen;
  opacity: 0.22;
  border-radius: inherit;
  pointer-events: none;
}
.stamp--real { color: var(--green); }
.stamp--fake { color: var(--red); }

@keyframes slam {
  0%   { transform: rotate(-27deg) scale(2.7); opacity: 0; }
  55%  { opacity: 1; }
  72%  { transform: rotate(-5deg) scale(0.93); }
  100% { transform: rotate(-8deg) scale(1); opacity: 0.94; }
}
.stamp--slam { animation: slam 0.52s var(--slam) both; }

/* ------------------------------------------------------------------ timer */

.timer {
  height: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.timer__fill {
  height: 100%;
  width: 100%;
  background: var(--ink);
  transform-origin: left center;
  transform: scaleX(1);
}
.timer__fill.is-urgent { background: var(--red); }

/* ------------------------------------------------------- distribution bars */

.bars { display: grid; gap: 10px; }
.bar__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 5px;
}
.bar__label { font-weight: 700; }
.bar__count { font: 600 0.85rem/1 var(--mono); color: var(--gray); }
.bar__track {
  height: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  width: 0;
  background: var(--gray);
  transition: width 0.8s var(--ease);
}
.bar.is-correct .bar__fill { background: var(--green); }
.bar.is-correct .bar__label::after {
  content: " ✓";
  color: var(--green);
}

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

.btn {
  min-height: 52px;
  padding: 14px 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  transition: transform 0.12s var(--ease), opacity 0.12s;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
/* Red is reserved for destructive actions; primary CTAs follow the accent. */
.btn--danger { background: var(--red); }
.btn--accent { background: var(--accent); }
.btn--accent:hover { background: var(--accent-deep); }

/* ------------------------------------------------------------- effects layer */

.fx-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 900;
}
.fx-p {
  position: absolute;
  will-change: transform, opacity;
  user-select: none;
  line-height: 1;
}
.fx-ring {
  position: absolute;
  width: 84px;
  height: 84px;
  border: 6px solid currentColor;
  border-radius: 50%;
  will-change: transform, opacity;
}

/* --------------------------------------------------------------- progress */

.progress {
  height: 5px;
  background: var(--paper-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s var(--ease);
}

/* Per-question review strip on the homework results screen. */
.review {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.review__dot {
  width: 34px;
  height: 34px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  border: 2px solid var(--line);
  font: 800 0.82rem/1 var(--mono);
  color: var(--gray);
}
.review__dot.is-right { border-color: var(--green); background: var(--green-wash); color: var(--green-deep); }
.review__dot.is-wrong { border-color: var(--red); background: var(--red-wash); color: var(--red-deep); }

/* --------------------------------------------------------------- controls */

.pill {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font: 600 0.6rem/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
  transition: transform 0.12s var(--ease), border-color 0.2s, color 0.2s;
}
.pill:active { transform: scale(0.94); }
.pill.is-on { border-color: var(--accent); color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .fx-layer { display: none; }
}
