/* ==========================================================================
   cross-country-analytics - common overrides shared by cx-banner,
   cx-explorer and cx-srcs (data-sources). Everything here exists to
   counteract site-wide rules on the real Drupal site (gff theme),
   confirmed against https://gffstage-d10.panapps.net/cross-country-analytics
   and its actual CSS - none of this is reproducible from this repo's
   local base/ copy, since the live theme's CSS differs slightly:

   1. components/common/css/button.css:
        .pager li>.button, body button, body .btn, body .button {
          box-shadow: none !important;
          outline: 0 !important;
          font-size: 14px; border: 1px solid #1fa29c; color: #1fa29c;
          height: 34px; line-height: 34px; padding: 0 15px;
          font-weight: 700; border-radius: 4px; ... }
        body button:hover, body button:focus {
          color: #fff; background: #1fa29c; border-color: #1fa29c; }
      Two separate problems from the same file:
        a. The non-!important properties (height, padding, border, etc.)
           are already beaten by any of our own class selectors (a class
           beats a bare `button` type selector) - except `height`, which
           none of our own rules declared at all until now, so that one
           was free to apply.
        b. `box-shadow`/`outline` are !important - no selector,
           regardless of specificity, can override those without also
           being !important. Any button here with its own box-shadow
           (.cx-tab, .cx-info-fab) loses it entirely; EVERY button loses
           its native focus ring (outline: 0), so one has to be added
           back explicitly - also with !important - for keyboard focus
           to be visible at all.
        c. The :hover/:focus rule paints a button teal unless it already
           sets background/color/border-color for BOTH pseudo-classes -
           an existing :hover-only override still gets caught by the
           separate :focus rule.

   2. components/redesign/base/base.css:
        [class*=" radius-"] { overflow: hidden; }
      A generic corner-clipping utility - intended for elements that use
      a `radius-*` class for their OWN border-radius. This page's chapter
      wrapper (`.cross-country-explore`, alongside `.page-main-chapter`)
      also happens to carry `radius-sm` for unrelated reasons, so this
      rule's `overflow: hidden` lands on an ancestor of .cx-rail.

   3. components/common/css/layout.css:
        .main-container { overflow: hidden; ... }
      A second, unrelated ancestor between <body> and .cx-rail with the
      same effect - `position: sticky` stops working the moment ANY
      ancestor up to the scroll container has overflow other than
      visible, so both (2) and (3) have to be fixed together.

   4. components/redesign/base/spacing/spacing.css:
        .sections-alt-bg .page-main-chapter { margin-top: var(--sp8); }
        .p-styl-1 { padding: var(--sp-large) var(--px) !important; }
      Both chapter wrappers (`.cross-country-explore`, `.cross-country-sources`)
      carry `page-main-chapter` + `p-styl-1`, and the page's <body> carries
      `sections-alt-bg` (confirmed on the live site). Two different problems:
        a. The margin-top rule is a *descendant* selector - specificity
           (0,2,0) - which beats a plain single-class rule like
           `.cross-country-explore { margin-top: 0 }` (0,1,0) no matter
           which stylesheet loads last. Needs either higher specificity or
           !important; used !important here to match fix 1's approach.
        b. The padding rule is !important, same story as fix 1's box-shadow/
           outline - nothing without !important can touch it.

   5. components/common/css/button.css, @media (max-width: 767px):
        .pager li>.button, body button:not(.navbar-toggle), body .btn,
        body .button { height: 30px; line-height: 30px; }
      A SEPARATE, mobile-only button-height rule from fix 1's desktop-wide
      `body button { height: 34px }` - not just a breakpoint variant of it,
      a different selector with different specificity math: `:not(.navbar-
      toggle)` counts its own argument's specificity same as a real class,
      so `body button:not(.navbar-toggle)` is (0,1,2) - MORE specific than
      a plain class alone. Fix 1's own `.cx-tab, .cx-acc-h, .cx-radio {
      height: auto }` (0,1,0) is enough to beat the 34px desktop rule
      (bare type selectors, 0,0,2) but not this one - confirmed broken on
      the live site at <=767px (.cx-tab's own badge/title text overlapping
      the next stacked tab card, screenshot). Needs !important, see below.

   Load this after each component's own CSS (see gff.libraries.yml's
   cx_banner/cx_explorer/cx_data_sources - each depends on gff/cx_common).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Fix 1: the sticky rail (page-template ancestors' overflow).
   `.cross-country-explore` is this page's own chapter-wrapper class
   (confirmed on the live site) - scoping to it directly, rather than to
   `.page-main-chapter` or `[class*=" radius-"]` outright, keeps this from
   touching unrelated sections sitewide that may actually need the
   corner-clipping those rules normally provide. The `:has()` versions are
   a fallback for the same components used somewhere without that class.
   -------------------------------------------------------------------------- */
.cross-country-explore,
.main-container:has(.cx-explorer),
.page-main-chapter:has(.cx-banner),
.page-main-chapter:has(.cx-explorer),
.page-main-chapter:has(.cx-srcs) {
  overflow: visible;
}

/* This page's own chapter wrapper: drop the page template's default top
   margin (the banner already provides its own spacing above) and use a
   plain, even 40px top/bottom instead of whatever `.page-main-chapter`'s
   other modifier classes would otherwise produce. !important on all three:
   margin-top fights a higher-specificity `.sections-alt-bg .page-main-
   chapter` rule, padding fights `.p-styl-1`'s own !important - see fix 4. */
