/* ============================================================================
   Handicap Tracker — handicaptracker.app
   Shared design system. One source of truth for every page.

   Aesthetic: "Clubhouse Light" — the visual language of the 3.0 App Store
   screenshot set. Pale green-tinted canvas, ink headlines, iOS system green
   as the single accent family, gold reserved for rating stars, white float
   cards with green-tinted borders, and the descending trend-line motif.
   Light + dark themes, system-aware with a manual toggle.

   Shape system (locked): interactive elements are pills (999px);
   containers and cards are 24px; device bezels are 44px. Nothing else.

   Accent contract:
     --accent          interactive green (buttons, links)   AA on white
     --accent-display  headline accent words (large text)   3:1+ large-only
     --green           motif green (trend line, bars, dots) graphics only
     --star            gold, rating stars only
   ========================================================================== */

@font-face {
  font-family: 'Geist';
  src: url('/assets/fonts/GeistVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  color-scheme: light dark;

  /* Surfaces & ink */
  --bg: #F7F9F7;
  --surface: #FFFFFF;
  --surface-2: #EDF3EE;
  --text: #101613;
  --text-2: #3C4540;
  --text-3: #5A6660;            /* AA 4.5:1+ on bg & white */

  /* Brand */
  --accent: #0C7A36;            /* interactive green — buttons, links */
  --accent-strong: #095C29;
  --accent-display: #0F9D45;    /* accent words at display sizes only */
  --green: #34C759;             /* motif green — graphics only */
  --green-deep: #28A745;        /* gradient pair for bars */
  --accent-dim: rgba(15, 157, 69, 0.09);
  --accent-glow: rgba(15, 157, 69, 0.16);
  --accent-border: rgba(15, 157, 69, 0.22);
  --star: #FFB400;              /* rating stars only */
  --gold: #0F9D45;              /* legacy var name: small labels (doc pages) */
  --gold-soft: rgba(15, 157, 69, 0.10);
  --on-accent: #FFFFFF;
  --cta-panel: #0D3B1F;         /* deep pine — CTA band + footers of trust */
  --on-cta: #F2F7F3;

  /* Lines & chrome */
  --nav-bg: rgba(247, 249, 247, 0.82);
  --nav-border: rgba(16, 22, 19, 0.07);
  --card-border: rgba(16, 22, 19, 0.09);
  --card-border-hover: rgba(16, 22, 19, 0.16);
  --card-border-green: rgba(15, 157, 69, 0.18);
  --btn-border: rgba(16, 22, 19, 0.14);
  --btn-border-hover: rgba(16, 22, 19, 0.26);
  --bar-muted: #DCE2DD;         /* non-counted bars in the best-8 dataviz */

  /* Shadows (tinted to the pine hue, never pure black) */
  --shadow-card: 0 22px 54px rgba(13, 59, 31, 0.14);
  --shadow-pill: 0 14px 36px rgba(13, 59, 31, 0.12);

  /* Phone frames */
  --phone-bezel: #0D0F0E;
  --phone-ring: rgba(255, 255, 255, 0.18);
  --phone-shadow: rgba(13, 59, 31, 0.22);

  /* Info / callout box (doc pages) */
  --info-bg: rgba(15, 157, 69, 0.07);
  --info-border: rgba(15, 157, 69, 0.24);
  --info-text: #0B5F2B;
}

/* System dark preference (when no manual choice stored) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B120E;
    --surface: #121A15;
    --surface-2: #17221A;
    --text: #EDF2EE;
    --text-2: #A6B4AA;
    --text-3: #85948B;

    --accent: #2FBF57;
    --accent-strong: #4ED07E;
    --accent-display: #4ECF7D;
    --green: #34C759;
    --green-deep: #28A745;
    --accent-dim: rgba(52, 199, 89, 0.12);
    --accent-glow: rgba(52, 199, 89, 0.18);
    --accent-border: rgba(52, 199, 89, 0.24);
    --star: #FFC94A;
    --gold: #4ECF7D;
    --gold-soft: rgba(78, 207, 125, 0.12);
    --on-accent: #06140C;
    --cta-panel: #10331D;
    --on-cta: #EDF5EF;

    --nav-bg: rgba(11, 18, 14, 0.78);
    --nav-border: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.07);
    --card-border-hover: rgba(255, 255, 255, 0.14);
    --card-border-green: rgba(52, 199, 89, 0.22);
    --btn-border: rgba(255, 255, 255, 0.12);
    --btn-border-hover: rgba(255, 255, 255, 0.24);
    --bar-muted: #243128;

    --shadow-card: 0 22px 54px rgba(0, 0, 0, 0.45);
    --shadow-pill: 0 14px 36px rgba(0, 0, 0, 0.4);

    --phone-bezel: #050806;
    --phone-ring: rgba(255, 255, 255, 0.1);
    --phone-shadow: rgba(0, 0, 0, 0.55);

    --info-bg: rgba(52, 199, 89, 0.09);
    --info-border: rgba(52, 199, 89, 0.24);
    --info-text: #8FDCAB;
  }
}

/* Explicit manual dark (mirror of the media-query block) */
:root[data-theme="dark"] {
  --bg: #0B120E;
  --surface: #121A15;
  --surface-2: #17221A;
  --text: #EDF2EE;
  --text-2: #A6B4AA;
  --text-3: #85948B;

  --accent: #2FBF57;
  --accent-strong: #4ED07E;
  --accent-display: #4ECF7D;
  --green: #34C759;
  --green-deep: #28A745;
  --accent-dim: rgba(52, 199, 89, 0.12);
  --accent-glow: rgba(52, 199, 89, 0.18);
  --accent-border: rgba(52, 199, 89, 0.24);
  --star: #FFC94A;
  --gold: #4ECF7D;
  --gold-soft: rgba(78, 207, 125, 0.12);
  --on-accent: #06140C;
  --cta-panel: #10331D;
  --on-cta: #EDF5EF;

  --nav-bg: rgba(11, 18, 14, 0.78);
  --nav-border: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-hover: rgba(255, 255, 255, 0.14);
  --card-border-green: rgba(52, 199, 89, 0.22);
  --btn-border: rgba(255, 255, 255, 0.12);
  --btn-border-hover: rgba(255, 255, 255, 0.24);
  --bar-muted: #243128;

  --shadow-card: 0 22px 54px rgba(0, 0, 0, 0.45);
  --shadow-pill: 0 14px 36px rgba(0, 0, 0, 0.4);

  --phone-bezel: #050806;
  --phone-ring: rgba(255, 255, 255, 0.1);
  --phone-shadow: rgba(0, 0, 0, 0.55);

  --info-bg: rgba(52, 199, 89, 0.09);
  --info-border: rgba(52, 199, 89, 0.24);
  --info-text: #8FDCAB;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.content { position: relative; z-index: 2; }

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 48px);
}

