/* Webcam Test — webcamtest.yumeco.shop
   Dark, mobile-first, no external assets. */

:root {
  --bg: #0b0f17;
  --bg-raised: #141a25;
  --bg-sunken: #080b11;
  --border: #232c3b;
  --border-strong: #33405480;
  --text: #e8edf5;
  --text-muted: #94a1b8;
  --text-faint: #6b7a94;
  --accent: #35d6a4;
  --accent-hover: #4ae7b6;
  --accent-ink: #04231a;
  --danger: #ff6b6b;
  --danger-bg: #2a1418;
  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 880px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

/* The hidden attribute only works through the UA stylesheet rule
 * `[hidden] { display: none }`, and any author rule setting `display`
 * outranks it — which silently turns `el.hidden = true` into a no-op.
 * Several elements here are flex containers, so this makes the
 * attribute mean what it says. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 50% -12%, #162033 0%, transparent 70%);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 18px;
}

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600; z-index: 20;
}
.skip-link:focus { left: 0; }

.icon {
  width: 1.05em; height: 1.05em;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: #0b0f17d9;
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}

.header-inner { display: flex; align-items: center; height: 60px; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); text-decoration: none;
  font-size: 1.06rem; letter-spacing: -0.01em;
}
.brand strong { color: var(--accent); font-weight: 700; }

.brand-mark {
  width: 26px; height: 26px;
  fill: none; stroke: var(--accent);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- intro ---------- */

.intro { padding: 36px 0 26px; text-align: center; }

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 5.5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.lede {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--text-muted);
  font-size: 1.03rem;
}

.privacy {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 18px 0 0;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-faint);
  font-size: 0.83rem;
  text-align: left;
}
.privacy .icon { color: var(--accent); }

/* ---------- alert ---------- */

.alert {
  margin: 0 0 20px;
  padding: 15px 18px;
  border: 1px solid #6b2b30;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
}
.alert-title { margin: 0 0 5px; font-size: 1rem; color: #ffb4b4; }
.alert-message { margin: 0; color: #f0cdcd; font-size: 0.93rem; }

/* ---------- stage ---------- */

.tester { margin-bottom: 46px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  overflow: hidden;
  display: grid;
  place-items: center;
  max-height: 78vh;
}

@media (min-width: 620px) {
  .stage { aspect-ratio: 16 / 9; }
}

.preview {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}
.stage.is-live .preview { display: block; }
.stage.is-mirrored .preview { transform: scaleX(-1); }

.stage-idle, .stage-busy {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  color: var(--text-faint);
  text-align: center;
  padding: 20px;
}
.stage.is-live .stage-idle { display: none; }

.stage-idle p, .stage-busy p { margin: 0; font-size: 0.94rem; }

.stage-icon {
  width: 52px; height: 52px;
  fill: none; stroke: currentColor;
  stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.55;
}

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.live-badge {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #000000a6;
  border: 1px solid var(--border-strong);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 #35d6a480;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 9px #35d6a400; }
  100% { box-shadow: 0 0 0 0 #35d6a400; }
}

.status {
  margin: 14px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  min-height: 1.6em;
}

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

.controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover { background: #1c2431; border-color: #35405a; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-lg { padding: 14px 26px; font-size: 1.02rem; }

/* ---------- panel ---------- */

.panel {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.panel-heading {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.camera-switch {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.switch-label {
  font-size: 0.78rem; font-weight: 650;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-sunken);
}

.seg {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit; font-size: 0.9rem; font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg:hover { color: var(--text); }
.seg.is-active { background: var(--accent); color: var(--accent-ink); }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg[disabled] { opacity: 0.45; cursor: not-allowed; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.78rem; font-weight: 650;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-faint);
}
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit; font-size: 0.93rem;
}
.field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions {
  display: flex; flex-wrap: wrap; gap: 9px;
  margin-bottom: 20px;
}

/* ---------- info grid ---------- */

.info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--border);
  overflow: hidden;
}

.info-item { padding: 12px 14px; background: var(--bg-sunken); }

/* A deviceId is a long opaque hash; give it the full row width. */
.info-item-wide { grid-column: 1 / -1; }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  color: var(--text-muted);
  line-height: 1.45;
}

.info dt {
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.info dd {
  margin: 3px 0 0;
  font-size: 0.98rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.info dd.is-live { color: var(--accent); }

/* ---------- authenticity verdict ---------- */

.verdict {
  margin-bottom: 22px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-faint);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}
.verdict[data-verdict="likely-real"] { border-left-color: var(--accent); }
.verdict[data-verdict="suspicious"]  { border-left-color: #f0b342; }
.verdict[data-verdict="virtual"]     { border-left-color: var(--danger); }

.verdict-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.verdict-badge {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
  font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap;
}
.verdict[data-verdict="likely-real"] .verdict-badge { background: #123a2d; color: var(--accent); }
.verdict[data-verdict="suspicious"]  .verdict-badge { background: #3a2f12; color: #f0b342; }
.verdict[data-verdict="virtual"]     .verdict-badge { background: #3a1519; color: #ff8f8f; }

.verdict-summary {
  margin: 0;
  flex: 1 1 240px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.signals { margin: 14px 0 0; padding: 0; list-style: none; }
.signals li {
  padding: 11px 13px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
}
.signals li:last-child { margin-bottom: 0; }
.signal-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 0.92rem; font-weight: 600;
}
.signal-severity {
  font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px;
  background: var(--border); color: var(--text-muted);
  white-space: nowrap;
}
.signal-severity[data-severity="strong"] { background: #3a1519; color: #ff8f8f; }
.signal-detail { margin: 5px 0 0; font-size: 0.87rem; color: var(--text-muted); }

.verdict-foot { margin-top: 13px; }
.btn-small { padding: 7px 13px; font-size: 0.86rem; }
.verdict-note {
  margin: 10px 0 0;
  font-size: 0.79rem;
  line-height: 1.5;
  color: var(--text-faint);
}

.snapshot-verdict {
  margin: -6px 0 14px;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.snapshot-verdict[data-verdict="virtual"] { color: #ff8f8f; }
.snapshot-verdict[data-verdict="suspicious"] { color: #f0b342; }

/* ---------- snapshot ---------- */

.snapshot {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.snapshot img {
  display: block;
  width: 100%; height: auto;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
}

/* ---------- help ---------- */

.help { margin-bottom: 56px; }
.help h2 {
  font-size: 1.28rem;
  letter-spacing: -0.015em;
  margin: 0 0 14px;
}

.help details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  margin-bottom: 9px;
  overflow: hidden;
}
.help summary {
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.96rem;
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.help summary::-webkit-details-marker { display: none; }
.help summary::before {
  content: "+";
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
  width: 1ch;
  flex: none;
}
.help details[open] summary::before { content: "−"; }
.help summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.help details p {
  margin: 0;
  padding: 0 16px 15px 42px;
  color: var(--text-muted);
  font-size: 0.93rem;
}
.help em { color: var(--text); font-style: normal; font-weight: 600; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 30px;
}
.site-footer p {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}

/* Fullscreen: let the video fill the screen edge to edge */
.stage:fullscreen { aspect-ratio: auto; border-radius: 0; border: 0; }
.stage:fullscreen .preview { object-fit: contain; }
