/* ==========================================================================
   Revenue calculator — rebuilt against the Figma frames (node 144:3 "League
   estimate" / node 144:4 "Calculate yourself"), per docs/handoff-revenue-
   calculator.md. Two modes toggled by #modeToggle; the 3 stat cards and the
   formula card are shared by both and just re-render off whichever mode is
   active. See CLAUDE.md's "Conventions established" for the shared patterns
   reused here (.segmented is CSS Grid, not flex; badges are the sitewide
   tokens; stat cards use the tan beige-200/24px-radius pattern).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&display=swap');

/* No size override here -- .section-title's own default (text-4xl) is used
   at every width. The desktop 5xl bump (matching permit-breakdown's old
   override) was leaving a trailing orphan word on its own line; both
   sections' titles dropped back to 4xl to avoid that. */
.revenue-calculator .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);
}

/* An "outlined only" card fill — matches the page background (beige-100),
   so it reads as a bordered region rather than a raised white/tan surface.
   Distinct from both .card (white, 32px radius) and the tan stat-card
   pattern; used for the league snapshot, the calculate-yourself panel, and
   the formula card. All three share --radius-xl (24px) -- the formula
   card originally shipped at --radius-md (16px), sourced from Figma at the
   time, but that read as an unexplained mismatch against its two siblings
   and was corrected to match. */
.outline-card {
  background: var(--bg-page);
  border: var(--outline-thick);
}

/* ---------------- mode segmented control ---------------- */
/* Duplicated from permit-breakdown.css's .segmented (this page doesn't load
   that stylesheet) -- same CSS Grid approach, kept in sync with its fixes. */
.revenue-calculator .segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  padding: 6px;
  border: var(--outline-thick);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  height: var(--control-height);
  margin-bottom: var(--space-6);
}
.revenue-calculator .segmented button {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  margin: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm); /* concentric with --radius-md above -- see permit-breakdown.css */
  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);
}
.revenue-calculator .segmented button.active { background: var(--state-selected); color: var(--surface-1); }
@media (max-width: 480px) { .revenue-calculator .segmented { width: 100%; } }
/* "Calculate yourself" overflows a 52px-tall pill at phone widths -- shrink
   the label and let the control grow past its min-height to fit 2 lines
   instead of clipping (align-items:stretch already keeps both pills the
   same height at every width; this block is just the text/wrap side). */
@media (max-width: 560px) {
  .revenue-calculator .segmented {
    height: auto;
    min-height: var(--control-height);
  }
  .revenue-calculator .segmented button {
    height: auto;
    min-height: 36px;
    font-size: var(--text-sm);
    line-height: 1.25;
    white-space: normal;
    text-align: center;
    padding: var(--space-2);
  }
}

/* ---------------- org picker ---------------- */
/* Horizontal scroll rather than wrapping or shrinking the tiles -- keeps
   logos legible at their full 96px size on any viewport. On desktop the 5
   tiles fit within --content-max with room to spare, so scrolling never
   actually triggers there.
   Full-bleed technique: negative left/right margin pulls the scroll
   container's own box out to the viewport edges; matching positive padding
   pushes the *content* back in, so the tiles align with the rest of the
   section even though the scrollable box itself spans edge to edge.
   The classic version of this trick uses calc(50% - 50vw) for the margin,
   but that "50%" resolves against .org-picker's own containing block (a
   plain wrapper div nested inside .container), not the viewport -- on a
   narrower nested box that produces the wrong offset. Since .container
   reliably renders at exactly 100% width with a fixed --space-5 gutter on
   any viewport at or below its own 800px max-width (true for every mobile
   width this actually needs to handle), a fixed pixel value sidesteps that
   containing-block ambiguity entirely: cancel exactly --space-5, restore it
   as padding. The ::after spacer exists because browsers drop a scroll
   container's own trailing-edge padding from the scrollable range -- without
   a real element there, the last tile ends up flush against the screen edge
   with no padding to its right at all.
   scroll-padding-left/right: without this, scroll-snap-type ignores the
   container's own padding when deciding where "start"/"end" are -- it was
   silently snapping the first tile flush to the true edge on load (undoing
   padding-left entirely) because scroll-snap-align:start on the tile has no
   way to know the padded position is where it should land instead.
   Scrollbar hidden across engines -- it's a touch/drag affordance here, not
   something that needs a visible track. Vertical padding still exists, now
   purely to give the selected tile's box-shadow (see .org-tile.active) room
   to render above/below without the scroll box clipping it -- the 24px
   left/right gutters already give it plenty of horizontal room. */
