/* ======================================================================
   hero-pop.css — "Broadcast Leaderboard" treatment for the hero.

   Loaded AFTER the inline <style> block, so equal-specificity rules here
   win. That's deliberate: this file is an additive skin, not a fork of
   the base sheet. Nothing in here hardcodes a brand colour — everything
   derives from the --green / --sand custom properties so the owner-facing
   Theme Editor keeps working exactly as before.

   Layers, top to bottom:
     1. Tokens          — hero-local design tokens
     2. Stage           — hero backdrop, aurora, rails, fade-out
     3. Identity        — avatar, name, meta chips
     4. Stat cards      — the old .quick-stats, promoted to real cards
     5. Analytics panel — chart + tiles + recent-form leaderboard
     6. Motion / a11y   — reveal animation + reduced-motion opt-out
   ====================================================================== */

/* ---------- 1. Tokens ---------- */
.hero {
  /* Derived once, consumed everywhere below. Change a token, change the
     whole hero — no find-and-replace archaeology. */
  --h-ink:        #ffffff;
  --h-ink-dim:    rgba(255, 255, 255, 0.72);
  --h-ink-faint:  rgba(255, 255, 255, 0.62);
  /* Glass tints need a DARK component, not just white-on-green — a pure
     white wash over mid-green reads as "slightly lighter green" and the
     card edges vanish. The dark base is what gives the panels depth. */
  --h-glass:      rgba(6, 24, 14, 0.30);
  --h-glass-hi:   rgba(255, 255, 255, 0.10);
  --h-edge:       rgba(255, 255, 255, 0.22);
  --h-edge-hot:   color-mix(in srgb, var(--sand) 45%, transparent);
  --h-under:      #7ff0a8;  /* under par  — good */
  --h-over:       #ff8f8f;  /* over par   — bad  */
  --h-card-r:     16px;
}

