/* =========================================================================
   Page Hero (split hero): photo on the top half, solid panel on the bottom
   half, title straddling the seam.

   Usage (title, subtitle and image are the only inputs):

   <section class="page-hero" style="--hero-image: url('/assets/images/your-photo.jpg');">
     <div class="page-hero__image" role="img" aria-label="Describe the photo"></div>
     <div class="page-hero__panel"></div>
     <div class="page-hero__mark" aria-hidden="true"><span></span><span></span><span></span></div>
     <div class="page-hero__text">
       <div class="page-hero__top"><h1>Service name</h1></div>
       <div class="page-hero__bottom"><p class="page-hero__sub">One-line subheading</p></div>
     </div>
     <a class="page-hero__cue" href="#next-section-id"><span>Read more</span><i aria-hidden="true"></i></a>
   </section>

   Give --hero-image a site-root path (/assets/...): a relative url() inside a
   custom property resolves against this stylesheet's folder, not the page.
   Optional: --hero-image-position (default: center) sets the photo's focal point.
   Load js/page-hero.js for the parallax.
   ========================================================================= */

.page-hero {
  --hero-panel: var(--deep-space);
  --hero-text: var(--champagne);
  --hero-title: var(--ghost-white);
  --hero-accent: var(--scarlet);
  /* No grey-beige token on this site: champagne mixed into deep-space gives a
     low-contrast neutral on the panel without adding a new hex value. */
  --hero-muted: color-mix(in srgb, var(--champagne) 55%, var(--deep-space));
  --hero-title-size: 54px;
  --hero-inset: 50px;

  position: relative;
  height: 100vh;
  height: 100svh; /* ignore the mobile browser toolbar */
  min-height: 560px;
  overflow: hidden;
  background: var(--hero-panel);
  color: var(--hero-text);
}

/* 1. Photo: top half */
.page-hero__image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  z-index: 1;
  background-image: var(--hero-image);
  background-size: cover;
  background-position: var(--hero-image-position, center);
  will-change: transform;
}

/* 25% dark overlay to calm the photo; moves with it during parallax */
.page-hero__image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
}

/* Keeps the white logo and menu icon readable over a bright photo */
.page-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 25%;
  z-index: 2;
  background: linear-gradient(rgba(0, 0, 0, 0.35), transparent);
  pointer-events: none;
}

/* 2. Solid panel: bottom half. Sits above the photo so the parallax slides under it. */
.page-hero__panel {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 50%;
  z-index: 2;
  background: var(--hero-panel);
}

/* 3. Text: two rows that meet exactly on the seam */
.page-hero__text {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-rows: 1fr 1fr;
  padding: 0 var(--hero-inset);
  pointer-events: none;
}

.page-hero__top {
  align-self: end;
}

.page-hero__text h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--hero-title-size);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: var(--hero-title);
  /* keeps the light title readable over bright parts of the photo */
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  margin: 0;
  /* The title sits on the seam: about 57% of the capitals on the photo and
     43% on the panel. Fallback for browsers without text-box trimming,
     tuned for Inter 900 at line-height 1. Extra lines stack upward. */
  margin-bottom: -0.57em;
  pointer-events: auto;
}

.page-hero__sub {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 20px;
  line-height: 1.4;
  color: var(--hero-text);
  margin: 0;
  /* clear the part of the title that hangs below the seam, plus a small gap */
  margin-top: calc(var(--hero-title-size) * 0.57 + 14px);
  max-width: 60ch;
  pointer-events: auto;
}

/* Where supported, trim the title's box to cap height and baseline, so the
   seam position no longer depends on the font's line metrics. */
@supports (text-box: trim-both cap alphabetic) {
  .page-hero__text h1 {
    text-box: trim-both cap alphabetic;
    margin-bottom: -0.43cap; /* baseline 43% of the cap height below the seam */
  }

  .page-hero__sub {
    /* 0.43 of Inter's cap height (0.727em) is about 0.31em, plus the gap */
    margin-top: calc(var(--hero-title-size) * 0.31 + 22px);
  }
}

/* 4. Accent mark: three bars on the left edge, centred on the seam (the title's cap line) */
.page-hero__mark {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateY(-50%);
}

.page-hero__mark span {
  display: block;
  height: 4px;
  width: 30px;
  background: var(--hero-accent);
}

.page-hero__mark span:nth-child(2) {
  width: 20px;
}

/* Scroll cue: bottom centre of the panel */
.page-hero__cue {
  position: absolute;
  bottom: 24px;
  left: 50%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--hero-text);
  text-decoration: none;
}

.page-hero__cue span {
  opacity: 0.85;
}

.page-hero__cue i {
  display: block;
  width: 1px;
  height: 55px;
  background: var(--hero-muted);
  transform-origin: top;
  animation: page-hero-cue 2s ease-in-out infinite;
}

@keyframes page-hero-cue {
  0% { transform: scaleY(0); opacity: 1; }
  70% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .page-hero__cue i {
    animation: none;
  }
}

/* Desktop: bigger type, text lines up with the site header gutter */
@media (min-width: 769px) {
  .page-hero {
    --hero-title-size: clamp(3.25rem, 7vw, 7rem);
    --hero-inset: var(--gutter);
  }

  .page-hero__sub {
    font-size: 24px;
  }
}
