/* MPD Range — base layout & shared components. Loaded after tokens.css on every page. */

/* ---------- reset / root ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + var(--s4)); }
body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;          /* sticky-footer layout */
  font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh);
  color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background-color: var(--bg);
}
img, svg, video { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

h1, h2, h3, h4 { line-height: 1.22; color: var(--brand-ink); font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-1); }
h2 { font-size: var(--fs-2); }
h3 { font-size: var(--fs-3); }
p { line-height: var(--lh); }
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--brand-ink); text-decoration-color: currentColor; }
strong { font-weight: 700; }
ul, ol { padding-left: 1.25em; }
hr { border: 0; border-top: 1px solid var(--border); }

/* ---------- container ---------- */
/* Wide layout — fills the screen on normal monitors; capped on ultrawides so text lines stay sane.
   Readable prose (.lead, .prose, .card p) is separately width-limited (--maxw-prose). */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(var(--s4), 2vw, var(--s5)); }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: var(--on-brand); padding: var(--s2) var(--s4); border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; top: 0; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--brand) 92%, black);
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 2px 12px rgba(16,24,40,.18);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); color: var(--on-brand); text-decoration: none; }
.brand > span { display: inline-flex; flex-direction: column; line-height: 1.2; font-weight: 800; font-size: 1.1rem; }
.brand small { font-weight: 500; opacity: .82; font-size: var(--fs-xs); }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  color: var(--on-brand); text-decoration: none; padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem;
  transition: background-color .15s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: var(--on-brand); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.16); color: var(--on-brand); box-shadow: inset 0 -2px 0 var(--brand-accent); }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: var(--on-brand);
  border-radius: var(--radius-sm); min-width: var(--tap); min-height: var(--tap); font-size: 1.25rem; cursor: pointer;
}
.nav-toggle:hover { background: rgba(255,255,255,.12); }

/* Theme toggle (sun/moon/auto) — injected by theme.js into .site-header .nav. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: var(--on-brand);
  border-radius: var(--radius-sm); min-width: var(--tap); min-height: var(--tap);
  margin-left: var(--s2); padding: 0 var(--s3); font-size: 1.15rem; cursor: pointer;
  line-height: 1; font-weight: 700;
}
.theme-toggle:hover { background: rgba(255,255,255,.12); }
.theme-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 720px) { .theme-toggle { margin-left: 0; } }
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--brand-strong); padding: var(--s2); box-shadow: var(--shadow-lg);
  }
  .nav.open { display: flex; }
  .nav a { padding: var(--s3) var(--s4); border-radius: var(--radius-sm); }
}

/* ---------- main / page shell ---------- */
main { flex: 1 0 auto; padding-block: clamp(var(--s6), 5vw, var(--s8)); }
main.home, main.with-hero { padding-top: 0; }       /* pages that lead with a full-bleed hero band */
.page-title { margin-bottom: var(--s2); }
.lead { color: var(--ink-2); font-size: 1.075rem; max-width: var(--maxw-prose); }
main > .container > h1 + .lead, main > .container > .page-title + .lead { margin-bottom: var(--s5); }
.prose, .prose p, .lead, .card p { max-width: var(--maxw-prose); }
main > .container > * + * { margin-top: var(--s4); }

/* ---------- hero (home page) ---------- */
.hero {
  /* range photo as the hero banner — clearly visible, under a colour wash so the dark text stays readable.
     scrolls with the page (NOT background-attachment:fixed) so it doesn't "split" against the rest of the page. */
  background-color: var(--surface-2);
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 42%, transparent) 0%, color-mix(in srgb, var(--bg) 55%, transparent) 70%, var(--bg) 100%),
    url('/assets/img/rangeshooters.jpg'),
    var(--bg-accent);
  background-size: cover; background-position: center, center 35%, center; background-repeat: no-repeat;
  border-bottom: 1px solid var(--border);
  padding-block: clamp(var(--s7), 7vw, var(--s9));
}
.hero .hero-title, .hero .hero-lead, .hero .hero-eyebrow { text-shadow: 0 1px 3px color-mix(in srgb, var(--bg) 55%, transparent), 0 0 3px color-mix(in srgb, var(--bg) 72%, transparent); }
.hero-eyebrow { color: var(--brand-accent-ink); font-weight: 800; letter-spacing: .07em; text-transform: uppercase; font-size: clamp(.95rem, 1.7vw, 1.2rem); margin-bottom: var(--s3); }
.hero-title { font-size: var(--fs-display); color: var(--brand-ink); margin-bottom: var(--s4); }
.hero-lead { color: var(--ink-2); font-size: 1.15rem; max-width: 60ch; margin-bottom: var(--s5); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
.home-body { padding-block: clamp(var(--s7), 6vw, var(--s8)); }

/* ---------- inner-page hero band (compact .hero with a faded range photo) ---------- */
.page-hero {
  background-color: var(--surface-2);
  background-image:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 38%, transparent) 0%, color-mix(in srgb, var(--bg) 54%, transparent) 78%, var(--bg) 100%),
    var(--page-hero-img, none),
    var(--bg-accent);
  background-size: cover; background-position: center, center 38%, center; background-repeat: no-repeat;
  border-bottom: 1px solid var(--border);
  padding-block: clamp(var(--s5), 4.5vw, var(--s7));
  margin-bottom: clamp(var(--s5), 4vw, var(--s6));
}
.page-hero .page-title { text-shadow: 0 1px 3px color-mix(in srgb, var(--bg) 56%, transparent), 0 0 2px color-mix(in srgb, var(--bg) 68%, transparent); }
.page-hero .lead { color: var(--ink-2); margin-bottom: 0; text-shadow: 0 1px 3px color-mix(in srgb, var(--bg) 56%, transparent), 0 0 2px color-mix(in srgb, var(--bg) 68%, transparent); }
.page-hero--calendar { --page-hero-img: url('/assets/img/rifleshooting.jpg'); }
.page-hero--rules    { --page-hero-img: url('/assets/img/singleshooterrangemaster.jpg'); }
.page-hero--contact  { --page-hero-img: url('/assets/img/rangeshoters.jpg'); }
.page-hero--request  { --page-hero-img: url('/assets/img/rangeshoters.jpg'); }
.page-hero--legal    { --page-hero-img: url('/assets/img/singleshooterrangemaster.jpg'); }

