/* Hero Block Styles
 *
 * Two display modes, switched by the same condition everywhere (CSS and the <picture> source in hero.php):
 *
 *   Stacked  - phones and portrait tablets (< 1024px wide, or < 768px in any orientation).
 *              Image on top, text on a card below it (or text over the image).
 *   Wide     - desktops and landscape tablets (>= 1024px, or >= 768px in landscape).
 *              Full screen layout: image behind the text.
 *              Split layout: 50/50 image and text panel.
 *
 * The un-queried rules below are the stacked styles; the wide styles live in the last media query.
 */

/* Main container */
.hero-container {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Multiplier for the editor's spacing sliders (--hero-headline-gap / --hero-content-gap) */
  --hero-gap-scale: 0.75;
}

/* Height options - min-height caps out at a sensible floor on short viewports */
.hero-container.hero-height-small {
  min-height: max(25vh, 320px);
}

.hero-container.hero-height-medium {
  min-height: max(50vh, 420px);
}

.hero-container.hero-height-large {
  min-height: max(75vh, 520px);
}

.hero-container.hero-height-full {
  min-height: max(100vh, 600px);
}

/* Background image - stacked above the content card. Capped relative to the width so
   it never dominates a tall phone or tablet screen. */
.hero-container .hero-bg {
  position: relative;
  z-index: 0;
  width: 100%;
  height: min(var(--hero-mobile-image-height, 66vh), 110vw);
  overflow: hidden;
  /* The theme styles its own .hero-bg (light blue background); don't inherit it */
  background: transparent;
}

