@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700;900&family=Roboto+Mono:wght@400;700&display=swap');

:root {
  /* Colors - Matte Technical Palette */
  --bg: #0c0c0f;
  --surface: #15151e;
  --surface-raised: #1d1d26;
  --surface-muted: #111118;
  --accent: #e10600;
  --accent-soft: rgba(225, 6, 0, 0.15);
  --text: #ffffff;
  --text-muted: #949498;
  --border: #2b2b30;
  --border-strong: #3e3e46;
  
  /* System */
  --radius: 4px;
  --radius-sm: 2px;
  --space-unit: 8px;
  
  /* Layout */
  --nav-width: 260px;
  --nav-mobile-height: 64px;
  --content-max-width: 1400px;
  
  /* Typography */
  --font-main: "Titillium Web", sans-serif;
  --font-mono: "Roboto Mono", monospace;
  
  /* Transitions */
  --trans: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: 
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
  color: var(--text);
  font-family: var(--font-main);
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--trans);
}

a:hover {
  color: var(--accent);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 0.9rem;
  z-index: 999;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--nav-width);
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 1rem;
  z-index: 100;
}

.brand {
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-bottom: 3rem;
  padding: 0 1rem;
  color: var(--text);
  font-size: 1.2rem;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand::before {
  content: "";
  display: block;
  width: 4px;
  height: 24px;
  background: var(--accent);
}

.sidebar nav,
.bottom-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  border-radius: var(--radius);
  transition: var(--trans);
  position: relative;
  overflow: hidden;
}

.nav-item svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: var(--surface-raised);
  color: var(--text);
  outline: none;
}

.sidebar .nav-item.is-active {
  background: var(--surface-raised);
  color: var(--text);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.content {
  margin-left: var(--nav-width);
  min-height: 100dvh;
  padding: 2rem 2rem 4rem;
  max-width: var(--content-max-width);
}

.home-content {
  padding-top: 2.5rem;
}

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius);
  padding: 4rem 2rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(225, 6, 0, 0.05));
  pointer-events: none;
}

.hero h1,
.page-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 0.95;
  font-style: italic;
}

.eyebrow {
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.eyebrow::before {
  content: "";
  width: 20px;
  height: 2px;
  background: currentColor;
}

.page-header p,
.hero p {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 650px;
  line-height: 1.6;
}

.page-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.section {
  margin-bottom: 3rem;
}

.section h2 {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-weight: 800;
}

.section h2::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--trans);
  position: relative;
  overflow: hidden;
}

.card:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
  background: var(--surface-raised);
}

.badge-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.toolbar {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-bottom: 3rem;
  background: var(--surface);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field span {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 600;
  transition: var(--trans);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-raised);
}

.grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}

.driver-card,
.team-card,
.champion-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: var(--trans);
}

.driver-card:hover,
.team-card:hover,
.champion-card:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
}

.driver-header,
.team-header,
.champion-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 2rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.portrait,
.logo {
  width: 100px;
  height: 100px;
  object-fit: cover;
  object-position: top center; /* Focus on the driver's face */
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.team-header .logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05) !important; /* Force visibility over dark card */
  border: 1px solid var(--border);
}

.name-brand {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
  color: #fff;
  line-height: 0.85;
  font-style: italic;
}

