/**
 * Page banners on inner pages, styled after the homepage banner (no arrows).
 *
 * - .page-hero: the first Cover block on a page, tagged by App\Helpers\PageHero.
 * - .resources-header: the XPT News (posts page) header, views/templates/posts.twig.
 *
 * Dark charcoal-green field from the left, thin green frame clear of the
 * header, short green rule above the title, condensed title face.
 * :not(#xpt-hero) outranks the Customizer CSS and the blocks' inline styles.
 *
 * Plain CSS outside the Sass build; loaded by AssetsServiceProvider.
 */

:is(.page-hero, .resources-header):not(#xpt-hero) {
  --hero-ink: 22, 32, 29;
  --hero-green: #00ce7c;
  --hero-mist: #d6e6df;
  position: relative;
  isolation: isolate;
}

/* ---- Dark field -------------------------------------------------------- */

.page-hero:not(#xpt-hero) .wp-block-cover__background {
  z-index: 1;
  opacity: 1 !important;
  background:
    linear-gradient(90deg,
      rgba(var(--hero-ink), 0.92) 0%,
      rgba(var(--hero-ink), 0.8) 32%,
      rgba(var(--hero-ink), 0.4) 55%,
      rgba(var(--hero-ink), 0.08) 75%),
    linear-gradient(180deg, rgba(var(--hero-ink), 0.6) 0%, rgba(var(--hero-ink), 0) 28%) !important;
}

/* Centred banners (e.g. the brand pages) get an even wash instead. */
.page-hero:not(#xpt-hero):has(.wp-block-cover__inner-container > .has-text-align-center) .wp-block-cover__background {
  background:
    linear-gradient(180deg, rgba(var(--hero-ink), 0.7) 0%, rgba(var(--hero-ink), 0.45) 35%, rgba(var(--hero-ink), 0.6) 100%) !important;
}

.resources-header:not(#xpt-hero)::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(var(--hero-ink), 0.9) 0%,
      rgba(var(--hero-ink), 0.7) 35%,
      rgba(var(--hero-ink), 0.2) 70%,
      rgba(var(--hero-ink), 0) 100%),
    linear-gradient(180deg, rgba(var(--hero-ink), 0.55) 0%, rgba(var(--hero-ink), 0) 30%);
  pointer-events: none;
}

/* ---- Thin green frame, clear of the 94px header ------------------------ */
/* Not on the XPT News header: its cards overlap the bottom edge. */

.page-hero:not(#xpt-hero)::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 102px 24px 24px 24px;
  border: 1px solid rgba(0, 206, 124, 0.45);
  pointer-events: none;
}

