/* ============================================
   Christchurch Irish Golf Society
   Design tokens pulled from the club crest:
   navy + kelly green + white, silver-fern echo
   ============================================ */

:root {
  /* Navy is now the site's base background, the way LFC use red */
  --navy: #10203f;
  --navy-deep: #0a1730;
  --green: #1c8f49;
  --green-deep: #0f5b2d;
  --gold: #c7a038;
  --silver: #9aa5b4;

  /* White "surfaces" float on top of the navy background */
  --surface: #ffffff;
  --surface-dim: #f1f2ee;

  --ink: #10203f;        /* dark text, used on white surfaces */
  --text: #dde2ef;       /* light body text, used on the navy background */
  --text-dim: #aab2c8;   /* muted light text on navy */

  --line: rgba(255, 255, 255, 0.16);  /* dividers on the navy background */
  --line-soft: #e1e3dd;               /* dividers within white surfaces */
  --white: #ffffff;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --nav-h: 96px;
  --container: 1120px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
}

#main { flex: 1 0 auto; }

img { max-width: 100%; display: block; }

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--white);
  margin: 0 0 0.4em;
  line-height: 1.1;
  font-weight: 600;
}

p { line-height: 1.6; }

.container-wide {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: #7fd39c; /* mint green, readable on the navy background */
}

/* ---------- Skip link / a11y ---------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy);
  color: var(--white);
  padding: 10px 16px;
  z-index: 200;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ============================================
   Top navigation
   Mobile:  [hamburger] ---- [crest] ---- [sponsor]
   Desktop: [crest] -------- [nav] ------ [sponsor]
   ============================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  border-bottom: 3px solid var(--green);
}

.nav-bar {
  height: var(--nav-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 12px;
}

.nav-brand {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.nav-brand img {
  height: 80px;
  width: 80px;
}
.hamburger {
  justify-self: start;
  background: none;
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  position: relative;
  width: 22px;
  height: 2px;
  background: var(--white);
  display: block;
}
.hamburger span::before,
.hamburger span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background: var(--white);
  transition: transform 0.2s ease;
}
.hamburger span::before { top: -7px; }
.hamburger span::after { top: 7px; }

.sponsor-slot {
  justify-self: end;
  display: flex;
  align-items: center;
  margin-left: 10px;
}
.sponsor-slot img {
  height: 22px;
  width: auto;
}

/* Off-canvas mobile nav */
.nav-links {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(78vw, 300px);
  background: var(--navy-deep);
  padding: 138px 0 24px;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 110;
  display: flex;
  flex-direction: column;
}
.nav-links.is-open { transform: translateX(0); }

.nav-links a {
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.25rem;
  padding: 14px 28px;
}
.nav-links a.is-active { color: var(--gold); }

.nav-links a.nav-drawer-logo {
  position: absolute;
  top: 28px;
  left: 28px;
  padding: 0;
}
.nav-drawer-logo img { height: 86px; width: auto; }

.nav-drawer-close {
  position: absolute;
  top: 28px;
  right: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  color: var(--white);
  cursor: pointer;
}
.nav-drawer-close svg { width: 100%; height: 100%; fill: currentColor; }

@media (max-width: 859px) {
  .nav-links > a:last-of-type { border-bottom: 1px solid rgba(255,255,255,0.08); }
}

.nav-drawer-social {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 40px 28px 0;
}
.nav-links a.nav-drawer-social-link {
  padding: 0;
  border-bottom: none;
}
.nav-drawer-social svg { width: 22px; height: 22px; fill: currentColor; }
.nav-drawer-social a[aria-label="Email"] svg { width: 30px; height: 30px; }

.nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10,23,48,0.55);
  z-index: 105;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-scrim.is-open { opacity: 1; pointer-events: auto; }

.nav-close {
  display: none;
}

/* ---------- Desktop nav ---------- */
@media (min-width: 860px) {
  .nav-bar {
    grid-template-columns: auto 1fr auto;
    padding: 0 24px;
  }
  .nav-brand { justify-self: start; }
  .hamburger { display: none; }

  .nav-links {
    position: static;
    height: auto;
    width: auto;
    background: none;
    transform: none;
    flex-direction: row;
    justify-content: center;
    padding: 0;
    justify-self: center;
  }
  .nav-drawer-logo,
  .nav-drawer-close,
  .nav-drawer-social { display: none; }
  .nav-links a {
    border-bottom: none;
    font-size: 0.95rem;
    padding: 8px 18px;
    position: relative;
  }
  .nav-links a::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 2px;
    height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.2s ease;
  }
  .nav-links a:hover::after,
  .nav-links a.is-active::after { transform: scaleX(1); }

  .nav-scrim { display: none; }
  .sponsor-slot img { height: 40px; }
}

/* ============================================
   Hero
   ============================================ */
