/* FairwayDesk — Below Zero Golf brand tokens and base styles. */
:root {
  --navy: #0E2236;
  --frost: #EEF6FA;
  --ice: #CFE6F2;
  --mid-blue: #2D5877;
  --deep-hole: #060F18;
  --flag-orange: #E8602C;      /* accent on light; graphics and large text only */
  --flag-orange-on-navy: #F26B3A;
  --white: #FFFFFF;
  --error: #A3261B;
  --error-bg: #FBE9E6;
  --ok: #1E6B3A;
  --ok-bg: #E4F3EA;

  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Type scale: Below Zero Golf Brand Style Guide v1.0, section 05 (Typography).
     These five are the ONLY type styles allowed. Every rule below uses one of them via
     `font: var(--type-...)`. tests/js/brand-typography.test.js fails on anything else. */
  --type-display: 700 40px/44px var(--font-head);      /* Display: Space Grotesk Bold 40/44 */
  --type-heading: 700 26px/32px var(--font-head);      /* Heading: Space Grotesk Bold 26/32 (also the wordmark) */
  --type-body: 400 16px/26px var(--font-body);         /* Body: Inter Regular 16/26 */
  --type-body-strong: 600 16px/26px var(--font-body);  /* Emphasis: Inter Semibold 16/26 */
  --type-label: 500 12px/18px var(--font-head);        /* Label: Space Grotesk Medium 12, caps, +3 tracking */
  --label-tracking: 3px;
  --tap: 48px;
  --radius: 10px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--frost);
  color: var(--navy);
  font: var(--type-body);
}
img { max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 .5em; }
h1 { font: var(--type-display); }
h2 { font: var(--type-heading); }
h3, b, strong, th, legend, label, .emphasis { font: var(--type-body-strong); }
small, input, select, textarea, option, td { font: var(--type-body); }
.label-caps, .label { font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking); }
.label-caps { color: var(--mid-blue); }
p { margin: 0 0 1em; }
a { color: var(--mid-blue); }

/* ---------- header ---------- */
.site-header {
  background: var(--navy); color: var(--frost);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px var(--gutter);
  border-bottom: 4px solid var(--flag-orange-on-navy);
}
/* Below Zero Golf logo: supplied file, used unmodified. Width only, so it keeps its own
   aspect ratio; never below 150 px (brand minimum for the horizontal logo). */
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--frost); padding: 4px 0; }
.brand-logo { display: block; flex: none; width: 184px; min-width: 150px; max-width: none; height: auto; }
.brand-product {
  font: var(--type-heading);
  padding-left: 16px; border-left: 2px solid var(--mid-blue); white-space: nowrap;
}
@media (max-width: 480px) {
  .brand-logo { width: 156px; }
  .brand { gap: 12px; }
  .brand-product { padding-left: 12px; }
  .site-header .who { width: 100%; justify-content: flex-end; }
}
@media (max-width: 400px) { .site-header .who > span { display: none; } }
.site-header .who { display: flex; gap: 12px; align-items: center; color: var(--ice); overflow-wrap: anywhere; text-align: right; }

/* ---------- admin nav ---------- */
.admin-nav {
  background: var(--white); border-bottom: 1px solid var(--ice);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
  padding: 0 var(--gutter);
}
.admin-nav .nav-course { font: var(--type-body-strong); padding: 8px 0; }
.admin-nav .nav-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.admin-nav a {
  display: inline-flex; align-items: center; min-height: var(--tap);
  font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking);
  color: var(--mid-blue); text-decoration: none; border-bottom: 3px solid transparent;
}
.admin-nav a[aria-current=page] { color: var(--navy); border-bottom-color: var(--navy); }

main { max-width: 760px; margin: 0 auto; padding: 24px var(--gutter) 64px; }

/* ---------- cards ---------- */
.card {
  background: var(--white); border: 1px solid var(--ice); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card > :last-child { margin-bottom: 0; }

/* ---------- forms ---------- */
label { display: block; margin-bottom: 6px; }
.hint { font: var(--type-body); color: var(--mid-blue); margin: 4px 0 0; }
input[type=text], input[type=number], input:not([type]), input[inputmode] {
  font: var(--type-body); color: var(--navy); background: var(--white);
  min-height: var(--tap); width: 100%; padding: 10px 12px;
  border: 2px solid var(--mid-blue); border-radius: 8px;
}
input:focus-visible, button:focus-visible, a:focus-visible, .file-btn:focus-within {
  outline: 3px solid var(--mid-blue); outline-offset: 2px;
}
input[aria-invalid=true] { border-color: var(--error); background: var(--error-bg); }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 140px; margin-bottom: 0; }

