/* ==========================================================================
   Bagel2Beer Marathon — main stylesheet
   Mobile-first. Warm "bagel + beer" palette. No external dependencies.
   ========================================================================== */

:root {
  /* Palette */
  --bg:        #faf6ee;   /* warm off-white (bagel crumb) */
  --surface:   #ffffff;
  --surface-2: #f3ead9;   /* soft cream */
  --ink:       #241d16;   /* near-black brown */
  --ink-soft:  #5c5145;
  --amber:     #d8962b;   /* beer amber (brand) */
  --amber-dk:  #b06f16;
  --crust:     #7a4a1e;   /* bagel crust brown */
  --rust:      #a8461c;   /* link / accent */
  --rust-dk:   #7f3313;
  --foam:      #fbf3df;   /* beer foam */
  --line:      #e6dcc8;   /* hairline */
  --good:      #2f7d4f;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(36,29,22,.06), 0 8px 24px rgba(36,29,22,.08);
  --shadow-sm: 0 1px 2px rgba(36,29,22,.08);
  --wrap:      1080px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Georgia", "Iowan Old Style", "Palatino Linotype", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #1c1712;
    --surface:   #262019;
    --surface-2: #2f2820;
    --ink:       #f3ecdf;
    --ink-soft:  #c3b7a3;
    --amber:     #e8ad4a;
    --amber-dk:  #d8962b;
    --crust:     #d9a86e;
    --rust:      #e58a5c;
    --rust-dk:   #e58a5c;
    --foam:      #2f2820;
    --line:      #3a3128;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  }
}

/* ---- Reset-ish ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 1.02rem;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--rust); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--rust-dk); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; color: var(--ink); font-weight: 700; }
h1 { font-size: clamp(2rem, 6vw, 3.1rem); margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 1.8em 0 .5em; }
h3 { font-size: 1.22rem; margin: 1.4em 0 .4em; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.25em; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: .6em 1em; border-radius: 0 0 var(--radius-sm) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

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

/* ==========================================================================
   Header / nav
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand-mark { border-radius: 50%; }
.brand-text { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: -.01em; }
.brand-2 { color: var(--amber-dk); }

.site-nav ul { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: .5rem .7rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: .96rem;
}
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--crust); background: var(--foam); }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px; justify-content: center;
  width: 44px; height: 44px; padding: 0 10px; background: none; border: 0; cursor: pointer;
}
.nav-toggle-bar { height: 2px; background: var(--ink); border-radius: 2px; transition: .25s; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: fixed; inset: 64px 0 auto 0; background: var(--surface);
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    max-height: 0; overflow: hidden; transition: max-height .3s ease;
  }
  .site-nav.open { max-height: 80vh; }
  .site-nav ul { flex-direction: column; padding: .5rem 1rem 1rem; gap: .1rem; }
  .site-nav a { padding: .8rem .6rem; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: .5em; justify-content: center;
  padding: .7rem 1.25rem; border-radius: 999px; font-weight: 700; font-size: 1rem;
  text-decoration: none; cursor: pointer; border: 2px solid transparent; transition: .15s;
}
.btn-primary { background: var(--amber); color: #241d16; }
.btn-primary:hover { background: var(--amber-dk); color: #fff; }
.btn-outline { background: transparent; color: var(--crust); border-color: var(--crust); }
.btn-outline:hover { background: var(--crust); color: #fff; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 80% at 80% -10%, color-mix(in srgb, var(--amber) 30%, transparent), transparent 60%),
    linear-gradient(180deg, var(--foam), var(--bg));
  /*border-bottom: 1px solid var(--line);*/
}
.hero-inner { padding-block: clamp(2.5rem, 8vw, 5rem); }
.hero h1 { max-width: 15ch; }
.hero .lede { font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: var(--ink-soft); max-width: 40ch; margin-bottom: 1.5rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.eyebrow {
  display: inline-block; text-transform: uppercase; letter-spacing: .12em;
  font-size: .8rem; font-weight: 700; color: var(--amber-dk); margin-bottom: .75rem;
}

/* ==========================================================================
   Sections / cards
   ========================================================================== */
.section { padding-block: clamp(2rem, 6vw, 3.5rem); }
.section-alt { background: var(--surface-2); }
.lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 62ch; }

.prose { max-width: 68ch; }
.prose > *:first-child { margin-top: 0; }
.prose img { border-radius: var(--radius); box-shadow: var(--shadow); margin: 1.5rem 0; }
.prose figure { margin: 1.5rem 0; }
.prose figcaption { font-size: .9rem; color: var(--ink-soft); text-align: center; margin-top: .5rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 0; }

