/* Ballwashers — design tokens and layout. Mobile-first: read outdoors, one-handed. */

:root {
  --sky: #41b6f0;
  --sky-deep: #0b6fa4;
  --paper: #fcfcfd;
  --ink: #10151a;
  --under: #c8102e;
  --birdie: #2f9e44;
  --rule: #dce3e8;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'SF Pro Text', -apple-system, ui-monospace, 'Helvetica Neue', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1216;
    --ink: #f4f6f8;
    --rule: #2a323a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sky-deep); }

button, input, select {
  font: inherit;
  color: inherit;
}

/* --- topbar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--sky);
  color: #fff;
}
.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
}

/* --- drawer --- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 29;
}
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 80vw);
  background: var(--paper);
  z-index: 30;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  padding: 16px 0;
  overflow-y: auto;
}
.drawer a, .drawer button.drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 20px;
  min-height: 48px;
  text-decoration: none;
  color: var(--ink);
  font-size: 17px;
  border: none;
  background: none;
  cursor: pointer;
}
.drawer a:hover, .drawer button.drawer-item:hover { background: color-mix(in srgb, var(--sky) 10%, transparent); }
.drawer hr { border: none; border-top: 1px solid var(--rule); margin: 8px 0; }
.drawer-year { padding: 6px 20px 14px; margin-bottom: 0; }
.drawer-item-inline {
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--sky-deep);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.drawer-menu-error { padding: 14px 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.year-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

/* --- layout --- */

main { padding: 16px; max-width: 720px; margin: 0 auto; }
h1, h2, h3 { font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--sky-deep); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--sky-deep); }
.field input, .field select, .field textarea {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  font-size: 17px;
  background: var(--paper);
  color: var(--ink);
  min-height: 48px;
}
.field textarea { min-height: 96px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  border: none;
  background: var(--sky);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--sky-deep); border: 1px solid var(--sky-deep); }
.btn.danger { background: var(--under); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

/* --- person picker: searchable name/email lookup over GET /users --- */

.person-picker { display: flex; flex-direction: column; gap: 6px; }
.person-picker input {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  font-size: 17px;
  background: var(--paper);
  color: var(--ink);
  min-height: 48px;
}
.person-picker-results { display: flex; flex-direction: column; gap: 4px; }
.person-picker-result {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.account-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }

/* --- tabs (leaderboard / day1 / day2) --- */

.tabs { display: flex; border-bottom: 1px solid var(--rule); margin-bottom: 16px; position: sticky; top: 56px; background: var(--paper); z-index: 10; }
.tab {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  min-height: 48px;
  border: none;
  background: none;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--sky-deep); border-bottom-color: var(--sky); }

/* --- leaderboard --- */

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.team-rank { width: 28px; font-weight: 700; color: var(--sky-deep); }
.team-name { flex: 1; font-size: 17px; font-weight: 600; }
.team-score { font-family: var(--font-num); font-weight: 700; font-size: 19px; min-width: 44px; text-align: right; }
.team-score.under { color: var(--under); }
.team-detail { padding: 4px 0 12px 32px; }
.pairing-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 15px; }
.pairing-row a { color: var(--ink); text-decoration: none; font-weight: 600; }
.pairing-score { font-family: var(--font-num); font-weight: 700; }

/* --- scorecard: vertical, one card per hole (mirrors the iOS app's ScorecardView/ScoreView —
   a scrolling list with everything entered inline, no modal) --- */

.scorecard-header { margin-bottom: 12px; }
.scorecard-total { font-size: 22px; font-weight: 800; font-family: var(--font-num); }

.hole-list { display: flex; flex-direction: column; gap: 12px; }
.hole-card { border: 1px solid var(--rule); border-radius: 12px; padding: 14px; }
.hole-card-head { display: flex; justify-content: space-between; margin-bottom: 12px; }
.hole-card-field { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hole-card-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--sky-deep);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.hole-card-field strong { font-family: var(--font-num); font-size: 20px; font-weight: 800; }
.hole-card-score { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding: 2px 6px; }
.hole-card-score.under { color: var(--under); }

