/* Saratoga Dads — "race program" design.
   Fonts: Archivo (variable width/weight) + IBM Plex Mono, from Google Fonts. */

:root {
  --paper: #F3EDE0;
  --paper-light: #FBF8F1;
  --ink: #1A1F1C;
  --body: #353A35;
  --muted: #5B5F57;
  --red: #B7322A;
  --green: #1D4535;
  --on-green: #DCE5DD;
  --photo: #CFD3C5;
  --sans: Archivo, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --max: 1120px;
  --gutter: 32px;
}

/* ---------- Base ---------- */

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}

h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}
.join :focus-visible { outline-color: var(--paper); }
.signup :focus-visible { outline-color: var(--red); }

section[id] { scroll-margin-top: 16px; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  box-sizing: border-box;
}

.mono {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Wide, heavy capitals used for the masthead and section titles */
.display {
  font-weight: 900;
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: -0.015em;
  line-height: 0.95;
}

.rule-double { border-top: 3px double var(--ink); }
.rule-double + .section-title { margin-top: 56px; }

/* ---------- Track awning (top and bottom of page) ---------- */

.awning {
  height: 22px;
  background: repeating-linear-gradient(90deg, var(--red) 0 32px, var(--paper-light) 32px 64px);
}
.scallop {
  height: 16px;
  background:
    radial-gradient(circle at 16px 0, var(--red) 15.5px, transparent 16px) 0 0 / 64px 16px repeat-x,
    radial-gradient(circle at 48px 0, var(--paper-light) 15.5px, transparent 16px) 0 0 / 64px 16px repeat-x;
}

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

.btn {
  display: inline-block;
  padding: 17px 26px;
  border: 0;
  border-radius: 2px;
  background: var(--red);
  color: #FFFFFF;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #9E2A23; }

/* ---------- Masthead ---------- */

.masthead {
  padding-top: 22px;
  text-align: center;
}
.brand {
  display: block;
  margin: 22px 0 10px;
  font-size: clamp(38px, 7.4vw, 90px);
  color: var(--green);
  text-decoration: none;
}
.tagline {
  margin-bottom: 16px;
  font-style: italic;
  font-size: 18px;
  color: var(--muted);
}
.masthead nav {
  display: flex;
  justify-content: center;
  gap: 36px;
  padding: 9px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.masthead nav a { text-decoration: none; }
.masthead nav a:hover { color: var(--red); }

/* ---------- Lead (hero) ---------- */

.lead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  padding-top: 48px;
  padding-bottom: 56px;
}
.kicker { color: var(--red); }
.lead h1 {
  margin: 10px 0 30px;
  font-weight: 800;
  font-stretch: 105%;
  font-size: clamp(40px, 5.4vw, 68px);
  line-height: 1;
  letter-spacing: -0.03em;
}
.lead h1 em { color: var(--red); }

/* Next hang callout under the headline */
.next-up {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: -6px 0 28px;
  padding: 18px 20px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
  text-decoration: none;
}
.next-up:hover { border-color: var(--red); }
.next-up .cloth { flex: none; }
.next-body { display: flex; flex-direction: column; gap: 2px; }
.next-label { color: var(--red); }
.next-name {
  font-weight: 800;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--green);
}
.next-when { font-family: var(--mono); font-size: 15px; }

/* Photo placeholders: double-ruled frame, like a printed photo plate */
.plate {
  background: var(--photo);
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 5px;
}
img.plate { display: block; width: 100%; object-fit: cover; }
.plate-hero { height: 400px; object-position: 45% 60%; }
.caption {
  margin-top: 14px;
  font-style: italic;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Program (events) ---------- */

.program {
  padding-top: 56px;
  padding-bottom: 64px;
}
.section-title { font-size: clamp(30px, 4.2vw, 50px); }
.section-sub {
  margin: 8px 0 28px;
  font-style: italic;
  color: var(--muted);
}
.program-table {
  width: 100%;
  border-collapse: collapse;
}
.program-table th {
  padding: 0 12px 8px 0;
  border-bottom: 2px solid var(--ink);
  text-align: left;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.program-table td {
  padding: 20px 12px 20px 0;
  border-bottom: 1px solid var(--ink);
  vertical-align: top;
}
.col-no { width: 72px; }
.col-where { width: 220px; }
.col-post { width: 120px; }
/* Saddle cloth: the numbered square a racehorse wears */
.cloth {
  display: grid;
  place-items: center;
  width: 48px;
  height: 56px;
  background: var(--red);
  color: #FFFFFF;
  font-weight: 900;
  font-stretch: 115%;
  font-size: 28px;
}
.event-name {
  display: block;
  font-weight: 700;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.event-desc {
  display: block;
  margin-top: 2px;
  font-style: italic;
  color: var(--muted);
}
.program-table .data {
  font-family: var(--mono);
  font-size: 14px;
}
.program-note {
  margin-top: 14px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---------- About ---------- */

.about {
  padding-top: 56px;
  padding-bottom: 72px;
}
.about-body {
  max-width: 720px;
  margin-top: 28px;
}
.about-lead {
  font-size: 21px;
  line-height: 1.5;
  color: var(--body);
}
.about-hi {
  margin-top: 20px;
  font-weight: 700;
  font-size: 21px;
  color: var(--green);
}
.about-note {
  margin-top: 16px;
  color: var(--muted);
}

/* ---------- Join ---------- */

.join {
  padding-top: 72px;
  padding-bottom: 80px;
  background: var(--green);
  color: var(--paper);
}
.join-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.join h2 { font-size: clamp(36px, 4.4vw, 58px); }
.join-copy p {
  max-width: 420px;
  margin-top: 20px;
  font-size: 19px;
  color: var(--on-green);
}
.signup {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 32px;
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
}
.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.optional { color: var(--muted); }
.field input {
  height: 48px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--paper-light);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
}
.field input::placeholder { color: #75796F; }
.field input:focus-visible { outline-offset: 1px; }
.field input[aria-invalid="true"] { border: 2px solid var(--red); }
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.turnstile:empty { display: none; }
.form-note a { color: inherit; }
.signup .btn { margin-top: 4px; width: 100%; padding: 18px 26px; }
.signup .btn:disabled { opacity: 0.7; cursor: progress; }
.form-note { font-size: 13px; color: var(--muted); }
.form-error {
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
}
.form-error:empty { display: none; }
.signup-done {
  padding: 32px;
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

/* ---------- Plain message page (used by /api/signup errors) ---------- */

.message {
  padding-top: 72px;
  padding-bottom: 96px;
}
.message p { margin: 16px 0 28px; font-size: 19px; color: var(--body); }

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  :root { --gutter: 18px; }
  body { -webkit-tap-highlight-color: transparent; }
  .brand { margin: 18px 0 6px; }
  .tagline { margin-bottom: 12px; font-size: 16px; }
  /* Bigger tap targets in the nav and footer */
  .masthead nav { gap: 0; padding: 0; font-size: 12px; letter-spacing: 0.1em; }
  .masthead nav a { padding: 12px 8px; }
  .site-footer a { display: inline-block; padding: 6px 0; }
  /* Tighter spacing between sections so the page scrolls less */
  .lead { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 28px; padding-bottom: 24px; }
  .lead h1 { margin-bottom: 22px; }
  .lead .btn { display: block; text-align: center; }
  .next-up { margin-bottom: 18px; padding: 16px; }
  .next-name { font-size: 21px; }
  .plate-hero { height: 220px; }
  .program, .about { padding-top: 24px; padding-bottom: 32px; }
  .rule-double + .section-title { margin-top: 28px; }
  .section-sub { margin-bottom: 20px; }
  .about-body { margin-top: 20px; }
  .about-lead { font-size: 19px; }
  .about-hi { font-size: 19px; }
  .join { padding-top: 48px; padding-bottom: 48px; }
  .join-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .join-copy p { margin-top: 14px; font-size: 17px; }
  .signup { padding: 22px 18px; gap: 14px; }
  .pair { gap: 12px; }
}

/* Program table becomes stacked cards on phones */
@media (max-width: 640px) {
  .program-table thead { display: none; }
  .program-table tr {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr);
    column-gap: 12px;
    padding: 18px 0;
    border-bottom: 1px solid var(--ink);
  }
  .program-table tbody tr:first-child { border-top: 2px solid var(--ink); }
  .program-table td { padding: 0; border: 0; }
  .program-table td:first-child { grid-row: span 3; }
  .program-table .data { margin-top: 8px; font-size: 13px; }
  .program-table .data + .data { margin-top: 2px; }
  .program-table .data::before { content: attr(data-label) ": "; color: var(--muted); }
}

/* Smallest phones: keep all four nav links on one line */
@media (max-width: 360px) {
  .masthead nav a { padding: 12px 5px; }
}
