/*
 * Hero Block Styles
 *
 * Layout variants controlled by Alignment:
 *   - Default: Two-column, content left, media right
 *   - align-center: Single column, stacked layout
 *   - align-right: Two-column, content right, media left
 *
 * Typography inherits from global base.css.
 * Only hero-specific overrides (h1 size, em colors) are here.
 */

/* ============================================
   BASE LAYOUT
   ============================================ */
.hero {
  position: relative;
  overflow: hidden;
  contain: layout style paint;
  z-index: 0;

  /* Hero typography tokens - all use clamp for fluid scaling */
  --hero-eyebrow-size: clamp(1.5rem, 1.4rem + 0.25vw, 1.8rem);
  --hero-headline-size: clamp(3rem, 2.5rem + 2.75vw, 5.25rem);  /* 48px → 84px */
  --hero-subline-size: clamp(1.5rem, 1.35rem + 0.3vw, 1.8rem);
  --hero-element-spacing: var(--space-xl);  /* 2rem between elements */
  --hero-svg-fallback-width: 512px;

  /* Mobile: flex column layout */
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--background-color);
  padding: var(--space-2xl) 0 var(--space-4xl) 0;
}

/* Hero wrapper - aligns with header/logo via container tokens.
   padding-block: 0 lets the hero block own its spacing — needed when hero is
   :nth-of-type(2) (banner-in-main case), where the section base rule
   would otherwise contribute padding-bottom at >=900px. Longhand on purpose:
   the shorthand would also zero the inline inset `.section.sides` puts on
   the section (see SPLIT SECTION CONTEXT below). */
main > .section.hero-container {
  margin: 0;
}

/* In a sides section the band belongs to the section, which frames both
   columns and paints their shared background, so hero does not take the
   spacing over there. */
main > .section:not(.sides).hero-container {
  padding-block: 0;
}