.hero {
  background: var(--navy);
  color: var(--white);
  padding: 0;
}
.hero-inner {
  padding: 52px 20px 64px;
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  gap: 32px;
}
@media (min-width: 860px) {
  .hero-inner {
    grid-template-columns: 1.1fr 1fr;
    align-items: start;
  }
}
.hero-carousel-track {
  position: relative;
  width: 100%;
  height: 240px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  touch-action: pan-y;
}
.hero-carousel-track img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hero-carousel-track img.is-active { opacity: 1; }
@media (min-width: 860px) {
  .hero-carousel-track { height: 360px; }
}

.hero-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.hero-carousel-dots button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
}
.hero-carousel-dots button.is-active { background: var(--gold); }
.hero h1 {
  color: var(--white);
  font-size: clamp(2rem, 6vw, 3.4rem);
  max-width: 14ch;
}
/* A phone in landscape has a much wider viewport than in portrait, which
   the vw-based clamp above reads as "desktop" and sizes accordingly —
   pin it back to the portrait size for short viewports (same threshold
   used for the race table's mobile breakpoint). */
@media (max-height: 500px) {
  .hero h1 { font-size: 2rem; }
}
.hero .lede {
  max-width: 46ch;
  color: rgba(255,255,255,0.85);
  font-size: 1.05rem;
}
.hero .eyebrow { color: #7fd39c; margin-top: 0; }

/* ============================================
   Sections / cards
   ============================================ */
section { padding: 56px 0; }
section + section { border-top: 1px solid var(--line); }

.section-head { margin-bottom: 28px; max-width: 60ch; }

/* ============================================
   Footer
   ============================================ */
.site-footer {
  background: var(--navy-deep);
  color: rgba(255,255,255,0.75);
  padding: 40px 0 28px;
  margin-top: 40px;
}
.site-footer a { color: var(--white); text-decoration: none; }
.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand img { height: 34px; }
.footer-brand span { font-family: var(--font-display); color: var(--white); font-size: 1.05rem; }
@media (max-width: 640px) {
  .footer-brand span { display: none; }
}

.footer-social { display: flex; align-items: center; gap: 14px; }
.footer-social-label { font-size: 0.85rem; color: rgba(255, 255, 255, 0.7); }
.footer-social a { display: flex; }
.footer-social svg { width: 20px; height: 20px; fill: currentColor; }
.footer-social a[aria-label="Email"] svg { width: 25px; height: 25px; }
.footer-social a:hover svg { fill: var(--gold); }
.footer-bottom {
  padding-top: 18px;
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

/* ============================================
   Race page — leaderboard + "race trail"
   ============================================ */
.race-hero {
  background: var(--navy);
  color: var(--white);
  padding: 40px 0 32px;
}
.race-hero .eyebrow { color: #7fd39c; }
.race-hero h1 { color: var(--white); margin-bottom: 6px; }
.race-hero p { color: rgba(255,255,255,0.8); }
.race-sponsor-line { margin-top: 14px; }

.hero-with-photo {
  display: grid;
  gap: 28px;
}
@media (min-width: 860px) {
  .hero-with-photo {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.race-status {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.leaderboard-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--white);
}

.leaderboard-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

.leaderboard-table th,
.leaderboard-table td {
  width: 90px;
  padding: 10px 5px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.leaderboard-table thead th { white-space: normal; }

.leaderboard-table tbody td {
  color: var(--ink);
  font-weight: 600;
}
.leaderboard-table tbody td.is-extra {
  text-decoration: line-through;
}

.leaderboard-table thead th {
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
  vertical-align: middle;
  overflow-wrap: break-word;
}
.leaderboard-table thead .th-date {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.leaderboard-table thead th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}
.leaderboard-table thead th[data-sort-key]:hover { background: var(--navy-deep); }
.leaderboard-table thead th.is-sorted { background: var(--green-deep); }
.leaderboard-table thead th.is-sorted.lb-col-name,
.leaderboard-table thead th.is-sorted.lb-col-score { background: var(--green-deep); }
.leaderboard-table .sort-arrow { font-size: 0.65em; margin-left: 3px; opacity: 0.85; }

.leaderboard-table tbody tr { background: var(--white); }
.leaderboard-table tbody tr.is-top10 { background: #fffaf0; }
.leaderboard-table tbody tr:last-child td { border-bottom: none; }

/* Pos + Player + Score columns stay pinned while the round columns scroll */
.leaderboard-table .lb-col-pos,
.leaderboard-table .lb-col-name,
.leaderboard-table .lb-col-score {
  position: sticky;
  background: inherit;
  z-index: 1;
}
.leaderboard-table .lb-col-pos {
  left: 0;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  font-family: var(--font-display);
  text-align: left;
}
.leaderboard-table .lb-col-name {
  left: 44px;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.leaderboard-table .lb-col-score {
  left: 244px;
  width: 70px;
  min-width: 70px;
  max-width: 70px;
  font-family: var(--font-display);
  box-shadow: 3px 0 6px -3px rgba(16, 32, 63, 0.25);
}
.leaderboard-table tbody .lb-col-pos,
.leaderboard-table tbody .lb-col-name,
.leaderboard-table tbody .lb-col-score {
  color: var(--navy);
  font-weight: 700;
}
.leaderboard-table thead .lb-col-pos,
.leaderboard-table thead .lb-col-name,
.leaderboard-table thead .lb-col-score {
  background: var(--navy);
  color: var(--white);
}

.lb-stars { font-size: 1.2rem; margin-left: 4px; white-space: nowrap; }
.lb-stars .star-event { color: var(--silver); }
.lb-stars .star-winner { color: var(--gold); }

/* Tighter rows + smaller type on small screens, so more of the table
   fits before the horizontal scroll kicks in. The max-height condition
   catches phones in landscape (short viewport, e.g. ~375-430px tall)
   which would otherwise read as "wide" on width alone — tablets in
   landscape stay tall enough (744px+) to not match this. */
@media (max-width: 640px), (max-height: 500px) {
  .leaderboard-table-wrap { order: 1; }
  .legend { order: 2; margin-top: 14px; }

  .leaderboard-table th,
  .leaderboard-table td {
    width: 90px;
    padding: 6px 6px;
    font-size: 0.78rem;
  }
  .leaderboard-table thead th { font-size: 0.64rem; }
  .leaderboard-table thead .th-date { font-size: 0.54rem; }
  .lb-stars { font-size: 0.95rem; }
  .legend .lb-stars { font-size: 1.9rem; }

  .leaderboard-table .lb-col-pos {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    padding-left: 4px;
    padding-right: 2px;
  }
  .leaderboard-table .lb-col-name {
    left: 34px;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
  }
  .leaderboard-table .lb-col-score {
    left: 194px;
    width: 55px;
    min-width: 55px;
    max-width: 55px;
  }
}

.rotate-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.rotate-hint svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-dim); }
@media (min-width: 640px) {
  .rotate-hint { display: none; }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 18px 0 6px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ============================================
   Events
   ============================================ */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.event-row {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px;
}
.event-date {
  text-align: center;
  font-family: var(--font-display);
  color: var(--navy);
  line-height: 1.1;
}
.event-date .day { font-size: 1.5rem; font-weight: 600; display: block; }
.event-date .mon { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--green); }
.event-name { font-weight: 700; color: var(--navy); }
.event-price {
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 600;
  font-size: 1.5rem;
  text-align: right;
  line-height: 1.1;
}
.event-price .green-fee-note {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 3px;
  white-space: nowrap;
}

/* ============================================
   Honours Board
   ============================================ */
.honours-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--white);
}
.honours-table {
  border-collapse: collapse;
  width: 100%;
}
.honours-table th,
.honours-table td {
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.92rem;
}
.honours-table thead th {
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: none;
}
.honours-table tbody td { color: var(--ink); }
.honours-table tbody td:first-child {
  font-family: var(--font-display);
  font-weight: 600;
}
.honours-table tbody tr:last-child td { border-bottom: none; }

.winner-photo {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  overflow: hidden;
}
.winner-photo img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}
.winner-photo figcaption { padding: 14px 18px; }
.winner-photo .cap-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green-deep);
  margin-bottom: 4px;
}
.winner-photo .cap-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--navy);
}

