/* ==========================================================================
   Permit breakdown
   Verified against the Figma frame (node 114:1719) — exact spacing, radii,
   type sizes, and bar colors below are pulled from that design context, not
   eyeballed from mockup screenshots. No white outer container — the tool
   sits directly on the page background.

   The script references these exact custom-property/class names directly —
   keep them even though everything else here is free to restyle:
     - --fp / --pickup / --semipro / --unknown / --other / --youth / --city
       (SUB_COLOR)
     - --org-1 .. --org-9, assigned to orgs, not display order (orgBreakdown()
       re-sorts by current total each render): NYC Footy, Love NY Soccer,
       NYC Soccer, NY Coed Soccer, Group Stage, Volo Sports, Round Play,
       Sunday League NYC, New York City Women's Soccer
     - .bar-row / .solo / .dimmed / .bar-fill / .bar-segment (built by addRow())
     - #hoverCard / .visible
     - the 768px mobile breakpoint (MOBILE_BREAKPOINT in JS)
   ========================================================================== */

.permit-breakdown {
  --fp: var(--subcat-for-profit);
  --pickup: var(--subcat-pickup);
  --semipro: var(--subcat-semipro);
  --unknown: var(--subcat-unknown);
  --other: var(--subcat-other);
  --youth: var(--category-youth);
  --city: var(--category-city);

  --org-1: var(--org-nyc-footy);
  --org-2: var(--org-love-ny);
  --org-3: var(--org-nyc-soccer);
  --org-4: var(--org-ny-coed);
  --org-5: var(--org-group-stage);
  --org-6: var(--org-volo);
  --org-7: var(--org-round-play);
  --org-8: var(--org-sunday-league);
  --org-9: var(--org-nycwsoc);
}

/* --content-max is 800px sitewide now (matches this Figma frame), so no
   section-specific override is needed here anymore -- hero, intro, and this
   tool all share the same column width via the plain .container class.
   No size override on .section-title either (as of the revenue calculator
   pass) -- the desktop 5xl bump this used to have was leaving a trailing
   orphan word on its own line; both feature titles dropped back to the
   plain text-4xl default. */
.feature-subtitle { font-size: var(--text-xl); line-height: var(--text-xl-leading); letter-spacing: var(--text-xl-tracking); margin: 0 0 var(--space-8); }
/* Plain wrapper — no card chrome around the whole tool. */
.feature-card { padding: 0; }

/* ---------------- Park / Period dropdowns ---------------- */
.select-row { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.control-block { min-width: 220px; flex: 1; }
.field-label {
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
  /* Matches the select's rendered text inset: its own --space-4 padding
     plus its 2px border (label has no border of its own). */
  padding-left: calc(var(--space-4) + 2px);
}
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  width: 100%;
  height: var(--control-height);
  border-radius: var(--radius-md);
  border: var(--outline-thick);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  padding: 0 2.75rem 0 var(--space-4); /* left was 18px, off the 4px grid */
  cursor: pointer;
}
.select-wrap .select-chevron {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: var(--control-icon-size);
  height: var(--control-icon-size);
  pointer-events: none;
}

/* ---------------- stat cards (Park + Period only) ---------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat {
  background: var(--surface-stat);
  border: var(--outline-thick);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}
.stat .label { font-size: var(--text-sm); font-weight: 500; text-transform: uppercase; margin-bottom: var(--space-2); }
.stat .hours { font-size: var(--text-2xl); font-weight: 700; line-height: var(--text-2xl-leading); letter-spacing: var(--text-2xl-tracking); }
.stat .bookings { font-size: var(--text-base); font-weight: 500; margin-top: var(--space-2); }
/* Matches the same 768px breakpoint everything else switches at -- a 4-col
   grid squeezed into the narrower single-column mobile layout is what was
   overflowing. */
@media (max-width: 768px) { .stats { grid-template-columns: repeat(2, 1fr); } }
/* Narrow columns can force "1,776 hrs" / "PRIME-TIME" to wrap -- step the
   two long-text pieces down a size rather than let them wrap awkwardly. */
@media (max-width: 480px) {
  .stat .label { font-size: var(--text-xs); }
  .stat .hours { font-size: var(--text-xl); }
}

/* ---------------- segmented + toggles (drive the bars, not the stat cards) ---------------- */
.control-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }

/* Reuses the same "muted" treatment as .coming-soon-note in hero.css --
   text stays fully black (no tinted grays sitewide) at reduced opacity
   rather than a separate color token. hint-desktop/hint-mobile swap on the
   same 768px breakpoint as everything else (MOBILE_BREAKPOINT in the
   script) -- plain CSS display toggle, no JS involved since it's static
   copy, not layout that needs recalculating on resize. Left-aligned on
   both breakpoints, matching .bar-label-cell's own left alignment on
   mobile (desktop's .bar-label-cell is right-aligned, but there's no
   label column here to align against, so left just reads as plain body
   copy). */
