/* ---------- 1. the opening ---------- */

/* still */

/* The sky: a soft blue at the top, deeper towards the top right, paling to near white at the bottom
   right, with a peach glow filling the bottom left. The layer that closes over the building
   (the veil, in index.html) is drawn from the same colours at the same places. */
.opening {
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 46% 46% at 8% 100%, var(--sky-glow) 0%, rgba(240, 204, 168, 0.78) 50%, rgba(240, 204, 168, 0) 100%),
    radial-gradient(ellipse 60% 60% at 90% 0%, var(--sky-deep) 0%, rgba(150, 177, 213, 0) 100%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 30%, var(--sky-3) 62%, var(--sky-4) 100%);
}

/* The soft clouds at the sides and low corners of the sky, painted by js/clouds.js, always behind
   the building. */
.opening__sky { position: absolute; z-index: 0; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.opening__sky canvas, .bank__cloud canvas { display: block; width: 100%; height: 100%; }

.opening__words {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: min(28px, 3vh);
  padding: min(48px, 3.4vh) 32px 0;
}
.goldbar { width: 56px; height: 4px; border-radius: 2px; background: var(--gold); }
.opening__headline {
  font-family: var(--head);
  font-size: clamp(44px, min(8.6vw, 14vh), 124px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.92;
  text-wrap: balance;
}
.opening__lede {
  max-width: 800px;
  font-size: clamp(19px, 1.7vw, 24px);
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: rgba(58, 16, 18, 0.62);
  text-wrap: balance;
}

/* The whole front view, roof to ground. Nothing is cropped and nothing sits in front of it.
   Standing still, it stands under the words. */
.opening__building {
  position: relative;
  z-index: 1;
  align-self: center;
  width: min(640px, 78%);
  margin-top: 40px;
  aspect-ratio: 1238 / 1271;
}
.opening__building img { width: 100%; height: auto; }

/* The name, the layer of sky that closes over the building, and the rising cloud belong to the
   moving page only. */
.opening__veil, .opening__outline, .opening__bank { display: none; }

@media (max-width: 640px) {
  .opening__words { padding-left: 22px; padding-right: 22px; }
  /* "Close to everything." is about 8.9 times the type size wide: at 9.4vw it fits one line on any
     phone, so the headline always stands on two lines. */
  .opening__headline { font-size: min(9.4vw, 56px); }
  .opening__lede { font-size: 17px; }
}

/* moving */

/* Held for four screens of scroll (the wrapper is five screens tall). js/opening.js drives it. */
.motion .hold--opening { height: 500vh; }
.motion .opening { min-height: 0; }
.motion .opening__words { will-change: transform, opacity; }

/* The script sets the picture's width, then moves and grows it from its top edge. */
.motion .opening__building { position: absolute; left: 50%; top: 0; margin: 0; transform-origin: 50% 0; will-change: transform; }

.wordmark {
  font-family: var(--head);
  font-size: 12.6vw;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-anchor: middle;
  dominant-baseline: central;
}
.motion .opening__veil { display: block; position: absolute; z-index: 2; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; }
/* The outlines are cut to the outside of the letters (the mask in index.html), so only the outer
   half of each stroke shows and the typeface's overlapping shapes leave no stray lines inside. */
.motion .opening__outline { display: block; position: absolute; z-index: 3; left: 0; top: 0; width: 100%; height: 100%; clip-path: inset(0 100% 0 0); }
.motion .opening__outline svg { width: 100%; height: 100%; }
.opening__outline .wordmark { fill: none; stroke: var(--cream-hi); stroke-width: 4px; }
.opening__outline .wordmark--dark { stroke: var(--ink); stroke-width: 2px; opacity: 0; }

/* The bank of cloud waits below the screen, then rises in front of everything: a soft edge
   70 hundredths of the screen tall, then the cream page. */
.motion .opening__bank { display: block; position: absolute; z-index: 5; left: 0; right: 0; top: 0; height: calc(170vh + 80px); pointer-events: none; transform: translate3d(0, 110vh, 0); will-change: transform; }
.bank__cloud { position: absolute; left: 0; right: 0; top: 0; height: 70vh; }
.bank__page { position: absolute; left: 0; right: 0; top: calc(70vh - 1px); bottom: 0; background: var(--page); }

/* moving, on a phone */

/* The building nearly fills the width, and the name is set on three lines (js/opening.js), large
   enough for the building to show through its letters. */
.motion.phone .wordmark { font-size: 25.5vw; }
.motion.phone .opening__outline .wordmark { stroke-width: 3px; }
.motion.phone .opening__outline .wordmark--dark { stroke-width: 1.5px; }
