.brand-intro { display: none; }

.is-opening :is(.wordmark, .site-header nav a, .hero-copy, .hero-link, .aerial-caption,
    .camera-position, .film-loading) { opacity: 0; animation: none; }

.brand-intro:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity .18s ease;
}

.brand-intro.is-complete { opacity: 0; }
.brand-intro-mark, .brand-loading { grid-area: 1 / 1; }
.brand-intro-mark {
  width: clamp(4.8rem, 9.6vw, 7.5rem);
  height: auto;
  opacity: 0;
  animation: opening-mark .62s ease both;
}

.brand-loading {
  display: grid;
  grid-template-columns: 1fr 4ch;
  align-items: baseline;
  gap: .8em 1em;
  width: min(16rem, calc(100% - 3rem));
  color: #e6e4e0;
  font: .65rem / 1.5 var(--label-font);
  letter-spacing: .14em;
  text-transform: uppercase;
  text-shadow: 0 1px 5px #080808;
  opacity: 0;
  transition: opacity .16s ease;
}
.is-counting .brand-loading { opacity: .85; }
.brand-loading-value { text-align: right; font-variant-numeric: tabular-nums; }
.brand-loading-track {
  position: relative;
  grid-column: 1 / -1;
  height: 1px;
  background: rgb(230 228 224 / .34);
}
/* Two points start in the middle and travel outwards, east and west, drawing the bar. */
.brand-loading-track::before,
.brand-loading-track::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 3px;
  height: 3px;
  background: currentColor;
  translate: -50% -50%;
}
.brand-loading-track::before { left: calc(50% - var(--p, 0) * 50%); }
.brand-loading-track::after { left: calc(50% + var(--p, 0) * 50%); }
.brand-loading-fill {
  display: block;
  height: 100%;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
}

/* First entry: larger crest, fades in, holds ~2s, fades out before loading. */
.brand-intro.is-first .brand-intro-mark {
  display: block;
  width: clamp(5.9rem, 11.2vw, 8.8rem);
  animation: opening-mark-hold 3.4s linear both;
}
@keyframes opening-mark-hold {
  0% { opacity: 0; animation-timing-function: ease-in-out; }
  26% { opacity: 1; }
  85% { opacity: 1; animation-timing-function: ease-in; }
  100% { opacity: 0; }
}

@keyframes opening-mark {
  0%, 100% { opacity: 0; }
  48%, 69% { opacity: 1; }
}

/* First entry: the page dims by 20% as the crest fades up, then lightens as the site loads. */
.brand-intro-shade {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #000;
  pointer-events: none;
  animation: intro-shade-in .9s ease-in-out both;
}
.brand-intro-shade.is-lifting {
  z-index: 3;
  animation: intro-shade-out 1.2s ease-in-out both;
}
@keyframes intro-shade-in { from { opacity: 0; } to { opacity: .2; } }
@keyframes intro-shade-out { from { opacity: .2; } to { opacity: 0; } }

/* Tagline under the crest on first entry: body font, spaced capitals. */
.brand-intro-line {
  grid-area: 1 / 1;
  margin: 0;
  padding-left: .34em; /* balances the trailing letter-space so the line stays centred */
  translate: 0 calc(clamp(5.9rem, 11.2vw, 8.8rem) / 2 + 1.7rem);
  color: #e6e4e0;
  font: 400 clamp(.62rem, 2.6vw, .72rem) / 1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: .34em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 6px #080808;
  animation: intro-line 3.4s linear both;
}
@keyframes intro-line {
  0%, 16% { opacity: 0; animation-timing-function: ease-in-out; }
  38% { opacity: .82; }
  85% { opacity: .82; animation-timing-function: ease-in; }
  100% { opacity: 0; }
}

/* First entry, drawn crest: B fades up; petals and ring draw in a fast linear stroke. */
.brand-intro.is-first .brand-intro-mark.is-drawn {
  aspect-ratio: 1;
  overflow: visible;
  animation: drawn-mark 3.4s linear both;
}
.brand-intro-mark.is-drawn .draw {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: crest-draw .7s linear .12s both;
}
.brand-intro-mark.is-drawn .ring { animation-duration: .55s; animation-delay: .3s; }
.brand-intro-mark.is-drawn .mark-b { animation: crest-b .9s ease-out both; }
@keyframes crest-draw { to { stroke-dashoffset: 0; } }
@keyframes crest-b { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawn-mark {
  0%, 85% { opacity: 1; animation-timing-function: ease-in; }
  100% { opacity: 0; }
}

/* Desktop: smaller crest on page transitions (first-entry crest keeps its own size). */
@media (min-width: 801px) {
  .brand-intro:not(.is-first) .brand-intro-mark { width: clamp(4.2rem, 5.6vw, 5.6rem); }
}

/* Smooth logo motion: every fade and stroke eases in and out (slightly longer to allow it). */
.brand-intro-mark { animation: opening-mark-smooth .9s both; }
@keyframes opening-mark-smooth {
  0% { opacity: 0; animation-timing-function: ease-in-out; }
  40% { opacity: 1; }
  62% { opacity: 1; animation-timing-function: ease-in-out; }
  100% { opacity: 0; }
}
.brand-intro.is-first .brand-intro-mark { animation-duration: 3.8s; }
.brand-intro.is-first .brand-intro-mark.is-drawn { animation: drawn-mark-smooth 3.8s both; }
@keyframes drawn-mark-smooth {
  0% { opacity: 0; animation-timing-function: ease-in-out; }
  10% { opacity: 1; }
  82% { opacity: 1; animation-timing-function: ease-in-out; }
  100% { opacity: 0; }
}
.brand-intro-mark.is-drawn .draw { animation: crest-draw .95s ease-in-out .15s both; }
.brand-intro-mark.is-drawn .ring { animation-duration: .8s; animation-delay: .35s; }
.brand-intro-mark.is-drawn .mark-b { animation: crest-b 1.1s ease-in-out both; }
.brand-intro-line { animation: intro-line-smooth 3.8s both; }
@keyframes intro-line-smooth {
  0%, 16% { opacity: 0; animation-timing-function: ease-in-out; }
  38% { opacity: .82; }
  82% { opacity: .82; animation-timing-function: ease-in-out; }
  100% { opacity: 0; }
}

/* Every page transition: the crest draws in too (quicker), then fades before the loader. */
.brand-intro-mark.is-drawn { aspect-ratio: 1; overflow: visible; }
.brand-intro:not(.is-first) .brand-intro-mark.is-drawn { animation: drawn-mark-quick 1.3s both; }
@keyframes drawn-mark-quick {
  0% { opacity: 0; animation-timing-function: ease-in-out; }
  8% { opacity: 1; }
  70% { opacity: 1; animation-timing-function: ease-in-out; }
  100% { opacity: 0; }
}
.brand-intro:not(.is-first) .brand-intro-mark.is-drawn .draw { animation: crest-draw .6s ease-in-out .05s both; }
.brand-intro:not(.is-first) .brand-intro-mark.is-drawn .ring { animation-duration: .5s; animation-delay: .18s; }
.brand-intro:not(.is-first) .brand-intro-mark.is-drawn .mark-b { animation: crest-b .6s ease-in-out both; }

/* Desktop: first-entry crest ("Foresight delivered") 20% smaller; the tagline follows it. */
@media (min-width: 801px) {
  .brand-intro.is-first .brand-intro-mark { width: clamp(4.72rem, 8.96vw, 7.04rem); }
  .brand-intro-line { translate: 0 calc(clamp(4.72rem, 8.96vw, 7.04rem) / 2 + 1.7rem); }
}
