/* ── Brand Variables ── */
:root {
  --ec-red:        #CC2424;
  --ec-red-dark:   #a81c1c;
  --ec-navy:       #1E3270;
  --ec-navy-dark:  #141f47;
  --ec-orange:     #E87722;

  /* Override Pico primary → navy */
  --pico-primary:          var(--ec-navy);
  --pico-primary-hover:    var(--ec-navy-dark);
  --pico-primary-focus:    rgba(30, 50, 112, 0.2);
  --pico-primary-inverse:  #ffffff;
}

/* ── Typography ── */
html {
  font-size: 95%;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Site Header ── */
header.site-header {
  background: var(--ec-navy);
  border-bottom: 3px solid var(--ec-red);
  padding: 0;
}

header.site-header > nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 2rem;
}

header.site-header > nav ul {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

header.site-header > nav ul:last-child {
  gap: 0.25rem;
}

header.site-header a,
header.site-header a:visited {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
}

header.site-header a:hover {
  color: #ffffff;
}

header.site-header ul:last-child a {
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}

header.site-header ul:last-child a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none !important;
}

.site-logo {
  height: 64px;
  width: 64px;
  object-fit: contain;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 6px;
  background: #fff;
  border-radius: 50%;
}

.site-title {
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff !important;
  line-height: 1.2;
}

.site-title span {
  display: block;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.65) !important;
  text-transform: uppercase;
}

/* ── Footer ── */
footer.site-footer {
  background: var(--ec-navy-dark);
  color: rgba(255, 255, 255, 0.6);
  border-top: none;
  padding: 1.5rem;
  margin-top: 3rem;
  text-align: center;
  font-size: 1rem;
}

footer.site-footer a {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Charge header ── */
.charge-header {
  margin-bottom: 1.5rem;
}

.charge-header h1 {
  margin-bottom: 0.25rem;
}

.charge-meta {
  color: var(--pico-muted-color);
  margin-bottom: 1rem;
}

.charge-meta a {
  color: var(--ec-navy);
  font-weight: 500;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.stat-card {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-top: 3px solid var(--ec-navy);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.stat-card .value {
  font-size: 1.4rem;
  font-weight: 800;
  display: block;
  color: var(--ec-navy);
}

.stat-card .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  display: block;
  margin-top: 0.25rem;
}

/* ── Entry overview (map + summary boxes) ── */
.entry-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 1.5rem;
  margin: 1.25rem 0;
}

.entry-overview--no-map {
  grid-template-columns: 1fr;
}

.entry-map {
  height: calc(50vh - 60px);
  min-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--pico-muted-border-color);
}

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

.stat-box {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.stat-box-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.stat-box-figure {
  text-align: center;
}

.stat-box-figure .value {
  font-size: 1.8rem;
  font-weight: 800;
  display: block;
  color: var(--ec-navy);
}

.stat-box-figure .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  display: block;
  margin-top: 0.25rem;
}

.data-list {
  margin: 0;
  padding: 0;
}

.data-list-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.92rem;
}

.data-list-row:first-child {
  border-top: none;
  padding-top: 0;
}

.data-list-row dt {
  color: var(--pico-muted-color);
}

