
.scanner-scanline {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 2px;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
  animation: scanline 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scanline {
  0%, 100% { top: calc(50% - 60px); opacity: 0.3; }
  50% { top: calc(50% + 60px); opacity: 0.7; }
}

/* Reticle pulse: quick accent glow on the corner brackets for every new
   capture, so the acknowledgment reads even with sound off. */
.scanner-reticle.pulse::before,
.scanner-reticle.pulse::after,
.scanner-reticle.pulse .corner-tl,
.scanner-reticle.pulse .corner-br {
  animation: reticlePulse 0.25s ease-out;
}
@keyframes reticlePulse {
  0% {
    border-color: #ffd479;
    box-shadow: 0 0 12px var(--accent), inset 0 0 8px rgba(245, 158, 11, 0.4);
  }
  100% {
    border-color: var(--accent);
    box-shadow: none;
  }
}

.scanner-detected-flash {
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  pointer-events: none;
  opacity: 0;
  border-radius: 2px;
  z-index: 3; /* above a displayed photo */
}
.scanner-detected-flash.flash {
  animation: detectFlash 0.6s ease;
}
@keyframes detectFlash {
  0% { opacity: 0.8; box-shadow: inset 0 0 40px rgba(245, 158, 11, 0.2); }
  100% { opacity: 0; }
}

.scanner-footer {
  padding: 16px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.scanner-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 28px;
  align-items: center;
  max-height: 168px;
  overflow-y: auto;
}
.scanner-result-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-data);
  font-size: 11px;
  animation: tagAppear 0.2s ease-out;
}
@keyframes tagAppear {
  0% { opacity: 0; transform: scale(0.7); }
  70% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}
.scanner-result-tag .tag-format {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
}
/* Catch chips (DESIGN_DECISIONS.md section 13, 16a): a big SIGNAL or TRACE
   word and nothing else — telling catches apart works by tapping the chip
   to flash the matching detection box in the picture, not by naming the
   code. The chip arrives bright: its border flashes and settles. */
.scanner-result-tag.catch-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  animation: tagAppear 0.2s ease-out, catchChipFlash 0.9s ease-out;
}
.catch-chip .catch-word {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  line-height: 1;
  color: #ffd479;
}
.catch-chip .chip-dismiss {
  font-size: 18px;
}
@keyframes catchChipFlash {
  0% {
    border-color: #ffe9b8;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.6), inset 0 0 12px rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.28);
  }
  100% {
    border-color: var(--accent-dim);
    box-shadow: none;
    background: rgba(245, 158, 11, 0.1);
  }
}
/* Duplicate catch (section 13): the existing chip jiggles — a short side
   shake plus a brief border glow so the chip is easy to spot. Reduced
   motion keeps only the glow. */
.scanner-result-tag.chip-jiggle {
  animation: chipJiggle 0.45s ease-in-out, chipDupGlow 0.7s ease-out;
}
@keyframes chipJiggle {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes chipDupGlow {
  0% { border-color: #ffe9b8; box-shadow: 0 0 14px rgba(245, 158, 11, 0.5); }
  100% { border-color: var(--accent-dim); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.chip-jiggle { animation: chipDupGlow 0.7s ease-out; }
}
/* Owned catch (DESIGN_DECISIONS.md section 11): grey means the system was
   already in the atlas before this session. The chip keeps its SIGNAL or
   TRACE wording but arrives grey, with no bright flash. */
.scanner-result-tag.catch-chip.chip-owned {
  animation: tagAppear 0.2s ease-out;
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.35);
  color: rgba(148, 163, 184, 0.9);
}
.catch-chip.chip-owned .catch-word { color: rgba(160, 172, 190, 0.9); }
/* The grey chip's jiggle glows grey, not amber. */
.scanner-result-tag.chip-owned.chip-jiggle {
  animation: chipJiggle 0.45s ease-in-out, chipOwnedGlow 0.7s ease-out;
}
@keyframes chipOwnedGlow {
  0% { border-color: rgba(200, 210, 225, 0.7); box-shadow: 0 0 14px rgba(148, 163, 184, 0.4); }
  100% { border-color: rgba(148, 163, 184, 0.35); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.chip-owned.chip-jiggle { animation: chipOwnedGlow 0.7s ease-out; }
}
/* Picture tap (direction two, DCOSMOS-HATCHCEREMONY): tapping a code's box
   in the picture jiggles the matching chip (reuses chip-jiggle above) plus
   this bright one-shot flash layered on top, so a tap from either side of
   the link reads the same way. JS removes the class once it finishes. */
.scanner-result-tag.chip-code-tap-flash {
  animation: chipCodeTapFlash 0.6s ease-out;
}
/* The animation shorthand does not merge across classes -- whichever rule
   wins takes the whole property. A chip carrying both classes plays the
   shake and the flash as one comma-joined animation list, and the selector
   outranks the grey chip's own three-class jiggle rule. */
.scanner-result-tag.chip-jiggle.chip-code-tap-flash,
.scanner-result-tag.chip-owned.chip-jiggle.chip-code-tap-flash {
  animation: chipJiggle 0.45s ease-in-out, chipCodeTapFlash 0.6s ease-out;
}
@keyframes chipCodeTapFlash {
  0% {
    border-color: #fff5da;
    box-shadow: 0 0 22px rgba(255, 245, 218, 0.9), inset 0 0 14px rgba(255, 245, 218, 0.5);
    background: rgba(255, 212, 121, 0.35);
  }
  100% { border-color: var(--accent-dim); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scanner-result-tag.chip-code-tap-flash {
    animation: none;
    box-shadow: 0 0 14px rgba(255, 245, 218, 0.6);
  }
}
.chip-dismiss {
  all: unset;
  cursor: pointer;
  margin-left: 2px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
  opacity: 0.6;
  padding: 0 2px;
}
.chip-dismiss:hover { opacity: 1; color: var(--accent); }
.scanner-actions {
  display: flex;
}
/* The one action: DONE. Always enabled, unmistakably bright. */
.scanner-actions .btn-primary {
  flex: 1;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.35);
}
.scanner-actions .btn-primary:hover {
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.5);
}

.scanner-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
}
.scanner-fallback p {
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 400px;
  line-height: 1.6;
}
.scanner-fallback .fallback-upload { position: relative; }
.scanner-fallback .fallback-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.scanner-fallback .fallback-upload .btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 12px 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: none;
}

