/* kpi-transform-2030 */

/* "tranform-2030-kpi" (typo preserved - matches the literal class already
   on the placeholder div in kpi.html.twig/kpi.stories.html) */
.tranform-2030-kpi {
  max-width: 1360px;
  margin: 0 auto;
}

/* Layout-only build-out of the "Transform 2030 KPIs" view (toggled via
   .kpi-view-switch in kpi.html.twig/kpi.js). Deliberately kept in its own
   file, separate from kpi.css, per explicit request - this view's styling
   is independent of the existing KPI Overview/SD1-5 view and shouldn't be
   mixed into that file's own rules. */

/* .t2030-kpi itself carries NO display/gap rules of its own - per explicit
   request, it reuses #kpi-2021-2025's own full wrapper class chain
   (`layout-wrapper aside-content-layout layout-card-wrapper
   logical-response-grid`, added in kpi.js's markup) for the two-column
   grid (minmax(350px,1fr) 3fr - see layouts/col-layout/col-layout.css),
   not a locally-invented flex layout. Declaring display/gap here too
   would fight that grid for the same element (this file loads after
   col-layout.css, so a conflicting rule here would win and silently
   break the grid). */

/* Left-side section nav (SO1/SO2/SO3/FOUNDATIONAL) - reuses the exact same
   wrapper classes as #kpi-2021-2025's own left sidebar (`aside-category-
   section filter-aside cx-rail`): `aside-category-section` for the
   mobile off-canvas Filter-drawer behavior (`.filter-show .logical-
   response-grid .aside-category-section`, see logic-model-responses-
   max-991.css), `filter-aside`/`cx-rail` for the navy card chrome -
   those classes' own rules live in kpi.css, not duplicated here. Only
   the sticky positioning (this view's own addition) stays local to this
   file. */
.t2030-kpi__nav {
  /* .aside-content-layout's grid sizes this column itself (minmax(350px,
     1fr)) - no flex-basis/width override needed. align-self:start is this
     grid's equivalent of align-items:flex-start on a flex row - sticky
     needs it, since a stretched grid item has nothing to "stick" against.
     --top-fixed-height (base/spacing/spacing.css) tracks whatever's really
     fixed at the top of the viewport right now - the header, plus
     section-cards's titles menu once pinned, reactive to both hiding -
     this single rule covers the "menu pinned, header still visible" case
     for free (a separate body:has(.section-cards-menu.is-pinned) override
     used to be needed here before that variable existed). */
  align-self: start;
  position: sticky;
  top: calc(var(--top-fixed-height) + var(--sp5));
  /* .layout--card's own padding:50px uses the browser default content-box
     model (no box-sizing rule anywhere in that shared utility class) -
     harmless at desktop where the grid gives this column a fixed 350px
     track, but at the mobile breakpoint below, width:100% + that padding
     ADDED on top of it overflowed the viewport by exactly 2x the padding
     (confirmed: 50px measured overflow, half of the 100px total from
     50px padding on both sides). */
  box-sizing: border-box;
  transition: var(--top-transition);
}

/* Once the header's also gone (page-scroll-down), the gap above the
   pinned menu is deliberately tighter than the sp5 breathing room used
   everywhere else (sp2, not sp5) - a header-present page already reads
   fine with the larger gap, but with nothing else at the top, sp5 read as
   an odd oversized gap under just the menu alone. --top-fixed-height
   itself already collapses to just the menu's height in this state (see
   spacing.css), so only the gap constant needs overriding here. */
body.page-scroll-down:has(.section-cards-menu.is-pinned) .t2030-kpi__nav {
  top: calc(var(--top-fixed-height) + var(--sp2));
}

/* Left nav is now a real accordion (SO1/SO2/SO3/FOUNDATIONAL groups, each
   KPI a nested sub-item) - .cx-acc/.cx-acc-h/.ic/.cx-acc-b/.cx-radio (see
   js/kpi.js's renderTransform2030Kpi()), styled in kpi.css under
   .kpi-component .filter-aside (not elements/accordion/accordion.css's
   classes/custom properties - this view's own .filter-aside gets the
   exact same cx-* rules as #kpi-2021-2025's own sidebar automatically, no
   duplicate ruleset needed here). js/kpi.js drives open/close + scrollspy
   highlighting directly (not window.accordionUI - see that function's
   own comment for why). */
.t2030-kpi__accordion {
  margin: 0;
}

/* No longer its own scroll container (previously max-height + overflow-y:
   auto here, independent of .t2030-kpi__nav's own overflow - a double-
   scroll setup, and like #kpi-2021-2025's own rail before its fix, an
   overflow:auto element sharing .filter-aside's rounded corner fights the
   native scrollbar's paint). js/kpi.js now wraps THIS (and .cx-rh above
   it) in one shared .cx-rail-scroll div - the real scroll container, see
   below - matching #kpi-2021-2025's own split exactly (kpi.css's own
   .cx-rail-scroll). Just a plain passthrough wrapper for the <ul> now -
   no rule needed, it carries no styling of its own. */

