/* Endestadstøylen opp – stil for resultatsidene */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --border: #dde3ea;
  --ink: #15212e;
  --ink-2: #4a5a6b;
  --ink-3: #6f7e8e;
  --accent: #2c6390;
  --accent-soft: #e3edf6;
  --bar: #3a78aa;
  --bar-hover: #1f5580;
  --highlight: #fff6d9;
  --gold: #b8860b;
  --silver: #7d8791;
  --bronze: #a0522d;
  --header-bg: #1a2a3a;
  --sans: 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1822;
    --surface: #16222f;
    --surface-2: #1c2a39;
    --border: #2a3a4b;
    --ink: #e8eef5;
    --ink-2: #aebccb;
    --ink-3: #8595a6;
    --accent: #8fc0e6;
    --accent-soft: #1f3447;
    --bar: #5b9bcf;
    --bar-hover: #9ccaf0;
    --highlight: #3a3420;
    --gold: #e0b44c;
    --silver: #b3bcc6;
    --bronze: #d08a5c;
  }
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Topp ── */
.page-header {
  position: relative;
  background-color: var(--header-bg);
  color: #fff;
  padding: 2.2rem 1rem 2.6rem;
  overflow: hidden;
}
.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('https://images.unsplash.com/photo-1531366936337-7c912a4589a7?auto=format&fit=crop&w=1600&q=70') center 40% / cover no-repeat;
  filter: brightness(0.45) saturate(0.85);
}
.page-header > * { position: relative; }
.page-header .inner { max-width: 1040px; margin: 0 auto; }

.crumbs {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  margin-bottom: 1.4rem;
  color: rgba(220, 235, 255, 0.75);
}
.crumbs a { color: #a8cce8; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #a8cce8;
  border: 1px solid rgba(168, 204, 232, 0.45);
  border-radius: 2px;
  padding: 0.3em 0.8em;
  margin-bottom: 0.9rem;
}
.page-header h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  line-height: 1.1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.page-header .lead {
  margin-top: 0.6rem;
  color: rgba(220, 235, 255, 0.9);
  font-size: 1.02rem;
}

.year-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.4rem;
}
.year-nav a {
  font-size: 0.85rem;
  color: #dbe9f5;
  text-decoration: none;
  border: 1px solid rgba(168, 204, 232, 0.4);
  border-radius: 999px;
  padding: 0.25em 0.9em;
}
.year-nav a:hover { background: rgba(168, 204, 232, 0.15); }
.year-nav a[aria-current="page"] { background: #a8cce8; color: #10202f; border-color: #a8cce8; font-weight: 600; }

/* ── Innhold ── */
main { max-width: 1040px; margin: 0 auto; padding: 1.8rem 1rem 3rem; }

section + section { margin-top: 2.6rem; }

h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  margin-bottom: 0.3rem;
}
.section-sub { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 1rem; }

.notice {
  background: var(--highlight);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 1.6rem;
}
.error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #c0392b;
  padding: 1rem;
  border-radius: 4px;
}
.loading { color: var(--ink-3); }

