/* ==========================================================================
   The cover

   Built from the supplied mockup. The video is the ground; everything else is
   ink laid on top of it. The hero is sticky at the top of the page and the
   sections that follow are opaque, so Issue #01 rises over it rather than the
   cover being scrolled past -- the same enter-and-exit-along-one-path logic
   the rest of the site follows.
   ========================================================================== */

.hero {
  position: sticky;
  inset-block-start: 0;
  z-index: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-block: var(--s-9) var(--s-7);
  padding-block-end: calc(env(safe-area-inset-bottom, 0px) + var(--s-7));
  overflow: hidden;
  isolation: isolate;
  background: #0b0b0b;
  /* The cover is a photograph. It does not have a light mode. */
  color: var(--cream);
  color-scheme: dark;
}

/* ---- the film ----------------------------------------------------------- */

.hero-stage {
  position: absolute;
  inset: 0;
  z-index: -2;
}

.hero-video,
.hero-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* He sits centre-right in frame; on a tall phone this keeps him in it. */
  object-position: 62% 42%;
  /* Driven by scroll as the cover is handed off. */
  transform: scale(var(--film-scale, 1.02)) translate3d(0, var(--par, 0px), 0);
  will-change: transform;
}

.hero-still {
  z-index: 1;
}

/* Once the video is actually playing we fade the poster out, so a slow
   connection never shows an empty rectangle. */
.hero.is-playing .hero-still {
  opacity: 0;
  transition: opacity 700ms ease;
}

/* ---- scrims -------------------------------------------------------------
   Three, each doing one job. Together they are also what keeps the display
   type legible over a moving image, which is the real reason they exist. */

.hero-scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    /* 1. type side -- ground under the words */
    linear-gradient(
      100deg,
      rgba(11, 11, 11, 0.96) 0%,
      rgba(11, 11, 11, 0.88) 26%,
      rgba(11, 11, 11, 0.35) 52%,
      rgba(11, 11, 11, 0.08) 72%,
      rgba(11, 11, 11, 0.3) 100%
    ),
    /* 2. bottom vignette -- carries the cover into the next section */
    linear-gradient(
      to bottom,
      rgba(11, 11, 11, 0.55) 0%,
      transparent 22%,
      transparent 62%,
      rgba(11, 11, 11, 0.9) 100%
    );
  opacity: var(--scrim-strength, 1);
}

/* 3. The corner plate. This is the ground the scroll cue sits on -- and it is
   also what keeps the bottom-right corner of the video quiet, whatever ends
   up rendered there. */
.hero-scrim::after {
  content: '';
  position: absolute;
  inset-block-end: 0;
  inset-inline-end: 0;
  width: min(46rem, 62%);
  height: min(22rem, 38%);
  background: radial-gradient(
    120% 130% at 100% 100%,
    rgba(8, 8, 8, 0.95) 0%,
    rgba(8, 8, 8, 0.82) 34%,
    rgba(8, 8, 8, 0.4) 62%,
    transparent 100%
  );
}

.hero-field {
  z-index: 3;
  opacity: 0.22;
  mix-blend-mode: screen;
}

/* ---- registration marks -------------------------------------------------- */

.mark {
  position: absolute;
  z-index: 4;
  color: var(--label-ink);
  opacity: 0.55;
  pointer-events: none;
}

.mark--crosshair {
  inset-block-start: calc(env(safe-area-inset-top, 0px) + 1.55rem);
  inset-inline-start: var(--gutter);
  width: 34px;
  height: 34px;
  translate: -50% 0;
}

@media (max-width: 46rem) {
  .mark--crosshair {
    display: none;
  }
}

/* ---- type ---------------------------------------------------------------- */

.hero-inner {
  position: relative;
  z-index: 5;
}

.hero-issue {
  display: flex;
  gap: 0.6em;
  align-items: baseline;
  margin-block-end: clamp(var(--s-5), 5vh, var(--s-8));
  color: var(--label-ink);
}

.hero-issue .issue-no {
  color: var(--label-ink);
}

.hero-name {
  margin-block-end: var(--s-6);
  color: var(--cream);
  /* Playfair's caps are tall; the mockup sets the three lines very tight. */
  font-weight: 500;
}

.hero-line {
  display: block;
}

/* The surname is the one that matters, and it is the only italic on the page. */
.hero-line--italic {
  font-style: italic;
  font-weight: 600;
  color: var(--bronze);
  /* Italic needs a nudge back into the optical margin the roman sets. */
  margin-inline-start: -0.02em;
}

.hero-lead {
  position: relative;
  max-width: 34rem;
  padding-inline-start: var(--s-5);
  font-size: clamp(0.9rem, 0.86rem + 0.28vw, 1.02rem);
  line-height: 1.85;
  letter-spacing: 0.005em;
  color: var(--tan);
}

