/* ============================================================================
   GridRunGP - SHARED STYLES
   Modern F1-themed CSS for all pages
   ============================================================================ */

/* CSS Variables - F1 Dark Theme */
:root {
  color-scheme: dark;
  --bg: #050609;
  --surface: #101217;
  --surface-alt: #13151a;
  --panel: #14171f;
  --text: #f5f5f5;
  --muted: #9ca3af;
  --accent: #ff1e00;      /* primary F1 red */
  --accent-alt: #ff4b2b;  /* lighter red for hovers */
  --border: #262a33;

  /* Surface tiers */
  --surface-0: #050609;
  --surface-1: #080b10;
  --surface-2: #101217;
  --surface-3: #161b24;

  /* Elevation (soft, neutral shadows) */
  --elev-1: 0 4px 12px rgba(5, 6, 9, 0.45);
  --elev-2: 0 8px 22px rgba(3, 4, 8, 0.55);
  --elev-3: 0 14px 32px rgba(3, 4, 8, 0.6);
  --elev-4: 0 18px 40px rgba(0, 0, 0, 0.65);

  /* Surface + border tokens */
  --card-radius: 14px;
  --card-border: 1px solid rgba(255,255,255,0.05);
  --card-border-strong: 1px solid rgba(255,255,255,0.12);
  --divider: rgba(255,255,255,0.08);
  --carbon-texture: repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 4px);
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: 0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   HEADER
   ============================================================================ */

header {
  padding: 0.6rem 1.25rem;
  text-align: left;
  background: linear-gradient(90deg, #aa1f16 0%, #a8261b 100%);
  border-bottom: 1px solid rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25) inset;
  position: relative;
  overflow: hidden;
  z-index: 0;
}

header::before,
header::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

header::before {
  background:
    radial-gradient(circle at 15% 30%, rgba(255,255,255,0.1), transparent 45%),
    radial-gradient(circle at 70% 20%, rgba(0,0,0,0.35), transparent 60%);
  mix-blend-mode: overlay;
  opacity: 0.45;
}

header::after {
  background:
    linear-gradient(120deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 35%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.08) 0 8px, transparent 8px 16px),
    repeating-linear-gradient(315deg, rgba(0,0,0,0.15) 0 10px, transparent 10px 20px);
  mix-blend-mode: soft-light;
  opacity: 0.6;
}

header > * {
  position: relative;
  z-index: 1;
}

.header-compressed {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 6px 24px rgba(5, 6, 9, 0.55);
  background:
    linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.18)),
    linear-gradient(90deg, #b42d1f 0%, #951d13 100%);
}

/* Header Logo */
header .header-logo {
  height: 72px;
  width: auto;
  cursor: pointer;
}

/* Header Content Area */
header .header-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.nav-strava-badge {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.nav-strava-badge a {
  display: inline-block;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
}

.nav-strava-badge a:hover {
  color: #fff;
}

.nav-menu.open .nav-strava-badge {
  opacity: 1;
  transform: translateY(0);
}

/* Header Title */
header .header-title {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  line-height: 1.1;
}

/* Header Subtitle */
header .header-subtitle {
  margin: 0;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.05em;
  font-weight: 400;
  font-size: 0.7rem;
  line-height: 1.1;
}

/* Strava Badge */
header .strava-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: rgba(252, 76, 2, 0.15);
  border: 1px solid rgba(252, 76, 2, 0.4);
  border-radius: 6px;
  text-decoration: none;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: background 0.2s ease;
  white-space: nowrap;
}

header .strava-badge:hover {
  background: rgba(252, 76, 2, 0.25);
}

/* Legacy support for h1 in header */
h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
}

header p {
  margin: 0.15rem 0 0;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 0.9rem;
}

h2 {
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
  font-size: 1.05rem;
  border-left: 5px solid var(--accent);
  padding-left: 0.75rem;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

main {
  padding: 0 1.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ============================================================================
   CARDS
   ============================================================================ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  justify-items: center;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(0,0,0,0.02)), var(--surface-3);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  border: var(--card-border);
  border-top: 2px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: center;
  width: 100%;
  box-shadow: var(--elev-3);
  transition:
    background 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.card span {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.card strong {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.card:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02)), var(--surface-3);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

/* ============================================================================
   PANELS & CHARTS
   ============================================================================ */

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(0,0,0,0.02)), var(--surface-2);
  border-radius: var(--card-radius);
  padding: 1.5rem 1.25rem;
  border: var(--card-border);
  box-shadow: var(--elev-2);
  position: relative;
}