.page-hero:not(#xpt-hero) .wp-block-cover__inner-container { z-index: 3; }

/* ---- Title ------------------------------------------------------------- */

.page-hero:not(#xpt-hero) .wp-block-cover__inner-container h1,
.page-hero:not(#xpt-hero):not(:has(h1)) .wp-block-cover__inner-container h2:first-of-type,
.resources-header:not(#xpt-hero) .resources-heading {
  font-family: "TradeGothicLT-BoldCondTwenty", "TradeGothicLT-Bold", "Arial Narrow", sans-serif !important;
  font-weight: normal !important;
  font-size: clamp(36px, 4.6vw, 72px) !important;
  line-height: 1 !important;
  letter-spacing: 0 !important;
  text-transform: none;
  color: #fff !important;
}

/* Short green rule above the banner title (not on leader profiles, where the
   title sits beside a portrait with contact details under it). */
.page-hero:not(#xpt-hero):not(.leader-profile) .wp-block-cover__inner-container h1::before,
.page-hero:not(#xpt-hero):not(.leader-profile):not(:has(h1)) .wp-block-cover__inner-container h2:first-of-type::before,
.resources-header:not(#xpt-hero) .resources-heading::before {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  margin-bottom: clamp(20px, 2.4vw, 32px);
  background: var(--hero-green);
}

.page-hero:not(#xpt-hero) .wp-block-cover__inner-container .has-text-align-center:is(h1, h2)::before {
  margin-left: auto;
  margin-right: auto;
}

.page-hero:not(#xpt-hero) .wp-block-cover__inner-container > p:not(.has-text-align-center),
.resources-header:not(#xpt-hero) .resources-description p {
  max-width: 60ch;
  /* Left-aligned with the title: the constrained layout would otherwise
     centre this narrower block. Margin % is of the container width, so this
     matches the 1440px content box on wide screens. */
  margin-left: max(0px, calc((100% - 1440px) / 2)) !important;
  margin-right: auto !important;
  font-family: "TradeGothicLT", "Helvetica Neue", Arial, sans-serif !important;
  font-weight: normal !important;
  font-size: clamp(17px, 1.3vw, 20px) !important;
  line-height: 1.6 !important;
  color: var(--hero-mist) !important;
}

/* ---- Phones ------------------------------------------------------------ */

@media (max-width: 781px) {
  /* Clear the fixed mobile header. */
  .page-hero:not(#xpt-hero) { padding-top: 112px !important; }
  .page-hero:not(#xpt-hero) .wp-block-cover__background {
    background: rgba(var(--hero-ink), 0.72) !important;
  }
  .resources-header:not(#xpt-hero)::before { background: rgba(var(--hero-ink), 0.72); }
  .page-hero:not(#xpt-hero)::after { display: none; }
}

/* ---- Single news post banner (views/templates/single.twig) -------------- */
/* Same treatment as the page banners: dark field from the left, thin green
   frame, green rule above the title. Background image per post:
   App\Helpers\PostBanner. */

.post-hero:not(#xpt-hero) {
  --hero-ink: 22, 32, 29;
  --hero-green: #00ce7c;
  --hero-mist: #d6e6df;
  position: relative;
  isolation: isolate;
  min-height: clamp(380px, 32vw, 480px);
  display: flex;
  align-items: center;
  /* On posts the header is a solid bar above the banner, not overlaid. */
  padding: 72px 0;
}

.post-hero:not(#xpt-hero)::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(var(--hero-ink), 0.92) 0%,
      rgba(var(--hero-ink), 0.8) 38%,
      rgba(var(--hero-ink), 0.35) 70%,
      rgba(var(--hero-ink), 0.15) 100%),
    linear-gradient(180deg, rgba(var(--hero-ink), 0.6) 0%, rgba(var(--hero-ink), 0) 30%);
  pointer-events: none;
}

.post-hero:not(#xpt-hero)::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 24px;
  border: 1px solid rgba(0, 206, 124, 0.45);
  pointer-events: none;
}

.post-hero:not(#xpt-hero) .xpt-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: max(var(--global--container-horizontal-padding, 20px), min(56px, calc(56px - (100vw - 1440px) / 2)));
  padding-right: var(--global--container-horizontal-padding, 20px);
}

.post-hero:not(#xpt-hero) .single-post-heading { max-width: 980px; }

.post-hero:not(#xpt-hero) .single-post-heading p {
  margin: 0 0 18px;
  font-family: "TradeGothicLT-Bold", "Helvetica Neue", Arial, sans-serif !important;
  font-weight: normal !important;
  font-size: 16px !important;
  color: var(--hero-mist) !important;
}

.post-hero:not(#xpt-hero) .single-post-heading p::before {
  content: "";
  display: block;
  width: 72px;
  height: 4px;
  margin-bottom: 24px;
  background: var(--hero-green);
}

.post-hero:not(#xpt-hero) h1 {
  max-width: none;
  margin: 0;
  font-family: "TradeGothicLT-BoldCondTwenty", "TradeGothicLT-Bold", "Arial Narrow", sans-serif !important;
  font-weight: normal !important;
  font-size: clamp(34px, 3.8vw, 60px) !important;
  line-height: 1.04 !important;
  letter-spacing: 0 !important;
  color: #fff !important;
  text-wrap: balance;
}

.post-hero:not(#xpt-hero) .yoast-breadcrumbs {
  margin-top: 28px;
  font-size: 15px;
  color: var(--hero-mist);
}

.post-hero:not(#xpt-hero) .yoast-breadcrumbs a {
  color: #fff !important;
  text-decoration-color: rgba(255, 255, 255, 0.45);
}

.post-hero:not(#xpt-hero) .yoast-breadcrumbs a:hover { color: var(--hero-green) !important; }

@media (max-width: 781px) {
  .post-hero:not(#xpt-hero) { min-height: 0; padding: 48px 0; }
  .post-hero:not(#xpt-hero)::before { background: rgba(var(--hero-ink), 0.75); }
  .post-hero:not(#xpt-hero)::after { display: none; }
  .post-hero:not(#xpt-hero) .xpt-container { padding-left: var(--global--container-horizontal-padding, 20px); }
}

/* Visually hidden, still read by screen readers and search engines (used for
   the H1 on the Portfolio and brand pages, whose banners show logos). */
.screen-reader-text:not(:focus):not(:active) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}