/* ---------- 2. Stage ---------- */
.hero {
  min-height: unset;
  align-items: stretch;
  padding: 0 0 5.5rem;
  /* Deeper, moodier bed than the original 3-stop gradient. The dark
     anchor at the bottom is what makes the sand accents actually pop. */
  background:
    radial-gradient(120% 90% at 78% 8%,
      color-mix(in srgb, var(--green-soft) 55%, transparent) 0%, transparent 55%),
    radial-gradient(90% 70% at 12% 0%,
      color-mix(in srgb, var(--sand) 22%, transparent) 0%, transparent 50%),
    linear-gradient(168deg,
      color-mix(in srgb, var(--green-deep) 88%, #000) 0%,
      var(--green-deep) 32%,
      var(--green) 72%,
      color-mix(in srgb, var(--green-deep) 70%, #000) 100%);
}

/* Brand rail — the thin tri-tone stripe every sports broadcast has. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--sand) 0%,
    var(--green-soft) 38%,
    var(--sand) 62%,
    var(--green-soft) 100%);
  background-size: 200% 100%;
  animation: hero-rail 9s linear infinite;
  z-index: 3;
}
@keyframes hero-rail { to { background-position: 200% 0; } }

/* Soft fade into the page background so the hero doesn't end in a
   hard seam above the tab strip. */
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 160px;
  background: linear-gradient(to bottom,
    transparent, color-mix(in srgb, var(--ivory) 92%, transparent));
  pointer-events: none;
  z-index: 0;
}

/* Texture: fairway mow-stripes + a faint contour wash. Reuses the
   existing .hero-overlay element — no extra markup needed. */
.hero-overlay {
  background-image:
    repeating-linear-gradient(102deg,
      rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-14deg,
      rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 60px);
  opacity: 0.9;
}

.hero-content {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 3.4rem 1.5rem 0;
  z-index: 2;
}

/* ---------- 3. Identity ---------- */
.hero-identity {
  display: flex;
  align-items: center;
  gap: clamp(1.1rem, 3vw, 2.2rem);
  text-align: left;
  margin-bottom: 2rem;
}

.hero-avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
/* No photo on file → fall back to a monogram instead of collapsing the
   slot. An empty left column makes the whole identity row look broken,
   and the halo pseudo-element would otherwise linger as a glowing pea.
   Initials come from data-initials, set by renderHero(). */
.hero-avatar.is-empty .player-photo { display: none; }
.hero-avatar.is-empty::after {
  content: attr(data-initials);
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  width: clamp(104px, 15vw, 150px);
  height: clamp(104px, 15vw, 150px);
  border-radius: 50%;
  border: 5px solid color-mix(in srgb, var(--green-deep) 85%, #000);
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--green-deep) 92%, #000),
    color-mix(in srgb, var(--green) 70%, #000));
  box-shadow: 0 0 0 1px var(--h-edge-hot), 0 18px 40px rgba(0, 0, 0, 0.45);
  font-size: clamp(2.1rem, 4.4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--sand);
}
/* Nothing to show at all (no photo AND no name) — drop the slot. */
.hero-avatar.is-empty[data-initials=""] { display: none; }
/* Rotating conic halo. Sits behind the photo; the photo's own border
   masks the inner edge so it reads as a ring, not a disc. */
.hero-avatar::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    var(--sand), var(--green-soft), var(--sand), var(--green-soft), var(--sand));
  filter: blur(1px);
  opacity: 0.85;
  animation: hero-halo 7s linear infinite;
}
@keyframes hero-halo { to { transform: rotate(360deg); } }

.hero .player-photo {
  position: relative;
  z-index: 1;
  width: clamp(104px, 15vw, 150px);
  height: clamp(104px, 15vw, 150px);
  margin: 0;
  border-width: 5px;
  border-color: color-mix(in srgb, var(--green-deep) 85%, #000);
  box-shadow:
    0 0 0 1px var(--h-edge-hot),
    0 18px 40px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hero .player-photo:hover { transform: scale(1.05) rotate(-1.5deg); }

.hero-identity-text { min-width: 0; }

.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  padding: 0.28rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  background: var(--h-glass-hi);
  border: 1px solid var(--h-edge-hot);
  backdrop-filter: blur(4px);
}
/* Live-scoring blip. Pure decoration, so it's a pseudo-element rather
   than a span the JS would have to remember to re-create. */
.hero .eyebrow::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--sand);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--sand) 70%, transparent);
  animation: hero-blip 2.2s ease-out infinite;
}
@keyframes hero-blip {
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero h1 {
  font-size: clamp(2.1rem, 5.6vw, 4.1rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  background: linear-gradient(178deg, #fff 30%,
    color-mix(in srgb, var(--sand) 90%, #fff) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
}

/* Meta chips. renderHero() emits one <span> per fact; styling lives
   here so the JS stays a dumb data-to-DOM mapper. */
.hero .tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.85rem 0 0;
  opacity: 1;
}
.hero .tagline span {
  padding: 0.26rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--h-glass);
  border: 1px solid var(--h-edge);
  color: var(--h-ink-dim);
}

/* ---------- 4. Stat cards ---------- */
.hero .quick-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.6rem;
}

.hero .stat {
  position: relative;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.95rem 1rem 0.9rem;
  min-width: 0;
  border-radius: var(--h-card-r);
  background:
    linear-gradient(160deg, var(--h-glass-hi), transparent 60%),
    var(--h-glass);
  border: 1px solid var(--h-edge);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.28s, box-shadow 0.28s;
}
/* Accent cap — the leaderboard "position marker" cue. */
.hero .stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sand), transparent 85%);
  opacity: 0.75;
}
/* Sheen that sweeps across on hover. transform-only = cheap to animate. */
.hero .stat::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%,
    rgba(255, 255, 255, 0.16) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.65s ease;
}
.hero .stat:hover {
  transform: translateY(-4px);
  border-color: var(--h-edge-hot);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.3);
}
.hero .stat:hover::after { transform: translateX(120%); }

