/* ============================================================
   RealtimeBiker — Material Design 3 Design System (Dark)
   ============================================================ */

/* --- Google Fonts: Roboto + JetBrains Mono + Material Symbols --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

/* --- MD3 Dark Theme Tokens --- */
:root {
  /* Primary */
  --md-primary: #A8C7FA;
  --md-on-primary: #062E6F;
  --md-primary-container: #004A77;
  --md-on-primary-container: #D3E3FD;

  /* Secondary */
  --md-secondary: #BCC7DC;
  --md-on-secondary: #263141;
  --md-secondary-container: #3C4758;
  --md-on-secondary-container: #D7E3F8;

  /* Tertiary */
  --md-tertiary: #D4BEE6;
  --md-on-tertiary: #392A4A;
  --md-tertiary-container: #504061;
  --md-on-tertiary-container: #F0DBFF;

  /* Error */
  --md-error: #FFB4AB;
  --md-on-error: #690005;
  --md-error-container: #93000A;
  --md-on-error-container: #FFDAD6;

  /* Surface */
  --md-surface: #111318;
  --md-surface-dim: #111318;
  --md-surface-bright: #37393E;
  --md-surface-container-lowest: #0C0E13;
  --md-surface-container-low: #191C20;
  --md-surface-container: #1D2024;
  --md-surface-container-high: #282A2F;
  --md-surface-container-highest: #33353A;
  --md-on-surface: #E2E2E9;
  --md-on-surface-variant: #C4C6CF;
  --md-outline: #8E9099;
  --md-outline-variant: #44474E;

  /* Inverse */
  --md-inverse-surface: #E2E2E9;
  --md-inverse-on-surface: #2F3036;
  --md-inverse-primary: #005FAE;

  /* Success (custom, not in MD3 baseline) */
  --md-success: #7DD079;
  --md-success-container: #1B5E20;
  --md-on-success-container: #C8E6C9;

  /* Warning (custom) */
  --md-warning: #FFD54F;
  --md-warning-container: #5D4200;
  --md-on-warning-container: #FFECB3;

  /* Shape */
  --md-shape-xs: 4px;
  --md-shape-sm: 8px;
  --md-shape-md: 12px;
  --md-shape-lg: 16px;
  --md-shape-xl: 28px;
  --md-shape-full: 9999px;

  /* Elevation (dark uses tonal approach) */
  --md-elevation-1: 0 1px 3px 1px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.3);
  --md-elevation-2: 0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.3);
  --md-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px 0 rgba(0,0,0,0.3);

  /* Motion */
  --md-motion-duration-short: 150ms;
  --md-motion-duration-medium: 250ms;
  --md-motion-duration-long: 400ms;
  --md-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-motion-easing-decelerate: cubic-bezier(0, 0, 0, 1);

  /* Typography */
  --md-font-sans: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

/* --- CSS Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--md-font-sans);
  font-weight: 400;
  color: var(--md-on-surface);
  background-color: var(--md-surface);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  letter-spacing: 0.01em;
}

a {
  color: var(--md-primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  font-size: inherit;
  letter-spacing: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  border: none;
  background: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

/* --- Material Symbols --- */
.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  vertical-align: middle;
  user-select: none;
}

.material-symbols-outlined.filled {
  font-variation-settings:
    'FILL' 1,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
}

/* --- MD3 Components --- */

/* Connection status indicator */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--md-shape-full);
  background-color: var(--md-error);
  transition: background-color var(--md-motion-duration-medium) var(--md-motion-easing-standard);
}

.connection-dot.connected {
  background-color: var(--md-success);
  box-shadow: 0 0 8px rgba(125, 208, 121, 0.4);
}

/* Status badges (MD3 chips/labels) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--md-shape-sm);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge--riding {
  background: rgba(168, 199, 250, 0.12);
  color: var(--md-primary);
}

.badge--paused {
  background: rgba(255, 213, 79, 0.12);
  color: var(--md-warning);
}

.badge--crashed {
  background: rgba(255, 180, 171, 0.15);
  color: var(--md-error);
  animation: badge-pulse 1.5s ease infinite;
}

.badge--finished {
  background: rgba(125, 208, 121, 0.12);
  color: var(--md-success);
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* MD3 Card */
.card {
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-md);
  padding: 16px;
  transition: all var(--md-motion-duration-medium) var(--md-motion-easing-standard);
}

.card:hover {
  border-color: var(--md-outline);
}

/* Section label (MD3 label-small) */
.section-label {
  font-size: 0.69rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--md-on-surface-variant);
  margin-bottom: 8px;
}

/* Monospace values */
.mono {
  font-family: var(--md-font-mono);
  font-variant-numeric: tabular-nums;
}

/* Scrollbar (subtle) */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--md-outline-variant);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--md-outline);
}

/* Focus visible (MD3 focus ring) */
:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
  border-radius: var(--md-shape-sm);
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
