/* Lab reports, scratch card, reactor button, lab clock and sound toggle.
   Uses the tokens defined in styles.css. */

/* ---------- Topbar tools ---------- */
.topbar-tools { display: flex; align-items: center; gap: 12px; }
.lab-clock { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.sound-toggle {
  padding: 7px 12px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper); font-size: 11px; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, transform 0.2s var(--ease-spring);
}
.sound-toggle:hover { transform: rotate(-3deg); }
.sound-toggle[aria-pressed="true"] { background: var(--pop); }
.sound-toggle:focus-visible { outline: 3px solid var(--pop); outline-offset: 3px; }

/* ---------- Lab reports ---------- */
.reports { display: grid; gap: clamp(64px, 9vw, 120px); }
.report { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: center; }
.report.flip .report-media { order: 2; }

.report-media { position: relative; display: flex; justify-content: center; align-items: center; min-height: 420px; }
.specimen {
  position: relative; margin: 0; width: 46%;
  padding: 10px 10px 34px; background: #fff; border: var(--border);
  box-shadow: var(--shadow); rotate: var(--tilt);
  transition: rotate 0.35s var(--ease-spring), transform 0.35s var(--ease-spring), z-index 0s;
}
.specimen + .specimen { margin-left: -12%; margin-top: 60px; }
.report-media.count-3 .specimen { width: 38%; }
.report-media.count-3 .specimen:nth-child(2) { margin-top: -40px; z-index: 2; }
.specimen:hover { rotate: 0deg; transform: scale(1.06); z-index: 5; }
.specimen img, .specimen video { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--paper-2); }
.specimen-video video { aspect-ratio: 9 / 16; }
.tape {
  position: absolute; top: -14px; left: 50%; width: 84px; height: 26px; translate: -50% 0; rotate: -4deg; z-index: 2;
  background: color-mix(in srgb, var(--sticky) 80%, transparent); border: 1px solid rgba(15, 14, 13, 0.15);
}

.report-sheet {
  position: relative; padding: clamp(24px, 3vw, 36px);
  border: var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-lg);
  background-image: repeating-linear-gradient(transparent 0 31px, var(--logic-soft) 31px 32px);
}
.report-top {
  display: flex; justify-content: space-between; margin: calc(clamp(24px, 3vw, 36px) * -1) calc(clamp(24px, 3vw, 36px) * -1) 20px;
  padding: 12px clamp(24px, 3vw, 36px); background: var(--ink); color: var(--pop); border-radius: 12px 12px 0 0;
}
.report-cat { margin: 0 0 6px; color: var(--accent); font-weight: 700; transition: color 0.4s; }
.report-client { font-size: clamp(30px, 3.4vw, 46px); font-weight: 900; text-transform: uppercase; }
.report-headline { margin: 12px 0 10px; font-size: clamp(20px, 2vw, 26px); font-weight: 800; line-height: 1.2; }
.report-notes { margin: 0 0 20px; color: var(--ink-soft); }
.report-fields { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; align-items: center; }
.report-fields dt { color: var(--ink-soft); }
.report-fields dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; font-weight: 700; }
.pill { padding: 3px 10px; border: 2px solid var(--ink); border-radius: 999px; font-size: 13px; background: var(--paper); }
.report-stamp {
  position: absolute; right: 22px; bottom: 22px;
  padding: 6px 12px; border: 3px solid var(--logic); color: var(--logic); border-radius: 8px;
  font-size: 15px; font-weight: 700; rotate: -12deg; opacity: 0.85;
}
.report.in .report-stamp { animation: stampIn 0.5s 0.4s var(--ease-spring) both; }
@keyframes stampIn { from { scale: 2.4; opacity: 0; } }

/* ---------- Scratch card ---------- */
.scratch-section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.scratch-card {
  position: relative; min-height: 320px; border: var(--border); border-radius: 22px;
  box-shadow: var(--shadow-lg); overflow: hidden; background: var(--logic); color: #fff; rotate: 1.5deg;
}
.scratch-prize { display: grid; gap: 10px; align-content: center; justify-items: start; height: 100%; min-height: 320px; padding: clamp(24px, 4vw, 40px); }
.prize-label { margin: 0; color: var(--pop); }
.prize-title { margin: 0; font-size: clamp(32px, 3.8vw, 52px); font-weight: 900; font-stretch: 118%; text-transform: uppercase; line-height: 0.95; }
.prize-text { margin: 0 0 10px; max-width: 380px; }
.scratch-prize .btn { background: var(--pop); color: var(--ink); }
.scratch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; transition: opacity 0.6s; }
.scratch-card.revealed .scratch-canvas { opacity: 0; pointer-events: none; }
.scratch-card.revealed .prize-title { animation: bubble 0.5s var(--ease-spring); }
.scratch-skip {
  position: absolute; right: 12px; bottom: 10px; z-index: 2;
  padding: 4px 8px; border: 0; border-radius: 6px; background: rgba(15, 14, 13, 0.75); color: #fff;
  font-size: 10px; cursor: pointer; opacity: 0.7;
}
.scratch-skip:hover, .scratch-skip:focus-visible { opacity: 1; outline: 2px solid var(--pop); }
.scratch-card.revealed .scratch-skip { display: none; }

/* ---------- Reactor (hold to start) ---------- */
.reactor-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 26px; margin-top: 44px; }
.reactor {
  --fill: 0;
  position: relative; overflow: hidden; width: 168px; height: 168px; padding: 0 18px;
  border: 3px solid var(--paper); border-radius: 50% 50% 46% 46% / 40% 40% 60% 60%;
  background: #1f1d1b; color: var(--paper); cursor: pointer; user-select: none; touch-action: none;
  font: 800 15px var(--font-display); text-transform: uppercase; line-height: 1.1;
  box-shadow: 6px 6px 0 var(--accent);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.4s;
}
.reactor.holding { transform: scale(0.95) rotate(-3deg); animation: jitter 0.12s linear infinite; }
@keyframes jitter { 50% { translate: 1px -1px; } }
.reactor:focus-visible { outline: 3px solid var(--pop); outline-offset: 5px; }
.reactor-liquid {
  position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(var(--fill));
  background: linear-gradient(var(--pop), #9bd400);
}
.reactor-liquid::before {
  content: ""; position: absolute; left: -10%; right: -10%; top: -10px; height: 20px;
  background: radial-gradient(circle at 10px 10px, var(--pop) 8px, transparent 9px) 0 0 / 22px 20px repeat-x;
}
.reactor-label {
  position: relative; z-index: 1; display: inline-block; padding: 5px 9px; border-radius: 8px;
  background: var(--ink); color: var(--pop); box-shadow: 0 0 0 2px var(--paper);
}
.reactor.done { box-shadow: 0 0 0 10px var(--pop), 6px 6px 0 var(--accent); }
.reactor-hint { margin: 0; color: #a8a39a; max-width: 260px; }

@media (max-width: 1100px) {
  .lab-clock { display: none; }
}

@media (max-width: 900px) {
  .report, .scratch-section { grid-template-columns: minmax(0, 1fr); }
  .report.flip .report-media { order: 0; }
  .report-media { min-height: 0; }
}

@media (max-width: 640px) {
  .sound-toggle { display: none; }
  .specimen { width: 52%; padding: 6px 6px 22px; }
  .report-media.count-3 .specimen { width: 40%; }
  .report-stamp { position: static; display: inline-block; margin-top: 18px; }
  .reactor { width: 140px; height: 140px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .reactor.holding { animation: none; }
}
