/* Components for the whole app. Uses only semantic tokens from tokens.css (no raw colors here).
   Replaces the old styles.css and schedule.css. See /kit/ for every component and state. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: var(--text-md)/1.4 var(--font-ui); color: var(--text); background: var(--surface-page);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0 0 var(--space-2); }
h1 { font-size: var(--text-xl); }
h2 { font-size: 22px; }
.num, .score, .tee { font-variant-numeric: tabular-nums; }

/* ---- App bar ---- */
header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--brand); color: var(--on-brand); }
header button { font: inherit; border: 0; border-radius: var(--radius-pill); padding: var(--space-2) 14px; min-height: var(--tap); }
#title { display: flex; align-items: center; gap: 10px; background: transparent; color: var(--on-brand); padding-left: 0; cursor: pointer; }
#title .mark { width: 30px; height: 30px; color: var(--sand); flex: none; }
#title .wordmark { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.01em; }
#loc { background: var(--surface-page); color: var(--text); font-size: var(--text-sm); font-weight: 500; display: inline-flex; align-items: center; }
#loc::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); margin-right: 8px; }
#loc[aria-pressed="true"] { background: var(--sand); }
#loc[aria-pressed="true"]::before { background: var(--accent); }

/* ---- Banner and as-of notes (attention accent is a rule, never text) ---- */
#banner, .asof.stale { padding: var(--space-2) var(--space-3); background: var(--sand); color: var(--text); font-size: var(--text-sm); border-left: 4px solid var(--attention); }
.asof { margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 15px; font-weight: 600; }
.asof.stale { border-radius: var(--radius-sm); }

main { flex: 1; overflow: auto; padding: var(--space-3); padding-bottom: 88px; }

/* ---- Tab bar ---- */
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; font-size: var(--text-xs); font-weight: 500; border: 0; border-top: 3px solid transparent; background: transparent; padding: 8px 4px 6px; min-height: 56px; color: var(--text-muted); }
nav button svg { width: 24px; height: 24px; }
nav button.on { color: var(--brand); font-weight: 700; border-top-color: var(--brand); }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=search], select { width: 100%; font: inherit; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: var(--tap); background: var(--surface); color: var(--text); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.days label { display: flex; gap: 10px; align-items: center; font-weight: 400; margin: var(--space-1) 0; min-height: var(--tap); }
.days input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---- Buttons ---- */
.primary { width: 100%; margin-top: 18px; font: inherit; font-weight: 700; color: var(--on-brand); background: var(--brand); border: 0; border-radius: var(--radius-md); padding: var(--space-4) 14px; min-height: 48px; }
.refresh-btn { margin: var(--space-3) 0; }
button.refresh-btn:disabled { cursor: default; background: var(--text-muted); }
button.refresh-btn.busy { background: var(--accent); color: var(--on-accent); }
button.refresh-btn.done { background: var(--brand); }
button.refresh-btn.fail { background: var(--attention); color: var(--on-attention); }

/* ---- Cards and lists ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 10px var(--space-3); margin: var(--space-2) 0; display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.card.tall { min-height: 72px; align-items: flex-start; padding: var(--space-3); }
.card .grow { flex: 1; min-width: 0; }
.card .sub { color: var(--text-muted); font-size: var(--text-sm); }
.card .tee { font-size: 17px; font-weight: 600; margin-top: 2px; }
.card .status { font-size: 15px; margin-top: 2px; }
.card .status.warm { font-weight: 600; }
.card .status.warm::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--attention); margin-right: 6px; vertical-align: 1px; }
.card .score { font-size: var(--text-md); font-weight: 700; margin-top: var(--space-1); }
.star { font-size: 30px; line-height: 1; background: transparent; border: 0; min-width: 56px; min-height: 56px; color: var(--accent); }
.note { color: var(--text-muted); font-size: var(--text-sm); }
.empty { padding: var(--space-4); background: var(--surface-soft); border-radius: var(--radius-md); }

/* ---- Chips and segmented controls ---- */
.chips { display: flex; gap: var(--space-2); margin: 0 0 var(--space-2); overflow-x: auto; }
.chip { font: inherit; min-height: 48px; padding: 0 var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); white-space: nowrap; }
.chip.on { background: var(--chip-on-bg); border-color: var(--chip-on-bg); color: var(--chip-on-text); font-weight: 700; }
.controls { margin: 0 0 var(--space-2); }
.seg { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-2); overflow-x: auto; }
.seglabel { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); min-width: var(--tap); }
.search { margin: 0 0 var(--space-2); }
.search .note { margin: var(--space-1) 0 0; min-height: 20px; }

/* ---- Players ---- */
.avatar { position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--sand); border: 1px solid var(--border); }
.avatar .ini { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: var(--brand); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; background: var(--sand); }
.ghead { position: sticky; top: -12px; z-index: 2; margin: var(--space-4) -12px var(--space-1); padding: var(--space-2) var(--space-3); background: var(--sand); font-family: var(--font-ui); font-size: var(--text-md); font-weight: 700; letter-spacing: 0; border-bottom: 1px solid var(--border); }
.ghead .count { color: var(--text-muted); font-weight: 400; font-size: var(--text-sm); margin-left: var(--space-1); }

/* ---- Map screen ---- */
#map { height: calc(100vh - 360px); min-height: 260px; border-radius: var(--radius-md); }
.maptools { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; margin: 0 0 var(--space-2); }
.legend { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; font-size: var(--text-sm); color: var(--text-muted); }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--text-muted); margin-right: var(--space-1); vertical-align: -3px; }
.legend .me { background: var(--marker-me); }
.legend .fol { background: var(--marker-followed); box-shadow: 0 0 0 2px var(--brand); }
.legend .oth { background: var(--marker-player); }
#locate { font: inherit; font-size: var(--text-sm); font-weight: 600; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); }
#locate:disabled { opacity: .6; }

/* Markers drawn by public/coursemap.js */
.gpin { display: flex; align-items: center; justify-content: center; font: 700 12px/1 var(--font-ui); color: var(--white); border: 2px solid var(--white); box-shadow: var(--shadow-marker); }
.gpin.tee { background: var(--marker-tee); color: var(--on-brand); border-radius: 6px; }
.gpin.green { background: var(--marker-green); border-radius: 50%; }
.gpin.pa { background: var(--marker-practice); color: var(--text); border-color: var(--brand); border-radius: var(--radius-sm); }
.gplayer { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; background: var(--marker-player); color: var(--white); font: 700 11px/1 var(--font-ui); padding: 4px 6px; border-radius: var(--radius-pill); border: 2px solid var(--white); box-shadow: var(--shadow-marker); }
.gplayer.follow { background: var(--marker-followed); color: var(--text); border-color: var(--brand); font-size: var(--text-xs); padding: 5px 8px; box-shadow: 0 0 0 3px rgba(47, 125, 79, .55), var(--shadow-marker); }
.gplayer.low { opacity: .7; border-style: dashed; }
.gplayer i { display: none; }