.hero .stat-num {
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, var(--sand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .stat-label {
  font-size: 0.63rem;
  letter-spacing: 0.18em;
  color: var(--h-ink-faint);
  font-weight: 700;
}

/* ---------- 5. Analytics panel ---------- */
.hero-analytics {
  max-width: none;
  margin-top: 0;
  padding: 1.35rem 1.4rem 1.5rem;
  background:
    linear-gradient(155deg, var(--h-glass-hi), transparent 55%),
    rgba(6, 24, 14, 0.34);
  border-color: var(--h-edge);
  border-radius: calc(var(--h-card-r) + 4px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

.hero-analytics-header { margin-bottom: 1rem; }
.hero-analytics-eyebrow {
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sand) 16%, transparent);
  border: 1px solid var(--h-edge-hot);
}
.hero-analytics-title { font-size: 1.2rem; letter-spacing: -0.01em; }

.hero-analytics-body { gap: 1rem; }

.hero-chart-wrap {
  position: relative;           /* tooltip anchor */
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.12));
  border: 1px solid var(--h-edge);
  border-radius: 12px;
  padding: 0.7rem 0.8rem 0.6rem;
  min-height: 210px;
}
.hero-chart { height: 210px; }

/* Hover readout, built by ChartTip. translateX(-50%) keeps it centred
   on the point while `left` stays a plain pixel value the JS can clamp. */
.hc-tip {
  position: absolute;
  z-index: 4;
  transform: translateX(-50%);
  display: grid;
  gap: 0.05rem;
  padding: 0.4rem 0.6rem;
  border-radius: 9px;
  pointer-events: none;
  white-space: nowrap;
  background: color-mix(in srgb, var(--green-deep) 88%, #000);
  border: 1px solid var(--h-edge-hot);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}
.hc-tip[hidden] { display: none; }
.hc-tip-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--h-ink-faint);
}
.hc-tip-value {
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--sand);
}

/* Active point grows; its halo blooms. */
.hero-chart .hc-pt-g { transition: opacity 0.2s; }
.hero-chart .hc-pt-g .hc-point,
.hero-chart .hc-pt-g .hc-point-halo { transition: r 0.18s ease, opacity 0.18s ease; }
.hero-chart .hc-pt-g .hc-point-halo { opacity: 0; }
.hero-chart .hc-pt-g.is-active .hc-point-halo { opacity: 1; }
.hero-chart .hc-pt-g.is-active .hc-point { r: 6.5; }

/* SVG skin. The gradient/glow <defs> are injected by drawHeroChart(). */
.hero-chart .hc-grid        { stroke: rgba(255, 255, 255, 0.09); stroke-dasharray: 3 5; }
.hero-chart .hc-axis-label  { fill: var(--h-ink-faint); font-size: 9.5px; font-weight: 600; }
.hero-chart .hc-line        { stroke: url(#hc-stroke); stroke-width: 3.25; filter: url(#hc-glow); }
.hero-chart .hc-area        { fill: url(#hc-fill); }
.hero-chart .hc-point       { fill: #fff; stroke: var(--sand); stroke-width: 3; }
.hero-chart .hc-point-halo  { fill: color-mix(in srgb, var(--sand) 30%, transparent); }
.hero-chart .hc-point-label { font-size: 11px; font-weight: 800; }
.hero-chart .hc-x-label     { fill: var(--h-ink-faint); font-size: 9.5px; font-weight: 600; }

/* Draw-in animation. --hc-len is set per-path by the renderer so the
   dash offset matches the real path length at any point count. */
.hero-chart .hc-line {
  stroke-dasharray: var(--hc-len);
  stroke-dashoffset: var(--hc-len);
  animation: hc-draw 1.1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes hc-draw { to { stroke-dashoffset: 0; } }
.hero-chart .hc-area  { animation: hc-fade 0.9s 0.5s ease both; }
.hero-chart .hc-pt-g  { animation: hc-fade 0.45s ease both; }
@keyframes hc-fade { from { opacity: 0; } to { opacity: 1; } }

/* Tiles — same data, more presence. */
.hero-analytics-tiles { gap: 0.6rem; }
.hero-analytics-tiles li {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--h-edge);
  background:
    linear-gradient(160deg, var(--h-glass-hi), transparent 65%),
    var(--h-glass);
  transition: transform 0.25s, border-color 0.25s;
}
.hero-analytics-tiles li:hover {
  transform: translateX(3px);
  border-color: var(--h-edge-hot);
}
.hero-analytics-tiles .tile-value { font-size: 1.5rem; letter-spacing: -0.02em; }
.hero-analytics-tiles .tile-value.trend-up   { color: var(--h-over); }
.hero-analytics-tiles .tile-value.trend-down { color: var(--h-under); }

/* ---------- 5b. Recent-form leaderboard ---------- */
.hero-form {
  margin-top: 1rem;
  border: 1px solid var(--h-edge);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.16);
}
.hero-form[hidden] { display: none; }

/* One shared grid template for the header and every row — the whole
   point of a leaderboard is that the columns line up. Defined once. */
.hero-form .fs-head,
.hero-form .fs-row {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) auto 4.2rem 3.6rem;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.9rem;
}
.hero-form .fs-head {
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--h-edge);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--h-ink-faint);
}
.hero-form .fs-rows { list-style: none; margin: 0; padding: 0; }
.hero-form .fs-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s;
}
.hero-form .fs-rows li:first-child .fs-row,
.hero-form .fs-rows .fs-row:first-child { border-top: 0; }
.hero-form .fs-row:hover { background: var(--h-glass); }

