/* ===== BION SportsFest '26 =====
   Palette taken from the venue: court green, chalk line, BION lime.
   The medal dot is the one repeated mark — tally, results, legend. */

:root {
  --ink: #10201a;
  --ink-2: #4e635a;
  --paper: #f3f5f0;
  --card: #ffffff;
  --court: #1b4a38;
  --lime: #a8db3c;
  --line: #e0e5dc;

  /* Lime is the brand accent only. Medals are metal. */
  --gold: #d9a419;
  --gold-ink: #8a6600;
  --silver: #bcc3c7;
  --silver-ink: #6b7378;

  --display: 'Archivo', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  --wrap: 1200px;
  --radius: 14px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--court);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ===== Masthead ===== */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(243, 245, 240, 0.88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 62px;
}

.masthead img { height: 30px; width: auto; display: block; }

.masthead nav {
  margin-left: auto;
  display: flex;
  gap: 26px;
  font-size: 0.9rem;
  font-weight: 500;
}

.masthead nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--lime);
}

/* ===== Hero ===== */
/* Longhand only — .hero is also a .wrap, and shorthand would wipe its side padding. */
.hero { padding-top: 38px; padding-bottom: 24px; }

.hero h1 {
  font-family: var(--display);
  font-variation-settings: 'wdth' 125, 'wght' 800;
  font-size: clamp(2.4rem, 8.5vw, 6.4rem);
  line-height: 0.86;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  margin: 10px 0 0;
}

.hero h1 i { font-style: normal; color: var(--lime); }

.hero .lede {
  margin-top: 12px;
  max-width: 52ch;
  font-size: 1rem;
  color: var(--ink-2);
}

/* ===== Medals by tower — one row, no pile of pips ===== */
.tally {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px 22px;
  flex-wrap: wrap;
}

.tally-rows { display: flex; flex-wrap: wrap; }

.tally-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 2px 16px;
  border-left: 1px solid var(--line);
}

.tally-row:first-child { border-left: 0; padding-left: 0; }

.tower {
  font-family: var(--display);
  font-variation-settings: 'wdth' 125, 'wght' 800;
  font-size: 1.2rem;
  line-height: 1;
}

.tally-total {
  font-family: var(--display);
  font-variation-settings: 'wdth' 112, 'wght' 700;
  font-size: 1.05rem;
  line-height: 1;
}

/* .tally is a flex row — full basis puts the note on its own line below. */
.tally-note {
  flex-basis: 100%;
  margin-top: -2px;
  font-size: 0.8rem;
  color: var(--ink-2);
}

.tally-count { font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; margin-left: 3px; }
.tally-count .g { color: var(--gold-ink); }
.tally-count .s { color: var(--silver-ink); }

.pip { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.pip.silver { background: var(--silver); }

/* ===== Tabs ===== */
.tabs {
  position: sticky;
  top: 62px;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  margin-top: 24px;
}

.tabs .wrap {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-top: 10px;
  padding-bottom: 10px;
}

.tabs .wrap::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover { border-color: var(--ink-2); color: var(--ink); }

.tab[aria-selected='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.tab b {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.72rem;
  opacity: 0.65;
}

/* ===== Panel ===== */
.panel-head { padding: 18px 0 14px; }
.panel-note { margin-top: 10px; max-width: 64ch; color: var(--ink-2); font-size: 0.92rem; }

/* When / where for a category that has not been played yet. */
.fixture {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.fixture > div {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.fixture svg { width: 19px; height: 19px; flex: none; color: var(--court); }

.fixture .k {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.fixture .v { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }

/* Cards vary in height (team events list five names, some have no photo yet),
   so columns rather than grid rows — no holes to fill. */
.grid {
  columns: 3 295px;
  column-gap: 20px;
  padding-bottom: 72px;
}

/* ===== Event card ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  break-inside: avoid;
  margin-bottom: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(16, 32, 26, 0.1);
}

.plate {
  position: relative;
  background: var(--court);
  overflow: hidden;
  color: #fff;
}

/* Photos are a mix of 16:9, 4:3 and portrait. 3:2 crops all three least,
   and the crop is biased upward because faces sit above centre. */
.plate--photo { aspect-ratio: 3 / 2; }

.plate img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
  transition: transform 0.5s ease;
}

.card:hover .plate img { transform: scale(1.04); }

.plate--photo::after {
  content: '';
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(180deg, transparent, rgba(8, 20, 15, 0.85));
  pointer-events: none;
}

/* Events still waiting on a photo get a plain court-green band, not a gap. */
.plate--blank { padding: 26px 16px 18px; }

.plate--photo .plate-label {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
}

.plate-label h3 {
  font-family: var(--display);
  font-variation-settings: 'wdth' 112, 'wght' 700;
  font-size: 1.3rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

.plate-label p {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-top: 4px;
}

.results { list-style: none; padding: 6px 16px 14px; }

.result {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 11px 0;
  align-items: start;
}

.result + .result { border-top: 1px solid var(--line); }

.medal {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--gold);
  color: var(--ink);
  margin-top: 1px;
}

.medal.silver { background: var(--silver); }

.player {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.player + .player { margin-top: 3px; }

.player span { font-weight: 600; font-size: 0.97rem; }

.flat {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ===== Past events ===== */
.past-list { display: grid; gap: 16px; padding-bottom: 72px; max-width: 640px; }

.past-item {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.past-item:hover {
  transform: translateY(-3px);
  border-color: var(--ink-2);
  box-shadow: 0 10px 30px rgba(16, 32, 26, 0.1);
}

.past-item h3 {
  font-family: var(--display);
  font-variation-settings: 'wdth' 118, 'wght' 700;
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin: 10px 0 6px;
}

.past-item p { color: var(--ink-2); font-size: 0.95rem; }

.past-item .go {
  display: inline-block;
  margin-top: 14px;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid var(--lime);
  padding-bottom: 2px;
}

/* ===== Footer ===== */
.foot {
  background: var(--court);
  color: #dfe8e0;
  padding: 40px 0;
  font-size: 0.88rem;
}

.foot .wrap { display: grid; gap: 16px; }
.foot strong { color: #fff; font-weight: 600; }

.legend { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend .pip.silver { box-shadow: inset 0 0 0 1.5px #9db3a4; }

/* ===== Motion ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card, .past-item { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 560px) {
  .masthead .wrap { gap: 12px; }
  .masthead nav { gap: 16px; font-size: 0.85rem; }
  .hero { padding-top: 28px; padding-bottom: 20px; }
  /* SPORTSFEST cannot break, so drop the width axis rather than overflow. */
  .hero h1 { font-size: clamp(2.4rem, 13vw, 4rem); font-variation-settings: 'wdth' 100, 'wght' 800; }
  /* Four towers wrap raggedly in a flex row. Grid to 2x2, dropping to one
     column below ~380px where two cells no longer fit. */
  .tally-rows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px 14px;
    width: 100%;
  }
  .tally-row { padding: 0; border-left: 0; }
}
