/* Mobile-first: base styles are for phones; min-width queries add tablet (48rem) and desktop (64rem) layouts.
   Palette taken from the 1965 Shelby GT350: Wimbledon White with Guardsman Blue stripes. */
/* Archivo, self-hosted (SIL Open Font License, see fonts/OFL.txt): one variable font covering widths 62–125% and weights 400–800 */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Light theme (default). Dark values below; a footer switch can force either via <html data-theme>. */
:root {
  --white: #f1f2ef;        /* Wimbledon White: page background */
  --paper: #fafaf8;        /* raised surfaces: header, hero, tinted sections */
  --blue: #1b2a4e;         /* Guardsman Blue: headings, links, outlines */
  --ink: #161b2c;          /* body text */
  --red: #b3121b;          /* Candyapple Red: button fills */
  --red-hover: #8f0e15;
  --on-red: #fff;
  --accent: #b3121b;       /* red text: dates, distances, email addresses */
  --focus: #b3121b;        /* focus ring: needs 3:1 against whatever it sits on */
  --chrome: #5f687c;       /* secondary text */
  --rule: #d6d9df;
  --stripe-colour: #1b2a4e; /* hero racing stripes */
  --band: #1b2a4e;         /* the blue "Join" section */
  --band-heading: #fff;
  --band-text: #c5cbd8;
  --band-muted: #aab3c7;
  --band-rule: #3b4a70;
  --light-button-hover: #fff;
  --field: #fff;
  --placeholder: #5f687c;
  --thumb: #fff;           /* behind event logos, which are mostly drawn on white */

  --font: "Archivo", system-ui, sans-serif;
  --narrow: 62;
  --measure: 34rem;
  --gutter: max(1rem, env(safe-area-inset-left), env(safe-area-inset-right));
  --max: 72rem;
  --tap: 2.75rem;          /* minimum touch target */

  color-scheme: light;
}

/* Dark theme: night-time Guardsman Blue. Applied when the device asks for dark (unless the
   visitor chose Light), or when the visitor chose Dark. Keep the two blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --white: #0f1526;
    --paper: #161e33;
    --blue: #b8c8ec;
    --ink: #e6e9f0;
    --red: #c8202a;
    --red-hover: #a8141d;
    --accent: #ff7a7f;
    --focus: #ff7a7f;      /* the dark red is under 3:1 on paper */
    --chrome: #9ba4b8;
    --rule: #2a3552;
    --stripe-colour: #34508f;
    --band: #1b2a4e;
    --light-button-hover: #1f2943;
    --field: #0f1526;
    --placeholder: #9ba4b8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --white: #0f1526;
  --paper: #161e33;
  --blue: #b8c8ec;
  --ink: #e6e9f0;
  --red: #c8202a;
  --red-hover: #a8141d;
  --accent: #ff7a7f;
  --focus: #ff7a7f;      /* the dark red is under 3:1 on paper */
  --chrome: #9ba4b8;
  --rule: #2a3552;
  --stripe-colour: #34508f;
  --band: #1b2a4e;
  --light-button-hover: #1f2943;
  --field: #0f1526;
  --placeholder: #9ba4b8;
  color-scheme: dark;
}

