/*
 * The masthead, V4.
 *
 * Designed at 375 px: headline, sentence, the two actions, then the product
 * index — one column. At 1200 the index moves beside the headline, into the
 * space the lanes ran through. Nothing is added or removed between the two.
 *
 * The stage is an overlay. It is positioned over the band and never takes part
 * in layout, so the opening cannot move a single line of type; it is `hidden`
 * in the markup and the client script un-hides it only while it plays.
 */

.band {
  position: relative;
  /* Visible: the mark leaves this band for the header above it. */
  overflow: visible;
  background: var(--navy);
  color: #fff;
  border-bottom: var(--hairline) solid var(--rule-navy);
}

.inner {
  position: relative;
}

/* ---- The stage ---------------------------------------------------------- */

.stage {
  position: absolute;
  inset: 0;
  /* Above the header, so the mark can fly into its corner uncovered. */
  z-index: 20;
  pointer-events: none;
  /* One number drives the whole opening: the mark's width on this screen. */
  --stage-w: min(76vw, 300px);
  --stage-top: var(--s6);
}

.stage[hidden] {
  display: none;
}

/*
 * The paper the opening plays on. The mark is drawn in its own colours, and
 * those are the colours of artwork on paper; at the release this plate wipes
 * up into the header and the system's navy is what remains. It is the band's
 * own child, so it runs edge to edge rather than stopping at the container.
 */
.plate {
  position: absolute;
  inset: 0;
  z-index: 19;
  background: var(--paper);
  pointer-events: none;
}

.plate[hidden] {
  display: none;
}

/*
 * From the first paint, not from hydration.
 *
 * The stage and the plate are `hidden` in the markup because the finished
 * hero is what a reader with no script must get. But a reader *with* script
 * would otherwise see that finished hero for the hundred-odd milliseconds
 * before hydration arms the opening — the end, flashed before the beginning.
 * `@media (scripting: enabled)` is CSS's honest answer: where script will
 * run, the stage is shown and its start states are set from the very first
 * frame, with no inline script and nothing for the CSP to allow. The opening
 * then takes over, and retires the stage by setting `data-opening-done`.
 *
 * And a safety net: if script is on but the opening never runs, the stage
 * expires on its own after seven seconds, and the page is simply there.
 */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .band:not([data-opening-done]) .stage[hidden],
  .band:not([data-opening-done]) .plate[hidden] {
    display: block;
  }

  .band:not([data-opening-done]) .stage[hidden] [data-mark="symbol"],
  .band:not([data-opening-done]) .stage[hidden] [data-mark="wordmark"] {
    clip-path: inset(0 100% 0 0);
  }

  .band:not([data-opening-done]):not([data-armed]) .stage,
  .band:not([data-opening-done]):not([data-armed]) .plate {
    animation: stage-expire 1ms linear 7s both;
  }

  /*
   * The corner the mark will land on starts empty for the same reason: it is
   * the destination, and it should not be seen before the journey. It
   * expires to visible on the same clock, so no reader is left without it.
   */
  body:has(.band:not([data-opening-done]):not([data-armed])) [data-corner-mark] {
    animation: corner-expire 1ms linear 7s both;
  }

  @keyframes stage-expire {
    from {
      visibility: visible;
    }
    to {
      visibility: hidden;
    }
  }

  @keyframes corner-expire {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

.band[data-opening-done] .stage,
.band[data-opening-done] .plate {
  display: none !important;
}

.lanes {
  position: absolute;
  left: var(--pad-x);
  top: var(--stage-top);
  width: var(--stage-w);
  /* The symbol's height for a logo this wide: symbol is 2.518:1 and takes
     the left ~70 % of the lockup. */
  /* The symbol is 2.518 : 1 and 2.518 / 6.27 of the lockup's width. */
  height: calc(var(--stage-w) / 6.27);
  z-index: 1;
}

.lane {
  position: absolute;
  left: 0;
  height: 2px;
  transform-origin: left center;
  width: 0;
}

.laneA {
  top: 22%;
  background: var(--mark-blue);
}

.laneB {
  top: 78%;
  background: var(--mark-green);
}

.token {
  position: absolute;
  left: 0;
  top: -1.6em;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
  opacity: 0;
}

.laneB .token {
  top: 0.6em;
}

/* One document per lane on a phone — two collide at the apex. */
@media (max-width: 599px) {
  .token[data-second] {
    display: none;
  }
}

.mark {
  position: absolute;
  left: var(--pad-x);
  top: var(--stage-top);
  z-index: 2;
  transform-origin: left top;
  will-change: transform;
  /* --mark-h is the symbol's height. Symbol 2.518, gap 0.2, wordmark
     0.44 × 8.078 = 3.554: the lockup is 6.27 symbol-heights wide, so this
     puts the whole mark at --stage-w. */
  --mark-h: calc(var(--stage-w) / 6.27);
}

/* ---- The hero at rest ------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--s7);
  padding-block: var(--s7) var(--s7);
}

.lede {
  display: grid;
  gap: var(--s5);
  align-content: start;
}

.h1 {
  font-size: var(--step-display);
  font-weight: 700;
  line-height: var(--lh-display);
  letter-spacing: -0.025em;
  max-width: 16ch;
  color: #fff;
}

.sub {
  color: var(--mat);
  max-width: 52ch;
  font-size: 1.0625rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4) var(--s5);
}

.phone {
  font-family: var(--font-mono);
  font-size: var(--step-small);
  letter-spacing: 0.04em;
  color: var(--mat);
  text-decoration: none;
  border-bottom: var(--hairline) solid var(--rule-navy);
  padding-bottom: 2px;
  transition: border-color var(--t-colour) linear;
}

.phone:hover {
  color: #fff;
  border-bottom-color: var(--blue-2);
}

/* ---- The product index -------------------------------------------------- */

.index {
  display: grid;
  gap: var(--s3);
  align-content: start;
  border-top: var(--hairline) solid var(--rule-navy);
  padding-top: var(--s4);
}

.indexLabel {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue-2);
}

.indexName {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
  text-decoration: none;
  justify-self: start;
}

.arrow {
  margin-left: var(--s3);
  color: var(--green);
  font-weight: 400;
  display: inline-block;
  transition: transform var(--t-colour) var(--ease);
}

.indexName:hover .arrow {
  transform: translateX(4px);
}

.family {
  list-style: none;
  margin: var(--s2) 0 0;
  padding: 0;
  border-top: var(--hairline) solid var(--rule-navy);
}

.familyLink {
  display: grid;
  grid-template-columns: 2.5ch minmax(0, 1fr);
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: var(--hairline) solid var(--rule-navy);
  text-decoration: none;
  color: inherit;
  transition: border-bottom-color var(--t-colour) linear;
}

.familyLink:hover {
  border-bottom-color: var(--green);
}

.familyCode {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: 0.08em;
  color: var(--blue-2);
}

.familyName {
  font-size: var(--step-small);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* The documents this part counts: the document voice, quiet. */
.familyUnit {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: 0.04em;
  color: var(--mat);
  grid-column: 2;
  min-width: 0;
}

/* ---- Wider -------------------------------------------------------------- */

@media (min-width: 768px) {
  .stage {
    --stage-w: min(48vw, 640px);
    --stage-top: var(--s7);
  }

  .grid {
    padding-block: var(--s8);
  }
}

@media (min-width: 1200px) {
  .grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--s9);
    align-items: end;
    padding-block: var(--s9) var(--s8);
  }

  .index {
    border-top: 0;
    padding-top: 0;
  }
}

/* ---- Print and reduced motion ------------------------------------------ */

@media print {
  .stage {
    display: none !important;
  }
}
