:root {
  color-scheme: light dark;

  --font-display: "Big Shoulders Display", sans-serif;
  --font-body: "Literata", Georgia, serif;
  --font-mono: "IBM Plex Mono", "SF Mono", monospace;

  --paper: #f4ecd8;
  --paper-alt: #ece0c4;
  --ink: #221d1a;
  --ink-soft: #5c5148;
  --rule: rgba(34, 29, 26, 0.16);
  --shadow: rgba(34, 29, 26, 0.18);

  --gold: #d9a622;
  --gold-deep: #a9780f;
  --green-jersey: #4c7a3f;
  --red-accent: #c1272d;
  --blue-accent: #2f5c8a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1815;
    --paper-alt: #24201b;
    --ink: #f1e7d2;
    --ink-soft: #b9ac97;
    --rule: rgba(241, 231, 210, 0.16);
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, var(--rule) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

/* ---------- Hero header ---------- */
.hero {
  position: relative;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #1c1305;
  padding: 3rem 2rem 4.5rem;
  overflow: hidden;
  text-align: center;
}

.hero-inner {
  position: relative;
  z-index: 2;
  animation: hero-rise 0.8s ease both;
}

.hero-kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  margin: 0 0 0.5rem;
  opacity: 0.75;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 9vw, 6.5rem);
  letter-spacing: 0.01em;
  line-height: 0.9;
  margin: 0;
  text-shadow: 0.06em 0.08em 0 rgba(28, 19, 5, 0.15);
}

.hero-year {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  margin: 0.25rem 0 0;
}

.hero-skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 70px;
  fill: var(--paper);
}

#status-bar {
  position: relative;
  z-index: 2;
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Layout ---------- */
.dashboard-grid {
  max-width: 1100px;
  margin: -2rem auto 3rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 1.5rem;
  position: relative;
  z-index: 3;
}

.col-main,
.col-side {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (max-width: 860px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 2rem 1.25rem 3.5rem;
  }

  .dashboard-grid {
    padding: 0 1rem;
  }

  .panel {
    padding: 1.25rem 1rem;
  }

  table {
    min-width: 420px;
    font-size: 0.78rem;
  }

  th,
  td {
    padding: 0.4rem 0.35rem;
  }
}

.panel {
  background: var(--paper-alt);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 10px 30px -20px var(--shadow);
  animation: panel-in 0.5s ease both;
}

.col-main .panel:nth-child(1) {
  animation-delay: 0.05s;
}
.col-main .panel:nth-child(2) {
  animation-delay: 0.1s;
}
.col-side .panel:nth-child(1) {
  animation-delay: 0.1s;
}
.col-side .panel:nth-child(2) {
  animation-delay: 0.15s;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
  display: inline-block;
}

/* ---------- Schedule table ---------- */
#schedule-content {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

th {
  text-align: left;
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--ink);
}

td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.col-date {
  white-space: nowrap;
}

.stage-row {
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.stage-row:hover {
  background: rgba(217, 166, 34, 0.16);
  transform: translateX(2px);
}

.status-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-completed .status-pill {
  background: var(--rule);
  color: var(--ink-soft);
}
.status-today .status-pill {
  background: var(--red-accent);
  color: #fff;
}
.status-upcoming .status-pill {
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink-soft);
}

/* ---------- Stage profile badges (flat/hilly/mountain/time trial) ---------- */
.profile-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
}
.profile-pill.profile-flat {
  background: var(--green-jersey);
}
.profile-pill.profile-hilly {
  background: #e07b1a;
}
.profile-pill.profile-mountain {
  background: var(--red-accent);
}
.profile-pill.profile-itt,
.profile-pill.profile-ttt {
  background: var(--blue-accent);
}

/* ---------- Jersey badges ---------- */
.jersey-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.25rem 0 0.5rem;
}
.jersey-row:first-of-type {
  margin-top: 0;
}

.jersey-badge {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.jersey-badge.gc {
  background: var(--gold);
}
.jersey-badge.points {
  background: var(--green-jersey);
}
.jersey-badge.youth {
  background: #fbf8f1;
}
.jersey-badge.mountains {
  background: #fbf8f1;
  background-image: radial-gradient(var(--red-accent) 32%, transparent 34%);
  background-size: 45% 45%;
}

.jersey-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

ol.standings-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
ol.standings-list li {
  counter-increment: rank;
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--rule);
}
ol.standings-list li::before {
  content: counter(rank) ".";
  color: var(--ink-soft);
  margin-right: 0.5rem;
  width: 1.3rem;
  display: inline-block;
}
ol.standings-list li .rider-name {
  flex: 1;
  font-family: var(--font-body);
}
ol.standings-list li .rider-gap {
  color: var(--ink-soft);
}

/* ---------- Climb chips ---------- */
.climb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin: 0.15rem 0.3rem 0.15rem 0;
  color: #fff;
}
.climb-chip.cat-hc {
  background: #1a1a1a;
}
.climb-chip.cat-1 {
  background: var(--red-accent);
}
.climb-chip.cat-2 {
  background: #e07b1a;
}
.climb-chip.cat-3 {
  background: var(--blue-accent);
}
.climb-chip.cat-4 {
  background: var(--green-jersey);
}

/* ---------- Stage detail ---------- */
.cheese-card {
  background: var(--paper);
  border: 1px dashed var(--ink-soft);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  margin: 1rem 0;
  font-family: var(--font-body);
  font-style: italic;
}
.cheese-card strong {
  font-style: normal;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.live-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--red-accent);
  text-decoration: none;
  border: 1px solid var(--red-accent);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}
.live-link::before {
  content: "●";
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

#stage-map {
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1rem;
  border: 1px solid var(--rule);
}

#elevation-chart {
  margin-top: 1rem;
}

.stage-profile-image {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 1rem;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fff;
}

.stage-winner {
  font-family: var(--font-body);
}

.jersey-holder {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ---------- News ---------- */
#news-content ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
#news-content li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
}
#news-content a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
#news-content a:hover {
  color: var(--red-accent);
}
.news-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

.stale-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--red-accent);
  margin: 0 0 0.75rem;
}