/* ── DCOSMOS-SCANFX: Enhanced scanner visual effects ──────────── */
/* Each effect is independently removable: yank its block + the class
   that triggers it in app.js. All are CSS-driven keyframe animations
   toggled by adding / removing a class on the viewfinder or overlay. */

/* 1. Full-viewfinder scan sweep ──────────────────────────────────
   A wide horizontal line that sweeps the entire viewfinder height while
   the camera is live. Complements the smaller reticle-confined scanline
   already present. Active only while .scanfx-scanning is on the
   viewfinder (camera mode — photo mode never adds it). */
.scanner-viewfinder.scanfx-scanning::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--accent) 50%, transparent 95%);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25), 0 0 4px var(--accent);
  animation: scanfxSweep 3.5s ease-in-out infinite;
}
@keyframes scanfxSweep {
  0%   { top: 2%;  opacity: 0; }
  8%   { opacity: 0.4; }
  50%  { top: 98%; opacity: 0.25; }
  92%  { opacity: 0.4; }
  100% { top: 2%;  opacity: 0; }
}

/* 2. Detection flash — brief white overlay on new datum capture ──
   Fires each time .scanfx-detected is toggled on the viewfinder (JS
   removes it after the animation so it can re-fire). Sits above the
   video but under buttons so controls stay tappable. */
.scanner-viewfinder.scanfx-detected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(255, 255, 255, 0.14) 0%, rgba(245, 158, 11, 0.06) 60%, transparent 100%);
  pointer-events: none;
  z-index: 2;
  animation: scanfxFlash 0.35s ease-out forwards;
}
@keyframes scanfxFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* 3. Lock-on pulse — pulsing inset glow around the viewfinder ────
   Added on the first detection in a session, stays until teardown.
   A slow pulse that says "locked on, still reading". */
.scanner-viewfinder.scanfx-locked {
  animation: scanfxLockPulse 1.6s ease-in-out infinite;
}
@keyframes scanfxLockPulse {
  0%, 100% { box-shadow: inset 0 0 18px rgba(245, 158, 11, 0.04); }
  50%      { box-shadow: inset 0 0 30px rgba(245, 158, 11, 0.1),
                          0 0 12px rgba(245, 158, 11, 0.06); }
}

/* 4. Success burst — radial flash on scan completion ─────────────
   A div inside the viewfinder; JS adds .active on DONE, then tears
   down the overlay after the animation. Short, bright, and radial. */
.scanfx-success-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}
.scanfx-success-burst.active {
  animation: scanfxBurst 0.45s ease-out forwards;
}
@keyframes scanfxBurst {
  0% {
    opacity: 1;
    background: radial-gradient(circle at center,
      rgba(245, 158, 11, 0.3) 0%, rgba(245, 158, 11, 0.08) 40%, transparent 70%);
  }
  60% {
    opacity: 0.5;
    background: radial-gradient(circle at center,
      rgba(245, 158, 11, 0.05) 0%, transparent 80%);
  }
  100% {
    opacity: 0;
  }
}

/* ── DCOSMOS-HATCHCEREMONY: barcode detection boxes ──────────────
   Like the iOS camera's yellow barcode indicator. Each box appears
   over its detected code in the live viewfinder and persists until
   the scanner closes. */
