:root {
  --harbour: #13233f;
  --harbour-2: #1d3560;
  --signal: #e8413a;
  --signal-dark: #c62f29;
  --ink: #1b2330;
  --muted: #5b6573;
  --paper: #ffffff;
  --wash: #f3f5f8;
  --line: #dde2ea;
  --radius: 8px;
  --max: 60rem;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-size: 1.0625rem;
  line-height: 1.6;
}

img { max-width: 100%; height: auto; }

a { color: var(--harbour-2); text-underline-offset: 2px; }
a:hover { color: var(--signal-dark); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1rem; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--paper); padding: .5rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; }

/* Header band: the name sits on the aerial course map */
.site-header {
  color: #fff;
  background:
    linear-gradient(rgba(19,35,63,.86), rgba(19,35,63,.9)),
    url("../img/course-map.jpg") center 74% / cover;
}
.site-header .wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 1rem; position: relative;
  padding-top: 2.25rem; padding-bottom: 2rem;
}
.brand { color: #fff; text-decoration: none; display: block; }
.brand:hover { color: #fff; }
.brand-name {
  display: block; margin: 0;
  font-size: 1.75rem; font-weight: 800; text-wrap: balance;
  letter-spacing: .03em; text-transform: uppercase; line-height: 1.1;
}
.brand-name span { color: var(--signal); }
.brand-date {
  display: block; color: #fff; margin-top: .6rem; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .25em;
}

.lang { display: flex; gap: .25rem; flex-shrink: 0; }
.lang a, .lang span {
  display: inline-block; min-width: 2.5rem; text-align: center;
  padding: .3rem .5rem; border-radius: var(--radius);
  font-weight: 700; font-size: .9rem; text-decoration: none;
}
.lang span { background: #fff; color: var(--harbour); }
.lang a { color: #fff; border: 1px solid rgba(255,255,255,.5); }
.lang a:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Navigation */
.site-nav { background: var(--harbour-2); }
.site-nav .wrap { display: flex; flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; }
.site-nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; flex: 1;
}
.site-nav a {
  display: block; padding: .75rem .8rem;
  color: #fff; text-decoration: none; font-weight: 600; font-size: .95rem;
}
.site-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--signal); }
.site-nav .results a {
  background: var(--signal); border-radius: var(--radius);
  padding: .4rem .9rem; margin: .35rem 0 .35rem .5rem;
}
.site-nav .results a:hover { background: var(--signal-dark); }
.site-nav ul .results { margin-left: auto; }

/* Without JS, phones get the full menu as a list. */
@media (max-width: 48rem) {
  .site-nav ul { flex-direction: column; flex-basis: 100%; padding-bottom: .5rem; }
  .site-nav a { padding: .65rem .25rem; }
  .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--signal); padding-left: .75rem; }
  .site-nav ul .results { margin-left: 0; }
  .site-nav .results a { display: inline-block; margin: .5rem 0 0; }
}

/* Countdown strip, added by js/site.js under the menu. */
.countdown {
  margin: 0; background: var(--signal); color: #fff; text-align: center;
  padding: .5rem 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: .7rem;
}
.countdown strong { font-size: 1.2rem; letter-spacing: .02em; margin-right: .5rem; vertical-align: -.1rem; }

/* Content: the page floats as a card */
main { padding: 1.25rem 0 2rem; }
.page {
  position: relative; background: var(--paper); border-radius: 12px;
  padding: 1.75rem 1.25rem;
  box-shadow: 0 1px 2px rgba(19,35,63,.06), 0 8px 24px rgba(19,35,63,.1);
}
.page > h1::before, .page > h2:first-child::before {
  content: ""; display: block; width: 3rem; height: 4px; margin-bottom: 1rem;
  border-radius: 2px; background: var(--signal);
}
.page > h1 { margin: 0 0 1rem; font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; color: var(--harbour); }
.page h2 { margin: 2rem 0 .75rem; font-size: 1.3rem; line-height: 1.3; color: var(--harbour); }
.page h1 + h2, .page > h2:first-child { margin-top: 0; }
.page p, .page ul, .page ol { margin: 0 0 1rem; }
.page li { margin-bottom: .35rem; }

/* Numbered rules (dl) */
.page dl { margin: 0 0 1.25rem; }
.page dt { font-weight: 700; color: var(--harbour); margin-top: 1rem; }
.page dd { margin: .25rem 0 0; }