.hero-form .fs-pos {
  justify-self: start;
  min-width: 2.5rem;
  text-align: center;
  padding: 0.22rem 0.4rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--h-glass-hi);
  border: 1px solid var(--h-edge);
  color: var(--h-ink);
}
/* Podium finishes get the trophy treatment. */
.hero-form .fs-pos.is-podium {
  background: linear-gradient(160deg, var(--sand),
    color-mix(in srgb, var(--sand) 60%, #b8952f));
  border-color: var(--sand);
  color: var(--green-deep);
  box-shadow: 0 0 16px color-mix(in srgb, var(--sand) 35%, transparent);
}

.hero-form .fs-event { min-width: 0; display: grid; gap: 0.1rem; }
.hero-form .fs-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--h-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-form .fs-meta {
  font-size: 0.66rem;
  color: var(--h-ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-form .fs-rounds { display: flex; gap: 0.28rem; }
.hero-form .fs-rounds i {
  font-style: normal;
  min-width: 1.9rem;
  text-align: center;
  padding: 0.16rem 0.3rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.09);
  color: var(--h-ink-dim);
}

.hero-form .fs-total {
  text-align: right;
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--h-ink);
}

/* Re-skin of the shared diffClass() output for the dark hero. Same
   class names as the light cards below the fold — one classifier
   function, two skins. */
.hero-form .fs-par {
  justify-self: end;
  min-width: 3rem;
  text-align: center;
  padding: 0.22rem 0.4rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: transparent;
}
.hero-form .fs-par.diff-under { color: var(--h-under); background: color-mix(in srgb, var(--h-under) 16%, transparent); }
.hero-form .fs-par.diff-even  { color: var(--sand);    background: color-mix(in srgb, var(--sand)    16%, transparent); }
.hero-form .fs-par.diff-over  { color: var(--h-over);  background: color-mix(in srgb, var(--h-over)  14%, transparent); }

/* ---------- 6. Motion & responsive ---------- */
/* Staggered entrance. JS only toggles .is-in on the hero; the delays
   are declarative so adding a 6th stat card needs zero JS changes. */
.hero [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
}
.hero.is-in [data-reveal] {
  animation: hero-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--reveal-i, 0) * 80ms);
}
@keyframes hero-rise {
  to { opacity: 1; transform: none; }
}

@media (max-width: 780px) {
  /* The mode / resume / theme pills are absolutely positioned in the
     hero's top-right. On a narrow screen they stop being "in the corner"
     and start being "on top of the avatar", so the content has to start
     below them. Owner mode shows one extra pill — reuse the existing
     body.is-owner switch rather than inventing a second mechanism. */
  .hero-content { padding-top: 7.6rem; }
  body.is-owner .hero-content { padding-top: 10.8rem; }

  .hero-identity { flex-direction: column; text-align: center; }
  .hero .tagline { justify-content: center; }
  .hero .eyebrow { margin-inline: auto; }
  .hero-form .fs-head,
  .hero-form .fs-row { grid-template-columns: 3rem minmax(0, 1fr) 3.4rem 3.2rem; }
  .hero-form .fs-rounds { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero *,
  .hero *::before,
  .hero *::after { animation: none !important; transition: none !important; }
  .hero [data-reveal] { opacity: 1; transform: none; }
  .hero-chart .hc-line { stroke-dashoffset: 0; }
}
