/* Scan page — phone-first camera tool using OpenDrumsOnly tokens */

:root {
  --scan-bg: #0a0a0a;
  --scan-fg: #ffffff;
  --scan-muted: #a3a3a3;
  --scan-accent: #111827;
  --scan-panel: #ffffff;
  --scan-border: #e5e7eb;
  --scan-danger: #b91c1c;
  --scan-ok: #065f46;
  --scan-shutter: #ffffff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html.scan-html,
body.scan-page {
  height: 100%;
  background: var(--scan-bg);
  color: var(--scan-fg);
  overscroll-behavior: none;
}

body.scan-page {
  min-height: 100svh;
  min-height: 100dvh;
}

body.scan-page header {
  background: rgba(255, 255, 255, 0.96);
}

body.scan-page header h1 a {
  text-decoration: none;
  color: inherit;
}

.scan-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - var(--header-height) - var(--safe-top));
  min-height: calc(100dvh - var(--header-height) - var(--safe-top));
  padding-top: calc(var(--header-height) + var(--safe-top));
  box-sizing: border-box;
}

.scan-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

.scan-video,
.scan-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.scan-canvas {
  display: none;
}

.scan-fallback-poster {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.08), transparent 50%),
    linear-gradient(160deg, #1a1a1a, #050505 60%);
  color: var(--scan-fg);
}

.scan-fallback-poster.is-visible {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scan-fallback-poster p {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  max-width: 22rem;
}

.scan-hint {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 8px 14px;
  max-width: min(92vw, 28rem);
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  pointer-events: none;
}

.scan-status {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.scan-status.is-visible {
  opacity: 1;
}

.scan-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 16px calc(18px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.scan-controls > * {
  pointer-events: auto;
}

.scan-shutter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
  max-width: 420px;
}

.scan-side-btn {
  min-width: 52px;
  min-height: 52px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.scan-side-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.scan-shutter {
  width: 84px;
  height: 84px;
  min-width: 84px;
  min-height: 84px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.95);
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.scan-shutter::after {
  content: "";
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--scan-shutter);
}

.scan-shutter:active::after {
  transform: scale(0.92);
}

.scan-shutter:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.scan-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.scan-results {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  background: var(--scan-panel);
  color: var(--text-color);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  box-sizing: border-box;
}

.scan-results.is-open {
  display: flex;
}

.scan-results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.scan-results-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.scan-results-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.scan-close-results {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 20px;
  cursor: pointer;
}

.scan-empty {
  margin: 24px 0;
  padding: 20px 16px;
  border: 2px solid #111;
  border-radius: 12px;
  background: #fafafa;
}

.scan-empty h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.scan-empty p {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  color: #374151;
}

.scan-hit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scan-hit {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--scan-border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  min-height: 88px;
}

.scan-hit:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.scan-hit img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
}

.scan-hit-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.scan-hit-artist {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.scan-hit-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  word-break: break-word;
}

.scan-hit-meta {
  margin-top: 4px;
  font-size: 14px;
  color: #111;
  font-weight: 600;
}

.scan-hit-conf {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.scan-second-prompt {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #111827;
  color: #fff;
}

.scan-second-prompt p {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.35;
}

.scan-second-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scan-action-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.scan-action-btn.primary {
  background: #fff;
  color: #111;
}

.scan-action-btn.ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.scan-results-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scan-results-actions .scan-action-btn.primary {
  background: #111827;
  color: #fff;
}

.scan-results-actions .scan-action-btn.ghost {
  background: #fff;
  color: #111;
  border-color: var(--input-border);
}

.scan-preview-strip {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  overflow-x: auto;
}

.scan-preview-strip img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--scan-border);
  flex: 0 0 auto;
}

@media (min-width: 900px) {
  .scan-shell {
    max-width: 980px;
    margin: 0 auto;
  }

  .scan-stage {
    border-radius: 0 0 16px 16px;
    min-height: calc(100dvh - var(--header-height) - var(--safe-top) - 24px);
  }

  .scan-video,
  .scan-canvas {
    object-fit: contain;
    background: #050505;
  }

  .scan-results {
    max-width: 720px;
    margin: 0 auto;
    left: 50%;
    right: auto;
    width: min(720px, 100%);
    transform: translateX(-50%);
    border-radius: 16px;
  }

  .scan-shutter {
    width: 92px;
    height: 92px;
  }

  .scan-shutter::after {
    width: 74px;
    height: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scan-status,
  .scan-shutter::after {
    transition: none;
  }
}