/* .cx-rail-scroll: real overflow-y:auto/scrollbar element for this nav,
   wrapping .cx-rh + .t2030-kpi__nav-inner together (js/kpi.js). Desktop-
   only (matches #kpi-2021-2025's own guard, kpi.css, widened to 1025px
   there too) - below 1025px this nav is the off-canvas Filter drawer
   (shares .aside-category-section) and scrolls via the page itself, same
   as before.
   .filter-aside.cx-rail's own shared rule (kpi.css) still sets this SAME
   element's overflow:auto !important for #kpi-2021-2025's benefit - this
   selector needs equal specificity (.t2030-kpi__nav + .filter-aside, two
   classes, same as kpi.css's own ".kpi-component .filter-aside") to win
   the tie, which it does by loading after kpi.css. */
@media (min-width: 1025px) {
  .t2030-kpi__nav.filter-aside {
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
  }

  .t2030-kpi__nav .cx-rail-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    box-sizing: border-box;
  }
}

/* Right side: every section's cards are now always stacked and visible
   (no more per-section show/hide) - the left accordion/scrollspy is what
   tracks which one you're currently reading, not a content switcher. */
.t2030-kpi__content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp10);
}

.t2030-kpi__section {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--clr-white);
  border-radius: var(--radius-24);
  border-top-right-radius: 0;
  border-bottom-left-radius: 0;
}

/* position:relative by default (NOT sticky) - only the CURRENTLY ACTIVE
   section's title-wrap gets the --active modifier (toggled by kpi.js,
   kept in sync with the left-nav accordion/scrollspy state). Every
   section's title being sticky at once meant that when a section was
   almost entirely scrolled past, CSS clips its sticky title to stay
   within that section's own shrinking box - leaving a visible sliver of
   the PREVIOUS section's title stacked above the new one, no matter how
   precisely the click-to-scroll offset was tuned (reported live bug).
   Only ever sticking one title at a time removes the possibility
   structurally, not just for whatever offset math happened to be tried. */
.t2030-kpi__section-title-wrap {
  position: relative;
  background: var(--clr-white);
}

.t2030-kpi__section-title-wrap:before {
  content: "";
  position: absolute;
  height: calc(100% + 15px);
  bottom: 0;
  background: var(--clr-neutral-200);
  left: 0;
  width: 100%;
}

/* --top-fixed-height (base/spacing/spacing.css) already reacts to both
   page-scroll-down (header hidden) and the section-cards menu pinning, so
   one rule now covers every combination - the two separate rules this
   used to need (default vs. page-scroll-down+pinned) reduced to the exact
   same formula once that variable did the state-tracking instead of each
   consumer re-deriving it. */
.t2030-kpi__section-title-wrap--active {
  position: sticky;
  top: calc(var(--top-fixed-height) + var(--sp2));
  transition: var(--top-transition);
}

.t2030-kpi__section-title {
  margin: 0;
  color: var(--clr-gray-dark);
  font-size: var(--fs-24);
  font-weight: var(--fw-bold);
  margin-bottom: 0;
  position: relative;
  padding: 15px 20px;
  border-bottom: 1px solid #cccccc;
  z-index: 1;
  background: var(--clr-white);
  border-top-right-radius: var(--radius-24);
  border-top-left-radius: var(--radius-24);
}

.t2030-kpi__cards {
  padding-left: var(--sp10);
  padding-right: var(--sp10);
}

.t2030-kpi__card {
  box-sizing: border-box;
  padding: var(--sp8) 0;
  background: var(--clr-white);
  border-bottom: 1px solid var(--clr-primary);
}

.t2030-kpi__card:last-child {
  border-bottom: none;
}

/* Alternating cut-corner pattern (same convention used elsewhere in this
   project, e.g. layouts/cards__layout2's own card-goal alternation).
   :nth-of-type, not :nth-child - each .t2030-kpi__section has an <h3>
   title before its cards, which would otherwise occupy child position 1
   and shift every card's odd/even parity by one; :nth-of-type counts only
   among same-tag (<div>) siblings, so the first card is always "odd"
   regardless of the heading before it. */
.t2030-kpi__card:nth-of-type(odd) {
  border-top-right-radius: 0;
  border-bottom-left-radius: 0;
}

.t2030-kpi__card:nth-of-type(even) {
  border-top-left-radius: 0;
  border-bottom-right-radius: 0;
}

.t2030-kpi__card-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp3);
  margin-bottom: var(--sp5);
}