/* Tabular figures for anything numeric that should align */
.num { font-feature-settings: 'tnum' 1; font-variant-numeric: tabular-nums; }

/* ---- Skip link ----------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0 0 10px 0;
  font-size: 14px;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---- Nav ----------------------------------------------------------------- */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 13px 24px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--nav-border);
}

nav .inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.logo-icon { width: 34px; height: 34px; flex-shrink: 0; }
.logo-icon img {
  width: 100%; height: 100%;
  border-radius: 9px;
  display: block;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); }

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text); }

.nav-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 2px 14px var(--accent-glow);
}
.nav-badge:hover { transform: translateY(-1px); box-shadow: 0 5px 22px var(--accent-glow); background: var(--accent-strong); }
.nav-badge:active { transform: translateY(0); }

/* ---- Theme toggle -------------------------------------------------------- */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: 999px;
}
.theme-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  color: var(--text-3);
  padding: 0;
}
.theme-toggle button:hover { color: var(--text-2); }
.theme-toggle button.active { background: var(--accent-dim); color: var(--accent); }

/* ---- Buttons ------------------------------------------------------------- */
.btn-appstore {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 30px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-appstore:hover { transform: translateY(-2px); box-shadow: 0 8px 32px var(--accent-glow); background: var(--accent-strong); }
.btn-appstore:active { transform: translateY(0) scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 28px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.btn-secondary:hover { transform: translateY(-2px); border-color: var(--btn-border-hover); }
.btn-secondary:active { transform: translateY(0) scale(0.98); }

.btn-label-short { display: none; }

/* ---- Focus visibility (a11y) -------------------------------------------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---- Star glyph (rating strips) ------------------------------------------ */
.icon-star {
  display: inline-block;
  width: 16px; height: 16px;
  background: var(--star);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.icon-star.half { background: linear-gradient(90deg, var(--star) 50%, var(--bar-muted) 50%); }

/* ---- Footer -------------------------------------------------------------- */
footer {
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 24px;
  border-top: 1px solid var(--card-border);
}
.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 24px;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand img { width: 30px; height: 30px; border-radius: 7px; }
.footer-brand-info strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.footer-brand-info span { font-size: 13px; color: var(--text-2); }

.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--text); }

.footer-disclaimer {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
  max-width: 760px;
  margin: 0 auto 14px;
  text-align: center;
}
.footer-copy { font-size: 12px; color: var(--text-3); text-align: center; }
.footer-copy a { color: var(--text-2); text-decoration: none; }
.footer-copy a:hover { color: var(--text); }

/* ---- Reveal-on-scroll ----------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .fade-in { opacity: 1; transform: none; }
}

/* ---- Small screens (shared chrome) -------------------------------------- */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .footer-inner { flex-direction: column; align-items: center; text-align: center; }
  .footer-links { justify-content: center; }
}
