:root {
  color-scheme: light dark;
  --ink: #1d1a16;
  --muted: #5e584e;
  --line: #e3dcd0;
  --paper: #f7f4ee;
  --card: #fffdf9;
  --field: #ffffff;
  --accent: #234036;
  --accent-soft: #e7efe9;
  --bar: #234036;
  --on-bar: #f4f7f4;
  --link-line: rgba(35, 64, 54, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ebe6dc;
    --muted: #b3ab9d;
    --line: #3a3d38;
    --paper: #171a18;
    --card: #1f2320;
    --field: #262a27;
    --accent: #9fd1b9;
    --accent-soft: #24372e;
    --bar: #1b3129;
    --on-bar: #eef3ef;
    --link-line: rgba(159, 209, 185, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

/* In tables, a lighter underline keeps rows of links from looking busy. */
td a {
  text-decoration-color: var(--link-line);
  text-underline-offset: 0.18em;
}
td a:hover,
td a:focus-visible { text-decoration-color: currentColor; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.9rem 1.25rem;
  background: var(--bar);
  color: var(--on-bar);
}

.site-header a { color: inherit; text-decoration: none; }
.site-header a:hover,
.site-header a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.2em; }

.brand { font-weight: 600; }

.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }

main,
footer {
  max-width: 52rem;
  margin: 0 auto;
}

main { padding: 1.5rem 1.25rem 3rem; }

main.wide,
footer.wide { max-width: 72rem; }

h1 {
  font-size: 1.85rem;
  line-height: 1.15;
  margin: 0 0 0.35rem;
}

h2 { font-size: 1.28rem; margin: 1.8rem 0 0.45rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 0.35rem; }
h4 { font-size: 0.98rem; margin: 0.9rem 0 0.3rem; }

.meta, .note { color: var(--muted); }
.meta { margin: 0.2rem 0 0.9rem; }

.crumb { color: var(--muted); font-size: 0.95rem; margin: 0 0 0.75rem; }
.crumb a { color: inherit; }

.lead { margin-top: 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}

.narrow-table { max-width: 36rem; }

table { width: 100%; border-collapse: collapse; }

/* Same column widths in every district table on a class page. */
table.fixed { table-layout: fixed; }
table.fixed .c-name { width: 52%; }
table.fixed .c-count { width: 14%; }
table.fixed .c-date { width: 20%; }

th, td {
  text-align: left;
  padding: 0.42rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}

tr:last-child td { border-bottom: 0; }

th {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.name-cell .team,
.team {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.banner {
  background: var(--accent-soft);
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  margin: 0 0 1rem;
}

[hidden] { display: none !important; }

.class-list, .letter-nav, .district-nav, .jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  padding: 0;
  list-style: none;
}

.jump-nav { margin: 0.4rem 0 1.2rem; font-size: 0.95rem; }

/* Home page */
.home-search { margin: 1rem 0 1.4rem; }
.home-search label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.search-row { display: flex; gap: 0.5rem; max-width: 36rem; }
.search-row input { flex: 1; min-width: 0; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  padding: 0.2rem 1rem 0.8rem;
}

.panel h2 { margin-top: 0.8rem; font-size: 1.1rem; }
.top-list { margin: 0; padding-left: 1.2rem; }
.top-list li { margin: 0.3rem 0; }
ul.top-list { list-style: none; padding-left: 0; }
.top-list .kind { display: block; font-size: 0.92rem; }
.panel-link { margin: 0.7rem 0 0; font-size: 0.95rem; }

/* Athlete sections */
.athlete {
  padding: 0.9rem 0 1.1rem;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1rem;
}

.athlete h3 { margin-top: 0; }

.athlete:target {
  background: var(--accent-soft);
  border-radius: 6px;
  padding-inline: 0.8rem;
  margin-inline: -0.8rem;
}

.fastest { padding-left: 1.1rem; }
.fastest li { margin: 0.15rem 0; }

/* Season best and personal record markers. Every time cell keeps the same
   slot, so times line up whether or not a marker is shown. */
.best-slot {
  display: inline-block;
  width: 2.3rem;
  text-align: right;
}

abbr.best {
  display: inline-block;
  padding: 0 0.3rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
  vertical-align: 0.1em;
}

/* Rankings: the detail line shows only when the extra columns are hidden. */
.row-detail {
  display: none;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
  margin-top: 0.15rem;
}

/* Forms */
.search input,
.contact input[type="text"],
.contact input[type="email"],
.contact input[type="url"],
.contact select,
.contact textarea {
  width: 100%;
  max-width: 36rem;
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

.contact label { font-weight: 600; }

.contact button,
.search-row button {
  font: inherit;
  padding: 0.5rem 1.2rem;
  border: 0;
  border-radius: 6px;
  background: var(--bar);
  color: var(--on-bar);
  cursor: pointer;
}

.contact button:disabled { opacity: 0.6; cursor: wait; }

.gotcha { position: absolute; left: -9999px; }

.match-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.match-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.kind { color: var(--muted); }

footer {
  padding: 0 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  main { padding: 1.1rem 0.85rem 2.4rem; }
  footer { padding: 0 0.85rem 2rem; }
  h1 { font-size: 1.5rem; }
  th { letter-spacing: 0; }
  th, td { padding: 0.38rem 0.18rem; }
  .wide-only { display: none; }
  .row-detail { display: block; }
  .best-slot { width: 2rem; }
}

.date { font-variant-numeric: tabular-nums; white-space: nowrap; }

h3.sub { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.team-scores .runners { font-variant-numeric: tabular-nums; color: var(--muted); }
.note.small { font-size: 0.9rem; margin: 0.35rem 0 0; }

.upcoming-list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.upcoming-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.upcoming-list li:last-child { border-bottom: 0; }
.meet-teams { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 0.15rem; }
.next-meet { margin: -0.4rem 0 1rem; }

/* Road rankings */
.road-nav a[aria-current="page"] { color: inherit; font-weight: 600; text-decoration: none; }
.road-toggle {
  font: inherit;
  font-size: 0.95rem;
  margin: 0.15rem 0 1.4rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--accent);
  cursor: pointer;
}
.road-toggle::after { content: " ▾"; }
.road-toggle[aria-expanded="true"]::after { content: " ▴"; }
.road-toggle:hover { background: var(--accent-soft); }
.road-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
