/* ──────────────────────────────────────────────────────────────────────────
   Money Caddie · Scramble Portal — design tokens & base components
   One stylesheet, every page. No Tailwind CDN, no inline styles.
   ────────────────────────────────────────────────────────────────────────── */

/* Self-hosted type (latin subsets, variable fonts). Served from /scramble/fonts/. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Brand */
  --pine:        #0F3D2E;   /* primary surfaces, nav, headers */
  --pine-deep:   #0A2C21;   /* nav hover / TV background */
  --fairway:     #1F6B45;   /* interactive: buttons, links, focus */
  --fairway-hi:  #27804F;
  --mint:        #DCEBE1;   /* tinted surfaces on cream */
  --cream:       #F6F3EA;   /* page background */
  --cream-2:     #EFEBDF;   /* card borders / zebra */
  --paper:       #FFFFFF;   /* cards */
  --ink:         #14201A;   /* text */
  --ink-2:       #4A5751;   /* secondary text (AA on cream) */
  --ink-3:       #6F7B75;   /* tertiary text (AA on white, large/semibold only) */
  --line:        #E3DED0;

  /* Gold — reserved: LIVE, leader, eagle. Nothing else. */
  --gold:        #C9A84C;
  --gold-soft:   #F3E9CB;

  /* Semantic */
  --under:       #C8102E;   /* under par */
  --over:        #1F3A5F;   /* over par */
  --danger:      #B42318;
  --danger-soft: #FCEBE9;
  --warn:        #B54708;
  --warn-soft:   #FEF0C7;
  --ok:          #1F6B45;
  --ok-soft:     #DCEBE1;
  --info:        #1F3A5F;
  --info-soft:   #E4EBF4;

  /* Type */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Shape */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20,32,26,.06), 0 1px 1px rgba(20,32,26,.04);
  --shadow-md: 0 4px 14px rgba(20,32,26,.08), 0 1px 3px rgba(20,32,26,.06);
  --shadow-lg: 0 16px 40px rgba(20,32,26,.14);

  /* Layout */
  --container: 1120px;
  --nav-h: 60px;
}

/* ── Reset-ish ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: var(--fairway); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; }
img, svg { display: block; }
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--fairway); outline-offset: 2px; border-radius: var(--r-sm); }

/* ── Type scale ──────────────────────────────────────────────────────────── */
.display   { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.display-xl{ font-size: clamp(36px, 5vw, 56px); line-height: 1.02; }
.display-lg{ font-size: clamp(28px, 3.5vw, 40px); }
.display-md{ font-size: 26px; }
.eyebrow   { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow.on-dark { color: rgba(255,255,255,.6); }
.muted     { color: var(--ink-2); }
.small     { font-size: 13px; }
.tiny      { font-size: 12px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Nav (one nav, every page) ───────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 40; height: var(--nav-h);
  background: var(--pine); color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.nav .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.nav-brand:hover { text-decoration: none; }
.nav-brand > span:last-child { display: flex; flex-direction: column; }
.nav-brand .mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--fairway);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; color: #fff;
}
.nav-brand img.mark { display: block; object-fit: cover; background: none; }
.nav-brand .name { font-weight: 600; font-size: 15px; line-height: 1; }
.nav-brand .sub  { font-size: 11px; color: rgba(255,255,255,.55); line-height: 1; margin-top: 3px; }
.nav-crumb { color: rgba(255,255,255,.5); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.nav-crumb b { color: #fff; font-weight: 500; }
.nav-links { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.nav-links a { color: rgba(255,255,255,.75); }
.nav-links a:hover { color: #fff; text-decoration: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--pine);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  padding: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 720px) { .nav-links .hide-m { display: none; } }

/* ── Buttons (one set) ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--fairway); color: #fff; }
.btn-primary:hover { background: var(--fairway-hi); }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--fairway); }
.btn-ghost:hover { background: var(--mint); }
.btn-danger { background: transparent; color: var(--danger); border-color: #E9B7B2; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-on-dark { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.18); }
.btn-on-dark:hover { background: rgba(255,255,255,.2); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 15px; font-weight: 600; }

/* ── Pills / badges ──────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.pill-live { background: var(--gold-soft); color: #7A5E12; }
.pill-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: pulse 1.6s ease-in-out infinite; }
.pill-draft { background: var(--cream-2); color: var(--ink-2); }
.pill-reg { background: var(--info-soft); color: var(--info); }
.pill-final { background: var(--mint); color: var(--pine); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: var(--cream-2); color: var(--ink-2); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .45; transform: scale(.8);} }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--ink-3); }
.hint { font-size: 12px; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--paper); color: var(--ink); font: inherit; outline: none; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--fairway); box-shadow: 0 0 0 3px rgba(31,107,69,.15); }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234A5751' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.segmented { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--paper); }
.segmented button { flex: 1; height: 40px; border: 0; background: transparent; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--pine); color: #fff; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  position: relative; padding: 12px 14px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--pine); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--pine); border-radius: 2px; }
.tab .count { margin-left: 6px; font-size: 11px; background: var(--cream-2); color: var(--ink-2); padding: 1px 7px; border-radius: var(--r-pill); }

/* ── Lifecycle stepper ───────────────────────────────────────────────────── */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.step { position: relative; padding: 12px 14px 12px 42px; border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--line); }
.step .n {
  position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--cream-2); color: var(--ink-2);
}
.step .t { font-weight: 600; font-size: 14px; }
.step .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.step.done { border-color: var(--mint); }
.step.done .n { background: var(--fairway); color: #fff; }
.step.current { border-color: var(--pine); background: var(--pine); color: #fff; box-shadow: var(--shadow-md); }
.step.current .n { background: var(--gold); color: var(--pine); }
.step.current .s { color: rgba(255,255,255,.7); }
.step.todo { opacity: .7; }
@media (max-width: 760px) { .stepper { grid-template-columns: 1fr 1fr; } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 14px 10px 12px; border-radius: var(--r-md);
  font-size: 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg);
  animation: toastIn .18s ease-out;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }

/* ── Modal / confirm ─────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(15,61,46,.45); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet { background: var(--paper); border-radius: var(--r-xl); width: 100%; max-width: 480px; padding: 28px; box-shadow: var(--shadow-lg); }
.hidden { display: none !important; }

/* ── Score symbology (shared by leaderboard + scorecards) ────────────────── */
.sc {
  display: inline-grid; place-items: center; width: 28px; height: 28px; font-weight: 600; font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--ink); position: relative;
}
.sc.birdie { color: var(--under); box-shadow: inset 0 0 0 1.5px var(--under); border-radius: 50%; }
.sc.eagle  { color: #8A6D1F; box-shadow: inset 0 0 0 1.5px var(--gold); border-radius: 50%; }
.sc.eagle::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--gold); }
.sc.bogey  { color: var(--over); box-shadow: inset 0 0 0 1.5px var(--over); border-radius: 3px; }
.sc.double { color: var(--over); box-shadow: inset 0 0 0 1.5px var(--over); border-radius: 3px; }
.sc.double::after { content: ''; position: absolute; inset: -4px; border-radius: 4px; border: 1.5px solid var(--over); }
.sc.empty { color: var(--line); }
.topar-under { color: var(--under); }
.topar-over  { color: var(--over); }
.topar-even  { color: var(--ink); }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-big { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: .08em; color: var(--pine); }
.divider { height: 1px; background: var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
