/* ============================================================
   F1 POINTS CHART — style.css
   Aesthetic: F1 2026 broadcast graphics
   Sharp edges, condensed type, red as structure, dense data
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;500;600;700;800&family=Barlow:wght@400;500;600&display=swap");

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --red: #e10600;
  --red-dim: rgba(225, 6, 0, 0.15);
  --bg: #080808;
  --surface: #0f0f0f;
  --surface-2: #161616;
  --border: #242424;
  --border-2: #2e2e2e;
  --text: #f0f0f0;
  --text-muted: #666;
  --text-dim: #999;
  --font-display: "Barlow Condensed", sans-serif;
  --font-body: "Barlow", sans-serif;
}

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

/* ── Base ──────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);

  /* subtle noise texture for depth */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.1;
}

p {
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 1rem;
  max-width: 68ch;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex; /* ADD THIS */
  align-items: center; /* ADD THIS */
  gap: 1.5rem; /* ADD THIS */
}

header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 120px;
  height: 2px;
  background: var(--red);
}

header h1 {
  font-size: 2rem;
  color: #fff;
  letter-spacing: 0.06em;

  /* Red left rule — structural, not decorative */
  padding-left: 14px;
  border-left: 3px solid var(--red);
}

/* ── Sidebar / Tower ───────────────────────────────────────── */
#tower {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  height: 100%;
  width: auto;
  position: relative;
}

/* Label above driver/team buttons */
#tower div {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  height: auto;
}

/* ── Driver / Team Toggle Buttons ──────────────────────────── */
#show-drivers,
#show-teams {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 0;
  transition: all 0.15s ease;
  cursor: pointer;
}

#show-drivers:hover,
#show-teams:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

#show-drivers.active,
#show-teams.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.tab-nav {
  display: flex;
  gap: 0;
  margin-top: 1rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: -1px; /* overlap the border-bottom of tab-nav */
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--red);
}

.tab-panel {
  width: 100%;
}

#quali-frame {
  width: 100%;
  height: calc(100vh - 120px);
  border: none;
  display: block;
}

/* ── Driver / Team List ────────────────────────────────────── */
.list-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.team-list {
  grid-template-columns: 1fr;
}

.list-group-item {
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 0 !important;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.12s ease;
  list-style: none;
  cursor: pointer;
}

.list-group-item:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

.list-group-item.selected {
  background-color: color-mix(in srgb, var(--team-color) 30%, transparent);
  border-bottom: 5px solid var(--team-secondary-color) !important;
  border-top: 0px solid var(--team-secondary-color);
  font-weight: 700;
  color: #fff;
}

/* ── Year Selector Navbar ──────────────────────────────────── */
.navbar {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
  border-radius: 0 !important;
  padding: 0.5rem 1rem;
}

.year-option {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.year-option:hover {
  color: var(--text);
  background: transparent;
  border-bottom-color: var(--border-2);
}

.year-option.current {
  color: #fff;
  border-bottom: 2px solid var(--red);
  background: transparent;
}

#share-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: 4px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto; /* pushes it to the right */
}

#share-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

#share-btn.copied {
  color: #4caf50;
  border-color: #4caf50;
}

#snapshot-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--red);
  border: none;
  color: #fff;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#snapshot-btn:hover {
  background: #b80400;
}
#races {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 3px;
  width: 100%;
  background-color: var(--surface);
  padding: 0.5rem;
}

#races .list-group-item {
  flex: 1;
  text-align: center;
  min-width: 42px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

#races .list-group-item.current-race {
    color: #fff;
    border-bottom: 2px solid var(--red);
}

/* ── Chart Container ───────────────────────────────────────── */
#chartContainer {
  display: flex;
  align-items: stretch;
  gap: 0;
}

#chart {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  padding: 0.75rem;
  width: 100%;
  height: auto;
}

.chart-container {
  width: 100%;
  height: calc(100vh - 60px);
  position: relative;
}

.svg-content-responsive {
  display: block;
  width: 100%;
  height: auto;
}

/* D3 axis text */
.tick text {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.04em;
  fill: var(--text-muted);
}

.tick line,
.domain {
  stroke: var(--border-2);
}

/* ── Tooltip ───────────────────────────────────────────────── */
#tooltip {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
  border-radius: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-left: 2px solid var(--red);
  color: var(--text);
  padding: 6px 10px;
}

/* ── About Section ─────────────────────────────────────────── */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 0;
  padding: 2.5rem;
  margin-top: 3rem;
  position: relative;
}

section h2 {
  font-size: 1.6rem;
  color: #fff;
  margin-bottom: 1.25rem;
  letter-spacing: 0.06em;
}

#contact {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

#contact:hover {
  border-bottom-color: var(--red);
}

/* ── Footer ────────────────────────────────────────────────── */
footer p {
  font-family: var(--font-display);
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  margin-top: 2rem;
}

/* ── Loading indicator ─────────────────────────────────────── */
#loading,
.loader {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 1rem 0.5rem;

  /* subtle pulse */
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container {
    display: flex;
    flex-direction: column;
  }

  header {
    padding: 1rem 1.25rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  #tower {
    order: -1;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }

  #tower > div {
    width: 100%;
  }

  .list-group {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: flex-start;
  }

  .list-group-item {
    flex: 0 0 auto;
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  #driver-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
    padding: 0;
  }

  #driver-list .list-group-item {
    min-width: 20px;
  }

  .navbar {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0;
    padding: 0.5rem 0.75rem;
  }

  .year-option {
    font-size: 0.8rem;
    padding: 4px 8px;
  }

  #chart {
    order: 0;
    width: 100%;
    height: auto;
    min-height: 400px;
    overflow-x: auto;
  }
}
