/* ════════════════════════════════════════════════════
   Murph — App Shell styles
   Reuses design tokens from tokens.css (dark theme, accent #C8FF00).
   uTrain-specific styles stay in legacy/ (styles.css); the new shell
   depends only on tokens.css + this file. (Spec §12.1)
   ════════════════════════════════════════════════════ */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: inherit; text-decoration: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── Boot screen ── */
.boot-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--space-4);
  background: var(--bg-base);
  z-index: 900;
  transition: opacity var(--duration-medium) var(--ease-snappy);
}
.boot-screen.dismissed { opacity: 0; pointer-events: none; }
.boot-wordmark {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.boot-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border-active);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-phrase {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Header / nav ── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--bg-base) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.brand-mark {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.app-nav {
  display: flex; gap: var(--space-1);
  flex: 1; flex-wrap: wrap;
}
.nav-link {
  display: inline-flex; align-items: center;
  min-height: var(--touch-target);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration-short), background var(--duration-short);
}
.nav-link:hover { color: var(--text-primary); }
.nav-link.active {
  color: var(--text-inverse);
  background: var(--accent);
  font-weight: 600;
}
.app-auth { margin-left: auto; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--duration-short) var(--ease-snappy),
              background var(--duration-short), border-color var(--duration-short);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--text-inverse); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-primary); border-color: var(--border-active); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent-dim); }
.btn-danger { background: var(--status-red-tint); color: var(--status-red); border-color: var(--status-red); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: var(--text-lg); }

/* ── Layout / views ── */
main {
  display: block;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-12);
}
.view { animation: viewIn var(--duration-medium) var(--ease-snappy); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-2);
  text-transform: uppercase;
}
.view-sub { color: var(--text-secondary); margin: 0 0 var(--space-5); }

.card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

/* ── Home hero / CTAs ── */
.hero {
  text-align: center;
  padding: var(--space-8) var(--space-4) var(--space-6);
}
.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-2);
  text-transform: uppercase;
}
.hero-sub { color: var(--text-secondary); margin: 0 0 var(--space-6); font-size: var(--text-lg); }
.cta-row { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }

/* ── Forms ── */
.field { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-input, .field-select {
  width: 100%;
  min-height: var(--touch-target);
  padding: 0 var(--space-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-inner);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
}
.field-input:focus, .field-select:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}
.field-hint { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: var(--space-1); }
.field-error { font-size: var(--text-sm); color: var(--status-red); margin-top: var(--space-1); }
.field-row { display: flex; gap: var(--space-3); }
.field-row > .field { flex: 1; }

.checkbox-field {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-inner);
  margin-bottom: var(--space-3);
}
.checkbox-field input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }
.checkbox-field label { font-size: var(--text-sm); color: var(--text-secondary); }

/* ── Chips / badges ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
}
.chip-verified { background: var(--accent-tint); color: var(--accent); }
.chip-pending { background: var(--status-yellow-tint); color: var(--status-yellow); }
.chip-honor { background: var(--bg-surface-3); color: var(--text-secondary); }
.chip-rejected { background: var(--status-red-tint); color: var(--status-red); }
.chip-extraordinary { background: var(--status-yellow-tint); color: var(--status-yellow); }

/* ── Leaderboard ── */
.lb-filters { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.lb-filter {
  min-height: 36px; padding: 0 var(--space-3);
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill); color: var(--text-secondary);
  font-size: var(--text-sm); cursor: pointer;
}
.lb-filter.active { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); font-weight: 600; }

.lb-table { display: flex; flex-direction: column; gap: var(--space-2); }
.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-inner);
  cursor: pointer;
  min-height: var(--touch-target);
  transition: border-color var(--duration-short);
}
.lb-row:hover { border-color: var(--border-active); }
.lb-row-me { border-color: var(--accent-dim); }
.lb-rank { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 500; color: var(--text-secondary); text-align: center; }
.lb-rank-1 { color: #FFD700; }
.lb-rank-2 { color: #C0C0C0; }
.lb-rank-3 { color: #CD7F32; }
.lb-name-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lb-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.lb-time { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 500; text-align: right; }

/* ── Empty / status ── */
.empty-state { text-align: center; padding: var(--space-10) var(--space-4); color: var(--text-secondary); }
.empty-state h3 { font-family: var(--font-display); font-size: var(--text-2xl); color: var(--text-primary); margin: 0 0 var(--space-2); }

.toast {
  position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%);
  background: var(--bg-surface-3); color: var(--text-primary);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-pill);
  border: 1px solid var(--border-active); box-shadow: var(--shadow-lg);
  z-index: 800; font-size: var(--text-sm); max-width: 90vw;
}
.toast-error { border-color: var(--status-red); color: var(--status-red); }
.toast-success { border-color: var(--accent); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.modal {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
}
.modal-title { font-family: var(--font-display); font-size: var(--text-2xl); margin: 0 0 var(--space-4); text-transform: uppercase; }

/* ── Utility ── */
.muted { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.mt-4 { margin-top: var(--space-4); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
[hidden] { display: none !important; }

@media (max-width: 540px) {
  .app-header { flex-wrap: wrap; }
  .app-nav { order: 3; width: 100%; justify-content: space-between; }
  .hero-title { font-size: var(--text-3xl); }
}

/* ── Review console (Spec §7) ── */
.review-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: var(--space-4); align-items: start; }
.review-main, .review-side { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.review-main .card, .review-side .card { margin: 0; }

.review-video { width: 100%; max-height: 56vh; background: #000; border-radius: var(--radius-inner); display: block; }
.review-player-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); }
.review-speed { display: flex; gap: var(--space-2); }
.review-rate-btn.active, .review-part-btn.active { background: var(--accent); color: var(--bg-base); border-color: var(--accent); }

.review-chapters { position: relative; height: 14px; margin-top: var(--space-3); background: var(--bg-surface-2); border-radius: var(--radius-inner); overflow: hidden; cursor: pointer; }
.review-chapter { position: absolute; top: 0; bottom: 0; opacity: 0.85; }
.review-chapter.ex-pullups { background: var(--accent); }
.review-chapter.ex-pushups { background: var(--blue); }
.review-chapter.ex-squats { background: var(--accent-dim); }
.review-chapter.ex-rest { background: var(--bg-surface-3); }

.review-check { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); }
.review-check:last-child { border-bottom: none; }
.review-check-mark { width: 1.2em; color: var(--text-secondary); }
.review-check.done .review-check-mark { color: var(--accent); }
.review-check.done .review-check-label { color: var(--text-secondary); }
.review-check-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-jump, .review-jump-rep { padding: 2px 10px; }

.review-ledger { max-height: 320px; overflow-y: auto; }
.review-rep { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); }
.review-rep:last-child { border-bottom: none; }
.review-rep.judged { opacity: 0.75; }
.review-rep .btn { padding: 2px 10px; font-size: var(--text-sm); }

.review-map { width: 100%; max-width: 280px; background: var(--bg-surface-2); border-radius: var(--radius-inner); margin-top: var(--space-3); }
.review-queue-row { cursor: default; }

/* ── Admin panel (Spec §4.8) ── */
.admin-tab.active { background: var(--accent); color: var(--bg-base); border-color: var(--accent); }
.admin-config-row .field-row .field-input { flex: 1; }
.admin-event .field-row { flex-wrap: wrap; }

@media (max-width: 860px) {
  .review-grid { grid-template-columns: 1fr; }
}
