/* === STANDINGS PAGE === */

.standings-page {
  padding: var(--space-8) var(--space-6) var(--space-16);
  min-height: 60vh;
}

.standings-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
}

/* Header */
.standings-header {
  margin-bottom: var(--space-8);
}

.standings-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.standings-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.standings-title .accent {
  color: var(--color-primary);
}

.standings-season-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: var(--space-2);
}

.standings-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 60ch;
}

.standings-round {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  margin-top: var(--space-2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tabs */
.standings-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-1);
}

.standings-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: relative;
  cursor: pointer;
  transition: color var(--transition-interactive), background var(--transition-interactive);
}

.standings-tab:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.standings-tab--active {
  color: var(--color-text);
}

.standings-tab--active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px 2px 0 0;
}

.standings-tab svg {
  flex-shrink: 0;
}

/* Loading */
.standings-loading {
  text-align: center;
  padding: var(--space-16) 0;
  color: var(--color-text-muted);
}

.loading-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 32px;
  margin-bottom: var(--space-4);
}

.loading-bars span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--color-primary);
  animation: loadingBar 1s ease-in-out infinite;
}

.loading-bars span:nth-child(1) { height: 12px; animation-delay: 0s; }
.loading-bars span:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.loading-bars span:nth-child(3) { height: 28px; animation-delay: 0.2s; }
.loading-bars span:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.loading-bars span:nth-child(5) { height: 12px; animation-delay: 0.4s; }

@keyframes loadingBar {
  0%, 100% { opacity: 0.3; transform: scaleY(0.6); }
  50% { opacity: 1; transform: scaleY(1); }
}

/* Table */
.standings-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.standings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 var(--space-1);
}

.standings-table thead th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.standings-table thead th.col-pts,
.standings-table thead th.col-wins {
  text-align: center;
}

/* Rows */
.standings-row {
  background: var(--color-surface);
  animation: fadeSlideIn 0.4s ease-out both;
  transition: background var(--transition-interactive), transform var(--transition-interactive);
}

.standings-row:hover {
  background: var(--color-surface-2);
  transform: translateX(2px);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.standings-row td {
  padding: var(--space-3) var(--space-3);
  vertical-align: middle;
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}

.standings-row td:first-child {
  border-left: 3px solid var(--team-color, var(--color-primary));
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.standings-row td:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Position badges */
.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.pos-gold {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.pos-silver {
  background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.3);
}

.pos-bronze {
  background: linear-gradient(135deg, #CD7F32 0%, #A0522D 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.3);
}

/* Driver cell */
.col-driver {
  display: flex !important;
  align-items: center;
  gap: var(--space-2);
  min-width: 200px;
}

.driver-flag {
  font-size: 1.2em;
  flex-shrink: 0;
}

.driver-name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.driver-first {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.driver-last {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.driver-number {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 600;
  margin-left: auto;
  padding-left: var(--space-2);
}

/* Team cell */
.col-team {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.col-team span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* Constructors name cell */
.col-team-name {
  min-width: 200px;
}

.col-team-name span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  vertical-align: middle;
}

.constructor-color-bar {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  flex-shrink: 0;
}

.constructor-label {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Points & wins */
.col-pts {
  text-align: center;
  font-size: var(--text-base);
}

.col-pts strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.col-wins {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Points bar */
.col-bar {
  width: 180px;
  min-width: 120px;
}

.pts-bar {
  height: 6px;
  border-radius: 3px;
  min-width: 3px;
  opacity: 0.7;
  transition: width 0.6s var(--ease-out);
}

/* Footer */
.standings-footer {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.standings-source {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.standings-source a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.standings-source a:hover {
  color: var(--color-primary);
}

.standings-updated {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.standings-error {
  color: var(--color-primary);
  font-style: italic;
}

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

@media (max-width: 768px) {
  .standings-page {
    padding: var(--space-6) var(--space-4) var(--space-12);
  }

  .standings-header-top {
    flex-direction: column;
    gap: var(--space-2);
  }

  .standings-season-badge {
    margin-top: 0;
  }

  .standings-title {
    font-size: var(--text-xl);
  }

  .standings-table thead {
    display: none;
  }

  .standings-table,
  .standings-table tbody {
    display: block;
  }

  .standings-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 var(--space-2);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--team-color, var(--color-primary));
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    border-left: 3px solid var(--team-color, var(--color-primary));
  }

  .standings-row:hover {
    transform: none;
  }

  .standings-row td {
    padding: 0;
    border: none;
  }

  .standings-row td:first-child {
    border-left: none;
    border-radius: 0;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
  }

  /* Drivers mobile */
  #drivers-table .standings-row .col-driver {
    grid-column: 2;
    grid-row: 1;
  }

  #drivers-table .standings-row .col-team {
    grid-column: 2;
    grid-row: 2;
    font-size: var(--text-xs);
    padding-top: 2px;
  }

  #drivers-table .standings-row .col-pts {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
    font-size: var(--text-lg);
  }

  #drivers-table .standings-row .col-wins,
  #drivers-table .standings-row .col-bar {
    display: none;
  }

  .driver-number {
    display: none;
  }

  /* Constructors mobile */
  #constructors-table .standings-row .col-team-name {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
  }

  #constructors-table .standings-row .col-pts {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
    font-size: var(--text-lg);
  }

  #constructors-table .standings-row .col-wins,
  #constructors-table .standings-row .col-bar {
    display: none;
  }

  .standings-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
