/* =========================================================================
   Golf Stats — DaltonApps
   Dark navy palette, sidebar nav layout.
   ========================================================================= */

:root {
  --bg:            #07111e;
  --bg-soft:       #0b1c33;
  --bg-card:       #0d2040;
  --fg:            #dbd7cc;
  --fg-muted:      #7590b2;
  --fg-dim:        #4a6080;
  --accent:        #ffb454;
  --accent-soft:   rgba(255, 180, 84, 0.12);
  --red:           #e76f51;
  --red-soft:      rgba(231, 111, 81, 0.12);
  --green:         #52b788;
  --green-soft:    rgba(82, 183, 136, 0.12);
  --border:        rgba(100, 155, 215, 0.10);
  --border-strong: rgba(100, 155, 215, 0.22);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: ui-serif, Georgia, "Iowan Old Style", "Apple Garamond", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius:    12px;
  --radius-sm: 7px;
  --ease:      cubic-bezier(.2, .7, .2, 1);
  --dur:       220ms;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.5rem;
  border-right: 1px solid var(--border);
  background: #060f1b;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-brand {
  margin-bottom: 2.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--accent);
  background: rgba(255, 180, 84, 0.10);
  border: 1px solid rgba(255, 180, 84, 0.25);
  border-radius: var(--radius-sm);
}
.brand-name {
  font-size: 0.88rem;
  color: var(--fg-muted);
}

.sidebar-hero {
  margin-bottom: 2.5rem;
}

.sidebar-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.75rem;
}

.sidebar-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 2.6rem;
  line-height: 1.0;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-bottom: 0.6rem;
}

.sidebar-lede {
  font-size: 0.82rem;
  color: var(--fg-dim);
}

/* Sidebar nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--fg-muted);
  font-weight: 500;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  position: relative;
}

.nav-link::before {
  content: '';
  width: 3px;
  height: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: height var(--dur) var(--ease);
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--fg);
  background: rgba(100, 155, 215, 0.06);
}

.nav-link.active {
  color: var(--fg);
  background: rgba(255, 180, 84, 0.08);
}

.nav-link.active::before {
  height: 1.1rem;
  background: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.back-home {
  font-size: 0.82rem;
  color: var(--fg-muted);
  transition: color var(--dur) var(--ease);
}
.back-home:hover { color: var(--fg); }

.sidebar-data-note {
  font-size: 0.72rem;
  color: var(--fg-dim);
}

/* =========================================================================
   Main content area
   ========================================================================= */

.main-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.main-content {
  flex: 1;
  padding: 0 clamp(1.5rem, 3.5vw, 2.75rem) 4rem;
}

/* =========================================================================
   Sections
   ========================================================================= */

.section {
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
  border-bottom: 1px solid var(--border);
}
.section:last-child { border-bottom: none; }

.section-header {
  margin-bottom: 2rem;
}

.section-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.section-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--fg);
}

/* =========================================================================
   Improvement banner
   ========================================================================= */

.banner {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.banner-stat { text-align: center; min-width: 90px; }
.banner-big {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1;
}
.banner-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-top: 0.35rem;
}
.banner-divider {
  width: 1px;
  height: 48px;
  background: var(--border-strong);
  flex-shrink: 0;
}
.banner-text { flex: 1; min-width: 200px; }
.banner-text h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}
.banner-text p {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

/* =========================================================================
   Stat cards
   ========================================================================= */

.stat-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card-accent::after { background: var(--accent); }
.stat-card-red::after    { background: var(--red); }

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.stat-value {
  font-family: var(--font-serif);
  font-size: 2.3rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.stat-card-accent .stat-value { color: var(--accent); }
.stat-sub {
  font-size: 0.76rem;
  color: var(--fg-dim);
  margin-top: 0.1rem;
}

/* =========================================================================
   Cards
   ========================================================================= */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 1.2rem;
}
.card-label-sub {
  color: var(--fg-dim);
  font-size: 0.63rem;
  text-transform: none;
  letter-spacing: 0;
}

.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.chart-card { margin-bottom: 0; }

.chart-wrap          { position: relative; height: 260px; }
.chart-wrap-pie      { height: 260px; display: flex; align-items: center; justify-content: center; }
.chart-wrap-pie canvas { max-height: 240px; }
.chart-wrap-tall     { height: 300px; }
.chart-wrap-short    { height: 190px; }

/* =========================================================================
   Tables
   ========================================================================= */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  white-space: nowrap;
}
thead th {
  text-align: left;
  padding: 0.5rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--accent); }