/* ---------- buttons ---------- */
button, .btn {
  font: var(--type-body-strong);
  min-height: var(--tap); min-width: var(--tap); padding: 0 20px;
  border-radius: 8px; border: 2px solid var(--navy);
  background: var(--navy); color: var(--frost);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--flag-orange); border-color: var(--flag-orange); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn-block { width: 100%; }
.site-header button { background: transparent; color: var(--frost); border-color: var(--ice); padding: 0 14px; }

/* ---------- messages ---------- */
.msg { border-radius: 8px; padding: 12px 14px; margin: 12px 0; font: var(--type-body-strong); }
.msg-error { background: var(--error-bg); color: var(--error); }
.msg-ok { background: var(--ok-bg); color: var(--ok); }
.msg p { margin: 0; }
.msg p + ul { margin-top: .4em; }
.msg ul { margin: 0; padding-left: 1.2em; font: var(--type-body); }

/* ---------- sign-in ---------- */
.signin { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.signin .btn { width: 100%; margin-top: 12px; background: var(--white); color: var(--navy); border-color: var(--navy); }
.signin svg { width: 20px; height: 20px; flex: none; }

/* ---------- course profile ---------- */
.logo-box {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 320px; min-height: 140px; padding: 12px;
  border: 2px dashed var(--ice); border-radius: var(--radius); background: var(--frost);
  margin-bottom: 12px; color: var(--mid-blue); text-align: center;
}
.logo-box img { max-height: 160px; object-fit: contain; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.required { color: var(--error); font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking); vertical-align: middle; }

.tee-list { list-style: none; margin: 0 0 16px; padding: 0; }
.tee-list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 14px 0; border-bottom: 1px solid var(--ice);
}
.tee-list li:first-child { border-top: 1px solid var(--ice); }
.tee-list .tee-name { font: var(--type-body-strong); flex: 1 1 100%; }
.tee-list .tee-facts { flex: 1 1 auto; color: var(--mid-blue); }
.tee-list .tee-actions { display: flex; gap: 8px; }
.empty { color: var(--mid-blue); }

/* ---------- tee holes ---------- */
.nines { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 640px) { .nines { grid-template-columns: 1fr 1fr; } }
.holes { width: 100%; border-collapse: collapse; }
.holes caption { text-align: left; padding-bottom: 6px; }
.holes th, .holes td { padding: 4px; text-align: center; }
.holes th[scope=row] { width: 3.2em; }
.holes thead th { font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking); color: var(--mid-blue); }
.holes input { text-align: center; padding: 8px 4px; }
.holes tfoot td, .holes tfoot th { font: var(--type-body-strong); border-top: 2px solid var(--ice); padding-top: 8px; }
.holes .hole-err td { padding: 0 4px 8px; text-align: left; color: var(--error); font: var(--type-body-strong); }

.sticky-save {
  position: sticky; bottom: 0; background: var(--frost);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ice);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.sticky-save .btn-primary { flex: 1 1 200px; }
.back { display: inline-flex; align-items: center; min-height: var(--tap); margin-bottom: 8px; font: var(--type-body-strong); }

/* ---------- events ---------- */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { padding: 16px 0; border-bottom: 1px solid var(--ice); display: grid; gap: 6px; }
.event-list li:first-child { border-top: 1px solid var(--ice); }
.event-list .event-name { font: var(--type-body-strong); }
.event-list .event-facts { color: var(--mid-blue); }
.event-list .tee-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.state {
  display: inline-block; font: var(--type-label); text-transform: uppercase;
  letter-spacing: var(--label-tracking); padding: 3px 8px; border-radius: 999px;
  background: var(--ice); color: var(--navy); vertical-align: middle; margin-left: 6px;
}
.state-live { background: var(--navy); color: var(--frost); }
.state-final { background: var(--deep-hole); color: var(--frost); }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