.data-list-row dd {
  margin: 0;
  font-weight: 700;
  color: var(--ec-navy);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.award-list {
  margin: 0.85rem 0 0;
  padding: 0;
  font-size: 0.88rem;
}

.award-list li {
  list-style: none;
  padding: 0.35rem 0;
  border-top: 1px solid var(--pico-muted-border-color);
}

.award-list li:first-child {
  border-top: none;
}

.award-section {
  margin-bottom: 1.25rem;
}

.award-section h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

@media (max-width: 760px) {
  .entry-overview {
    grid-template-columns: 1fr;
  }
}

/* ── Page tabs ── */
.page-tabs {
  display: flex;
  justify-content: flex-start;
  gap: 0.35rem;
  margin-bottom: 1.75rem;
  border-bottom: 2px solid var(--pico-muted-border-color);
  padding-bottom: 0;
  flex-wrap: wrap;
}

.page-tabs a {
  padding: 0.65rem 1.35rem;
  text-decoration: none;
  color: var(--pico-color);
  background: transparent;
  border-bottom: 4px solid transparent;
  margin-bottom: -2px;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.page-tabs a.active {
  color: var(--ec-red);
  border-bottom-color: var(--ec-red);
  background: rgba(204, 36, 36, 0.08);
}

.page-tabs a:hover {
  color: var(--ec-navy);
  border-bottom-color: var(--ec-navy);
  background: rgba(30, 50, 112, 0.06);
}

/* ── Results table ── */
table thead th {
  background: var(--ec-navy);
  color: #fff;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-color: var(--ec-navy-dark);
}

table tbody tr:hover {
  background: rgba(30, 50, 112, 0.04);
}

table thead th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.4rem;
}

table thead th.sortable:hover {
  background: var(--ec-navy-dark);
}

table thead th.sortable::after {
  content: '↕';
  position: absolute;
  right: 0.5rem;
  opacity: 0.5;
  font-size: 0.85em;
}

table thead th.sortable.sort-asc::after {
  content: '↑';
  opacity: 1;
}

table thead th.sortable.sort-desc::after {
  content: '↓';
  opacity: 1;
}

.result-complete { color: #2a7a2a; font-weight: 600; }
.result-dnf      { color: var(--ec-red); font-weight: 500; }

.team-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

td.distance { font-variant-numeric: tabular-nums; text-align: right; }
th.distance { text-align: right; }
td.car-no   { font-weight: 700; text-align: center; width: 3rem; color: var(--ec-navy); }

/* ── Home page charges map ── */
.home-map {
  height: 420px;
  border-radius: 8px;
  border: 1px solid var(--pico-muted-border-color);
  margin-top: 1.25rem;
}

/* ── Charges grid (home page) ── */
.charges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.charge-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  background: var(--pico-card-background-color);
}

.charge-card:hover {
  border-color: var(--ec-navy);
  box-shadow: 0 4px 16px rgba(30, 50, 112, 0.12);
  transform: translateY(-2px);
}

.charge-card h3 {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  color: var(--pico-color);
}

.charge-card .charge-year {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ec-red);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.charge-card .charge-location {
  color: var(--pico-muted-color);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.charge-card .charge-stats {
  font-size: 0.82rem;
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--pico-muted-border-color);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  color: var(--pico-muted-color);
}

.charge-card .charge-stats span.stat-highlight {
  font-weight: 700;
  color: var(--ec-navy);
}

/* ── Map downloads (charge page) ── */
.map-downloads {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.map-thumb {
  flex-shrink: 0;
  display: block;
  width: 160px;
  height: 110px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
}

.map-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.15s;
}

.map-thumb:hover img {
  transform: scale(1.05);
}

.map-downloads-links {
  flex: 1;
  min-width: 0;
}

.map-downloads-links h2 {
  margin-bottom: 0.15rem;
  font-size: 1.1rem;
}

.map-downloads-links p:last-child {
  margin-bottom: 0;
}

.map-downloads-links a[role="button"] {
  margin-right: 0.5rem;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}

@media (max-width: 600px) {
  .map-downloads { flex-direction: column; align-items: stretch; }
  .map-thumb { width: 100%; height: 160px; }
}

/* ── Map page ── */
#map {
  height: calc(100vh - 120px);
  min-height: 450px;
  border-radius: 8px;
  border: 1px solid var(--pico-muted-border-color);
}

/* Pico's global box-sizing:border-box throws off Leaflet's fixed-size
   zoom buttons, which rely on content-box sizing to center the +/- glyph.
   Width/height must be set here (not on the lower-specificity
   .leaflet-control-zoom-in/-out classes) to actually beat leaflet.css's
   own .leaflet-bar a rule. */
.leaflet-bar a,
.leaflet-touch .leaflet-bar a {
  box-sizing: content-box;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: normal;
  width: 13px;
  height: 13px;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  font-size: 9px;
}

.map-legend {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 6px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  max-height: 110px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  margin-right: 1rem;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}

.map-legend-item:hover {
  text-decoration: underline;
}

.leg-popup a {
  color: inherit;
  text-decoration: underline;
}

.leaflet-tooltip.checkpoint-label {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ec-navy);
  box-shadow: none;
}

.leaflet-tooltip.checkpoint-label--start {
  background: #2ecc71;
  border-color: #1e7a1e;
  color: #fff;
}

.leg-popup {
  font-size: 0.85rem;
  line-height: 1.5;
}

.leg-popup .team-dot {
  margin-right: 4px;
}

/* ── Awards ── */
.award-block {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.award-block:first-child { padding-top: 0; }
.award-block:last-child { border-bottom: none; }

.award-block-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.15rem;
}

.award-ordinal {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ec-navy);
  opacity: 0.4;
}

.award-trophy {
  font-size: 0.95rem;
}

.award-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ec-navy);
}

.award-block-scope {
  margin-bottom: 0.85rem;
}

.award-winner-row {
  background: rgba(204, 36, 36, 0.06);
}

.award-winner-row td {
  font-weight: 700;
  color: var(--ec-navy);
}

/* ── Beneficiary articles ── */
article {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

article header {
  border-bottom: none;
  background: none;
  padding: 0;
  margin-bottom: 0.5rem;
}

article header h2 {
  margin-bottom: 0.15rem;
  color: var(--ec-navy);
}

article footer {
  border-top: 1px solid var(--pico-muted-border-color);
  background: none;
  padding-top: 0.75rem;
  padding-bottom: 0;
  margin-top: 0.75rem;
  text-align: left;
  color: inherit;
}

/* ── Utilities ── */
.muted { color: var(--pico-muted-color); }
.small { font-size: 0.85rem; }
.no-wrap { white-space: nowrap; }

/* ── Hero strip on home page ── */
.page-hero {
  background: linear-gradient(135deg, var(--ec-navy) 0%, var(--ec-navy-dark) 100%);
  color: #fff;
  padding: 2.5rem 1.5rem;
  margin: -1rem -1.5rem 2rem;
  border-radius: 0 0 12px 12px;
}

.page-hero h1 {
  color: #fff;
  margin-bottom: 0.35rem;
  font-size: 2rem;
}

.page-hero p {
  color: rgba(255,255,255,0.7);
  margin: 0;
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .hide-mobile { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .page-hero { padding: 1.5rem 1rem; }
  .page-hero h1 { font-size: 1.4rem; }

  header.site-header > nav { padding: 0.5rem 1rem; }
  .site-title { display: none; }
}