@media (min-width: 48rem) {
  :root { --gutter: max(2rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 7rem;   /* keep anchored headings clear of the sticky header */
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (min-width: 48rem) {
  html { scroll-padding-top: 5rem; }
}

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

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

.wrap {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.display {
  font-variation-settings: "wdth" var(--narrow);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ---------- Tail-light mark ---------- */

.lights {
  display: inline-flex;
  gap: 3px;
  height: 1.1em;
  vertical-align: -0.15em;
}
.lights span {
  width: 0.32em;
  background: var(--red);
  border-radius: 1px;
}

@media (prefers-reduced-motion: no-preference) {
  .lights--sequence span { animation: light 0.9s ease-out both; }
  .lights--sequence span:nth-child(1) { animation-delay: 0.3s; }
  .lights--sequence span:nth-child(2) { animation-delay: 0.5s; }
  .lights--sequence span:nth-child(3) { animation-delay: 0.7s; }
}

@keyframes light {
  from { background: #4a1518; }
  40%  { background: #ff2a2f; box-shadow: 0 0 0.6em #ff2a2f; }
  to   { background: var(--red); box-shadow: none; }
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding-top: env(safe-area-inset-top);
}
.site-header .wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 3.5rem;
  font-weight: 800;
  font-size: 1.35rem;
  font-variation-settings: "wdth" var(--narrow);
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--blue);
}
.header-button {
  grid-row: 1;
  grid-column: -2;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 1.1rem;
  border-radius: 3px;
  background: var(--red);
  color: var(--on-red);
  font-weight: 700;
  text-decoration: none;
}
.header-button:hover, .header-button:active { background: var(--red-hover); }
.header-button--quiet { background: transparent; color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue); }
.header-button--quiet:hover, .header-button--quiet:active { background: var(--blue); color: var(--paper); }

/* Phones: section links get their own row of equal-width tap targets */
.nav {
  grid-column: 1 / -1;
  display: flex;
  margin-inline: calc(var(--gutter) * -1);
  border-top: 1px solid var(--rule);
}
.nav a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--blue);
}
.nav a + a { border-left: 1px solid var(--rule); }
.nav a:active { background: var(--white); }

@media (min-width: 48rem) {
  .site-header .wrap { grid-template-columns: auto 1fr auto; }
  .nav {
    grid-row: 1;
    grid-column: 2;
    justify-content: flex-end;
    gap: 0.25rem;
    margin: 0 0.75rem 0 0;
    border: 0;
  }
  .nav a { flex: none; padding-inline: 0.75rem; font-weight: 500; color: var(--ink); }
  .nav a + a { border: 0; }
  .nav a:hover { text-decoration: underline; text-underline-offset: 0.25em; }
}

/* ---------- Hero ---------- */

/* Le Mans stripes: two broad bands with a narrow gap, the way they run over a GT350's bonnet */
.hero {
  --stripe: 1.1rem;
  --stripe-gap: 0.35rem;
  --stripe-edge: var(--gutter);
  position: relative;
  overflow: hidden;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--stripe);
  background: var(--stripe-colour);
}
.hero::after  { right: var(--stripe-edge); }
.hero::before { right: calc(var(--stripe-edge) + var(--stripe) + var(--stripe-gap)); }

.hero .wrap {
  position: relative;
  z-index: 1;
  padding-right: calc(var(--stripe-edge) + var(--stripe) * 2 + var(--stripe-gap) + 1.25rem);
  padding-block: 2rem 2.25rem;
}
.hero h1 {
  font-size: clamp(2.6rem, 12.5vw, 7.5rem);
  color: var(--blue);
}
.hero h1 .lights { display: flex; font-size: 0.5em; height: 0.9em; margin-bottom: 0.3em; }
.hero p {
  max-width: var(--measure);
  margin: 1.25rem 0 0;
  font-size: 1.0625rem;
}

@media (min-width: 48rem) {
  .hero { --stripe: 4.5rem; --stripe-gap: 0.9rem; --stripe-edge: 4rem; }
  .hero .wrap { padding-block: 4rem 3.5rem; }
  .hero h1 { max-width: 11ch; }
  .hero p { font-size: 1.2rem; margin-top: 1.75rem; }
}
@media (min-width: 64rem) {
  .hero { --stripe: 7rem; --stripe-gap: 1.25rem; --stripe-edge: 10vw; }
  .hero .wrap { padding-block: 5.5rem 5rem; padding-right: var(--gutter); }
}

/* ---------- Buttons ---------- */

.actions {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: 3px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  background: var(--red);
  color: var(--on-red);
  cursor: pointer;
}
.button:hover, .button:active { background: var(--red-hover); }
.button--quiet {
  background: transparent;
  color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue);
}
.button--quiet:hover, .button--quiet:active { background: var(--blue); color: var(--paper); }
.button--light { background: var(--paper); color: var(--blue); }
.button--light:hover, .button--light:active { background: var(--light-button-hover); }