/* ---------- event form ---------- */
fieldset { border: 0; margin: 0 0 20px; padding: 0; min-width: 0; }
legend { margin-bottom: 8px; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.choice span { min-width: 0; overflow-wrap: anywhere; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; margin: 0; font: var(--type-body);
  min-height: var(--tap); padding: 12px 14px; border: 2px solid var(--ice); border-radius: 8px; background: var(--white);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--navy); background: var(--frost); }
.choice:has(input:disabled) { cursor: default; }
.choice input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--navy); }
.choice b { display: block; }
.choice small { display: block; color: var(--mid-blue); }
.nine-note {
  background: var(--ice); color: var(--navy); border-left: 6px solid var(--mid-blue);
  border-radius: 8px; padding: 14px 16px; margin: 0 0 20px; font: var(--type-body-strong);
}
.field-err { color: var(--error); font: var(--type-body-strong); margin: 6px 0 0; }
input[type=date], input[type=time] {
  font: var(--type-body); color: var(--navy); background: var(--white); min-height: var(--tap); width: 100%;
  padding: 10px 12px; border: 2px solid var(--mid-blue); border-radius: 8px;
}
.suffix { display: flex; align-items: center; gap: 8px; max-width: 160px; }
.suffix span { font: var(--type-body-strong); }
.is-disabled { opacity: .55; pointer-events: none; }

/* ---------- groups ---------- */
input.short { max-width: 120px; }
select {
  font: var(--type-body); color: var(--navy); background: var(--white); min-height: var(--tap); max-width: 100%;
  padding: 8px 10px; border: 2px solid var(--mid-blue); border-radius: 8px;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.start-holes { max-width: 360px; margin-bottom: 8px; }
.start-holes input { max-width: 90px; }
.start-holes .slots { text-align: left; color: var(--mid-blue); font: var(--type-body-strong); }
.cap { background: var(--frost); border: 1px solid var(--ice); border-radius: 8px; padding: 14px 16px; margin: 4px 0 16px; }
.cap-line { font: var(--type-heading); margin: 0 0 4px; }
.cap-roster { margin: 0; color: var(--mid-blue); }
.cap-roster.cap-over { color: var(--error); font: var(--type-body-strong); }
.group-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 640px) { .group-list { grid-template-columns: 1fr 1fr; } }
.group { border: 1px solid var(--ice); border-radius: 8px; padding: 12px 14px; background: var(--white); min-width: 0; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.group-label { font: var(--type-body-strong); }
.group-count { color: var(--mid-blue); white-space: nowrap; }
.group-players { list-style: none; margin: 0; padding: 0; }
.group-players li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 6px 0; border-top: 1px solid var(--ice); }
.group-players li:first-child { border-top: 0; }
.player-name { font: var(--type-body-strong); overflow-wrap: anywhere; }
.player-tee { font: var(--type-body); color: var(--mid-blue); }
.move-label { margin: 0; font: var(--type-body); }
.group-empty { margin: 0; }
#unassigned { margin-top: 20px; }
.groups-summary { margin: 0 0 12px; }