.barcode-box-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}
.barcode-detect-box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25),
              inset 0 0 6px rgba(245, 158, 11, 0.08);
  transform-origin: center;
  animation: barcodeBoxIn 0.35s ease-out forwards;
  /* DCOSMOS-LIVEBOX: ease the box from one detected spot to the next so it
     follows the code smoothly instead of jumping. */
  transition: left 0.28s ease-out, top 0.28s ease-out,
              width 0.28s ease-out, height 0.28s ease-out,
              border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}
.barcode-detect-box.captured {
  border-color: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.35),
              inset 0 0 6px rgba(52, 211, 153, 0.10);
}
/* Chip-tap highlight (DESIGN_DECISIONS.md section 16a): tapping a chip
   flashes this box over its code's own detection spot in the picture, so
   the player can tell two chips apart by pointing instead of by naming. A
   one-shot flash, removed by JS once the animation finishes. */
.barcode-detect-box.chip-tap-highlight {
  border-color: #fff5da;
  box-shadow: 0 0 16px rgba(255, 212, 121, 0.7),
              inset 0 0 10px rgba(255, 212, 121, 0.4);
  animation: chipTapFlash 0.9s ease-out forwards;
}
@keyframes chipTapFlash {
  0%   { opacity: 0; transform: scale(1.2); }
  15%  { opacity: 1; transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes barcodeBoxIn {
  0%   { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── DCOSMOS-HATCHCEREMONY: stardust flare per detection ─────────
   A small radial glow + 6 particle dots that radiate outward from
   the detection point. Spawned by JS, auto-removed after animation. */
.stardust-flare {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 4;
}
.stardust-flare::before {
  content: "";
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(245, 210, 100, 0.55) 0%,
    rgba(245, 158, 11, 0.15) 45%,
    transparent 70%);
  animation: stardustGlow 0.6s ease-out forwards;
}
@keyframes stardustGlow {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.2); }
  40%  { opacity: 0.9; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
}
.stardust-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(245, 220, 130, 0.9);
  box-shadow: 0 0 3px rgba(245, 158, 11, 0.5);
  animation: stardustDot 0.55s ease-out forwards;
}
@keyframes stardustDot {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* ── DCOSMOS-HATCHCEREMONY: hatch counter overlay ───────────────
   "2 of 4" indicator on the reveal view during a multi-code hatch
   ceremony. Top-left, semi-transparent, unobtrusive. */
.hatch-counter {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 4px 12px;
  background: rgba(8, 14, 26, 0.6);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1.5px;
  pointer-events: none;
  animation: hatchCounterIn 0.3s ease-out;
}
@keyframes hatchCounterIn {
  0%   { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Scanner mobile overrides. These must stay AFTER the base scanner rules:
   equal-specificity rules are resolved by file order, so an earlier media
   block would lose to the base rules. */
@media (max-width: 768px) {
  .scanner-reticle { width: min(320px, 85vw); height: 190px; }
  .scanner-scanline { width: min(280px, 76vw); }
  .scanner-footer { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
}

/* ── Probe This Device (DCOSMOS-PROBE) ─────────────── */

.probe-intro {
  max-width: 640px;
  margin: 0 auto 24px;
  text-align: center;
}
.probe-intro h2 { font-size: 20px; margin-bottom: 6px; }
.probe-intro p { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

.probe-stage {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* The one bright button. */
.btn-probe-start {
  padding: 16px 44px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.35);
}
.btn-probe-start:disabled {
  opacity: 0.7;
  cursor: default;
  box-shadow: none;
}

/* Chip strip: the scanner's chip language, laid out as a wrapping sweep.
   Identity chips are the solid house chip; flavor chips are dimmer and
   dashed — visibly weather, not identity. */
.probe-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}
.probe-chips .scanner-result-tag.probe-flavor {
  opacity: 0.55;
  border-style: dashed;
  background: rgba(245, 158, 11, 0.04);
}

/* Re-probe note: same device, same cosmos. */
.probe-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.4;
}
.probe-note[hidden] { display: none; }
.probe-note .btn-reconfirm {
  padding: 4px 12px;
  font-size: 11px;
}

/* Model confirm: "Which device is this?" */
.probe-confirm { text-align: center; }
.probe-confirm[hidden] { display: none; }
.probe-confirm-title {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.probe-candidates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.probe-candidate {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.probe-candidate:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.probe-candidate.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}
.probe-candidate.generic { border-style: dashed; }

.probe-reveal-row { display: flex; justify-content: center; }
.probe-reveal-row[hidden] { display: none; }
.probe-reveal-row .btn-primary {
  padding: 14px 36px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.35);
}

/* The ethics stance, made visible. */
.probe-disclosure {
  max-width: 520px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}