thead th.num { text-align: center; }

tbody tr {
  border-bottom: 1px solid rgba(100, 155, 215, 0.05);
  transition: background var(--dur) var(--ease);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(100, 155, 215, 0.04); }

tbody td {
  padding: 0.72rem 0.8rem;
  color: var(--fg-muted);
}
tbody td.num { text-align: center; }
tbody td strong { color: var(--fg); font-weight: 600; }

/* Score pills */
.score-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.76rem;
  font-family: var(--font-mono);
}
.pill-great { background: var(--green-soft);          color: var(--green); }
.pill-good  { background: rgba(82,183,136,0.07);      color: #74c69d; }
.pill-avg   { background: var(--accent-soft);         color: var(--accent); }
.pill-bad   { background: var(--red-soft);            color: var(--red); }

/* Hole result colors */
.val-birdie { color: var(--accent); font-weight: 600; }
.val-par    { color: var(--green); }
.val-bogey  { color: var(--fg-muted); }
.val-double { color: var(--red); }

/* =========================================================================
   Table controls
   ========================================================================= */

.table-controls {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.select {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  padding: 0.42rem 0.72rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.select:focus, .select:hover { border-color: var(--accent); color: var(--fg); }

.table-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
}

/* =========================================================================
   Bar list (course best scores)
   ========================================================================= */

.bar-list { display: flex; flex-direction: column; gap: 0.65rem; }
.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
}
.bar-label {
  font-size: 0.81rem;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s var(--ease);
}
.bar-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg);
  font-weight: 600;
  text-align: right;
  min-width: 2.5rem;
}

/* =========================================================================
   Footer
   ========================================================================= */

.site-footer {
  padding: 1.75rem clamp(1.5rem, 3.5vw, 2.75rem) 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 0.86rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.footer-meta { display: flex; gap: 1rem; }
.footer-meta a { color: var(--fg-muted); transition: color var(--dur) var(--ease); }
.footer-meta a:hover { color: var(--accent); }

/* =========================================================================
   Scorecard (expandable row)
   ========================================================================= */

.round-row { cursor: pointer; }
.round-row:hover td { background: rgba(255, 180, 84, 0.03); }
.round-row.open td  { background: rgba(255, 180, 84, 0.05); color: var(--fg); }

.scorecard-row td {
  padding: 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.scorecard {
  padding: 1rem 1.5rem 1.25rem;
}

.sc-label {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.75rem;
}

.sc-table {
  border-collapse: collapse;
  font-size: 0.82rem;
  width: auto;
}

.sc-th {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  padding: 0.28rem 0.52rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.sc-label-cell {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  padding: 0.42rem 0.52rem;
  white-space: nowrap;
  text-transform: uppercase;
}

.sc-hole {
  text-align: center;
  padding: 0.42rem 0.52rem;
  color: var(--fg-muted);
  min-width: 1.9rem;
}

.sc-total {
  background: rgba(100, 155, 215, 0.05);
  border-left: 1px solid var(--border);
  font-weight: 600;
  color: var(--fg) !important;
}

.sc-par {
  color: var(--fg-dim) !important;
  font-size: 0.76rem;
}

.scorecard-empty {
  padding: 1rem 1.5rem;
  font-size: 0.84rem;
  color: var(--fg-dim);
  font-style: italic;
}

/* =========================================================================
   Mobile — sidebar collapses to top bar
   ========================================================================= */

@media (max-width: 820px) {
  body {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.75rem 1.1rem;
    gap: 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 30;
  }

  .sidebar-brand  { margin-bottom: 0; }
  .sidebar-hero   { display: none; }
  .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }

  .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.83rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
  }

  .nav-link::before { display: none; }

  .nav-link.active {
    background: rgba(255, 180, 84, 0.12);
    color: var(--accent);
  }

  .main-content { padding: 0 1.1rem 3rem; }
  .section { padding-top: 2rem; padding-bottom: 2rem; }

  .chart-row { grid-template-columns: 1fr; }
}

/* =========================================================================
   Reduced motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