.cross-country-explore {
  margin-top: 0 !important;
  padding-top: 40px !important;
  padding-bottom: 40px !important;
}

/* data-sources' own chapter wrapper: the page template's default section
   background/padding (odd-even striping + `.p-styl-1`) don't apply here -
   the cx-srcs component inside already draws its own card background and
   spacing. Same !important reasoning as .cross-country-explore above. */
.cross-country-sources {
  background: transparent !important;
  padding: 0 !important;
}

/* site header's own box-shadow (components/header/css/header.css's
   `header.navbar { box-shadow: var(--header-box-shadow) }`) is unwanted
   on this page - scoped to body's own page-route class (confirmed on
   the live site) so it only drops here, not sitewide. Higher specificity
   than the plain `header.navbar` rule, no !important needed. */
body.path-cross-country-analytics header.navbar {
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Fix 2a: box-shadow/outline are !important in the site's button.css, so
   restoring either needs !important too - nothing else can beat it.
   -------------------------------------------------------------------------- */
.cx-tab {
  box-shadow: 0 6px 14px rgba(13, 30, 55, 0.14) !important;
}

.cx-tab:hover,
.cx-tab.is-on {
  box-shadow: 0 6px 14px rgba(13, 30, 55, 0.14), inset 0 0 0 999px var(--cxe-navy-overlay, rgba(6, 26, 56, 0.42)) !important;
}

/* cx-info-fab: `body button { padding: 0 15px }` eats 30px of this 45px-
   wide round button's horizontal space. Height has no padding to fight,
   so the svg (flex item, flex-shrink:1) keeps its full 30px intrinsic
   height but shrinks to fit the remaining 15px width, rendering as a
   squashed 15x30 icon instead of 30x30 - confirmed via computed styles
   on the live site. Only `padding` needs restating (not !important: a
   plain class already beats the site's `body button` on specificity,
   it just never declared this property before). */
.cx-info-fab {
  padding: 0;
  box-shadow: 0 10px 24px rgba(13, 30, 55, 0.28) !important;
}

.cx-info-fab:hover {
  box-shadow: 0 12px 28px rgba(13, 30, 55, 0.34) !important;
}

/* Every other interactive button here loses its native focus ring to the
   same `outline: 0 !important` - .cx-tab/.cx-radio/.cx-country-dot/
   .cx-profile-link already define their own :focus-visible outline
   elsewhere (an <a>, like .cx-profile-link, isn't touched by button.css
   at all), these are the ones that had none. */
.cx-acc-h:focus-visible,
.cx-ddl-trigger:focus-visible,
.cx-seg-btn:focus-visible,
.cx-drawer .x:focus-visible,
.cx-info-fab:focus-visible {
  outline: 3px solid var(--cxe-accent, #F8B323) !important;
  outline-offset: 2px !important;
}

/* --------------------------------------------------------------------------
   Fix 2b: body button:hover / body button:focus leaking in. Each block
   restates color/background/border-color (and height, where the site's
   `body button { height: 34px }` would otherwise also apply) for both
   pseudo-classes together, since fixing only :hover still leaves :focus
   (keyboard tab, or a click that keeps focus) painted teal.
   -------------------------------------------------------------------------- */

/* cx-explorer: level cards and the accordion header need their natural
   content height, not the sitewide fixed button height.
   !important: beats fix 1's desktop body button{height:34px} (0,0,2) on
   plain specificity alone, but not fix 5's mobile body button:not(...)
   {height:30px} (0,1,2, same as this selector) - needed at <=767px too
   (reported: .cx-tab's badge/title overlapping the next stacked card). */
.cx-tab,
.cx-acc-h,
.cx-radio {
  height: auto !important;
}

/* cx-explorer: accordion header - only the label span should turn
   yellow on hover/focus, the row itself stays transparent */
.cx-acc-h:hover,
.cx-acc-h:focus,
.cx-acc-h:focus-visible {
  background: none;
  color: var(--cxe-white, #FFFFFF);
  border-color: transparent;
}

/* cx-explorer: sort/view/country dropdown triggers - flat underline
   trigger, just a colour change, no fill */
.cx-ddl-trigger:hover,
.cx-ddl-trigger:focus,
.cx-ddl-trigger:focus-visible {
  color: #0F37A9;
  background: var(--cxe-white, #FFFFFF);
  border-color: transparent;
  border-bottom-color: var(--cxe-line, #DBDBDB);
}

/* cx-explorer: scope toggle's unchecked side - already had its own
   background override, just needed color restated too (was leaking
   white-on-white text) */
.cx-seg-btn[aria-checked="false"]:hover,
.cx-seg-btn[aria-checked="false"]:focus,
.cx-seg-btn[aria-checked="false"]:focus-visible {
  background: var(--cxe-white, #FFFFFF);
  color: var(--cxe-ink, #4D4D4D);
}

/* cx-explorer: country profile drawer's close button - design's own
   .cx-info-close:hover convention (same round gray icon-close button
   family elsewhere on this page) */
.cx-drawer .x:hover,
.cx-drawer .x:focus,
.cx-drawer .x:focus-visible {
  background: #DBDBDB;
  color: #00413C;
  border-color: transparent;
}