.hero-container .hero-bg picture {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-container .hero-bg .hero-bg-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Overlay (gradient or solid). Solid "one side" overlays set their own inset/width inline. */
.hero-bg-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Content area (stacked: a card overlapping the bottom of the image) */
.hero-content {
  /* Lets the small-tablet row layout respond to the width of the text column */
  container: hero-content / inline-size;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  padding: 2rem 1.25rem 2.5rem;
  width: 100%;
  /* The block's background colour, else the Mobile Card Background field, else white */
  background-color: var(--hero-split-bg, var(--hero-mobile-card-bg, #ffffff));
  margin: 0;
  border-radius: 0;
}

/* Inner content wrapper */
.hero-content-inner {
  display: flex;
  flex-direction: column;
  /* Space between the logo, the headline + text block, the buttons and the quote */
  gap: var(--hero-content-gap, clamp(1rem, 0.85rem + 0.7vw, 1.5rem));
  width: 100%;
  max-width: min(var(--hero-content-width-mobile, 800px), 100%);
}

/* Wraps the headline/text and the buttons. Invisible (display: contents) except on small tablets. */
.hero-main-row {
  display: contents;
}

/* Headline + supporting text */
.hero-text-group {
  display: flex;
  flex-direction: column;
  gap: var(--hero-headline-gap, clamp(0.5rem, 0.35rem + 0.5vw, 0.875rem));
  align-items: inherit;
  text-align: inherit;
  max-width: 100%;
}

/* Mobile text alignment: phones only (below 768px). Tablets use the desktop alignment setting. */
@media (max-width: 767px) {
  .hero-container.hero-align-mobile-left .hero-content-inner {
    align-items: flex-start;
    text-align: left;
  }

  .hero-container.hero-align-mobile-center .hero-content-inner {
    align-items: center;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }

  .hero-container.hero-align-mobile-right .hero-content-inner {
    align-items: flex-end;
    text-align: right;
    margin-left: auto;
  }
}

/* Logo / supporting image. The chosen width never exceeds the container and
   scales down when stacked so it doesn't dominate small screens. */
.hero-logo {
  width: min(max(96px, calc(var(--hero-logo-width, 200px) * 0.75)), 100%);
  max-width: 100%;
  line-height: 0;
}

.hero-logo-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* Logo pinned to the top of the hero */
.hero-logo-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 11;
  box-sizing: border-box;
  display: flex;
  padding: 1rem 1.25rem 0;
  pointer-events: none;
}

.hero-logo-top .hero-logo {
  pointer-events: auto;
}

@media (max-width: 767px) {
  .hero-container.hero-align-mobile-left .hero-logo-top {
    justify-content: flex-start;
  }

  .hero-container.hero-align-mobile-center .hero-logo-top {
    justify-content: center;
  }

  .hero-container.hero-align-mobile-right .hero-logo-top {
    justify-content: flex-end;
  }
}

/* Title - fluid so there are no hard jumps between breakpoints */
.hero-title {
  font-family: "DM Serif Display", serif;
  font-size: clamp(1.75rem, 0.95rem + 3.4vw, 3.5rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--hero-title-color-mobile, #003558);
  margin: 0 !important;
  overflow-wrap: break-word;
}

/* Text. Scoped under the container so theme paragraph margins can't add unrequested space. */
.hero-container .hero-text {
  font-family: "Open Sans", sans-serif;
  font-size: clamp(0.9375rem, 0.85rem + 0.4vw, 1.125rem);
  line-height: 1.6;
  color: var(--hero-text-color-mobile, #0580d2);
  margin: 0;
}

/* CTA wrapper */
.hero-cta-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

@media (max-width: 767px) {
  .hero-container.hero-align-mobile-center .hero-cta-wrapper {
    justify-content: center;
  }

  .hero-container.hero-align-mobile-right .hero-cta-wrapper {
    justify-content: flex-end;
  }
}

/* CTA button */
.hero-cta-button {
  /* Button padding scales with the screen; the outlined button subtracts its 2px border */
  --hero-btn-py: clamp(0.8rem, 0.7rem + 0.4vw, 1rem);
  --hero-btn-px: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);
  display: inline-block;
  box-sizing: border-box;
  font-family: "Open Sans", sans-serif;
  font-weight: 600;
  font-size: clamp(0.9375rem, 0.88rem + 0.25vw, 1.125rem);
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  background-color: #0580d2;
  color: #ffffff;
  padding: var(--hero-btn-py) var(--hero-btn-px);
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background-color 200ms ease-in-out, filter 200ms ease-in-out;
}

.hero-cta-button:hover {
  background-color: #046ba8;
}

/* Custom button colours: darken on hover instead of swapping to the default hover colour */
.hero-cta-button.hero-cta-custom-bg:hover {
  filter: brightness(0.9);
}

/* Secondary (outlined) button */
.hero-cta-button.hero-cta-button-secondary {
  background-color: transparent;
  color: #0580d2;
  border: 2px solid currentColor;
  padding: calc(var(--hero-btn-py) - 2px) calc(var(--hero-btn-px) - 2px);
}

.hero-cta-button.hero-cta-button-secondary:hover {
  background-color: transparent;
  filter: brightness(0.85);
}

/* Quote */
.hero-quote {
  margin: 0;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  color: #0580d2;
}

/* Over an image there's no guarantee of contrast, so the quote gets a tinted panel unless a
   background colour is chosen (that is set inline and wins over this). */
.hero-container.hero-layout-full .hero-quote {
  background-color: rgba(0, 53, 88, 0.55);
}

.hero-container.hero-layout-full.hero-mobile-card .hero-quote {
  background-color: transparent;
}

.hero-container .hero-quote-text {
  font-family: "Open Sans", sans-serif;
  font-size: clamp(0.9375rem, 0.88rem + 0.25vw, 1.125rem);
  font-style: italic;
  line-height: 1.5;
  margin: 0 0 0.5rem;
  max-width: 50ch;
}

.hero-quote-citation {
  display: block;
  font-family: "Open Sans", sans-serif;
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 600;
  opacity: 0.8;
}

/* Small phones: stack the buttons full width so they're easy to tap */
@media (max-width: 479px) {
  .hero-cta-wrapper {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .hero-cta-button {
    width: 100%;
  }
}

/* Portrait tablets: still stacked, but with roomier spacing and a shorter image */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .hero-container .hero-bg {
    height: min(var(--hero-mobile-image-height, 66vh), 60vw);
  }

  .hero-content {
    padding: 2.5rem 2.5rem 3rem;
    width: 100%;
  }

  .hero-logo-top {
    padding: 1.5rem 2.5rem 0;
  }
}

/* Stacked layouts (phones and portrait tablets) */
@media (max-width: 767px), (max-width: 1023px) and (orientation: portrait) {
  /* Optional: no overlay once the layout stacks */
  .hero-container.hero-overlay-off-stacked .hero-bg-overlay {
    display: none;
  }

  /* "Text on card": the hero is only as tall as its image plus card, with no dead space */
  .hero-container.hero-mobile-card {
    min-height: 0;
  }

  /* "Text over image" */
  .hero-container.hero-mobile-overlay.hero-height-full {
    min-height: max(100vh, 560px);
    min-height: max(100svh, 560px);
  }

  .hero-container.hero-mobile-overlay .hero-bg {
    position: absolute;
    inset: 0;
    height: 100%;
    z-index: 0;
  }

  .hero-container.hero-mobile-overlay .hero-content {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 2.5rem 1.25rem;
    background-color: transparent;
    border-radius: 0;
  }

  /* Vertical alignment (stacked) */
  .hero-container.hero-mobile-overlay.hero-valign-mobile-top .hero-content {
    align-items: flex-start;
  }

  .hero-container.hero-mobile-overlay.hero-valign-mobile-center .hero-content {
    align-items: center;
  }

  .hero-container.hero-mobile-overlay.hero-valign-mobile-bottom .hero-content {
    align-items: flex-end;
  }

  /* Leave room for a logo pinned to the top of the hero */
  .hero-container.hero-mobile-overlay.hero-has-logo-top.hero-valign-mobile-top .hero-content {
    padding-top: 6rem;
  }

  /* Light text defaults when sitting over the image */
  .hero-container.hero-mobile-overlay .hero-title {
    color: var(--hero-title-color-mobile, #ffffff);
  }

  .hero-container.hero-mobile-overlay .hero-text {
    color: var(--hero-text-color-mobile, rgba(255, 255, 255, 0.9));
  }

  .hero-container.hero-mobile-overlay .hero-quote {
    color: rgba(255, 255, 255, 0.9);
  }

  .hero-container.hero-mobile-overlay .hero-cta-button.hero-cta-button-secondary {
    color: #ffffff;
  }
}

/* Wide layouts: desktops and landscape tablets */
@media (min-width: 1024px), (min-width: 768px) and (orientation: landscape) {
  /* Container changes to row layout */
  .hero-container {
    flex-direction: row;
    --hero-gap-scale: 1;
  }

  /* Positions the content box (capped at max-width) within the full-width container */
  .hero-container.hero-align-left {
    justify-content: flex-start;
  }

  .hero-container.hero-align-center {
    justify-content: center;
  }

  .hero-container.hero-align-right {
    justify-content: flex-end;
  }

  /* Background fills the whole hero behind the content */
  .hero-container .hero-bg {
    position: absolute;
    inset: 0;
    height: auto;
    z-index: 0;
  }

  /* Content area adjustments for desktop */
  .hero-content {
    padding: 3rem clamp(1.5rem, 4vw, 4rem);
    width: 100%;
    background-color: transparent;
    margin: 0;
    border-radius: 0;
    display: flex;
    align-items: center;
  }

  /* Vertical alignment (desktop) */
  .hero-container.hero-valign-top .hero-content {
    align-items: flex-start;
  }

  .hero-container.hero-valign-center .hero-content {
    align-items: center;
  }

  .hero-container.hero-valign-bottom .hero-content {
    align-items: flex-end;
  }

  /* Constrains the content column to the theme's wide content width */
  .hero-container.hero-content-contained .hero-content {
    max-width: var(--wp--style--global--wide-size, 1680px);
    margin: 0 auto;
  }

  /* Positions the content block within the full-width row on desktop */
  .hero-container.hero-align-left .hero-content {
    justify-content: flex-start;
  }

  .hero-container.hero-align-center .hero-content {
    justify-content: center;
  }

  .hero-container.hero-align-right .hero-content {
    justify-content: flex-end;
  }

  /* Text alignment options (desktop) - overrides the stacked alignment above */
  .hero-container.hero-align-left .hero-content-inner {
    align-items: flex-start;
    text-align: left;
    margin: 0;
  }

  .hero-container.hero-align-center .hero-content-inner {
    align-items: center;
    text-align: center;
    margin: 0;
  }

  .hero-container.hero-align-right .hero-content-inner {
    align-items: flex-end;
    text-align: right;
    margin: 0;
  }

  .hero-container.hero-align-left .hero-cta-wrapper {
    justify-content: flex-start;
  }

  .hero-container.hero-align-center .hero-cta-wrapper {
    justify-content: center;
  }

  .hero-container.hero-align-right .hero-cta-wrapper {
    justify-content: flex-end;
  }

  /* CTAs go back to natural width side by side */
  .hero-cta-wrapper {
    flex-direction: row;
    align-items: center;
    width: auto;
    gap: 1rem;
  }

  .hero-cta-button {
    width: auto;
  }

  /* Pinned logo on desktop */
  .hero-logo-top {
    padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 0;
  }

  .hero-container.hero-content-contained .hero-logo-top {
    max-width: var(--wp--style--global--wide-size, 1680px);
    margin: 0 auto;
  }

  .hero-container.hero-align-left .hero-logo-top {
    justify-content: flex-start;
  }

  .hero-container.hero-align-center .hero-logo-top {
    justify-content: center;
  }

  .hero-container.hero-align-right .hero-logo-top {
    justify-content: flex-end;
  }

  /* Leave room for a logo pinned to the top of the hero */
  .hero-container.hero-has-logo-top.hero-valign-top .hero-content {
    padding-top: 8rem;
  }

  /* Logo shows at the full chosen width, still capped to its container */
  .hero-logo {
    width: min(var(--hero-logo-width, 200px), 100%);
  }

  /* Content width on desktop - overrides the stacked width above */
  .hero-content-inner {
    gap: var(--hero-content-gap, clamp(1.25rem, 0.8rem + 1vw, 1.75rem));
    max-width: min(var(--hero-content-width-desktop, 800px), 100%);
  }

  /* Title / text: light colours by default over the image */
  .hero-title {
    font-size: clamp(2.5rem, 1rem + 3vw, 4.5rem);
    color: var(--hero-title-color-desktop, #ffffff);
  }

  .hero-container .hero-text {
    font-size: clamp(1rem, 0.7rem + 0.55vw, 1.375rem);
    line-height: 1.6;
    color: var(--hero-text-color-desktop, rgba(255, 255, 255, 0.9));
  }

  .hero-quote {
    padding: clamp(1rem, 0.7rem + 0.6vw, 1.375rem) clamp(1.25rem, 1rem + 0.7vw, 1.75rem);
    color: rgba(255, 255, 255, 0.9);
  }

  .hero-container.hero-layout-full.hero-mobile-card .hero-quote {
    background-color: rgba(0, 53, 88, 0.55);
  }

  .hero-cta-button.hero-cta-button-secondary {
    color: #ffffff;
  }

  /* ---------------------------------------------------------------------
   * Split layout: 50/50 image and text panel. The text panel uses the
   * block's background colour (--hero-split-bg). No overlay is rendered.
   * ------------------------------------------------------------------ */
  .hero-container.hero-layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .hero-container.hero-layout-split .hero-bg {
    position: relative;
    inset: auto;
    grid-row: 1;
    grid-column: 1;
    height: auto;
  }

  /* The image fills its half whatever the height of the text */
  .hero-container.hero-layout-split .hero-bg picture {
    position: absolute;
    inset: 0;
  }

  .hero-container.hero-layout-split .hero-bg .hero-bg-image {
    position: absolute;
    inset: 0;
  }

  .hero-container.hero-layout-split .hero-content {
    grid-row: 1;
    grid-column: 2;
    max-width: none;
    margin: 0;
    padding: clamp(2rem, 5vw, 5rem) clamp(1.5rem, 4vw, 4rem);
    background-color: var(--hero-split-bg, #ffffff);
  }

  .hero-container.hero-layout-split.hero-split-image-right .hero-bg {
    grid-column: 2;
  }

  .hero-container.hero-layout-split.hero-split-image-right .hero-content {
    grid-column: 1;
  }

  /* The wide-size container cap doesn't apply: the panel is already half the width */
  .hero-container.hero-layout-split.hero-content-contained .hero-content {
    max-width: none;
    margin: 0;
  }

  /* Pinned logo sits inside the text panel, not across the image */
  .hero-container.hero-layout-split .hero-logo-top {
    left: 50%;
    right: 0;
    max-width: none;
    margin: 0;
  }

  .hero-container.hero-layout-split.hero-split-image-right .hero-logo-top {
    left: 0;
    right: 50%;
  }

  /* Dark text on the light panel by default */
  .hero-container.hero-layout-split .hero-title {
    font-size: clamp(2.25rem, 0.9rem + 2.4vw, 3.75rem);
    color: var(--hero-title-color-desktop, #003558);
  }

  .hero-container.hero-layout-split .hero-text {
    color: var(--hero-text-color-desktop, #0580d2);
  }

  .hero-container.hero-layout-split .hero-quote {
    color: #0580d2;
  }

  .hero-container.hero-layout-split .hero-cta-button.hero-cta-button-secondary {
    color: #0580d2;
  }
}

@media (min-width: 1920px) {
  .hero-container.hero-content-contained .hero-content,
  .hero-container.hero-content-contained .hero-logo-top {
    max-width: 1680px;
  }

  .hero-container.hero-layout-split .hero-content,
  .hero-container.hero-layout-split .hero-logo-top {
    max-width: none;
  }
}

/* ---------------------------------------------------------------------
 * Intro animation. Elements get .hero-anim-item and a --hero-anim-step (0, 1, 2...);
 * the delay is the start delay plus step x stagger. "both" keeps them hidden until
 * their delay has passed. No JavaScript needed.
 * ------------------------------------------------------------------ */
.hero-container.hero-anim .hero-anim-item {
  animation-name: hero-fade-in;
  animation-duration: var(--hero-anim-duration, 700ms);
  animation-delay: calc(var(--hero-anim-delay, 0ms) + var(--hero-anim-step, 0) * var(--hero-anim-stagger, 0ms));
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
  animation-fill-mode: both;
}

.hero-container.hero-anim-fade-up .hero-anim-item {
  animation-name: hero-fade-in-up;
}

.hero-container.hero-anim-fade-down .hero-anim-item {
  animation-name: hero-fade-in-down;
}

@keyframes hero-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes hero-fade-in-up {
  from {
    opacity: 0;
    transform: translate3d(0, 1.5rem, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-fade-in-down {
  from {
    opacity: 0;
    transform: translate3d(0, -1.5rem, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Visitors who ask for reduced motion get the content straight away */
@media (prefers-reduced-motion: reduce) {
  .hero-container.hero-anim .hero-anim-item {
    animation: none;
  }
}

/* ---------------------------------------------------------------------
 * Small tablets (768px - 1023px): headline/text and buttons sit side by side so the
 * headline doesn't run across the full width. Container query: only when the text
 * column is wide enough, so a half-width split column stays stacked.
 * ------------------------------------------------------------------ */
@media (min-width: 768px) and (max-width: 1023px) {
  @container hero-content (min-width: 560px) {
    .hero-main-row {
      display: flex;
      flex-direction: row;
      align-items: stretch;
      gap: var(--hero-content-gap, 2rem);
      width: 100%;
    }

    .hero-main-row > .hero-text-group {
      flex: 1 1 0;
      min-width: 0;
      align-items: stretch;
    }

    /* Buttons stack in their own column, level with the bottom of the text */
    .hero-main-row > .hero-cta-wrapper {
      flex: 0 0 auto;
      flex-direction: column;
      align-items: stretch;
      align-self: flex-end;
      width: auto;
    }
  }
}

/* Right-aligned text: mirror the row so the text stays on the right with the buttons opposite */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  @container hero-content (min-width: 560px) {
    .hero-container.hero-align-right .hero-main-row {
      flex-direction: row-reverse;
    }
  }
}

/* Landscape: the text sits over the image, so keep the text and buttons together on the
   aligned side (right-aligned mirrors the row) instead of pushing the buttons across the photo */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  @container hero-content (min-width: 560px) {
    .hero-main-row {
      justify-content: flex-start;
    }

    .hero-main-row > .hero-text-group {
      flex: 0 1 auto;
    }

    .hero-container.hero-align-right .hero-main-row {
      flex-direction: row-reverse;
    }

    .hero-container.hero-align-center .hero-main-row {
      justify-content: center;
    }
  }
}

/* Portrait tablets (768px - 1023px) are stacked but use the desktop text alignment setting */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .hero-container.hero-align-left .hero-content-inner { align-items: flex-start; text-align: left; }
  .hero-container.hero-align-center .hero-content-inner { align-items: center; text-align: center; margin-left: auto; margin-right: auto; }
  .hero-container.hero-align-right .hero-content-inner { align-items: flex-end; text-align: right; margin-left: auto; }
  .hero-container.hero-align-left .hero-logo-top { justify-content: flex-start; }
  .hero-container.hero-align-center .hero-logo-top { justify-content: center; }
  .hero-container.hero-align-right .hero-logo-top { justify-content: flex-end; }
  .hero-container.hero-align-left .hero-cta-wrapper { justify-content: flex-start; }
  .hero-container.hero-align-center .hero-cta-wrapper { justify-content: center; }
  .hero-container.hero-align-right .hero-cta-wrapper { justify-content: flex-end; }
}

/* Supporting text paragraphs (blank line in the editor = new paragraph) */
.hero-container .hero-text-body {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}
