/* ============================================================
   ui.css — All non-game screens: loading, settings, webcam, countdown
   Design language: FIFA × Swiss Grid  (light mode, flat, sharp)
   ============================================================ */

/* ── Screen container ───────────────────────────────────────── */
[data-screen] {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
}

[data-screen][hidden] { display: none; }

/* ── FIFA-style top accent bar (appears on every UI screen) ─── */
[data-screen]::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--accent);
  z-index: 2;
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */
[data-screen="loading"] {
  background: #000;
  justify-content: center;
  align-items: center;
}

/* Background video — fills entire screen */
.loading__video-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.loading__content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-3xl);
  gap: var(--space-lg);
  width: 100%;
  max-width: 520px;
  text-align: center;
  background: var(--bg);
  border: var(--border);
}

.loading__ball {
  font-size: 52px;
  line-height: 1;
}

.loading__title {
  font-weight: var(--fw-black);
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.loading__title .word-1 {
  display: block;
  color: #000000;
}

.loading__title .word-2 {
  display: block;
  color: var(--accent);
}

.loading__title .word-3 {
  display: block;
  font-size: 0.28em;
  font-weight: var(--fw-semi);
  letter-spacing: 0.22em;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

.loading__cam-status {
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-left: 3px solid var(--border-light);
  padding-left: var(--space-sm);
}

.loading__cam-status.available {
  border-color: #2e7d32;
  color: #2e7d32;
}

/* ── Play button ─────────────────────────────────────────────── */
.btn-play {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-contrast);
  background: var(--accent);
  border: var(--border);
  border-color: var(--accent);
  border-radius: var(--radius);
  transition: background var(--transition), border-color var(--transition);
  cursor: pointer;
}

.btn-play:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-play:active { opacity: 0.85; }

/* ============================================================
   SETTINGS SCREEN
   ============================================================ */
[data-screen="settings"] {
  background: var(--bg);
  padding: var(--space-lg) var(--space-lg) 0;
  overflow-y: auto;
  justify-content: flex-start;
  align-items: stretch;
}

.settings__inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-2xl) 0 var(--space-2xl);
}

/* Page heading */
.settings__title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-black);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: var(--border);
  padding-bottom: var(--space-md);
}

.settings__title::first-letter { color: var(--text); }

/* Section label — FIFA category tab style */
.settings__section-label {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-contrast);
  background: var(--text);
  padding: 3px var(--space-sm);
  margin-bottom: var(--space-md);
}

/* ── Song cards ─────────────────────────────────────────────── */
#song-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-sm);
}

.song-card {
  position: relative;
  padding: var(--space-md);
  padding-right: 90px;
  border: var(--border);
  background: var(--surface);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
  border-left-width: 5px;
  border-left-color: var(--border-light);
}

.song-card:hover { background: var(--surface-alt); }

.song-card.selected {
  border-left-color: var(--accent);
  background: #fff5f5;
}

.song-card__title {
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  line-height: 1.3;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.song-card__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: var(--fw-semi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.song-card__note {
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: var(--fw-semi);
  line-height: 1.4;
}

.song-card__bpm {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-size: var(--text-xs);
  font-weight: var(--fw-black);
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ── Difficulty / mode button group ─────────────────────────── */
.btn-group {
  display: flex;
  gap: 0;
}

.btn-option {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: var(--border);
  border-right-width: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--surface);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-option:last-child { border-right-width: 2px; }

.btn-option:hover {
  background: var(--surface-alt);
}

.btn-option.selected {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* Restore right border on the element after a selected one */
.btn-option.selected + .btn-option { border-left-color: var(--accent); }

.btn-option:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Toggle rows ─────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: var(--border-thin);
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--text);
  letter-spacing: 0.02em;
}

.toggle-row:last-child { border-bottom: none; }

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0; height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ── Instructions ────────────────────────────────────────────── */
.instructions {
  background: var(--surface-alt);
  border: var(--border-thin);
  border-left: 4px solid var(--text);
  padding: var(--space-md);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.instructions strong { color: var(--text); }

.instructions p { margin: 0; }

.instructions__privacy {
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: #f0fff4;
  border-left: 4px solid #2e7d32;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--fw-semi);
}

.instructions__privacy strong { color: #2e7d32; }

/* ── Continue button ─────────────────────────────────────────── */
.btn-continue {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-contrast);
  background: var(--text);
  border: var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-continue:hover { background: #1a1a1a; }

/* ============================================================
   WEBCAM SETUP SCREEN
   ============================================================ */
[data-screen="webcam-setup"] {
  background: var(--bg);
  padding: var(--space-lg);
}

.webcam-setup__inner {
  position: relative;
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.webcam-setup__title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-black);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: var(--text);
  align-self: flex-start;
  border-bottom: var(--border);
  width: 100%;
  padding-bottom: var(--space-sm);
}

.webcam-setup__title span { color: var(--accent); }

.webcam-setup__preview-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4/3;
  border: var(--border);
  background: #000;
  overflow: hidden;
}

#webcam-preview {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.webcam-setup__silhouette {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.silhouette-svg {
  height: 85%;
  opacity: 0.5;
  filter: drop-shadow(0 0 6px rgba(227,0,11,0.5));
}

.silhouette-svg circle,
.silhouette-svg line {
  stroke: var(--accent);
}

.webcam-setup__goal-ref {
  position: absolute;
  left: 10%; right: 10%;
  top: 8%; bottom: 8%;
  border: 2px dashed rgba(255,255,255,0.4);
  pointer-events: none;
}

.webcam-setup__goal-ref::after {
  content: 'GOAL ZONE';
  position: absolute;
  top: -1.6em;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: var(--fw-black);
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.5);
}

.webcam-setup__hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.webcam-setup__status {
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-height: 1.5em;
}

[data-tracking="ready"]         .webcam-setup__status { color: #2e7d32; }
[data-tracking="no-permission"] .webcam-setup__status { color: var(--accent); }

.webcam-setup__actions {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 480px;
}

.btn-back {
  flex: 1;
  padding: var(--space-md);
  border: var(--border);
  border-right: none;
  font-family: var(--font);
  font-weight: var(--fw-black);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-back:hover { background: var(--surface-alt); }

.btn-start-match {
  flex: 2;
  padding: var(--space-md);
  border: var(--border);
  font-family: var(--font);
  font-weight: var(--fw-black);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-contrast);
  background: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-start-match:hover:not(:disabled) { background: #1a1a1a; }

.btn-start-match:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ============================================================
   COUNTDOWN SCREEN
   ============================================================ */
[data-screen="countdown"] {
  background: var(--bg);
  justify-content: center;
  align-items: center;
}

#countdown-number {
  font-family: var(--font);
  font-weight: var(--fw-black);
  font-size: clamp(7rem, 25vw, 16rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
  /* Red shadow gives it FIFA scoreboard energy */
  text-shadow: 6px 6px 0 var(--accent);
}

#countdown-number.pop {
  animation: count-pop 0.88s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes count-pop {
  0%   { transform: scale(1.5) translateY(-8px); opacity: 0; }
  18%  { transform: scale(1);   translateY(0);   opacity: 1; }
  80%  { transform: scale(1);                    opacity: 1; }
  100% { transform: scale(0.9) translateY(4px);  opacity: 0; }
}

.reduced-motion #countdown-number.pop {
  animation: none;
  opacity: 1;
}