/* Timelines: front page and party programmes, the course route */
.timeline { margin: 0 0 1.5rem; }
.timeline dl { display: grid; grid-template-columns: 4rem 1fr; gap: 0 .75rem; margin: 0; }
.timeline dt {
  margin: 0; padding: .55rem 0; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--signal-dark);
}
.timeline dd {
  margin: 0; grid-column: 2;
  position: relative; padding: .55rem 0 .55rem 1.25rem;
  border-left: 2px solid var(--line);
}
.timeline dd::before {
  content: ""; position: absolute; left: -7px; top: 1.05rem;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--signal);
}
.timeline dl:first-of-type dd { border-image: linear-gradient(transparent 1.2rem, var(--line) 1.2rem) 1; }
.timeline dl:last-of-type dd { border-image: linear-gradient(var(--line) 1.2rem, transparent 1.2rem) 1; }
.km { display: block; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Red call-to-action button (party tickets) */
.page .cta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0 0 1.5rem; }
.cta strong { color: var(--signal-dark); }
.button {
  display: inline-block; background: var(--signal); color: #fff; font-weight: 700;
  text-decoration: none; padding: .7rem 1.3rem; border-radius: var(--radius);
}
.button:hover { background: var(--signal-dark); color: #fff; }

/* Highlighted box */
.note {
  background: var(--wash); border-left: 4px solid var(--signal);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 1rem 1.25rem; margin: 0 0 1.5rem;
}
.page .note h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.page .note > :last-child { margin-bottom: 0; }

/* Cards side by side (classes, trophies, addresses) */
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin: 0 0 1.5rem; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.page .card h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
.page .card > :last-child { margin-bottom: 0; }
.card-role { color: var(--signal-dark); font-weight: 600; font-size: .95rem; }
.card address { font-style: normal; margin: 0 0 .75rem; }
.page .plain { list-style: none; padding: 0; }
.page .plain li { margin-bottom: .2rem; }
.page .facts {
  display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem;
  padding-top: .75rem; border-top: 1px solid var(--line);
}
.page .facts dt { margin: 0; color: var(--muted); font-weight: 600; font-size: .9rem; padding-top: .1rem; }
.page .facts dd { margin: 0; }

/* Gold, silver and bronze places */
.page .medals { list-style: none; padding: 0; counter-reset: place; }
.page .medals li { display: flex; align-items: center; gap: .65rem; margin-bottom: .5rem; }
.medals li::before {
  counter-increment: place; content: counter(place);
  flex: none; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  font-weight: 800; font-size: .85rem; color: var(--ink);
}
.medals li:nth-child(1)::before { background: #ecc75e; }
.medals li:nth-child(2)::before { background: #cfd4dc; }
.medals li:nth-child(3)::before { background: #d9a273; }

/* Numbered rules: one row per rule with a thin line between */
.rulebook { margin: 0 0 1.5rem; }
.page .rulebook dl { margin: 0; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.page .rulebook dl:last-child { border-bottom: 0; }
.page .rulebook dt { margin: 0 0 .25rem; color: var(--signal-dark); }
.page .rulebook dd { margin: 0; }
.page .rulebook dd + dd { margin-top: .4rem; }
.page .rulebook.compact dl { display: grid; grid-template-columns: 3rem 1fr; gap: 0 1rem; }
.page .rulebook.compact dd { grid-column: 2; }

.points { border-collapse: collapse; margin: .5rem 0 1.5rem; font-variant-numeric: tabular-nums; }
.points caption { text-align: left; font-weight: 700; color: var(--harbour); padding-bottom: .4rem; }
.points th, .points td { padding: .3rem 1rem; text-align: center; border-bottom: 1px solid var(--line); }
.points thead th { color: var(--harbour); font-size: .9rem; }
.points tbody th { text-align: left; color: var(--muted); font-weight: 600; }

/* Checklist (safety) */
.page .checklist { list-style: none; padding: 0; }
.checklist li { position: relative; padding-left: 1.9rem; }
.checklist li::before {
  content: ""; position: absolute; left: .25rem; top: .5rem;
  width: .75rem; height: .4rem; border-left: 2.5px solid var(--signal); border-bottom: 2.5px solid var(--signal);
  transform: rotate(-45deg);
}

/* Photos in a grid with captions */
.photos { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 0 0 1.5rem; }
.photos figure { margin: 0; }
.photos a { display: block; }
.photos img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.photos figcaption { font-size: .9rem; color: var(--muted); margin-top: .35rem; }

.map { margin: 1rem 0 1.5rem; }
.map a { display: block; }
.map img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.map figcaption { font-size: .9rem; color: var(--muted); margin-top: .4rem; }

/* Handicap calculator (handicap.html, js/handicap.js) */
.crew { width: 100%; max-width: 30rem; border-collapse: collapse; margin: 0 0 1rem; font-variant-numeric: tabular-nums; }
.crew th, .crew td { padding: .3rem .5rem .3rem 0; text-align: left; border-bottom: 1px solid var(--line); }
.crew thead th { color: var(--harbour); font-size: .9rem; }
.crew tbody th { color: var(--muted); font-weight: 600; }
.crew th:last-child, .crew td:last-child { text-align: right; padding-right: 0; }
.page select, .page input {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem .5rem;
}
.page input[type="number"] { width: 5.5rem; }
.page [aria-invalid="true"] { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal); }
.page .time { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin-bottom: 1.5rem; }
.time label { font-weight: 700; color: var(--harbour); flex-basis: 100%; }
.time input { width: 8rem; }
.time span { color: var(--muted); font-size: .9rem; }
.result .facts { padding-top: 0; border-top: 0; }
.result strong { font-size: 1.2rem; color: var(--harbour); }
.result .warn { margin: .75rem 0 0; color: var(--signal-dark); font-weight: 600; }

/* Full-size image overlay (opened from js/site.js) */
.viewer {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 18, 32, .94);
  display: flex; align-items: center; justify-content: center; overflow: auto;
  padding: calc(3.5rem + env(safe-area-inset-top)) 0 env(safe-area-inset-bottom);
  animation: fade .15s ease-out;
}
.viewer img { max-width: 100%; max-height: 100%; margin: auto; }
.viewer-close {
  position: fixed; top: calc(.75rem + env(safe-area-inset-top)); right: 1rem;
  background: #fff; color: var(--harbour); border: 0; border-radius: 2rem;
  font: inherit; font-weight: 700; padding: .45rem 1.1rem; cursor: pointer;
}
body.viewer-open { overflow: hidden; }

/* Footer */
.site-footer { background: var(--harbour); color: #c9d3e6; padding: 2rem 0; font-size: .95rem; }
.site-footer a { color: #fff; }
.site-footer .wrap { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.site-footer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #8fa0bd; margin: 0 0 .6rem; }
.site-footer p { margin: 0 0 .4rem; }
.logos { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logos img { background: #fff; border-radius: 6px; padding: .4rem; }
.logos a { display: block; line-height: 0; border-radius: 6px; }
.logos a:hover img { box-shadow: 0 0 0 3px var(--signal); }
.logo-kr { width: 190px; }
.logo-bryggens { width: 72px; }
.copyright { grid-column: 1 / -1; color: #8fa0bd; font-size: .85rem; margin: 0; }

/* ---------- App layout on phones (JS on): compact sticky header, bottom tab bar, "More" sheet ---------- */
.tabbar, .sheet { display: none; }

@media (max-width: 48rem) {
  .js body {
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }
  /* A slim map banner stays at the top, so changing page doesn't jump; only the content scrolls. */
  .js { scroll-padding-top: calc(5rem + env(safe-area-inset-top)); }
  .js .site-header {
    position: sticky; top: 0; z-index: 20;
    padding-top: env(safe-area-inset-top);
    background-position: center 70%;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
  }
  .js .site-header .wrap { padding-top: .75rem; padding-bottom: .7rem; }
  .js .brand-name { font-size: clamp(1rem, 5.2vw, 1.25rem); letter-spacing: .02em; white-space: nowrap; }
  .js .brand-date { font-size: .65rem; margin-top: .3rem; letter-spacing: .22em; }
  .js .site-header .lang { display: none; } /* the language switch lives in the "More" sheet */
  .js .site-nav { display: none; }
  .js main .wrap { padding: 0 .75rem; }
  .js .site-footer { padding-bottom: 1.5rem; }

  .js .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--paper); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(19,35,63,.08);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    min-height: 3.6rem; padding: .35rem 0;
    color: var(--muted); text-decoration: none; font: inherit; font-size: .7rem; font-weight: 600;
    background: none; border: 0; cursor: pointer;
  }
  .tabbar svg {
    width: 1.5rem; height: 1.5rem;
    fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  }
  .tabbar button svg { fill: currentColor; stroke: none; }
  .tabbar a[aria-current="page"], .tabbar .is-current, .tabbar button[aria-expanded="true"] { color: var(--signal-dark); }
  .tabbar a:active, .tabbar button:active { background: var(--wash); }

  .js .sheet:not([hidden]) {
    display: flex; align-items: flex-end;
    position: fixed; inset: 0; z-index: 25;
    background: rgba(19,35,63,.45);
    animation: fade .15s ease-out;
  }
  .sheet-panel {
    width: 100%; background: var(--paper);
    border-radius: 16px 16px 0 0;
    padding: .5rem 1rem calc(4.75rem + env(safe-area-inset-bottom));
    animation: rise .2s ease-out;
  }
  .sheet-head { display: flex; justify-content: center; position: relative; padding: .25rem 0 .5rem; }
  .sheet-grip { width: 2.5rem; height: .3rem; border-radius: 1rem; background: var(--line); margin-top: .35rem; }
  .sheet-close {
    position: absolute; right: 0; top: 0;
    background: none; border: 0; font: inherit; font-weight: 600; color: var(--harbour-2); padding: .25rem .5rem; cursor: pointer;
  }
  .sheet-list { list-style: none; margin: 0; padding: 0; }
  .sheet-list a {
    display: block; padding: .9rem .25rem; border-bottom: 1px solid var(--line);
    color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.05rem;
  }
  .sheet-list a[aria-current="page"] { color: var(--signal-dark); }
  .sheet-lang { display: flex; justify-content: space-between; align-items: center; padding: 1rem .25rem 0; color: var(--muted); }
  .sheet-lang a { font-weight: 700; }
  body.sheet-open { overflow: hidden; }
}


/* ---------- Computer screens: bigger banner, menu bar, wider card ---------- */
@media (min-width: 48.01rem) {
  .site-header .wrap { padding-top: 4rem; padding-bottom: 3.5rem; }
  .brand-name { font-size: 3rem; }
  .brand-date { margin-top: .75rem; font-size: .9rem; letter-spacing: .3em; }
  .lang { position: absolute; top: 1.25rem; right: 1rem; }

  /* Dark menu bar under the banner; it stays in view while scrolling. */
  .site-nav { position: sticky; top: 0; z-index: 20; background: var(--harbour); }
  .site-nav a { padding: .9rem .55rem; color: #c9d3e6; text-transform: uppercase; font-size: .85rem; letter-spacing: .06em; }
  .site-nav a:hover { background: none; color: #fff; }
  .site-nav a[aria-current="page"] { color: #fff; }
  .site-nav .results a { color: #fff; text-transform: none; letter-spacing: 0; font-size: .95rem; }

  .countdown { padding: .55rem 1rem; letter-spacing: .2em; font-size: .85rem; }
  .countdown strong { font-size: 1.5rem; margin-right: .6rem; }

  main { padding: 2.5rem 0 4rem; }
  .page {
    padding: 3rem 3.5rem;
    box-shadow: 0 1px 2px rgba(19,35,63,.06), 0 12px 32px rgba(19,35,63,.12);
  }

  .timeline dl { grid-template-columns: 5rem 1fr; gap: 0 1rem; }
  .timeline dd { padding-left: 1.75rem; }

  /* Rules: title in a left column, text on the right. */
  .page .rulebook dl { display: grid; grid-template-columns: 13rem 1fr; gap: 0 1.5rem; }
  .page .rulebook dd { grid-column: 2; }

  /* Text on the left, tall map on the right (course, addresses). */
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; align-items: start; margin-bottom: 1.5rem; }
  .split .map { margin: 0; max-width: none; }
}

/* Words like "Line-up" and "Vending" need a wider label column than times. */
.timeline.wide dl { grid-template-columns: 6rem 1fr; }

/* Keep the tall course map at a readable size instead of the full card width. */
@media (min-width: 48.01rem) {
  .map { max-width: 32rem; margin: 1.5rem auto 2rem; }
  .map figcaption { text-align: center; }
}

/* Changing page fades the content over instead of redrawing the whole screen; on phones the
   header and the tab bar stay put. Browsers without view transitions just load the page as before. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (max-width: 48rem) {
  .js .site-header { view-transition-name: header; }
  .js .tabbar { view-transition-name: tabbar; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-panel, .viewer { animation: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