.org-picker {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--space-5);
  scroll-padding-right: var(--space-5);
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: var(--space-2) 0;
  margin-left: calc(-1 * var(--space-5));
  margin-right: calc(-1 * var(--space-5));
  padding-left: var(--space-5);
}
.org-picker::-webkit-scrollbar { display: none; }
/* padding-right is deliberately absent -- confirmed by measurement that
   browsers drop it entirely from the scrollable range here, not just
   under-count it. The ::after spacer is what actually reserves the trailing
   gutter instead. Its flex-basis is --space-5 *minus* --space-4 because
   `gap` automatically inserts --space-4 between the last tile and this
   spacer too (gap applies between every adjacent flex item, spacer
   included) -- without subtracting that, the trailing gutter would end up
   --space-4 wider than the leading one instead of matching it. */
.org-picker::after {
  content: '';
  flex: 0 0 calc(var(--space-5) - var(--space-4));
}
.org-tile {
  width: var(--space-9);
  height: var(--space-9);
  padding: 0;
  border: var(--outline-thick);
  border-radius: var(--radius-xl);
  background: none;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  scroll-snap-align: start;
}
.org-tile img { width: 100%; height: 100%; object-fit: cover; }
/* Outset (not inset) box-shadow -- inset caused its own corner-radius
   mismatch (an inset shadow's rounded corners shrink by the spread
   distance per spec, tapering visibly against the tile's real 24px corner)
   and needed an extra overlay element just to be visible over the logo
   image at all. Outset avoids both problems: it isn't hidden by the image
   (it paints outside the box, not underneath in-flow content), and its
   corners follow the tile's own border-radius directly with no erosion
   math to compensate for. box-shadow (not a thicker border) still matters
   for not resizing the image -- box-shadow never affects box-sizing. */
.org-tile.active {
  border-color: var(--state-selected);
  box-shadow: 0 0 0 2px var(--state-selected);
}

/* ---------------- league snapshot card ---------------- */
.league-card {
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
/* Badge sits to the right of the name on desktop, per Figma; DOM order is
   name-then-badge to match. At narrow widths the row runs out of space and
   would otherwise wrap the badge below the name -- column-reverse flips the
   *visual* order without touching the DOM, so the badge lands above the
   name instead of below it. */
.league-card-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
@media (max-width: 480px) {
  .league-card-header { flex-direction: column-reverse; align-items: flex-start; gap: var(--space-2); }
}
.league-card-name { font-size: var(--text-lg); font-weight: 500; }

/* Estimated badge's tooltip -- a real popover (not title="") so it works on
   tap, not just mouse hover. .badge-tip-trigger is a <button> wrapping the
   existing .badge styling; button UA defaults (border, font-family) are
   reset here since .badge itself already covers the rest (size/weight/
   color/padding/radius). line-height/vertical-align/appearance are reset
   too -- missing line-height specifically was the actual bug behind the
   confirmed/estimated badges rendering at different heights: browsers give
   <button> its own default line-height distinct from the inherited value a
   plain <span> (the confirmed badge) picks up, so without an explicit
   override here the two badge variants disagreed on height by a couple of
   pixels, enough to shift the row below it. */
.badge-tip-wrap { position: relative; display: inline-block; }
.badge-tip-trigger {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  margin: 0;
  cursor: pointer;
  font-family: var(--font-body);
  line-height: inherit;
  vertical-align: baseline;
}
/* Left-anchored (not centered) -- a centered bubble on a badge that sits
   near the left edge of the page was overflowing off-screen at phone
   widths. Left-aligning off the trigger's own left edge means it only ever
   extends rightward, into room the card generally has. */
.badge-tip {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  transform: translateY(4px);
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: none;
  white-space: nowrap;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 10;
}
.badge-tip-wrap:hover .badge-tip,
.badge-tip-wrap:focus-within .badge-tip,
.badge-tip-wrap.open .badge-tip {
  opacity: 1;
  transform: translateY(0);
}

.league-stats { display: flex; width: 100%; }
.league-stats .col { flex: 1; min-width: 0; padding-left: var(--space-4); border-left: var(--outline-thick); }
.league-stats .col:first-child { padding-left: 0; border-left: none; }
.league-stats .col-label { font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-2); }
.league-stats .col-value { font-size: var(--text-lg); font-weight: 500; }

/* Mobile swaps the 4-column divided row for a stacked label:value list
   (sentence case + colon, right-aligned value) -- the divided-column layout
   didn't have a good wrapped form at narrow widths. Both blocks are always
   rendered by the script; only one is ever visible per breakpoint. */
.league-stats-mobile { display: none; flex-direction: column; gap: var(--space-3); width: 100%; }
@media (max-width: 768px) {
  .league-stats { display: none; }
  .league-stats-mobile { display: flex; }
}
.league-stats-mobile .row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.league-stats-mobile .row-label { font-size: var(--text-lg); font-weight: 500; }
.league-stats-mobile .row-value { font-size: var(--text-lg); font-weight: 700; }