/* ── Statistikk-fliser ── */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 0.75rem;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  min-width: 0;
}
.tile-label { font-size: 0.78rem; color: var(--ink-2); }
.tile-value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.tile-detail {
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Pallen ── */
.podium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}
.podium-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--medal);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
.podium-card .pos { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.podium-card .who { font-size: 1.1rem; font-weight: 600; margin-top: 0.2rem; }
.podium-card .club { font-size: 0.85rem; color: var(--ink-2); }
.podium-card .time { font-size: 1.3rem; font-variant-numeric: tabular-nums; margin-top: 0.3rem; }
.podium-card .gap { font-size: 0.85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.medal-1 { --medal: var(--gold); }
.medal-2 { --medal: var(--silver); }
.medal-3 { --medal: var(--bronze); }

/* ── Histogram ── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 0.6rem;
  position: relative;
}
.chart-card svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-card .grid line { stroke: var(--border); stroke-width: 1; }
.chart-card .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.chart-card .bar { fill: var(--bar); }
.chart-card .hit:hover + .bar, .chart-card .bar.active { fill: var(--bar-hover); }
.chart-card .hit { fill: transparent; cursor: default; }
.chart-card .value-label { fill: var(--ink-2); font-size: 11px; font-family: var(--sans); text-anchor: middle; }
.chart-card .you { stroke: var(--gold); stroke-width: 2; }
.chart-card .you-label { fill: var(--ink); font-size: 11px; font-weight: 600; font-family: var(--sans); }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
  opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.show { opacity: 1; }

/* ── Tabeller ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.search {
  flex: 1 1 240px;
  max-width: 360px;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.toolbar .count { font-size: 0.85rem; color: var(--ink-3); }
.toolbar a.download { font-size: 0.85rem; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 0.55rem 0.75rem; text-align: left; white-space: nowrap; }
thead th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
thead th button {
  all: unset;
  cursor: pointer;
}
thead th button:focus-visible { outline: 2px solid var(--accent); }
thead th[aria-sort="ascending"] button::after { content: ' ▲'; font-size: 0.7em; }
thead th[aria-sort="descending"] button::after { content: ' ▼'; font-size: 0.7em; }
tbody tr + tr td { border-top: 1px solid var(--border); }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.place { font-weight: 600; width: 3.5rem; }
td.name { font-weight: 500; white-space: normal; min-width: 10rem; }
td.club { color: var(--ink-2); white-space: normal; min-width: 8rem; }
td.muted, .muted { color: var(--ink-3); }
tr.dnf td { color: var(--ink-3); }
tr.top3 td.place::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--medal);
  margin-right: 0.4rem;
  vertical-align: middle;
}
.empty-row td { text-align: center; color: var(--ink-3); padding: 1.5rem; }

/* ── Løpskort på oversikten ── */
.race-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.race-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.2rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.race-card:hover, .race-card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.race-card .year { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1; }
.race-card .date { font-size: 0.85rem; color: var(--ink-2); margin-top: 0.25rem; }
.race-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.9rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.race-card dt { color: var(--ink-2); }
.race-card dd { font-variant-numeric: tabular-nums; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-card .card-note {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  background: var(--highlight);
  border-left: 3px solid var(--gold);
  padding: 0.35rem 0.6rem;
  border-radius: 3px;
}
.race-card .cta { display: inline-block; margin-top: 1rem; font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.tag { display: inline-block; font-size: 0.7rem; background: var(--highlight); border-radius: 3px; padding: 0.1em 0.5em; margin-left: 0.4rem; vertical-align: middle; font-family: var(--sans); font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 2.6rem; }

/* ── Nyheter ── */
.news-list { list-style: none; max-width: 720px; display: grid; gap: 1rem; }
.news-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  overflow: hidden;
}
.news-image {
  display: block;
  width: calc(100% + 2.6rem);
  max-width: none;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  margin: -1.2rem -1.3rem 1rem;
  background: var(--surface-2);
}
.news-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-2);
}
.news-type {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.news-type-presse { color: var(--gold); }
.news-item h2 { font-size: 1.3rem; margin: 0.35rem 0 0.5rem; line-height: 1.25; }
.news-item h2 a { color: inherit; text-decoration: none; }
.news-item h2 a:hover { text-decoration: underline; }
.news-item p + p { margin-top: 0.6rem; }
.news-item .news-link { margin-top: 0.8rem; font-size: 0.9rem; font-weight: 600; }
.news-item .tag { margin-left: 0.3rem; }

footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-3);
  padding: 2rem 1rem;
  letter-spacing: 0.05em;
}

@media (max-width: 600px) {
  th, td { padding: 0.5rem 0.55rem; }
  .hide-sm { display: none; }
  .tile-value { font-size: 1.35rem; }
}
