/* ── App layout ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;   /* fallback for browsers without dvh support */
  height: 100dvh;
  width: 100%;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#header {
  height: 52px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  z-index: 10;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

#header-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

#header-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-header);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

#header-sub {
  font-size: 0.58rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  line-height: 1.1;
}

#header-divider {
  width: 1px;
  height: 28px;
  background: var(--border-light);
  margin: 0 4px;
  flex-shrink: 0;
}


#header-event {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-header);
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

/* ── Header right: theme toggle + Kenya flag ─────────────────────────────── */
#header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#theme-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 1.0rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

#theme-toggle:hover {
  transform: scale(1.15);
}

#kenya-flag {
  font-size: 1.0rem;
  line-height: 1;
  cursor: default;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

#kenya-flag:hover {
  transform: scale(1.2);
}

/* ── Map container ───────────────────────────────────────────────────────── */
#map {
  flex: 1;
  width: 100%;
  position: relative;
}

/* ── Custom zoom buttons ─────────────────────────────────────────────────── */

#custom-zoom {
  position: absolute;
  bottom: 90px;
  right: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: bottom 0.2s ease;
}

@media (max-width: 768px) {
  body.race-weekend-strip-active #custom-zoom {
    bottom: 160px; /* moved up, out of the strip's row, matching where the strip used to sit */
  }
}



#custom-zoom button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: rgba(15,15,26,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  transition: background 0.15s, transform 0.1s;
}

#custom-zoom button:hover {
  background: rgba(40,40,60,0.9);
  transform: scale(1.08);
}

body.light-theme #custom-zoom button {
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.1);
  color: #111122;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

body.light-theme #custom-zoom button:hover {
  background: rgba(235,235,245,0.95);
}








/* ── Circuit markers ─────────────────────────────────────────────────────── */
.f1-marker {
  

  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  border: 4px solid #999; 






  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  transition: transform 0.15s ease-out, box-shadow 0.15s, border-color 0.2s;
  transform: scale(var(--marker-scale, 1));
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  letter-spacing: 0.03em;
}



.f1-marker:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}





/* ── Status ring colors — the ONLY differentiator between markers ────────── */
.f1-marker.status-live {
  border-color: #2ecc71;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

.f1-marker.status-past {
  border-color: #e74c3c;
}

.f1-marker.status-upcoming {
  border-color: #f5a623;
}

.f1-marker.status-cancelled {
  border-color: #9b59b6;
}

/* ── Dashed rotating ring — replaces the old glow for live/next-up markers.
   Same pattern as the mini track-centroid marker's spinning dashed ring. ── */
.f1-marker.status-live::before,
.f1-marker.next-up::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed currentColor;
  opacity: 0.75;
  animation: marker-ring-spin 4s linear infinite;
  pointer-events: none;
}

.f1-marker.status-live::before {
  color: #2ecc71;
}

.f1-marker.next-up::before {
  color: #f5a623;
}

@keyframes marker-ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}














body.light-theme .f1-marker {
  background: rgba(255,255,255,0.95);
}





















/* ── Initials ⇄ round number cycle (20s loop, 10s each) ──────────────────── */
.f1-marker-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.f1-marker-initials {
  animation: marker-cycle-initials 20s steps(1, end) infinite;
}

.f1-marker-round {
  animation: marker-cycle-round 20s steps(1, end) infinite;
}

@keyframes marker-cycle-initials {
  0%, 49.9%  { opacity: 1; }
  50%, 100%  { opacity: 0; }
}

@keyframes marker-cycle-round {
  0%, 49.9%  { opacity: 0; }
  50%, 100%  { opacity: 1; }
}


















/* ── Leaflet tile fix ────────────────────────────────────────────────────── */
.leaflet-tile {
  outline: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #header {
    padding: 0 10px;
    gap: 6px;
  }

  #header-logo {
    width: 28px;
    height: 28px;
    font-size: 0.62rem;
  }

  #header-title {
    font-size: 0.88rem;
  }

  #header-sub {
    font-size: 0.5rem;
  }

  #header-divider {
    height: 22px;
    margin: 0 2px;
  }

  #header-event {
    font-size: 0.76rem;
  }

  #theme-toggle {
    font-size: 0.8rem;
  }

  #kenya-flag {
    font-size: 0.8rem;
  }

  #custom-zoom {
    bottom: 110px;
    right: 10px;
  }

  #custom-zoom button {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }
}


/* ── Track centroid marker (shown when track outline is revealed) ────────── */
.track-centroid-marker {
  width: 26px;
  height: 26px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}


.track-centroid-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--circuit-color, var(--accent));
  opacity: 0.9;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 6px color-mix(in srgb, var(--circuit-color, var(--accent)) 60%, transparent);
  animation: centroidDotPulse 1.8s ease-in-out infinite;
}

.track-centroid-pulse {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px dashed var(--circuit-color, var(--accent));
  opacity: 0.6;
  animation: centroidSpin 5s linear infinite;
}


@keyframes centroidSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}


@keyframes centroidDotPulse {
  0%, 100% { transform: scale(1);   opacity: 0.9; }
  50%      { transform: scale(1.3); opacity: 0.5; }
}

@media (max-width: 768px) {
  .track-centroid-marker {
    width: 18px;
    height: 18px;
  }

  .track-centroid-dot {
    width: 7px;
    height: 7px;
  }

  .track-centroid-pulse {
    width: 18px;
    height: 18px;
  }
}

/* ── On-map track stats overlay (shown when a circuit panel is open) ──────── */
#track-stats-overlay {
  position: absolute;
  z-index: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

#track-stats-overlay.visible {
  opacity: 1;
}

#track-stats-overlay.position-top {
  top: 64px;
  left: 20px;
  transform: none;
  max-width: calc(100% - 380px);
  text-align: left;
}