/* ---------------- calculate-yourself panel ---------------- */
.calc-card {
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
/* Clear all is positioned absolutely, out of flow with the label/radio row --
   matches the Figma source (an absolutely-positioned node, not a flex
   sibling). Sharing a flex row with .calc-as-row was clipping "Clear all" at
   narrow widths once the row's wrapped content pushed against it; decoupling
   them means the row can wrap freely at any width without the button ever
   competing for horizontal space. calc-card needs position:relative as the
   positioning context, with right-side padding held clear of the label row
   only where they'd actually overlap (they don't in practice -- the label
   row's content is short and left-aligned). */
.calc-card { position: relative; }
/* padding-right just needs to clear "Clear all" (~65px wide, positioned
   right:space-5 off the card edge) so the label/radio row never runs under
   it. space-9 (96px) is the nearest token with enough margin -- picked off
   the spacing scale rather than a hand-measured pixel value. */
.calc-header { margin-bottom: var(--space-5); padding-right: var(--space-9); }
.calc-as-row { display: flex; flex-wrap: wrap; row-gap: var(--space-3); column-gap: var(--space-4); align-items: center; }
.calc-as-label { font-size: var(--text-lg); font-weight: 500; }
.radio-pair { display: flex; gap: var(--space-4); align-items: center; }
.radio-option { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); font-weight: 500; cursor: pointer; }
.radio-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-dot { position: relative; width: var(--control-icon-size); height: var(--control-icon-size); border-radius: 50%; border: var(--outline-thick); background: var(--surface-1); flex-shrink: 0; }
.radio-option input:checked + .radio-dot { background: var(--state-selected); }
.radio-option input:checked + .radio-dot::after {
  content: ''; position: absolute; inset: var(--space-1); border-radius: 50%; background: var(--surface-1);
}
.clear-all {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  font-family: var(--font-body); /* buttons don't inherit font-family by default -- was rendering in the browser's UI font, reading as a different weight than the rest of the page */
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--state-selected);
  background: none;
  border: none;
  border-radius: 4px; /* no visible fill/border, but rounds the focus ring's corners to match everything else */
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.calc-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
@media (max-width: 768px) { .calc-fields { grid-template-columns: repeat(2, 1fr); } }
/* Indented to align with the field-box's own inner left padding, same
   convention as the permit breakdown's dropdown field-label. The grid itself
   switches to 2 columns at 768px, but there's still plenty of room in each
   half-width cell at that width for the indent -- it's only real phones
   (≤480px) where the longer labels ("PLAYERS ON TEAM") get close enough to
   the column edge that the indent risks pushing them past it, so the reset
   uses its own narrower breakpoint rather than reusing the layout one. */
.field-label { display: block; font-size: var(--text-sm); font-weight: 500; text-transform: uppercase; margin-bottom: var(--space-2); padding-left: var(--space-4); }
@media (max-width: 480px) { .field-label { padding-left: 0; } }
.field-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-height);
  border-radius: var(--radius-md);
  border: var(--outline-thick);
  background: var(--surface-1);
  padding: 0 var(--space-4);
}
.field-box input {
  border: none;
  background: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  width: 100%;
  min-width: 0;
  padding: 0;
}
.fee-box .prefix { font-size: var(--text-lg); font-weight: 500; }

/* ---------------- stat cards ---------------- */
.calc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 768px) { .calc-stats { grid-template-columns: 1fr; } }
.calc-stat {
  background: var(--surface-stat);
  border: var(--outline-thick);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
}
.calc-stat-label { font-size: var(--text-base); font-weight: 500; text-transform: uppercase; margin-bottom: var(--space-2); }
.calc-stat-value { font-size: var(--text-2xl); font-weight: 700; line-height: 1; }
.calc-stat-value .unit { font-size: var(--text-xl); font-weight: 500; }
/* Placeholder "—" reads as a value at 700 weight -- lighten it so an empty
   card doesn't look like it's just displaying a very short number. */
.calc-stat-value.is-empty { font-weight: 400; }
.calc-stat-sub { font-size: var(--text-sm); font-weight: 500; margin-top: var(--space-2); min-height: 1.2em; }

/* ---------------- formula card ---------------- */
.formula-card { border-radius: var(--radius-xl); padding: var(--space-5); }
.eq-label { font-size: var(--text-base); font-weight: 500; margin: var(--space-5) 0 var(--space-2); }
.eq-label:first-child { margin-top: 0; }
/* Each formula is a flex row of self-contained terms (script wraps each
   operand + its label in its own span) rather than one long string -- wraps
   only ever happen between terms, never mid-phrase. At phone widths the row
   switches to a column so each term gets its own line instead of an
   equation-shaped run-on sentence. */
.eq {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5em;
  font-family: "Courier Prime", "Courier New", Courier, monospace;
  font-size: var(--text-lg);
  line-height: 1.6;
  margin: 0;
}
.eq-term { white-space: nowrap; }
.eq b { color: var(--money-accent); font-weight: 700; }
@media (max-width: 480px) {
  .eq { flex-direction: column; gap: var(--space-1); }
}
.about-text { font-size: var(--text-sm); line-height: 1.5; margin: 0; }
