/* Theme: a club can restyle the whole page by editing these variables. */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #14181f;
  --muted: #4a5360;
  --border: #c4cad3;
  /* The default theme; /api/theme.css overrides these three (the values here are what it produces by default).
     --primary fills buttons, selected slots and the header band, --on-primary is the text on those fills, and
     --accent is link text and the outline and text of secondary buttons. */
  --primary: #0b5cad;
  --on-primary: #ffffff;
  --accent: #0b5cad;
  --focus: #b45309;
  --danger-bg: #fdecec;
  --danger-text: #8a1111;
  --notice-bg: #fff4d6;
  --notice-text: #5c3b00;
  --radius: 12px;
  --gap: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #1a1f26;
    --text: #f1f3f6;
    --muted: #b3bbc7;
    --border: #3b4350;
    --primary: #236cb5;
    --on-primary: #ffffff;
    --accent: #4f8ac4;
    --focus: #fbbf24;
    --danger-bg: #3a1618;
    --danger-text: #ffb4b4;
    --notice-bg: #3a2e0c;
    --notice-text: #ffe29a;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.5rem 0 1rem; overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 0.5rem; }

a { color: var(--accent); }

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

.event, .slots, form, .confirmation, .message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.event { margin-top: 0.5rem; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.details { white-space: pre-line; margin: 0; overflow-wrap: anywhere; }

.slots-left { color: var(--muted); margin: 0 0 var(--gap); font-weight: 600; }

.slot-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}
@media (min-width: 360px) {
  .slot-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 560px) {
  .slot-grid { grid-template-columns: repeat(4, 1fr); }
}

.slot, .button, input {
  font: inherit;
  font-size: 1rem; /* 16px minimum, or iOS zooms on focus */
}

.slot {
  width: 100%;
  min-height: 56px;
  min-width: 48px;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}
.slot[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.slot.past {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  color: var(--muted);
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
  cursor: not-allowed;
}
.slot.past .slot-time { text-decoration: line-through; }
.slot.past .slot-note { font-size: 0.8125rem; font-weight: 600; overflow-wrap: anywhere; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.5rem 1.25rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--accent);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}
.button.primary {
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
}
.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

form .button { width: 100%; margin-top: 0.5rem; }

.field { margin-bottom: 1rem; }
/* Grid and flex items default to min-width: auto, which lets a wide child (a date or time input) push them past the card. */
form, .field, .break-row { min-width: 0; max-width: 100%; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
}
/* iOS Safari gives date and time inputs an intrinsic minimum width and its own appearance, so on a narrow screen they
   overflow the card and neighbours overlap. Dropping the native appearance lets width and height apply like any input;
   without an explicit height an empty one collapses on iOS. The line-height fills the content box (48px less the borders),
   which centres the value; the value is centred by default and must be left-aligned like the other fields. */
input[type="date"], input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding-block: 0;
  line-height: 44px;
}
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; }
input[aria-invalid="true"] { border-color: var(--danger-text); }

.field-error:not(:empty), .form-error:not(:empty) {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  color: var(--danger-text);
  background: var(--danger-bg);
  border-radius: 8px;
  font-weight: 600;
}
.form-error:not(:empty) { margin: 0 0 1rem; }
.field-error:empty { margin: 0; }

.notice {
  margin: 0 0 var(--gap);
  padding: 0.75rem 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--notice-text);
  background: var(--notice-bg);
  border: 2px solid currentColor;
  border-radius: var(--radius);
}

/* The link sits on the notice's own background, which the accent colour isn't checked against. */
.notice a { color: inherit; }

.privacy { margin: 0 0 1rem; color: var(--muted); font-size: 0.9375rem; }
.privacy h3 { margin: 0 0 0.25rem; font-size: 1rem; color: var(--text); }
.privacy p { margin: 0 0 0.5rem; white-space: pre-line; overflow-wrap: anywhere; }
.privacy p:last-child { margin-bottom: 0; }

.progress { margin: 0.5rem 0 0; color: var(--muted); }
.progress:empty { margin: 0; }

.message p { margin: 0; }
.message button { margin-top: 1rem; }

.confirmation h1 { font-size: 2rem; }
.event-name { margin: 0 0 1rem; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.confirmation .details { margin-bottom: 1rem; }
.actions { display: grid; gap: var(--gap); margin: 1rem 0 0.5rem; }
@media (min-width: 420px) {
  .actions { grid-template-columns: 1fr 1fr; }
}
.copy-status { min-height: 1.5em; margin: 0 0 0.5rem; font-weight: 600; }
.keep { margin: 0; color: var(--muted); }

/* Off-screen but still selectable, for the legacy copy fallback. */
.clipboard-buffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .slot, .button { transition: background-color 0.15s, color 0.15s; }
}

/* Admin sign-in page (public/admin/login.html) and first-run setup page (public/setup.html). */
.login { max-width: 24rem; padding-top: 2rem; }
.login form { margin-top: 0; }
.login .message .button { display: flex; width: 100%; margin: 0 0 1rem; }

/* The admin secret, shown once on the setup page: one unbroken, selectable string in a monospace block. */
.message .secret {
  margin: 1rem 0;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.0625rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow-wrap: anywhere;
  user-select: all;
}
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 48px; margin: 0 0 0.5rem; }
.check input { display: inline-block; flex: none; width: 24px; min-height: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.login .message .button:disabled { margin-bottom: 0.5rem; cursor: not-allowed; }
.login .message .hint { margin: 0 0 0.5rem; color: var(--muted); }
.login .message .copy-status { margin: 0.5rem 0 1rem; }

/* Landing page (public/index.html): one big tap target per event. */
.event-links { list-style: none; margin: 0; padding: 0; }
.event-link {
  display: block;
  min-height: 48px;
  padding: 0.75rem 1rem;
  margin-bottom: var(--gap);
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}
.event-link-name { display: block; font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.event-link-when { display: block; color: var(--muted); }

/* Branding (public/branding.js): the band is the primary colour, so everything in it uses the text colour for it. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 1rem;
  color: var(--on-primary);
  background: var(--primary);
}
.site-header a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: inherit;
  overflow-wrap: anywhere;
}
/* The usual focus colour has no guaranteed contrast against the band; the text colour does. */
.site-header a:focus-visible { outline-color: currentColor; }
/* At most the band's width, so a wide logo can't push it past a 320px screen; the band wraps, so a wide logo takes a
   row to itself at a legible height instead of shrinking beside the name. */
.site-logo { max-height: 40px; max-width: 100%; width: auto; height: auto; flex: 0 1 auto; }
.site-footer { max-width: 40rem; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); }
.site-footer a { display: inline-flex; align-items: center; min-height: 48px; }