@media (min-width: 30rem) {
  .actions { display: flex; flex-wrap: wrap; }
  .button { display: inline-flex; }
}

/* ---------- Sections ---------- */

.section { padding-block: 2.75rem 3rem; }
.section h2 {
  font-size: clamp(2.25rem, 10vw, 3.75rem);
  color: var(--blue);
  margin-bottom: 1rem;
}
.section p { max-width: var(--measure); }
.section--tint { background: var(--paper); border-block: 1px solid var(--rule); }
.section--blue { background: var(--band); color: var(--band-text); --focus: #ff7a7f; }  /* red is 2:1 on the band */
.section--blue h2 { color: var(--band-heading); }

@media (min-width: 48rem) {
  .section { padding-block: 4.5rem; }
}

.subhead {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.1rem;
  color: var(--chrome);
}
.section--blue .subhead { color: var(--band-muted); }

.small { font-size: 1rem; color: var(--chrome); }
.small a { color: var(--blue); }

.empty {
  padding: 1.25rem;
  border: 2px dashed var(--rule);
  border-radius: 3px;
  background: var(--paper);
}

/* ---------- Events ---------- */

.next-event {
  display: grid;
  gap: 1.25rem;
  margin: 1.25rem 0 0;
  max-width: 52rem;
}
.next-event-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 4px;
  background: var(--rule);
}
.next-event time,
.event time {
  font-variation-settings: "wdth" var(--narrow);
  font-weight: 800;
  color: var(--accent);
}
.next-event time { font-size: 1.6rem; line-height: 1; }
.next-event h3 {
  margin: 0.35rem 0 0;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--blue);
}
.next-event .event-note {
  margin: 0.75rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--red);
}
.next-event .button { margin-top: 1.25rem; }

@media (min-width: 48rem) {
  .next-event { grid-template-columns: 1fr 1fr; align-items: center; gap: 2rem; }
  .next-event time { font-size: 2rem; }
}

.event-location { margin: 0.25rem 0 0; color: var(--chrome); }

.event-list {
  list-style: none;
  margin: 0 0 1.75rem;
  padding: 0;
  max-width: 52rem;
  border-top: 2px solid var(--blue);
}
.event {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}
.event img {
  grid-row: span 2;
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
  border-radius: 4px;
  background: var(--thumb);
  box-shadow: inset 0 0 0 1px var(--rule);
}
.event h4 { margin: 0; font-size: 1.05rem; line-height: 1.25; }
.event h4 a { color: var(--blue); text-decoration: none; }
.event h4 a:hover { text-decoration: underline; }
.event time { grid-column: 2; font-size: 1.1rem; }

@media (min-width: 48rem) {
  .event { grid-template-columns: 4rem 1fr auto; column-gap: 1.25rem; }
  .event img { grid-row: auto; width: 4rem; height: 4rem; }
  .event time { grid-column: auto; font-size: 1.3rem; white-space: nowrap; }
}
#events .button--quiet { margin-top: 1.75rem; }
#more-events + .button--quiet { margin-top: 0; }

/* ---------- Meeting finder ---------- */

.finder {
  display: grid;
  gap: 1rem;
  max-width: 30rem;
  margin-top: 1.5rem;
}
.postcode-form label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.postcode-row { display: flex; gap: 0.5rem; }
.postcode-row input {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  padding: 0 0.85rem;
  border: 2px solid var(--chrome);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;   /* 16px+ stops iOS zooming on focus */
  text-transform: uppercase;
}
.postcode-row input::placeholder { text-transform: none; color: var(--placeholder); }
.postcode-row input:focus-visible { border-color: var(--blue); outline-offset: 1px; }
.finder-status { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--blue); }

.area-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  max-width: 44rem;
  border-top: 2px solid var(--blue);
}
.area { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.area-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.area h3 { margin: 0; font-size: 1.15rem; color: var(--blue); }
.distance {
  font-variation-settings: "wdth" var(--narrow);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--accent);
  white-space: nowrap;
}
.area p { margin: 0.2rem 0 0; }
.area-when { font-weight: 600; }
.area-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.area-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--blue);
  font-weight: 600;
}