main > .section.hero-container > .hero-wrapper {
  box-sizing: border-box;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* ============================================
   TYPOGRAPHY
   Inherits from global styles. Only hero-specific overrides here.
   ============================================ */

/* Entrance animation (opacity fade) - all hero-content children */
.hero .hero-content > * {
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

/* Hero content spacing - explicit elements for predictability */
.hero h1,
.hero h2,
.hero h3,
.hero p,
.hero .button-container {
  margin-bottom: var(--hero-element-spacing);
}

/* Eyebrow - smaller text above headline */
.hero .hero-content > h3:has(+ h1) {
  font-size: var(--hero-eyebrow-size);
  line-height: 1;
}

.hero h1 {
  font-size: var(--hero-headline-size);
  line-height: 1;
  text-wrap: balance;
}

/* When the hero is authored as two consecutive H1s (static prefix + animated
   tail), collapse the margin between them so the pair reads as one headline
   instead of two stacked elements. */
.hero h1:has(+ h1) {
  margin-bottom: 0;
}

/* Subline - smaller, lighter than standard h2 */
.hero h2 {
  font-size: var(--hero-subline-size);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  color: var(--digicert-neutral-700);
  text-wrap: balance;
}

/* Inline-mark animation:
   <strong>       → .hero-accent (blue accent)
   <em>A | B | C> → .hero-animate (grid-stack of phrases, swap via aria-hidden)

   Block-local custom props drive duration / easing / hidden-transform so
   reduced-motion can zero them in one place and future variants can
   override individual values without re-stating the whole rule. */
.hero h1 .hero-accent {
  color: var(--digicert-blue);
}

/* Block-level row break around the animate cell so the rotating phrases
   sit on their own line. Segments wrap naturally — no nowrap — so long
   prefixes/suffixes stay on multiple lines without clipping. */
.hero h1 .hero-segment {
  display: block;
}

.hero h1 .hero-animate {
  /* Block-local animation tokens — kept as named props so future variants
     (effect × granularity) can override individual values cleanly. */
  --hero-animate-duration: var(--duration-normal);
  --hero-animate-easing: var(--ease-out);
  --hero-animate-hidden-transform: translateY(-0.2em);

  /* inline-grid flows with surrounding text and stacks phrases in one cell
     (sized to the widest) for CLS-free swaps. The H1's clamped font-size
     plus text-wrap: balance handles line breaks around the animation. */
  display: inline-grid;
  grid-template-areas: "stack";
}

.hero h1 .hero-animate > .hero-animate-phrase {
  grid-area: stack;
  transition:
    opacity var(--hero-animate-duration) var(--hero-animate-easing),
    transform var(--hero-animate-duration) var(--hero-animate-easing);

  /* Incoming phrase waits for outgoing to finish — eliminates crossfade overlap */
  transition-delay: var(--hero-animate-duration);
}

.hero h1 .hero-animate > .hero-animate-phrase[aria-hidden="true"] {
  opacity: 0;
  transform: var(--hero-animate-hidden-transform);

  /* Outgoing transitions immediately — no wait */
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  .hero h1 .hero-animate {
    --hero-animate-duration: 0s;
    --hero-animate-hidden-transform: none;
  }
}

/* ============================================
   BUTTONS
   Mobile: full-width stacked, Tablet+: uses global inline styles
   ============================================ */
@media (width < 600px) {
  .hero .button-container {
    display: flex;
  }

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

@media (width >= 600px) {
  .hero .button-container .button {
    width: auto;
  }
}

/* ============================================
   STRUCTURE
   ============================================ */

/* Hide metadata rows (original media fields kept for UE) */
.hero > .hero-meta {
  display: none;
}

/* Remove default padding from EDS wrappers */
.hero > div {
  min-width: 0;
  padding: 0;
}

/* Content wrapper - let global typography margins handle rhythm */
.hero .hero-content {
  min-width: 0;
  padding: 0;
}

/* ============================================
   MEDIA
   ============================================ */
.hero .hero-media {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero .hero-media p {
  margin: 0;
}

.hero .hero-media picture {
  display: block;
}

.hero .hero-media img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-l);
}

/* SVGs without intrinsic dimensions: fallback size matching typical hero illustrations.
   Constrained by max-width:100% on smaller viewports. */
.hero .hero-media img[src*=".svg"] {
  width: var(--hero-svg-fallback-width);
}

/* ============================================
   MOBILE LAYOUT
   ============================================ */

/* Mobile: content first, media last */
.hero > .hero-text { order: 1; }

.hero > .hero-media {
  order: 2;
  width: 100%;
  margin: var(--space-xl) 0 0;  /* 24px - consistent with element spacing */
}

/* ============================================
   TABLET+ LAYOUT (600px+)
   Two-column grid
   ============================================ */
@media (width >= 600px) {
  .hero {
    display: grid;
    grid-template-columns: 1fr minmax(250px, 40%);
    gap: var(--space-xl);
    align-items: center;
    padding: var(--space-2xl) 0 var(--space-3xl) 0;
  }

  .hero > .hero-text { order: 1; }

  .hero > .hero-media {
    order: 2;
    margin: 0;
    width: 100%;
  }

  .hero .hero-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Push content down when eyebrow present (side-by-side layout only) */
  .hero .hero-content:has(> h3 + h1) {
    padding-top: var(--space-xl);
  }

  /* No media - single column layout (class added by JS) */
  .hero.no-media {
    grid-template-columns: 1fr;
    max-width: 900px;
  }

  .hero .hero-content > h1,
  .hero .hero-content > h2,
  .hero .hero-content > h3,
  .hero .hero-content > p:not(.button-container) {
    width: 100%;
    flex-shrink: 0;
  }
}

@media (width >= 900px) {
  .hero {
    padding: var(--space-3xl) 0;
  }
}


/* ============================================
   ALIGNMENT VARIANTS
   ============================================ */

/* Align right: content right, media left */
@media (width >= 600px) {
  .hero.align-right > .hero-text { order: 2; }
  .hero.align-right > .hero-media { order: 1; }
}

/* Align center: single column, stacked layout */
@media (width >= 600px) {
  .hero.align-center {
    grid-template-columns: 1fr;
    grid-template-areas:
      "media"
      "text";
    text-align: center;
    max-width: 900px;
    margin-inline: auto;
  }

  .hero.align-center > .hero-text {
    grid-area: text;
  }

  .hero.align-center > .hero-media {
    grid-area: media;
    justify-self: center;
    max-width: 500px;
  }

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

/* ============================================
   FULL-BLEED MEDIA
   Edge-to-edge images for photos/video posters
   ============================================ */
.hero.full-bleed .hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* ============================================
   HERO-FULL VARIANT
   Taller hero for prominent placements
   ============================================ */

/* Tablet+ - taller minimum height */
@media (width >= 600px) {
  .hero.hero-full {
    min-height: 500px;
  }
}

@media (width >= 900px) {
  .hero.hero-full {
    min-height: 70vh;
    max-height: 800px;
  }
}

/* ============================================
   ENTRANCE ANIMATIONS
   Staggered delays for opacity fade (base styles in TYPOGRAPHY section)
   ============================================ */
.hero .hero-content > *:nth-child(1) { transition-delay: calc(var(--stagger-delay) * 0); }
.hero .hero-content > *:nth-child(2) { transition-delay: calc(var(--stagger-delay) * 1); }
.hero .hero-content > *:nth-child(3) { transition-delay: calc(var(--stagger-delay) * 2); }
.hero .hero-content > *:nth-child(4) { transition-delay: calc(var(--stagger-delay) * 3); }
.hero .hero-content > *:nth-child(5) { transition-delay: calc(var(--stagger-delay) * 4); }
.hero .hero-content > *:nth-child(6) { transition-delay: calc(var(--stagger-delay) * 5); }

/* Trigger animation when hero is ready */
.hero.hero-ready .hero-content > * {
  opacity: 1;
}

/* ============================================
   BACKGROUND VARIANTS
   ============================================ */
.hero.bg-neutral {
  background-color: var(--digicert-neutral-100);
}

.hero.bg-primary {
  background-color: var(--digicert-blue);
}

.hero.bg-outlined {
  box-shadow: inset 0 0 0 var(--space-s) var(--digicert-neutral-200);
  background: transparent;
}

/* ============================================
   BACKGROUND IMAGE VARIANT
   Uses CSS custom property from background-image.js
   ============================================ */

/* When bg-image is set, wrapper goes full-width for edge-to-edge background */
main > .section.hero-container:has(.hero.bg-image) > .hero-wrapper {
  max-width: none;
  width: 100%;
  padding: 0;
}

/* Standard variant (default): Content aligned with header/logo */
.hero.bg-image {
  background-image: var(--background-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  --content-inset: max(var(--container-padding), calc((100% - var(--container-max-width)) / 2 + var(--container-padding)));

  padding-left: var(--content-inset);
  padding-right: var(--content-inset);
}

/* Full variant: Content uses wider area (just container padding) */
.hero.bg-image.hero-full {
  --content-inset: var(--container-padding);
}

/* ============================================
   SIDES SECTION CONTEXT (Section Metadata `Style: Sides`)
   styles/sections.css lays the section's wrappers out as a two-column grid
   at >=900px (copy left, card right), carries the container inset, and owns
   the band padding — hero's band reset above excludes `.sides` so those values
   live in one file. Hero declares the rest of its posture inside that grid
   here, block-local, so a hero restyle sees the contract in the file it
   edits. Nothing in this section applies outside `.section.sides`.

   In-column hero is the single-content-row shape (no image); full-bleed and
   bg-image inside a column are unsupported.
   ============================================ */

.section.sides .hero {
  padding: 0;
  background: transparent;
}

@media (width >= 600px) {
  /* Fill the column. The single-column cap and the eyebrow push-down both
     assume the hero is a page-wide band beside its own media. */
  .section.sides .hero.no-media {
    max-width: none;
  }

  .section.sides .hero .hero-content:has(> h3 + h1) {
    padding-top: 0;
  }
}

@media (width >= 900px) {
  /* The section carries the container inset; the wrapper drops its own.
     Repeats sections.css's generic wrapper reset because the `.hero-wrapper`
     rule above outranks it. */
  main > .section.sides > .hero-wrapper {
    max-width: none;
    padding-inline: 0;
  }
}