.chart-hint { font-size: var(--text-sm); font-style: normal; color: var(--text-primary); opacity: 0.7; margin: 0 0 var(--space-6) 0; text-align: left; }
.chart-hint .hint-mobile { display: none; }
@media (max-width: 768px) {
  .chart-hint .hint-desktop { display: none; }
  .chart-hint .hint-mobile { display: inline; }
}
@media (max-width: 768px) {
  .control-row { flex-direction: column; align-items: stretch; }
  .segmented { width: 100%; }
}

/* Grid, not flex: an inline-flex container with flex:1/min-width:0 children
   miscalculates its own shrink-to-fit width (a well-known flexbox quirk),
   which was wrapping "All for-profit" even at full desktop width. Grid's
   1fr columns size correctly off the widest cell in both shrink-to-fit and
   width:100% (mobile) contexts. */
.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch; /* button height comes from the row, not a hardcoded number */
  padding: 6px; /* off the 4px grid, but deliberate -- see the active pill's radius below */
  border: var(--outline-thick);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  height: var(--control-height);
}
.segmented button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  /* No explicit height -- stretch above fills this from the row (52px outer
     minus 2px border minus 6px padding each side = 36px), so it can't go
     stale if those change again. */
  margin: 0;
  border: none;
  background: transparent;
  /* Concentric with .segmented's 16px radius: border(2px)+padding(6px)=8px
     inset, and 16-8=8 = var(--radius-sm). That's also why .segmented's
     padding stays at 6px instead of snapping to the 4px grid -- 4 or 8
     would land the math on 10px/6px, neither a real radius token. */
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: 1;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0 var(--space-3);
}
.segmented button.active { background: var(--state-selected); color: var(--surface-1); }

.toggle-group { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); }
.chip-toggle { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-lg); font-weight: 500; color: var(--text-primary); }
.chip-toggle input { position: absolute; opacity: 0; width: 0; height: 0; } /* not display:none -- that removes it from the tab order entirely, making the toggle keyboard-unreachable */
.chip-track {
  position: relative;
  width: 2.5rem;
  height: var(--control-icon-size);
  background: var(--surface-1);
  border: var(--outline-thick); /* was --outline-thin (1.5px), the only fractional border on the site -- collapsed into this one */
  border-radius: var(--radius-pill);
  transition: background 0.15s;
  flex-shrink: 0;
}
.chip-thumb {
  /* 16px, 2px from the track's interior (post-border) edge on all sides:
     interior is 24 - 2*2px border = 20px tall, so 20 - 2*2px = 16px. */
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.15s;
}
.chip-toggle input:checked + .chip-track { background: var(--state-selected); border-color: var(--border-strong); }
.chip-toggle input:checked + .chip-track .chip-thumb { transform: translateY(-50%) translateX(16px); background: var(--surface-1); } /* travel distance -- recheck by hand if track/thumb sizing changes */

/* ---------------- bars ---------------- */
.bars {
  position: relative;
  display: grid;
  grid-template-columns: 136px 1fr;
  column-gap: var(--space-5);
  row-gap: var(--space-5);
  align-items: center;
}
.bar-row { display: contents; }
.bar-label-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  text-align: right;
  /* Optical nudge: centered-by-grid still read as sitting low against the
     track, likely cap-height vs. descender space in the two lines of text
     being asymmetric. A little bottom padding pulls it back up visually. */
  padding-bottom: 6px;
  border-radius: 4px; /* rounds the focus ring's corners to match everything else */
}
.bar-label-name { font-size: var(--text-lg); font-weight: 500; white-space: nowrap; }
.bar-label-value { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }
/* Bar uses filter, not opacity -- opacity would let the gridline show
   through the fill. brightness() can't dim the border though (scaling
   black stays black), so the border gets its own rgba() at the standard
   0.5 dim/disabled opacity. Literal rgba(0,0,0,...) because you can't add
   alpha to --border-strong's opaque value without color-mix() -- keep this
   in sync by hand if that color ever changes. */
.bar-row.dimmed .bar-label-name, .bar-row.dimmed .bar-label-value { opacity: 0.5; }
.bar-row.dimmed .bar-fill { filter: saturate(0.35) brightness(1.55); border-color: rgba(0, 0, 0, 0.5); }
/* Labels are a hover/tap target too now (see wireHover in the script) --
   cursor signals that regardless of breakpoint. */
.bar-label-cell { cursor: pointer; }