.t2030-kpi__name {
  display: inline-block;
  flex-shrink: 0;
  padding: var(--sp1) var(--sp3);
  background: var(--clr-primary);
  border-radius: var(--radius-5);
  color: var(--clr-white);
  font-size: var(--fs-12);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.t2030-kpi__title {
  margin: 0;
  color: var(--section-sub-title, var(--clr-blue));
  font-size: var(--fs-21);
  font-weight: var(--fw-bold);
}

/* Formula: "left_label = numerator / denominator" - rendered as a classic
   stacked fraction (numerator over a rule over denominator) rather than
   one cramped inline sentence, since numerator/denominator are often full
   paragraphs of rich text, not short terms. */
.t2030-kpi__formula {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp8);
  padding-top: var(--sp5);
  border-top: 1px solid var(--clr-gray-light);
}

.t2030-kpi__formula-label {
  width: 300px;
  text-align: right;
  color: var(--clr-gray-dark);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
}

/* Own flex item (not appended into the label's own text) specifically so
   .t2030-kpi__formula's existing `gap` falls equally on both sides of it -
   the label's own trailing " =" before gave it a single space on the left
   but the full 40px gap on the right. */
.t2030-kpi__formula-eq {
  flex: 0 0 auto;
  color: var(--clr-gray-dark);
  font-size: var(--fs-24);
}

.t2030-kpi__formula-fraction {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.t2030-kpi__formula-numerator,
.t2030-kpi__formula-denominator {
  font-size: var(--fs-14);
  color: var(--clr-gray-dark);
}

.t2030-kpi__formula-numerator *,
.t2030-kpi__formula-denominator * {
  font-size: var(--fs-14);
}

.t2030-kpi__formula-numerator p,
.t2030-kpi__formula-denominator p {
  margin: 0;
}

.t2030-kpi__formula-numerator p+p,
.t2030-kpi__formula-denominator p+p {
  margin-top: var(--sp2);
}

.t2030-kpi__formula-rule {
  height: 1px;
  margin: var(--sp3) 0;
  background: var(--clr-gray-dark);
}

@media (max-width: 1024px) {

  /* Overrides .aside-content-layout's own grid-template-columns (same
     minmax(350px,1fr) 3fr two-column grid #kpi-2021-2025's sidebar uses,
     unchanged there - this override is scoped to .t2030-kpi only). */
  .t2030-kpi {
    grid-template-columns: 1fr;
  }

  /* .aside-category-section (reused for card chrome above) brings along
     #kpi-2021-2025's own real off-canvas mobile filter drawer behavior
     from logic-model-responses-max-991.css at this exact breakpoint
     (`.logical-response-grid .aside-category-section { position:absolute;
     left:-120% }`, revealed via a `.filter-show` class) - previously
     overridden away (forced always-visible/sticky) since this view had no
     matching Filter button; now that `.t2030-kpi__filter-btn` exists
     (wired in js/kpi.js), left to apply as-is rather than fighting it -
     "use same [behavior] in Transform 2030 KPIs" was explicit. `width`
     still needs asserting (the shared rule's own base, un-breakpointed
     declaration leaves it unset); `max-width:400px` matches the shared
     rule's own cap exactly, per explicit request. */
  .t2030-kpi .t2030-kpi__nav {
    width: 100%;
    max-width: 400px;
  }

  .t2030-kpi__formula-label {
    width: 200px;
  }

  .t2030-kpi__card {
    padding-left: 32px;
    padding-right: 32px;
  }
}

@media (max-width: 767px) {
  .t2030-kpi {
    grid-template-columns: 1fr;
  }

  /* Smaller card padding at this width - the desktop var(--sp8)/30px
     top-bottom reads as excess whitespace once the card is this narrow. */
  .t2030-kpi__card {
    padding-top: var(--sp5);
    padding-bottom: var(--sp5);
    padding-left: var(--sp6_5);
    padding-right: var(--sp6_5);
    border-radius: 10px;
  }

  /* flex-start (not the default baseline) so a wrapped 2-line KPI title
     doesn't drag the KPI-number badge down to its first line's baseline,
     which read as misaligned - badge now pins to the title's top line. */
  .t2030-kpi__card-head {
    align-items: flex-start;
    gap: var(--sp2);
  }

  .t2030-kpi__title {
    font-size: var(--fs-16);
  }

  /* The desktop/tablet side-by-side layout (fixed-width right-aligned
     label + "=" + fraction) breaks down at this width - a 200px label
     plus the fraction's own 320px min-width don't fit together, so it
     wrapped onto two lines on its own but kept the label's right-aligned
     text sitting oddly disconnected above a left-aligned fraction block.
     Restacked properly instead: label+"=" left-aligned together on one
     line, fraction below at full width. */
  .t2030-kpi__formula {
    gap: var(--sp2) var(--sp3);
  }

  .t2030-kpi__formula-label {
    width: auto;
    text-align: left;
  }

  .t2030-kpi__formula-eq {
    font-size: var(--fs-18);
  }

  .t2030-kpi__formula-fraction {
    flex-basis: 100%;
  }
}