/* ---------- roster ---------- */
input[type=email], input[type=tel] {
  font: var(--type-body); color: var(--navy); background: var(--white); min-height: var(--tap); width: 100%;
  padding: 10px 12px; border: 2px solid var(--mid-blue); border-radius: 8px;
}
select { width: 100%; }
.event-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-bottom: 8px; }
.event-head > div { flex: 1 1 240px; min-width: 0; }
.event-logo { display: block; width: auto; height: auto; max-width: 160px; max-height: 96px; flex: none; }
.event-head h1 { margin: 4px 0; overflow-wrap: anywhere; }
.event-sub { color: var(--mid-blue); margin: 0; }
.spots { font: var(--type-heading); margin: 16px 0; }
.player-list { list-style: none; margin: 0; padding: 0; }
.player { display: grid; gap: 2px; padding: 14px 0; border-bottom: 1px solid var(--ice); }
.player:first-child { border-top: 1px solid var(--ice); }
.player .player-facts, .player .player-contact { color: var(--mid-blue); overflow-wrap: anywhere; }
.player .tee-actions { display: flex; gap: 8px; margin-top: 6px; }
.edit-form { background: var(--frost); border-radius: 8px; padding: 12px; }
.form-actions { margin-top: 4px; }
.form-actions > button { flex: 1 1 160px; }
.links { display: grid; gap: 16px; }
.link-row { display: grid; gap: 6px; }
.link-row code { font: var(--type-body); background: var(--frost); border: 1px solid var(--ice); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.link-row .row { align-items: center; }
.row.fields { align-items: flex-start; }
.row.fields > .field { flex: 1 1 220px; margin-bottom: 16px; }

/* ---------- scoring page (sunlight: Navy on Frost, big targets, one hand) ---------- */
.msg-warn { background: var(--ice); color: var(--navy); border-left: 6px solid var(--navy); }
.msg > button { margin-top: 10px; }
.event-name { font: var(--type-body-strong); margin: 0; }
.scoring .event-logo { max-width: 96px; max-height: 56px; }
.scoring .event-head { margin-bottom: 4px; }
.hole { margin: 16px 0 24px; }
.hole h1 { margin: 0; }
.hole-par { font: var(--type-heading); margin: 4px 0 16px; color: var(--mid-blue); }
.score-players { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.score-player {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--white); border: 1px solid var(--ice); border-radius: var(--radius); padding: 12px 14px;
}
.score-who { display: grid; gap: 2px; min-width: 0; }
.score-who .player-facts { color: var(--mid-blue); }
.corrected { font: var(--type-body-strong); color: var(--mid-blue); }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.step {
  font: var(--type-heading); width: 56px; height: 56px; min-width: 56px; padding: 0; border-radius: 12px;
}
.strokes { font: var(--type-display); min-width: 48px; text-align: center; color: var(--navy); }
.stepper.read-only .strokes { min-width: 56px; }
.hole-nav { display: flex; gap: 10px; margin-top: 10px; }
.hole-nav > button { flex: 1 1 0; }
.hole-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.hole-chip { width: 100%; min-width: 0; padding: 0; height: 52px; border-radius: 10px; }
.hole-chip.open { background: var(--white); color: var(--navy); border-color: var(--ice); }
.hole-chip.done { background: var(--navy); color: var(--frost); border-color: var(--navy); }
.hole-chip.waiting { background: var(--white); color: var(--navy); border: 2px dashed var(--navy); }
.hole-chip[aria-current=true] { outline: 3px solid var(--mid-blue); outline-offset: 2px; }
#leaderboard-link { margin-top: 8px; }

.not-in { font: var(--type-body-strong); color: var(--mid-blue); white-space: nowrap; }
@media (max-width: 380px) {
  .brand-logo { width: 150px; }
  .brand { gap: 8px; }
  .brand-product { padding-left: 8px; }
}

/* ---------- leaderboard, phone layout (server-rendered at /l/<token>) ---------- */
.leaderboard .event-head h1 { margin: 4px 0 0; }
.lb-status { margin: 8px 0 16px; }
.lb-status .state { margin: 0 8px 0 0; }
.state-draft_published, .state-published { background: var(--ice); color: var(--navy); }
.lb-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--ice); border-radius: var(--radius); }
.lb-table thead th { font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking); color: var(--mid-blue); text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--ice); }
.lb-table td { padding: 10px 8px; border-bottom: 1px solid var(--ice); vertical-align: top; }
.lb-table .c-pos { width: 44px; font: var(--type-body-strong); }
.lb-table thead .c-pos { font: var(--type-label); text-transform: uppercase; letter-spacing: var(--label-tracking); }
.lb-table .c-num { text-align: right; white-space: nowrap; }
.lb-table .lb-score { font: var(--type-body-strong); }
.lb-name { display: block; font: var(--type-body-strong); overflow-wrap: anywhere; }
.lb-tee { display: block; color: var(--mid-blue); }
.lb-table tr.nr td { color: var(--mid-blue); }
.leaderboard .hint { margin-top: 12px; }

/* ---------- results (Admin) ---------- */
.state-live { background: var(--navy); color: var(--frost); }
.editor-row td { background: var(--frost); }
.editor { display: grid; gap: 10px; }
.editor p { margin: 0; }
.fix-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.fix-grid label { display: grid; gap: 2px; margin: 0; }
.fix-grid input { text-align: center; padding: 8px 4px; }
.fix-grid .corrected-input { border-color: var(--navy); background: var(--ice); }
.tie { border-top: 1px solid var(--ice); padding-top: 10px; margin-top: 10px; }
.tie:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.tie .group-players li { padding: 8px 0; }
.lb-table .row-btn { margin-top: 6px; }
.opt-in { margin: 0 0 16px; }