.name-official {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.meta,
.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.driver-card .meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.driver-flag-inline {
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 2px;
}

.team-logo-inline {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.driver-number,
.title-count,
.countdown-timer {
  font-family: 'Titillium Web', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.05em;
  font-style: italic;
  line-height: 1;
}

.countdown-timer {
  background: rgba(0, 0, 0, 0.5);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  display: inline-block;
  margin-top: 1.5rem;
  border: 1px solid var(--accent);
  box-shadow: 0 0 20px var(--accent-muted);
}

.expand-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.expand-btn:hover,
.expand-btn:focus-visible {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
}

.details {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
}

/* Detalhes unificados via .race-details-grid e .detail-item */

.list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-item {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.25rem;
}

.round {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
}

.calendar-item.past {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.calendar-item.next {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(225, 6, 0, 0.1), transparent);
}

.calendar-item.next .round {
  border-color: var(--accent);
  color: var(--accent);
}

.table-wrap {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
}

.standings-table th {
  text-align: left;
  padding: 1rem 0.75rem;
  border-bottom: 2px solid var(--border-strong);
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  background: var(--surface);
}

.standings-table td {
  padding: 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.standings-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.standings-table tr:hover {
  background: var(--surface-raised);
}

.race-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.5rem 1.5rem;
  margin: 2.5rem 0;
  padding: 2rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

@media (min-width: 992px) {
  .race-details-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-item:last-child {
  grid-column: 1 / -1;
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #888;
  font-weight: 800;
}

.detail-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-family: var(--font-mono);
}

.circuit-container {
  flex: 1.2;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  background: radial-gradient(circle at center, rgba(30, 30, 30, 0.4), var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 400px;
  position: relative;
  overflow: hidden;
}

.circuit-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.circuit-map {
  max-width: 100%;
  height: auto;
  filter: invert(1) brightness(1.2) drop-shadow(0 0 15px rgba(225, 6, 0, 0.3));
  transition: all 0.5s ease;
}

.card:hover .circuit-map {
  transform: scale(1.08) rotate(-2deg);
}

.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 800;
}

.detail-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.countdown-hud {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  padding: 2rem;
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  position: relative;
}

.countdown-hud::before {
  content: "LIVE TELEMETRY";
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 2px;
}

.countdown-hud .timer-wrapper {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.countdown-hud .label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--accent);
  opacity: 0.6;
}

.countdown-hud .timer {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.podium-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.podium-rank {
  font-size: 2.5rem;
  font-weight: 900;
  font-style: italic;
  color: var(--accent);
  opacity: 0.2;
  font-family: var(--font-mono);
  line-height: 1;
  min-width: 40px;
}

.podium-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--border);
}

.podium-code {
  font-weight: 900;
  font-size: 1.5rem;
}

.podium-time {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
}

.state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.state-card.error {
  border-color: rgba(225, 6, 0, 0.4);
  background: linear-gradient(145deg, var(--surface), rgba(225, 6, 0, 0.05));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 1rem;
}

.state-card-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-icon {
  font-size: 3.5rem;
  opacity: 0.2;
}

.empty-message {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 300px;
}

.cache-feedback {
  position: fixed;
  right: 1.5rem;
  top: 1.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 200;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.cache-feedback span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cache-feedback span::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #00ff00;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ff00;
}

.cache-feedback button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.cache-feedback button:hover {
  color: var(--text);
}

.button {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  transition: var(--trans);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.button:hover,
.button:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  outline: none;
}

.skeleton {
  background: linear-gradient(100deg, var(--surface) 20%, var(--surface-raised) 35%, var(--surface) 50%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 2s linear infinite;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2rem;
}

.skeleton-line {
  height: 14px;
  margin-bottom: 0.75rem;
}

.skeleton-line.short {
  width: 45%;
}

.skeleton-line.medium {
  width: 70%;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-mobile-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  display: none;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}

.bottom-nav .nav-item {
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.65rem;
  flex: 1;
  text-align: center;
}

.bottom-nav .nav-item.is-active {
  color: var(--accent);
  background: transparent;
}

.bottom-nav .nav-item.is-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}

.error-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1rem;
}

.error-card {
  width: min(560px, 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2.5rem;
  text-align: center;
}

@media (min-width: 768px) {
  .toolbar {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .grid.grid-drivers,
  .grid.grid-teams,
  .grid.grid-champions {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .table-wrap {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

@media (min-width: 1280px) {
  .content {
    padding: 2.5rem 2.5rem 4rem;
  }
}

@media (min-width: 1400px) {
  .grid.grid-drivers,
  .grid.grid-teams,
  .grid.grid-champions {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1023px) {
  .sidebar {
    display: none;
  }

  .content {
    margin-left: 0;
    margin-bottom: calc(var(--nav-mobile-height) + 1rem);
  }

  .bottom-nav {
    display: flex;
  }

  .cache-feedback {
    top: auto;
    bottom: calc(var(--nav-mobile-height) + 1.25rem);
    right: 1.25rem;
    left: 1.25rem;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .driver-header,
  .team-header,
  .champion-header {
    grid-template-columns: 66px 1fr;
  }

  .driver-number,
  .title-count {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .details dl {
    grid-template-columns: 1fr;
  }

  .calendar-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .hero {
    padding: 2.5rem 1.5rem;
  }
}

/* Team Logos in Tables */
.team-logo-mini {
  max-width: 42px;
  max-height: 22px;
  object-fit: contain;
  display: block;
  margin: 0;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.25));
  transition: transform 0.2s ease;
}

.team-logo-mini:hover {
  transform: scale(1.15);
}

.standings-table td {
  vertical-align: middle;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent) !important;
  outline-offset: 4px;
}
