/* ==========================================================================
   Section: Hero
   Full-screen title card video that hands over to the brand logo and a
   "coming soon" message when it finishes.
   Markup: index.html (.hero)  ·  Behaviour: js/sections/hero.js

   States (data-state on .hero, set to "intro" in the markup):
   "intro"  Starting state. Video playing, outro hidden, skip button visible.
   "outro"  Video finished / failed / reduced motion: outro fades in.
   (No JS: <noscript> styles in index.html force the outro visible.)
   ========================================================================== */

.hero {
  position: relative; /* anchors the skip button */
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* never wider than the screen */
  min-height: 100svh; /* small viewport height: avoids jumps from mobile browser bars */
  background: var(--color-bg);
  overflow: hidden;
}

/* Video and outro share the same grid cell, stacked on top of each other. */
.hero__video,
.hero__outro {
  grid-area: 1 / 1;
}

/* ---------- Video ---------- */

/* "contain" keeps the whole logo visible on any screen shape;
   the black page background blends with the video's black edges. */
.hero__video {
  width: 100%;
  height: 100svh;
  object-fit: contain;
}

/* Clicking/tapping anywhere during the video skips it (see hero.js). */
.hero[data-state="intro"] {
  cursor: pointer;
}

.hero:not([data-state="intro"]) .hero__video {
  visibility: hidden;
}

/* ---------- Outro: logo + message ---------- */
.hero__outro {
  position: relative;
  isolation: isolate; /* keeps the ambience layers (z-index: -1) inside the outro */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-5);
  /* Soft teal haze behind the logo, like the video's lighting */
  background: radial-gradient(
    ellipse 45% 40% at 50% 45%,
    color-mix(in srgb, var(--color-surface) 70%, var(--color-bg)),
    var(--color-bg) 70%
  );
}

/* Ambience 1: slow-drifting pools of teal and blue light. */
.hero__outro::before {
  content: "";
  position: absolute;
  inset: -25%;
  z-index: -1;
  background:
    radial-gradient(circle at 35% 40%, color-mix(in srgb, var(--color-accent) 7%, transparent), transparent 35%),
    radial-gradient(circle at 65% 60%, color-mix(in srgb, var(--color-brand-blue) 6%, transparent), transparent 40%);

  @media (prefers-reduced-motion: no-preference) {
    animation: hero-drift 24s ease-in-out infinite alternate;
  }
}

/* Ambience 2: fine film grain, matching the texture of the video.
   "overlay" keeps true blacks black, so grain only shows in the lit areas. */
.hero__outro::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.3;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Sized to roughly match the logo's size in the video on desktop. */
.hero__logo {
  position: relative;
  isolation: isolate;
  width: min(72vw, 30rem);
}

/* Breathing glow behind the logo mark. */
.hero__logo::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 30%; /* centre of the mark within the logo image */
  z-index: -1;
  width: 70%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--color-accent) 22%, transparent),
    transparent 65%
  );

  @media (prefers-reduced-motion: no-preference) {
    animation: hero-breathe 7s ease-in-out infinite alternate;
  }
}

@keyframes hero-drift {
  from { translate: -4% -3%; rotate: 0deg; }
  to   { translate: 4% 3%;   rotate: 8deg; }
}

@keyframes hero-breathe {
  from { opacity: 0.55; scale: 0.92; }
  to   { opacity: 1;    scale: 1.06; }
}

/* Message + contact, grouped closer together than the gap to the logo. */
.hero__details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.hero__message {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: clamp(0.8125rem, 0.75rem + 0.3vw, 1rem);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
  /* Balance the trailing letter-space so the text looks centred */
  margin-right: calc(var(--tracking-wide) * -1);
}

/* ---------- Contact email ---------- */
.hero__contact {
  font-style: normal; /* <address> is italic by default */
}

.hero__contact-link {
  display: inline-block;
  padding-block: var(--space-2); /* comfortable tap target */
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: clamp(0.9375rem, 0.875rem + 0.3vw, 1.0625rem);
  letter-spacing: 0.06em;
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.35em;
  text-decoration-color: color-mix(in srgb, var(--color-accent) 50%, transparent);
  transition:
    color var(--duration-fast) var(--ease-standard),
    text-decoration-color var(--duration-fast) var(--ease-standard);
}

.hero__contact-link:hover {
  color: var(--color-accent-strong);
  text-decoration-color: var(--color-accent-strong);
}

.hero__contact-link:focus-visible {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Intro → outro reveal ---------- */

/* Hidden while the video plays. Opacity (not display/visibility) keeps the
   h1 available to screen readers throughout. */
.hero[data-state="intro"] .hero__outro,
.hero[data-state="intro"] .hero__message {
  opacity: 0;
}

/* The link also gets visibility: hidden so keyboard users can't tab to it
   while it's invisible. */
.hero[data-state="intro"] .hero__contact {
  opacity: 0;
  visibility: hidden;
}

/* Starting positions for the entrance: the logo grows in gently and the
   text rises into place. Skipped for reduced motion (plain fade only). */
@media (prefers-reduced-motion: no-preference) {
  .hero[data-state="intro"] .hero__logo {
    scale: 0.94;
  }

  .hero[data-state="intro"] .hero__message,
  .hero[data-state="intro"] .hero__contact {
    translate: 0 0.75rem;
  }
}

/* Ambient loops wait until the outro is shown, then start from the beginning. */
.hero[data-state="intro"] .hero__outro::before,
.hero[data-state="intro"] .hero__logo::before {
  animation-play-state: paused;
}

/* Reveal once the video ends: logo, then message, then contact. */
.hero[data-state="outro"] .hero__outro {
  transition: opacity var(--duration-reveal) var(--ease-standard);
}

.hero[data-state="outro"] .hero__logo {
  transition: scale calc(var(--duration-reveal) * 2) var(--ease-standard);
}

.hero[data-state="outro"] .hero__message {
  transition:
    opacity var(--duration-reveal) var(--ease-standard) 600ms,
    translate var(--duration-reveal) var(--ease-standard) 600ms;
}

.hero[data-state="outro"] .hero__contact {
  transition:
    opacity var(--duration-reveal) var(--ease-standard) 900ms,
    translate var(--duration-reveal) var(--ease-standard) 900ms;
}

/* ---------- Skip intro button (only while the video plays) ----------
   Look comes from the .pill-button component. */
.hero__skip {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
}

.hero:not([data-state="intro"]) .hero__skip {
  display: none;
}