/* ---------- cards / sections ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft); padding: clamp(var(--s4), 3vw, var(--s5)); margin: var(--s5) 0;
}
.card h2, .card h3 { margin-bottom: var(--s2); }
.card > :last-child { margin-bottom: 0; }
.card-link, a.card { display: block; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card-link:hover, a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.grid { display: grid; gap: clamp(var(--s4), 2.5vw, var(--s5)); margin: var(--s5) 0; }
.grid.cards-grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
@media (min-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.grid > .card { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 10px var(--s5); border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 700; line-height: 1.1; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .12s, box-shadow .15s; box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); color: var(--on-brand); }
.btn-secondary { background: var(--surface); color: var(--brand-ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--brand-ink); }
.btn-accent { background: var(--brand-accent); color: #122740; }    /* always dark text on gold — keeps WCAG contrast in both themes */
.btn-accent:hover { background: color-mix(in srgb, var(--brand-accent) 88%, black); color: #122740; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--link); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-lg { font-size: 1.075rem; padding: 14px var(--s6); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }

/* ---------- status chips (calendar legend etc.) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--fs-sm); font-weight: 700;
  border: 1px solid currentColor; background: color-mix(in srgb, currentColor 12%, var(--surface));
}
.chip::before { content: "\25CF"; font-size: .7em; }
.chip.open    { color: var(--status-open); }
.chip.limited { color: var(--status-limited); }
.chip.full    { color: var(--status-full); }
.chip.closed  { color: var(--status-closed); }

/* ---------- banners ---------- */
.banner { border-radius: var(--radius); padding: var(--s3) var(--s4); margin: 0 0 var(--s5); border: 1px solid; font-size: var(--fs-sm); }
.banner.info  { border-color: color-mix(in srgb, var(--info) 35%, var(--border));  background: color-mix(in srgb, var(--info) 7%, var(--surface));  color: var(--brand-ink); }
.banner.warn  { border-color: color-mix(in srgb, var(--warn) 45%, var(--border));  background: color-mix(in srgb, var(--warn) 9%, var(--surface));  color: var(--brand-ink); }
.banner.ok    { border-color: color-mix(in srgb, var(--ok) 40%, var(--border));    background: color-mix(in srgb, var(--ok) 7%, var(--surface));    color: var(--brand-ink); }
.banner.error { border-color: color-mix(in srgb, var(--error) 45%, var(--border)); background: color-mix(in srgb, var(--error) 8%, var(--surface)); color: var(--brand-ink); }

/* ---------- footer ---------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border); background: var(--surface);
  padding-block: var(--s5); color: var(--muted); font-size: var(--fs-sm);
}
.site-footer .container { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; justify-content: space-between; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }
.site-footer nav a { white-space: nowrap; margin-inline: 2px; }

/* ---------- cookie banner ---------- */
#cookie-banner {
  position: fixed; left: var(--s3); right: var(--s3); bottom: var(--s3); z-index: 60;
  max-width: var(--maxw); margin-inline: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: var(--s3) var(--s4);
  display: none; gap: var(--s4); align-items: center; flex-wrap: wrap; justify-content: space-between;
}
#cookie-banner.show { display: flex; }

/* ---------- notice modal (e.g. the "under maintenance" message) ---------- */
.notice-modal-backdrop {
  position: fixed; inset: 0; z-index: 80; padding: var(--s4);
  background: rgba(11,18,28,.55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
.notice-modal-backdrop.show { display: flex; animation: noticeIn .18s ease-out; }
.notice-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 540px; width: 100%; padding: clamp(var(--s5), 4vw, var(--s6));
}
.notice-modal h2 { margin-bottom: var(--s3); }
.notice-modal p + p { margin-top: var(--s3); }
.notice-modal .notice-actions { display: flex; justify-content: flex-end; margin-top: var(--s5); }
@keyframes noticeIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- utilities ---------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.text-muted { color: var(--muted); }
.placeholder-note {
  border: 1px dashed var(--brand-accent); background: color-mix(in srgb, var(--brand-accent) 8%, var(--surface));
  color: var(--brand-ink); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); font-size: var(--fs-sm); margin: var(--s4) 0;
}
