/* =============================================
   DELTA — colapintovsgasly.com
   Design spec: WEB_DESIGN.md
   Mobile-first. Dark always.
   ============================================= */

/* --- Variables --- */
:root {
  --bg-void:        #050508;
  --bg-surface:     #0D0D12;
  --bg-elevated:    #141420;
  --border:         #1E1E2E;
  --border-active:  #2E2E4E;

  --text-primary:   #F0F0FF;
  --text-secondary: #7070A0;
  --text-dim:       #3A3A5C;

  --col-primary:    #FF2D6B;
  --col-light:      #FF6B9D;
  --col-glow:       rgba(255, 45, 107, 0.15);

  --gas-primary:    #00C8FF;
  --gas-light:      #60DFFF;
  --gas-glow:       rgba(0, 200, 255, 0.15);

  --delta-col:      #00FF87;
  --delta-neutral:  #444466;
  --delta-gas:      #FF4040;

  --accent-gold:    #FFD700;

  --s1:             #FF8C00;
  --s2:             #9B59B6;
  --s3:             #27AE60;

  --tap-min:        44px;
  --gap:            12px;
  --page-pad:       12px;
  --header-height:  48px;
}

@media (min-width: 1100px) {
  :root {
    --gap:           16px;
    --page-pad:      24px;
    --header-height: 56px;
  }
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
}

@media (min-width: 768px)  { html { font-size: 15px; } }
@media (min-width: 1200px) { html { font-size: 16px; } }

body {
  background: var(--bg-void);
  min-height: 100vh;
  font-family: 'Barlow', sans-serif;
}

/* --- Scrollbars --- */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--border-active); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-void);
  border-bottom: 1px solid var(--border-active);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--page-pad);
  padding-left:  max(var(--page-pad), env(safe-area-inset-left));
  padding-right: max(var(--page-pad), env(safe-area-inset-right));
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.site-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 20px;
  color: var(--text-primary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

@media (min-width: 1100px) {
  .header {
    height: 56px;
    justify-content: flex-start;
    gap: 32px;
  }
  .site-name { font-size: 24px; }
}

/* --- Pill group in header (desktop circuit pills) --- */
.pill-group {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pill-group::-webkit-scrollbar { display: none; }

/* --- Session Strip (mobile/tablet) --- */
.session-strip {
  position: sticky;
  top: var(--header-height);   /* uses CSS var — no magic number */
  z-index: 190;
  background: var(--bg-void);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
  padding: 8px var(--page-pad);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}
.session-strip::-webkit-scrollbar { display: none; }

@media (min-width: 1100px) {
  .session-strip { display: none; }
  /* Sessions live in header on desktop */
}

/* --- Pills --- */
.pill {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 14px;
  height: var(--tap-min);
  min-width: 44px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pill.active {
  background: var(--border-active);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.pill.disabled,
.pill[disabled] {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}

/* --- Page Container --- */
.page-container {
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
}

/* --- Driver Cards --- */
.driver-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: var(--gap) var(--page-pad);
}

.driver-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.driver-card.col {
  border-left: 3px solid var(--col-primary);
  box-shadow: 0 0 20px var(--col-glow);
}

.driver-card.gas {
  border-right: 3px solid var(--gas-primary);
  box-shadow: 0 0 20px var(--gas-glow);
  text-align: right;
}

.driver-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 20px;
  color: var(--text-primary);
  text-transform: uppercase;
  line-height: 1;
}

.driver-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  line-height: 1.8;
}

.driver-card.gas .stat-row {
  flex-direction: row-reverse;
}

.stat-label {
  font-family: 'Barlow', sans-serif;
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

@media (min-width: 1100px) {
  .driver-card { padding: 20px 24px; }
  .driver-card.col { border-left-width: 4px; }
  .driver-card.gas { border-right-width: 4px; }
  .driver-name  { font-size: 28px; }
  .stat-value   { font-size: 20px; }
  .stat-label   { font-size: 11px; }
}

/* --- Track Section (wraps track map + telemetry) --- */
.track-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

@media (min-width: 1100px) {
  .track-section {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--gap);
    padding: 0 var(--page-pad);
  }
}

/* --- Track Panel --- */
.track-panel {
  padding: 0 var(--page-pad);
}

.track-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.track-canvas-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

canvas.track-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

@media (min-width: 1100px) {
  .track-panel {
    width: 35%;
    padding: 0;
    position: sticky;
    top: 72px;
    align-self: flex-start;
    max-height: calc(100vh - 90px);
    flex-shrink: 0;
  }
  .track-canvas-wrapper {
    aspect-ratio: auto;
    height: calc(100vh - 240px);
    min-height: 300px;
  }
}

/* --- Delta Legend --- */
.delta-legend {
  margin-top: 8px;
  padding: 0 2px;
}

.delta-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--delta-col), var(--delta-neutral), var(--delta-gas));
}

.delta-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-secondary);
}

/* --- Telemetry Panel --- */
.telemetry-panel {
  flex: 1;
  min-width: 0;
}

/* --- Lap Selector --- */
.lap-selector-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px var(--page-pad);
}

.lap-select {
  width: 100%;
  height: var(--tap-min);
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 0 12px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.lap-context {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.col-time { color: var(--col-primary); }
.gas-time { color: var(--gas-primary); }

@media (min-width: 640px) {
  .lap-selector-row { flex-direction: row; align-items: center; }
  .lap-select       { width: auto; min-width: 200px; }
}

@media (min-width: 1100px) {
  .lap-selector-row { padding: 12px 0; }
}

/* --- Telemetry Tabs --- */
.telemetry-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 var(--page-pad);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-user-select: none;
}
.telemetry-tabs::-webkit-scrollbar { display: none; }

.telem-tab {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 16px;
  height: 36px;
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg-surface);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
}

.telem-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-active);
}

@media (min-width: 1100px) {
  .telemetry-tabs { display: none; }
  .telem-chart    { display: block !important; }
}

/* --- Telemetry Charts --- */
.telem-chart-container {
  position: relative;
  padding: 0 var(--page-pad);
}

.telem-chart {
  width: 100%;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: 0 4px 4px 4px;
  background: var(--bg-surface);
  overflow: hidden;
}

@media (min-width: 1100px) {
  .telem-chart-container { padding: 0; }

  .telem-chart.speed    { height: 200px; border-radius: 4px; margin-bottom: 4px; }
  .telem-chart.throttle { height: 120px; border-radius: 4px; margin-bottom: 4px; }
  .telem-chart.brake    { height: 70px;  border-radius: 4px; margin-bottom: 4px; }
  .telem-chart.gear     { height: 120px; border-radius: 4px; margin-bottom: 4px; }
  .telem-chart.drs      { height: 70px;  border-radius: 4px; }
}

/* --- Lap Time Section --- */
.laptime-section {
  padding: var(--gap) var(--page-pad);
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
}

.laptime-chart {
  width: 100%;
  height: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

@media (min-width: 1100px) {
  .laptime-chart { height: 320px; }
}

/* --- Loading Panel --- */
.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  gap: 10px;
  position: relative;
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.loading-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(600%); }
}

.loading-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--col-primary), transparent);
  animation: scanline 1.2s ease-in-out infinite;
}

/* --- No-Data Panel --- */
.no-data-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 24px;
  text-align: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.no-data-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.no-data-sub {
  font-family: 'Barlow', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* --- Transitions --- */
.pill, .telem-tab, .driver-card, select { transition: all 0.15s ease; }

/* --- Global polish --- */
.pill, .telem-tab, .header, .session-strip {
  user-select: none;
  -webkit-user-select: none;
}