/* ============================================
   Match Play bracket
   ============================================ */
.bracket-round-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--white);
  white-space: nowrap;
}
.bracket-match {
  position: relative;
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.bracket-trophy {
  position: absolute;
  left: 50%;
  top: -34px;
  transform: translateX(-50%);
  font-size: 1.6rem;
  line-height: 1;
}
.bracket-player {
  min-height: 1.1em;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bracket-player + .bracket-player { border-top: 1px solid var(--line-soft); }
.bracket-player.is-winner { color: var(--navy); }
.bracket-player.is-loser { color: rgba(16, 32, 63, 0.5); font-weight: 500; }

/* Full grid bracket with connector lines — wider than a phone screen,
   so it scrolls horizontally there rather than switching layouts */
.bracket-desktop {
  display: flex;
  gap: 64px;
  align-items: flex-start;
  overflow-x: auto;
  padding: 8px 8px 16px;
}
.bracket-round {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: 190px;
}
.bracket-round-head { text-align: center; margin-bottom: 16px; }
.bracket-round-grid { position: relative; display: grid; }

.bracket-match.has-next::after {
  content: "";
  position: absolute;
  right: -32px;
  width: 32px;
  border-right: 2px solid var(--line);
}
.bracket-match.pair-top.has-next::after {
  top: 50%;
  height: var(--connector-half);
  border-top: 2px solid var(--line);
}
.bracket-match.pair-bottom.has-next::after {
  bottom: 50%;
  height: var(--connector-half);
  border-bottom: 2px solid var(--line);
}
.bracket-match.has-prev::before {
  content: "";
  position: absolute;
  left: -32px;
  top: 50%;
  width: 32px;
  height: 0;
  border-top: 2px solid var(--line);
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.divider-crest {
  display: flex;
  justify-content: center;
  padding: 8px 0 32px;
}
.divider-crest img { height: 46px; width: 46px; opacity: 0.9; }