[data-section-focus] {
  transition:
    box-shadow 260ms ease,
    border-color 260ms ease,
    transform 260ms ease,
    filter 260ms ease;
}

[data-section-focus].is-focused {
  box-shadow: var(--elev-3);
  border-color: rgba(255,255,255,0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02)), var(--surface-3);
  filter: brightness(1.03);
  transform: translateY(-3px);
}

.gp-parallax {
  will-change: transform;
  transition: transform 320ms ease-out;
}

[data-personal-section="true"] {
  position: relative;
}

.personal-section--locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 9, 0.65);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
  z-index: 2;
}

.personal-lock {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}

.personal-section--locked .personal-lock {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 3;
  backdrop-filter: blur(2px);
  background: rgba(10, 12, 17, 0.35);
}

.personal-lock__inner h2 {
  margin-bottom: 0.5rem;
}

.personal-lock__inner p {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--muted);
}

.personal-lock .cta-button {
  min-width: auto;
  padding: 0.6rem 1.5rem;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

canvas {
  width: 100% !important;
  height: 320px !important;
}

/* ============================================================================
   AXIS TOGGLE
   ============================================================================ */

.axis-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.axis-toggle button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.axis-toggle button.active {
  background: #bdbdbd;
  color: var(--bg);
  font-weight: 600;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table-wrapper {
  overflow-x: auto;
  background: var(--surface-2);
  border: var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--elev-1);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
}

thead {
  color: var(--text);
  background: rgba(255,255,255,0.02);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  border-bottom: 1px solid var(--divider);
}

th,
td {
  padding: 0.85rem 0.75rem;
  text-align: left;
}

tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

tbody tr:nth-child(odd) {
  background-color: rgba(255,255,255,0.01);
}

tbody tr:nth-child(even) {
  background-color: rgba(0,0,0,0.05);
}

tbody tr:hover {
  background-color: rgba(255,255,255,0.05);
}

tbody tr.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background-color: #1d212a;
}

/* ============================================================================
   NAVIGATION MENU
   ============================================================================ */

.nav-menu {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background: linear-gradient(180deg, #14171f 0%, #0a0b0f 100%);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 10px rgba(0,0,0,0.5);
  transition: left 0.3s ease;
  z-index: 2500;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-menu.open {
  left: 0;
}

.nav-menu h2 {
  margin: 0 0 1.5rem 0;
  border: none;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 1.1rem;
  color: var(--text);
}

.nav-menu a {
  display: block;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.2s;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.nav-menu a:hover {
  background: var(--surface);
}

.nav-menu a.active {
  background: #c83324;
  color: #fff;
  font-weight: 600;
}

.nav-menu .nav-heading {
  display: block;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  border-radius: 6px;
  font-weight: 400;
  cursor: default;
}

.nav-menu summary.nav-heading {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}

.nav-menu summary.nav-heading::-webkit-details-marker {
  display: none;
}

.nav-menu .nav-grand-prix-block {
  margin-bottom: 0.75rem;
}

.nav-menu .nav-grand-prix-block > div {
  padding-left: 1.25rem;
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 2400;
}

.nav-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.logo-link {
  cursor: pointer;
}

/* ============================================================================
   VERIFICATION BADGES
   ============================================================================ */

.verification-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: help;
}

.verification-verified {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.verification-distance_only {
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.3);
}

.verification-rejected {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.verification-unknown {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

.challenge-btn {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.challenge-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.challenge-btn:active {
  transform: translateY(0);
}

.site-footer {
  margin-top: 2.5rem;
  padding: 1rem 0;
  font-size: 0.8rem;
  opacity: 0.7;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
}

.footer-links {
  margin-left: 0.5rem;
}

.footer-note {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
}

/* ============================================================================
   AUTH-GATED CONTENT
   ============================================================================ */

.requires-auth {
  /* Container for content that requires authentication */
  /* Will be hidden when user is not logged in */
}

.requires-auth-message {
  /* Message shown when user is NOT logged in */
  display: none;
  padding: 2rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--card-radius);
  margin: 1rem 0;
}

.requires-auth-message h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
}

.requires-auth-message p {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.6;
}

.requires-auth-message .cta-button {
  display: inline-block;
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.requires-auth-message .cta-button:hover {
  background: var(--accent-alt);
}

.requires-auth-content {
  /* Content shown when user IS logged in */
  /* Will be blurred when user is not logged in */
  transition: filter 0.3s ease;
}

.requires-auth-content[data-auth="false"] {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 640px) {
  th,
  td {
    font-size: 0.85rem;
  }
  
  .verification-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }
  
  .challenge-btn {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }
}
