/* The curtain between pages (js/core/curtain.js): a deep violet layer and a
   night-violet layer that sweep over the screen with a curved leading edge, the
   destination's name in huge type on the violet. */

.curtain {
  position: fixed;
  inset: 0;
  z-index: var(--z-curtain);
  overflow: hidden;
  visibility: hidden; /* curtain.js shows it when leaving or arriving */
  pointer-events: none;
}

.curtain__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  will-change: transform, border-radius;
}

.curtain__layer--back {
  /* deep violet, the leading wave */
  background: color-mix(in srgb, var(--color-violet) 45%, var(--color-bg));
}

/* Night blue-violet, close to the page's own background, lit from below by
   a soft violet glow, with the site's grain (darker since 2026-10-31: Jacob) */
.curtain__layer--front,
html[data-curtain="arriving"]::after {
  background:
    radial-gradient(120% 70% at 50% 115%, color-mix(in srgb, var(--color-violet) 40%, transparent), transparent 65%),
    radial-gradient(90% 60% at 15% -10%, color-mix(in srgb, var(--color-blue) 14%, transparent), transparent 60%),
    color-mix(in srgb, var(--color-indigo) 70%, var(--color-bg));
}

.curtain__layer--front {
  display: grid;
  place-items: center;
}

/* The site's grain texture on the violet (not a second .grain overlay: the
   page keeps a single one) */
.curtain__grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: var(--grain-image);
  background-size: 200px 200px;
  pointer-events: none;
}

/* The name: huge, sized to fit the width (0.62em ≈ an average glyph of
   Inter Tight 800); --curtain-chars is set on <html> by curtain.js and by the
   inline boot script, so the CSS cover and the real one match exactly. */
.curtain__title,
html[data-curtain="arriving"]::after {
  font-family: var(--font-sans);
  font-size: min(var(--step-6) * 1.6, calc((100vw - 2 * var(--gutter)) / (var(--curtain-chars, 12) * 0.62)));
  font-weight: 800;
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  white-space: nowrap;
}

.curtain__title {
  position: relative;
  z-index: 1;
  margin: 0;
  padding-inline: var(--gutter);
}

/* Each word rises out of its own line */
.curtain__word {
  display: inline-block;
  overflow: hidden;
  padding-bottom: 0.08em; /* room for descenders inside the mask */
  vertical-align: bottom;
}

.curtain__word > span {
  display: inline-block;
}

/* Arriving under the curtain: covered from the first paint (set by the inline
   <head> script) until curtain.js puts its own layers in place. */
html[data-curtain="arriving"]::after {
  content: attr(data-curtain-title);
  position: fixed;
  inset: 0;
  z-index: var(--z-curtain);
  display: grid;
  place-items: center;
  padding-bottom: 0.08em;
  /* Safety net: if curtain.js never runs (script error, blocked), the cover
     still goes away on its own. */
  animation: curtain-safety 0s 2.5s forwards;
}

@keyframes curtain-safety {
  to { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .curtain,
  html[data-curtain="arriving"]::after {
    display: none;
  }
}