#track-stats-overlay.position-left {
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  max-width: 220px;
  text-align: left;
}

#track-stats-overlay.position-right {
  top: 50%;
  right: 376px;
  transform: translateY(-50%);
  max-width: 220px;
  text-align: left;
}

.track-overlay-inner {
  padding: 0;
}

.track-overlay-gp {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
}

body.light-theme .track-overlay-gp {
  text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 0 10px rgba(255,255,255,0.6);
}

.track-overlay-circuit-name {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.5);
}

body.light-theme .track-overlay-circuit-name {
  color: #111122;
  text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 0 10px rgba(255,255,255,0.6);
}

.track-overlay-stats {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
  white-space: nowrap;
}


#track-stats-overlay.position-top .track-overlay-stats {
  justify-content: flex-start;
}


#track-stats-overlay.position-left .track-overlay-stats,
#track-stats-overlay.position-right .track-overlay-stats {
  flex-direction: column;
  align-items: flex-start;
  white-space: normal;
  gap: 8px;
}

.track-overlay-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.track-overlay-stat-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5);
}

body.light-theme .track-overlay-stat-label {
  color: rgba(0,0,0,0.6);
  text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 0 8px rgba(255,255,255,0.6);
}

.track-overlay-stat-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5);
}

body.light-theme .track-overlay-stat-value {
  color: #111122;
  text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 0 8px rgba(255,255,255,0.6);
}

.track-overlay-stat-unit {
  font-size: 0.6rem;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

body.light-theme .track-overlay-stat-unit {
  color: rgba(0,0,0,0.55);
  text-shadow: 0 1px 4px rgba(255,255,255,0.9);
}

.track-overlay-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

body.light-theme .track-overlay-divider {
  background: rgba(0,0,0,0.25);
}

#track-stats-overlay.position-left .track-overlay-divider,
#track-stats-overlay.position-right .track-overlay-divider {
  width: 100%;
  height: 1px;
}


.track-overlay-record {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.4);
  -webkit-text-stroke: 0px;
}

body.light-theme .track-overlay-record {
  text-shadow: 0 1px 3px rgba(255,255,255,1), 0 0 12px rgba(255,255,255,1),
               0 2px 6px rgba(255,255,255,0.9);
}


.track-overlay-record-meta {
  font-size: 0.62rem;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

body.light-theme .track-overlay-record-meta {
  color: rgba(0,0,0,0.55);
  text-shadow: 0 1px 4px rgba(255,255,255,0.9);
}


/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #track-stats-overlay.position-top,
  #track-stats-overlay.position-left,
  #track-stats-overlay.position-right {
    top: 56px;
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    text-align: left;
  }

  .track-overlay-gp {
    font-size: 0.52rem;
    margin-bottom: 1px;
    display: inline;
  }

  .track-overlay-circuit-name {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
  }


  /* Stats can wrap to a second line on mobile instead of being clipped */
  .track-overlay-stats {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: baseline !important;
    white-space: normal !important;
    gap: 4px 0 !important;
    overflow: visible;
  }


  .track-overlay-stat {
    flex-direction: row;
    align-items: baseline;
    gap: 3px;
    flex-shrink: 0;
  }

  .track-overlay-stat-label {
    font-size: 0.44rem;
    font-weight: 700;
    opacity: 0.7;
    margin-right: 2px;
  }

  .track-overlay-stat-value {
    font-size: 0.7rem;
    font-weight: 700;
  }

  .track-overlay-stat-unit {
    font-size: 0.5rem;
  }

  .track-overlay-divider {
    width: 1px;
    height: 12px;
    background: rgba(255,255,255,0.3);
    display: block;
    margin: 0 8px;
    flex-shrink: 0;
  }

  body.light-theme .track-overlay-divider {
    background: rgba(0,0,0,0.2);
  }

  /* Lap record inline */
  .track-overlay-record {
    font-size: 0.62rem;
  }

  .track-overlay-record-meta {
    font-size: 0.5rem;
  }
}

@media (max-width: 768px) {
  #custom-zoom {
    bottom: 90px;
    right: 10px;
  }
}





/* ── Mobile map maximize button ─────────────────────────────────────────── */
#map-maximize-btn {
  position: absolute;
  bottom: var(--maximize-btn-bottom, 160px);
  right: 14px;
  z-index: 1300;
  width: 38px;
  height: 38px;
  border: none;
  background: none;
  color: #ffffff;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
  transition: color 0.15s;
}

#map-maximize-btn .maximize-btn-icon {
  display: inline-flex;
  animation: maximize-btn-pulse 1.8s ease-in-out infinite;
}


#map-maximize-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px dashed currentColor;
  opacity: 0.7;
  animation: maximize-btn-ring-spin 4s linear infinite;
  pointer-events: none;
}

@keyframes maximize-btn-ring-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}



@keyframes maximize-btn-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}



body.light-theme #map-maximize-btn {
  color: #111122;
}






/* Only show on mobile */
@media (min-width: 769px) {
  #map-maximize-btn { display: none !important; }
}



#header-season.header-season-past {
  color: #e74c3c;
  font-weight: 700;
}

#header-season.header-season-active {
  color: inherit;
}


#header-season-dot {
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00c853;
  margin-left: 6px;
  flex-shrink: 0;
}



.f1-marker.championship-win-pulse,
.track-centroid-marker.championship-win-pulse {
  animation: championshipWinGlow 0.9s ease-in-out infinite;
}

@keyframes championshipWinGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,215,0,0.85), 0 2px 8px rgba(0,0,0,0.45); }
  50%      { box-shadow: 0 0 16px 7px rgba(255,215,0,0.9), 0 2px 8px rgba(0,0,0,0.45); }
}