.card-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Fact list (race details) */
.facts { display: grid; gap: .1rem; margin: 0; }
.facts div { display: flex; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.facts dt { flex: 0 0 8.5rem; font-weight: 700; color: var(--crust); }
.facts dd { margin: 0; }

.badge { display: inline-block; padding: .15em .7em; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge-muted { background: var(--surface-2); color: var(--ink-soft); }

/* ==========================================================================
   Tables (results)
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
table.results { border-collapse: collapse; width: 100%; background: var(--surface); font-variant-numeric: tabular-nums; }
table.results th, table.results td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
table.results thead th { background: var(--foam); color: var(--crust); position: sticky; top: 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
table.results tbody tr:hover { background: var(--surface-2); }
table.results td.place { color: var(--ink-soft); width: 3rem; }
table.results td.time { text-align: right; white-space: nowrap; }

.search-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.search-bar input, .search-bar select {
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
}
.search-bar input[type="search"] { flex: 1 1 220px; }

/* Year chips */
.year-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; list-style: none; padding: 0; }
.year-chips a {
  display: inline-block; padding: .4rem .85rem; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600;
}
.year-chips a:hover { background: var(--foam); border-color: var(--amber); }

/* ==========================================================================
   Photo gallery
   ========================================================================== */
.album-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); list-style: none; padding: 0; margin: 0; }
.album-card { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); background: var(--surface-2); aspect-ratio: 4/3; }
.album-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.album-card:hover img { transform: scale(1.05); }
.album-card .album-label {
  position: absolute; inset: auto 0 0 0; padding: 1.2rem .9rem .7rem;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff;
}
.album-label .yr { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.album-label .ct { font-size: .85rem; opacity: .9; }

.photo-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); list-style: none; padding: 0; margin: 1.5rem 0; }
.photo-grid li { margin: 0; }
.photo-grid button {
  display: block; width: 100%; padding: 0; border: 0; cursor: pointer; background: var(--surface-2);
  border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; box-shadow: var(--shadow-sm);
}
.photo-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photo-grid button:hover img { transform: scale(1.06); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(15,12,9,.94); z-index: 200; display: none; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lightbox-caption { position: fixed; bottom: 1rem; left: 0; right: 0; text-align: center; color: #f3ecdf; font-size: .9rem; }
.lightbox-btn {
  position: fixed; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff;
  border: 0; width: 52px; height: 52px; border-radius: 50%; font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.lightbox-btn:hover { background: rgba(255,255,255,.25); }
.lb-prev { left: 1rem; } .lb-next { right: 1rem; }
.lb-close { top: 1rem; right: 1rem; transform: none; }

/* ==========================================================================
   Maps
   ========================================================================== */
.map { height: min(65vh, 560px); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; }
.map-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: .8rem 0; font-size: .9rem; color: var(--ink-soft); }
.map-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-grid { display: grid; gap: 1.1rem; max-width: 520px; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 700; font-size: .95rem; }
.field input, .field select, .field textarea {
  padding: .7rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; width: 100%;
}
.field textarea { min-height: 6rem; resize: vertical; }
.form-note { font-size: .9rem; color: var(--ink-soft); }
.waiver {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; font-size: .92rem; max-height: 15rem; overflow-y: auto; margin-bottom: 1rem;
}
.form-status { padding: .8rem 1rem; border-radius: var(--radius-sm); font-weight: 600; display: none; }
.form-status.show { display: block; }
.form-status.ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.form-status.err { background: color-mix(in srgb, var(--rust) 15%, transparent); color: var(--rust-dk); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { background: var(--ink); color: var(--foam);/* margin-top: 4rem;*/ }
.footer-inner { display: grid; gap: 1.5rem; padding-block: 2.5rem; grid-template-columns: 1fr; }
.footer-brand { display: flex; align-items: center; gap: .75rem; }
.footer-brand img { border-radius: 50%; }
.footer-brand p { margin: 0; }
.site-footer a { color: var(--amber); }
.site-footer ul { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; padding: 0; margin: 0; }
.footer-note { font-size: .88rem; color: color-mix(in srgb, var(--foam) 70%, transparent); }
@media (min-width: 720px) {
  .footer-inner { grid-template-columns: 1.2fr 1fr; align-items: start; }
  .footer-note { grid-column: 1 / -1; }
}

/* Utilities */
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.muted { color: var(--ink-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