.hole-rel-row { display: flex; gap: 8px; margin-bottom: 10px; }
.hole-rel-row .btn { flex: 1; color: #fff; }
.hole-rel-row .btn.birdie { background: var(--birdie); }
.hole-rel-row .btn.par { background: var(--sky-deep); }
.hole-rel-row .btn.bogey { background: var(--under); }

.hole-num-row { display: flex; flex-wrap: wrap; gap: 6px; }
.hole-num-row button {
  flex: 1 1 30px;
  min-height: 44px;
  min-width: 30px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.hole-num-row button.selected { background: var(--sky); color: #fff; border-color: var(--sky); }

/* score glyphs: golf's own notation, drawn as borders around the number */
.glyph-eagle { box-shadow: 0 0 0 2px currentColor, 0 0 0 4px var(--paper), 0 0 0 5px currentColor; border-radius: 50%; }
.glyph-birdie { box-shadow: 0 0 0 2px currentColor; border-radius: 50%; }
.glyph-par { }
.glyph-bogey { box-shadow: 0 0 0 2px currentColor; border-radius: 3px; }
.glyph-double { box-shadow: 0 0 0 2px currentColor, 0 0 0 4px var(--paper), 0 0 0 5px currentColor; border-radius: 3px; }

/* --- misc --- */

.spinner { display: flex; justify-content: center; padding: 40px; }
.spinner-ball { width: 28px; height: 28px; border-radius: 50%; background: var(--sky); animation: bob 0.9s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-10px); opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .spinner-ball { animation: none; } }

.trash-item { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.trash-author { font-weight: 700; color: var(--sky-deep); }

.error-state { padding: 24px 0; }
.error-state p { color: var(--ink); opacity: 0.8; }

/* --- login --- */

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(165deg, var(--sky) 0%, var(--sky-deep) 100%);
}
.login-mark {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  color: #fff;
}
/* The injected SVG carries its own hardcoded width/height (pt units, from the source trace)
   — without this, it renders at intrinsic size and overflows .login-mark's 76px box instead
   of respecting it. */
.login-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.login-mark.working { animation: bob 0.9s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .login-mark.working { animation: none; } }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}
.login-title {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  text-align: center;
}
.login-subtitle {
  margin: 0 0 24px;
  font-size: 15px;
  text-align: center;
  color: var(--sky-deep);
}
.login-form .btn { width: 100%; margin-top: 4px; }
.login-error {
  font-size: 15px;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 15px;
}
.login-links button {
  background: none;
  border: none;
  color: var(--sky-deep);
  font: inherit;
  padding: 8px 0;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
}

.hole-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.hole-table th, .hole-table td { padding: 8px; border-bottom: 1px solid var(--rule); text-align: left; }

/* --- draft board --- */
/* Meant for one big screen at draft night, not one-handed on a phone — widen the shared
   `main { max-width: 720px }` layout just for this view rather than everywhere. */
#outlet:has(.draft-board) { max-width: 1400px; }

.draft-layout { display: flex; gap: 20px; align-items: flex-start; }
.draft-available {
  flex: 0 0 260px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}
.draft-player-list { display: flex; flex-direction: column; gap: 8px; }
.draft-player {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.draft-player.selected { background: var(--sky); color: #fff; border-color: var(--sky); }

.draft-teams {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.draft-team { border: 1px solid var(--rule); border-radius: 12px; padding: 14px; }
.draft-team h3 { margin-top: 0; }
.draft-slots { display: flex; flex-direction: column; gap: 8px; }
.draft-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px dashed var(--rule);
}
.draft-slot.filled { border-style: solid; background: color-mix(in srgb, var(--sky) 8%, transparent); }
.draft-slot.open.clickable { cursor: pointer; border-color: var(--sky-deep); }
.draft-slot.open.clickable:hover { background: color-mix(in srgb, var(--sky) 15%, transparent); }
.draft-slot-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sky-deep);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.draft-slot-name { flex: 1; font-weight: 600; }
.draft-slot-undo {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: none;
  color: var(--under);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 640px) {
  .draft-layout { flex-direction: column; }
  .draft-available { position: static; max-height: none; width: 100%; }
}

/* --- history page --- */

.history-section { margin-bottom: 32px; }
.history-intro { color: var(--sky-deep); font-weight: 600; }
.history-note { font-size: 14px; opacity: 0.75; margin: 4px 0 12px; }
.plain-list { margin: 0 0 12px; padding-left: 20px; font-size: 15px; }
.plain-list li { margin-bottom: 4px; }

.champion-year { width: 48px; flex-shrink: 0; font-weight: 700; color: var(--sky-deep); font-family: var(--font-num); }

.trophy-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.trophy-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sky) 12%, transparent);
  color: var(--sky-deep);
  font-weight: 700;
  font-size: 14px;
}

.award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.award-card { border: 1px solid var(--rule); border-radius: 12px; padding: 14px; }
.award-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--sky-deep); }
.award-value { font-size: 17px; font-weight: 800; margin-top: 4px; }
.award-sub { font-size: 13px; opacity: 0.8; margin-top: 4px; }

.stat-table { font-size: 14px; }
.stat-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--sky-deep); }

.bar-chart { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 20px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bar-label { width: 40px; flex-shrink: 0; font-weight: 700; }
.bar-day { width: 20px; flex-shrink: 0; opacity: 0.6; font-size: 11px; }
.bar-track { flex: 1; height: 16px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.bar-fill { height: 100%; }
.bar-fill.good { background: var(--birdie); }
.bar-fill.bad { background: var(--under); }
.bar-value { width: 40px; flex-shrink: 0; text-align: right; font-family: var(--font-num); font-weight: 700; }

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