.bar-track-cell { min-width: 0; }
.bar-track {
  position: relative;
  height: 3.75rem;
  display: flex;
  align-items: center;
}
.bar-fill {
  position: relative;
  z-index: 1; /* paint above the gridline overlay, which comes after it in the DOM */
  height: 100%;
  flex: 0 0 auto;
  display: flex;
  border: var(--outline-thick);
  overflow: hidden;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-segment {
  height: 100%;
  cursor: pointer;
  /* border-LEFT, exempting the FIRST segment (largest, since orgBreakdown()
     sorts descending) rather than border-right exempting the last. Every
     segment pays 2px of its own width to this border (border-box), so
     whichever one is exempted reads as strictly bigger at the same
     underlying value -- exempting the last used to make the *smallest* org
     look bigger than its neighbor, and doubled up with .bar-fill's own
     right border into a ~4px edge. Exempting the first instead loses the
     freebie on the segment where it's imperceptible, and the exemption
     falls on an edge with no border to double up with. */
  border-left: var(--outline-thick);
  min-width: 2px; /* keeps a genuinely tiny share (e.g. Round Play at McCarren) from rounding away to nothing */
}
.bar-segment:first-child { border-left: none; }
.bar-segment:hover, .bar-row.solo .bar-fill:hover { filter: brightness(1.1); }

/* Full-height gridlines, spanning every row (not just each bar's own track).
   Positioned absolutely, NOT placed as a grid item -- adding it as a child of
   .bars with an explicit grid-column/grid-row corrupts the auto-placement
   flow for every row that comes after it in the DOM. */
.chart-gridlines {
  position: absolute;
  z-index: 0;
  top: calc(-1 * var(--space-4)); bottom: calc(-1 * var(--space-4));
  left: calc(136px + var(--space-5));
  right: 0;
  pointer-events: none;
}
.chart-gridlines .gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--gridline); }

/* Mobile: per the mobile-chart Figma frame (node 157:175) -- labels stack
   above their bar (not beside it) in a single column, and now that the
   layout is single-column the gridlines run right behind the labels
   themselves, not just the track -- so the label needs a solid chip behind
   it to stay legible against a line passing through, which desktop's
   label-in-its-own-column layout never needed. Breakpoint matches
   MOBILE_BREAKPOINT in the script. */
@media (max-width: 768px) {
  .bars { grid-template-columns: 1fr; row-gap: var(--space-5); }
  .bar-row { display: block; }
  .bar-label-cell {
    position: relative;
    z-index: 1; /* same layer as .bar-fill -- paints above .chart-gridlines (z-index:0), so the chip's opaque background actually covers the line behind it instead of the line drawing over top of it */
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-2);
    text-align: left;
    margin-bottom: var(--space-2);
    display: inline-flex;
    background: var(--surface-0);
    border-radius: 4px;
    padding: 2px 4px 4px;
  }
  .bar-label-name { font-size: var(--text-base); }
  .bar-track { height: 1.25rem; } /* 20px, in rem to match the unit the rest of the chart's sizes use (e.g. desktop's 3.75rem) */
  .chart-gridlines { left: 0; }
}

/* ---------------- axis ---------------- */
/* margin-top accounts for the gridlines' var(--space-4) downward extension
   (.chart-gridlines bottom: calc(-1 * var(--space-4))) plus a bit of
   breathing room, so the tick numbers sit just below where the lines
   actually end, not where the bars container does. */
.axis { display: grid; grid-template-columns: 136px 1fr; column-gap: var(--space-5); margin-top: calc(var(--space-4) + var(--space-2)); }
.axis-ticks { display: flex; justify-content: space-between; font-size: var(--text-base); color: var(--text-primary); font-weight: 500; }
/* Placed after the base rule so it actually wins at this breakpoint -- an
   earlier attempt put this override inside the first @media block above,
   which sits *before* the unconditional .axis rule in source order, so the
   later rule silently won regardless of viewport (equal specificity, source
   order decides). No axis-spacer div exists on mobile (see the script), so
   .axis-ticks needs the full single column to actually spread its ticks
   with justify-content:space-between instead of being squeezed into what
   would've been just the 136px label column. */
@media (max-width: 768px) {
  .axis { grid-template-columns: 1fr; }
}

.empty-state { font-size: var(--text-lg); padding: var(--space-5) 0; }

/* ---------------- hover card ----------------
   Fixed width, not just a max-width: content varies a lot row to row (org
   name length, description length, example-list length), and letting the
   card resize per-row read as inconsistent/jumpy as you move between bars.
   A fixed width also makes the above/below flip positioning math predictable. */
#hoverCard {
  position: fixed;
  z-index: 50;
  width: 300px;
  background: var(--surface-0);
  border: var(--outline-thick);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  transform: translateY(4px);
}
#hoverCard.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* flex-start, not center -- a long org name can wrap to 2 lines, which would float a centered logo away from the name's first line */
#hoverCard .hc-header { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
#hoverCard .hc-logo { width: 44px; height: 44px; margin-top: 2px; /* optical nudge against the name's cap-height */ border-radius: var(--radius-sm); border: var(--outline-thick); flex-shrink: 0; object-fit: cover; }
#hoverCard .hc-title-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#hoverCard .hc-name { font-size: var(--text-xl); font-weight: 700; line-height: var(--text-xl-leading); }
#hoverCard .hc-hours { font-size: var(--text-sm); font-weight: 500; }
/* No trailing margin when the description is the last thing in the card (no
   examples/aliases list follows) -- otherwise that var(--space-4) stacks on
   top of the card's own bottom padding instead of replacing it. */
#hoverCard .hc-desc { font-size: var(--text-base); margin-bottom: var(--space-4); }
#hoverCard .hc-desc:last-child { margin-bottom: 0; }
#hoverCard .hc-examples-label { font-size: var(--text-sm); font-weight: 600; margin-bottom: 2px; }
#hoverCard .hc-examples { font-size: var(--text-base); }