/* The hairline the mockup runs down the left of the body copy. */
.hero-lead::before {
  content: '';
  position: absolute;
  inset-block: 0.35em 0.3em;
  inset-inline-start: 0;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--rule-strong) 12%,
    var(--rule-strong) 88%,
    transparent
  );
}

/* ---- foot: seal + credentials -------------------------------------------- */

.hero-foot {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  margin-block-start: clamp(var(--s-6), 6vh, var(--s-9));
}

.seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 4.1rem;
  height: 4.1rem;
  border-radius: 50%;
  border: 1px dashed rgba(186, 157, 124, 0.45);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--label-ink);
  letter-spacing: -0.02em;
  /* A stamped seal, not a button: it sits slightly off-square like a real one. */
  rotate: -4deg;
}

.hero-meta {
  font-size: 0.7rem;
  line-height: 1.9;
  letter-spacing: 0.05em;
  color: var(--label-ink);
  max-width: 34rem;
}

@media (max-width: 34rem) {
  .seal {
    display: none;
  }
}

/* ---- the handwritten annotation ------------------------------------------
   The video animates its own equations and polar diagrams down the right-hand
   side, so this one lives on the left where the frame is dark and empty.
   Putting a second block on the right would fight the video for the same
   space. */

.hero-note {
  position: absolute;
  z-index: 5;
  inset-block-start: clamp(5.5rem, 13vh, 9rem);
  inset-inline-start: clamp(28rem, 41vw, 46rem);
  max-width: 15rem;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 1.15vw, 1.3rem);
  line-height: 1.5;
  color: var(--hand);
  rotate: -2deg;
  pointer-events: none;
}

.hero-note-circled {
  position: relative;
  display: inline-block;
  padding: 0.1em 0.3em;
}

/* The hand-drawn ring, stroked so it can be drawn on rather than faded in. */
.hero-note-circled svg {
  position: absolute;
  inset: -0.35em -0.5em;
  width: calc(100% + 1em);
  height: calc(100% + 0.7em);
  overflow: visible;
  color: var(--hand);
}

.hero-note-circled path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  /* Set from the path length in JS, then animated to 0 on arrival. */
  stroke-dasharray: var(--len, 300);
  stroke-dashoffset: var(--len, 300);
}

.hero-note-circled.is-drawn path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 900ms cubic-bezier(0.4, 0, 0.2, 1) 300ms;
}

@media (prefers-reduced-motion: reduce) {
  .hero-note-circled path {
    stroke-dashoffset: 0;
  }
}

/* The annotation needs real estate the video is already using below this. */
@media (max-width: 62rem) {
  .hero-note {
    display: none;
  }
}

/* ---- scroll cue ---------------------------------------------------------- */

.hero-scroll {
  position: absolute;
  z-index: 5;
  inset-block-end: calc(env(safe-area-inset-bottom, 0px) + var(--s-6));
  inset-inline-end: var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--cue);
  text-decoration: none;
}

.hero-scroll-rule {
  position: relative;
  display: block;
  width: clamp(3rem, 7vw, 5.5rem);
  height: 1px;
  background: linear-gradient(to right, currentColor, transparent);
}

/* The bead runs the rule and falls off the end, over and over. */
.hero-scroll-bead {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 0;
  width: 6px;
  height: 6px;
  margin-block-start: -3px;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: bead 2.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes bead {
  0% { transform: translateX(0); opacity: 0; }
  18% { opacity: 1; }
  76% { opacity: 1; }
  100% { transform: translateX(clamp(3rem, 7vw, 5.5rem)); opacity: 0; }
}

@media (hover: hover) and (pointer: fine) {
  .hero-scroll:hover .hero-scroll-bead {
    animation-duration: 1.5s;
  }
}

@media (max-width: 40rem) {
  .hero-scroll {
    inset-inline: var(--gutter) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-scroll-bead {
    animation: none;
    opacity: 1;
  }
}

/* ---- portrait ------------------------------------------------------------
   16:9 cropped into a tall screen loses most of the frame, so the type stacks
   against a heavier bottom scrim and the display size steps down. */

@media (max-width: 46rem) {
  .hero {
    justify-content: flex-end;
  }

  .hero-video,
  .hero-still {
    object-position: 68% 38%;
  }

  .hero-scrim {
    background:
      linear-gradient(
        to bottom,
        rgba(11, 11, 11, 0.7) 0%,
        rgba(11, 11, 11, 0.25) 26%,
        rgba(11, 11, 11, 0.72) 58%,
        rgba(11, 11, 11, 0.96) 84%
      );
  }

  .hero-lead {
    font-size: 0.86rem;
    line-height: 1.75;
  }
}

@media (max-width: 30rem) {
  :root {
    --fs-display: clamp(2.6rem, 15vw, 3.6rem);
  }
}
