/* ============================================================
   F1 Telemetry Dashboard — Global Styles
   Dark race-engineer theme with glass panels & red accents
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0b0f1a;
  --bg-panel: rgba(255, 255, 255, 0.04);
  --bg-panel-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --text-muted: #8b93a7;
  --accent: #e10600;
  --accent-glow: rgba(225, 6, 0, 0.35);
  --green: #00d26a;
  --yellow: #ffc400;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --transition: 0.25s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(225, 6, 0, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(225, 6, 0, 0.05) 0%, transparent 50%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ── Navigation ───────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav__brand-mark {
  width: 8px;
  height: 28px;
  background: var(--accent);
  border-radius: 2px;
}

.nav__links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav__links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

.nav__links a:hover,
.nav__links a.active {
  color: var(--text);
}

.nav__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* LIVE pulsing dot */
.live-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
  transition: all var(--transition);
}

.live-indicator--active {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ── Layout ───────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Glass panels & cards ─────────────────────────────────── */
.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.data-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.data-card:hover {
  background: var(--bg-panel-hover);
}

.data-card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.data-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.data-card__unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Driver cards (live page) ─────────────────────────────── */
.driver-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.driver-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--team-colour, var(--accent));
}

.driver-card:hover {
  background: var(--bg-panel-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.driver-card--favourite {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.driver-card__number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 2rem;
  text-align: center;
}

.driver-card__info {
  flex: 1;
}

.driver-card__name {
  font-weight: 700;
  font-size: 1rem;
}

.driver-card__team {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.driver-card__position {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.driver-card__fav {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.3;
  transition: opacity var(--transition), transform var(--transition);
}

.driver-card__fav:hover,
.driver-card__fav.active {
  opacity: 1;
  transform: scale(1.15);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #ff1a0d;
  box-shadow: 0 4px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Landing page ─────────────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 70px);
  text-align: center;
  padding: 2rem;
}

.hero__title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero__title span {
  color: var(--accent);
}

.hero__subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 520px;
  margin-bottom: 2.5rem;
}

.hero__features {
  display: flex;
  gap: 2rem;
  margin-top: 3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hero__feature {
  text-align: center;
  max-width: 160px;
}

.hero__feature-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.hero__feature p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Telemetry bars ───────────────────────────────────────── */
.bar-group {
  margin-top: 0.5rem;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

.bar-fill--throttle {
  background: linear-gradient(90deg, #00d26a, #7fff00);
}

.bar-fill--brake {
  background: linear-gradient(90deg, var(--accent), #ff4444);
}

/* ── Driver dashboard layout ────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.driver-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.driver-header__accent {
  width: 6px;
  align-self: stretch;
  border-radius: 3px;
  background: var(--team-colour, var(--accent));
}

.driver-header__name {
  font-size: 1.5rem;
  font-weight: 700;
}

.driver-header__meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Compare page ─────────────────────────────────────────── */
.compare-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 600px) {
  .compare-selects {
    grid-template-columns: 1fr;
  }
}

.select-wrapper label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.select-wrapper select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b93a7'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 768px) {
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .compare-divider {
    display: none;
  }
}

.compare-driver {
  padding: 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.compare-driver__name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.compare-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
}

.compare-stat__label {
  color: var(--text-muted);
}

.compare-stat__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.compare-stat--winner .compare-stat__value {
  color: var(--green);
}

.compare-stat--loser .compare-stat__value {
  color: var(--text-muted);
}

.compare-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
}

.compare-diff {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.compare-diff--positive {
  color: var(--green);
}

.compare-diff--negative {
  color: var(--accent);
}

.compare-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ── Loading overlay ──────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 26, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.loading-overlay--visible {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 40px;
  height: 40px;
  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); }
}

/* ── Empty / error states ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer a {
  color: var(--accent);
}