.all-areas { margin-top: 2rem; max-width: 44rem; }
.all-areas summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
}
.all-areas[open] summary { margin-bottom: 0.25rem; }

/* ---------- Contacts and links ---------- */

.contacts,
.links {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  max-width: 64rem;
}
.contacts { border-top: 2px solid var(--blue); }
.contacts li { border-bottom: 1px solid var(--rule); }
.contacts a,
.links a {
  display: grid;
  gap: 0.15rem;
  padding: 0.9rem 0;
  text-decoration: none;
}
.contacts strong { color: var(--blue); font-size: 1.05rem; }
.contacts span { color: var(--ink); }
.contacts .addr { color: var(--accent); font-weight: 600; word-break: break-word; }
.contacts a:hover strong,
.links a:hover strong { text-decoration: underline; text-underline-offset: 0.2em; }

@media (min-width: 48rem) {
  .contacts { grid-template-columns: 1fr 1fr; column-gap: 2.5rem; }
}

.join { max-width: 40rem; }
.section--blue .join p { color: var(--band-text); }

.links { border-top: 1px solid var(--band-rule); }
.links li { border-bottom: 1px solid var(--band-rule); }
.links strong { font-size: 1.15rem; color: var(--band-heading); }
.links span { color: var(--band-text); }

@media (min-width: 48rem) {
  .links { grid-template-columns: repeat(2, 1fr); column-gap: 2.5rem; }
}
@media (min-width: 64rem) {
  .links { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Footer ---------- */

.site-footer {
  padding-block: 1.75rem calc(1.75rem + env(safe-area-inset-bottom));
  font-size: 1rem;
  color: var(--chrome);
}
.site-footer .wrap { display: grid; gap: 0.5rem; }
.site-footer p { margin: 0; }
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--blue); }

@media (min-width: 48rem) {
  .site-footer .wrap { grid-template-columns: 1fr auto; align-items: center; }
}

/* ---------- Simple page (members) ---------- */

.page {
  min-height: 60vh;
  padding-block: 3rem;
}
.page h1 { font-size: clamp(3rem, 14vw, 6rem); color: var(--blue); margin-bottom: 1.25rem; }
.page p { max-width: var(--measure); }

@media (min-width: 48rem) {
  .page { padding-block: 6rem; }
}

/* ---------- Install ---------- */

.install { margin-top: 1.5rem; max-width: var(--measure); }
.install .install-hint {
  margin: 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--red);
  background: var(--white);
  font-size: 1rem;
}

/* ---------- Theme switch ---------- */

.theme-switch { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.theme-switch button {
  min-height: var(--tap);
  padding: 0 0.85rem;
  border: 1px solid var(--chrome);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}
.theme-switch button[aria-pressed="true"] {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  color: var(--blue);
  font-weight: 700;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -10rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 3px;
  background: var(--blue);
  color: var(--paper);
  font-weight: 700;
}
.skip-link:focus { top: calc(env(safe-area-inset-top) + 0.5rem); }
main:focus { outline: none; }

/* ---------- Copy, directions and calendar links ---------- */

.copy-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: 1px solid var(--chrome);
  border-radius: 3px;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.copy-button[data-copied] { border-color: var(--blue); }

.contacts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.contacts li > a { flex: 1; min-width: 0; }

.event-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.next-event .event-actions .button { margin-top: 0; }
.text-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--blue);
  font-weight: 600;
}
.event .event-links { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0 1.25rem; margin: 0; }
@media (min-width: 48rem) {
  .event .event-links { grid-column: 2 / -1; }
}

.checked { margin-top: 0.75rem; }

/* ---------- Text pages (privacy) ---------- */

.prose h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.3rem;
  color: var(--blue);
}
.prose ul { max-width: var(--measure); padding-left: 1.25rem; }
.prose li + li { margin-top: 0.5rem; }
.prose a { color: var(--blue); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
