/* ==========================================================================
   8m/s — "Individualist" / THE SEAL
   The sleeve's heptagram sits fixed behind the page and the scroll turns it
   one vertex at a time; whichever song has just landed at the active notch
   is written beside it. Ten songs go round a seven-pointed seal more than
   once, then the green sleeve's seal rolls in for the four extended tracks.
   Tokens, nav and buttons come from style.css; the ledger and the lyric sheet
   from album.css. Only the seal is here.
   ========================================================================== */

/* A fixed layer under a scrolling page: stop the rubber-band at either end
   and paint the root the same colour in case a browser bounces anyway. */
html:has(body.seal) { background: #010203; overscroll-behavior-y: none; }
body.seal {
  background: #010203;
  overscroll-behavior-y: none;

  /* a heavy thing turning: slow to start, long to settle, and it goes a hair
     past the notch and comes back — that is the catch */
  --ease-turn: cubic-bezier(.32, .02, .2, 1.04);
  /* the roll coasts to a stop; no overshoot on a third of a turn */
  --ease-roll: cubic-bezier(.4, .02, .18, 1);

  /* --- the geometry, shared by the dial, the text and individualist.js ---
     Desktop: the seal on the left, the song beside its right-hand vertex, the
     pair centred as one composition. */
  --tw:  min(34rem, 42vw);                        /* the song column */
  --gap: clamp(2.5rem, 4vw, 4.5rem);              /* vertex to text */
  --d:   clamp(300px, min(64vh, 38vw), 800px);    /* the seal's diameter */
  --cx:  calc(50vw - (var(--tw) + var(--gap)) / 2);
  --cy:  50vh;
  --active: 0deg;                                 /* where a vertex lands: 3 o'clock */
  --tx:  calc(var(--cx) + var(--d) / 2 + var(--gap));
}

/* --- the nav keeps out of the reading (as on the wall) ---------------------
   Withdrawn on the way down, back on the first move up. No backdrop blur: it
   only shows on the way back up, which is when the seal is turning under it. */
body.seal .nav { transition: transform .45s var(--ease), background .45s var(--ease); }
body.seal .nav.is-stuck {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  background: rgba(4, 6, 10, .92);
}
body.seal .nav.is-hidden { transform: translateY(-100%); }
body.seal.menu-open .nav { transform: none; }

/* --- the stage ----------------------------------------------------------- */

.stage {
  position: fixed; inset: 0; z-index: 1;
  overflow: hidden;
  transition: opacity 1s var(--ease);
}
/* once the ledger has risen over it the seal stays, dimmed, behind the list */
.stage.is-past { opacity: .28; }

/* A hint of the sleeve's colour on the page: a pool of it behind the disc,
   nothing more. Purple gives way to green with the edition. */
.pool {
  position: absolute; left: var(--cx); top: var(--cy);
  width: calc(var(--d) * 2.3); height: calc(var(--d) * 2.3);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  opacity: 0; transition: opacity 1.8s var(--ease);
  pointer-events: none;
}
.pool--purple {
  background: radial-gradient(closest-side, rgba(118, 70, 158, .34), rgba(118, 70, 158, .12) 42%, transparent 100%);
  opacity: 1;
}
.pool--green {
  background: radial-gradient(closest-side, rgba(72, 146, 62, .3), rgba(72, 146, 62, .1) 42%, transparent 100%);
}
.stage.is-ext .pool--purple { opacity: 0; }
.stage.is-ext .pool--green  { opacity: 1; }

/* --- the dial -------------------------------------------------------------- */

.dial {
  position: absolute;
  width: var(--d); height: var(--d);
  left: calc(var(--cx) - var(--d) / 2);
  top:  calc(var(--cy) - var(--d) / 2);
}

/* the seven notches the vertices land in, around the outside of the disc;
   the whole set is turned so one notch sits at the active position */
.ring {
  position: absolute; inset: -14%; width: 128%; height: 128%;
  overflow: visible;
  transform: rotate(var(--active));
  pointer-events: none;
}
.ring__track { fill: none; stroke: rgba(143, 199, 220, .09); stroke-width: .5; }
.ring__ticks line { stroke: rgba(143, 199, 220, .36); stroke-width: .9; stroke-linecap: round; }

.disc {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  /* the one thing on the page that moves — promoted for the whole page, and
     the only property that ever changes on it is the transform */
  will-change: transform;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  backface-visibility: hidden;
}
/* transitions only once the script has parked the discs: without this the
   green seal would visibly roll off-screen on load */
.stage.is-live .disc { transition: transform 1.2s var(--ease-turn); }
.stage.is-live .dial.is-rolling .disc { transition: transform 2s var(--ease-roll); }

/* the active notch: a longer, brighter tick where the vertex lands */
.catch {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--d) * .575); height: 2px; margin-top: -1px;
  transform-origin: 0 50%;
  transform: rotate(var(--active));
  pointer-events: none;
}
.catch::after {
  content: ""; position: absolute; right: 0; top: 0;
  width: calc(var(--d) * .055); height: 2px;
  background: var(--ice);
  box-shadow: 0 0 8px rgba(143, 199, 220, .55);
  transform-origin: 100% 50%;
  opacity: .92;
  transition: opacity .6s var(--ease);
}
.stage.is-rest .catch::after { opacity: .38; }
/* the catch: the tick flares as the vertex lands on it */
@keyframes catch-hit {
  0%   { opacity: 1; transform: scaleX(2); box-shadow: 0 0 16px rgba(190, 228, 244, .95); }
  100% { opacity: .92; transform: none; box-shadow: 0 0 8px rgba(143, 199, 220, .55); }
}
.catch.is-hit::after { animation: catch-hit .6s var(--ease) both; }

/* --- the song at the vertex ------------------------------------------------ */

.song {
  position: absolute;
  left: var(--tx); top: var(--cy);
  width: var(--tw);
  transform: translateY(-50%);
  display: grid;
  align-items: start;
}
/* two slots in one cell: the leaving song fades up and out, the arriving one
   fades in a beat after the seal has landed */
.song__slot {
  grid-area: 1 / 1;
  opacity: 0; transform: translateY(12px);
  visibility: hidden; pointer-events: none;
  transition: opacity .4s var(--ease), transform .5s var(--ease), visibility 0s .4s;
}
.song__slot.is-in {
  opacity: 1; transform: none;
  visibility: visible; pointer-events: auto;
  transition: opacity .75s var(--ease) .55s, transform .85s var(--ease) .55s, visibility 0s .55s;
}
.song__n {
  font-family: var(--f-mono); font-size: .64rem;
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--ice); margin: 0 0 1.2rem;
}
.song__n em { font-style: normal; color: var(--ash); }
.song__title {
  font-family: var(--f-display); font-weight: 500; font-variation-settings: "opsz" 12;
  text-transform: uppercase; letter-spacing: .06em; line-height: 1;
  font-size: clamp(1.6rem, 1rem + 1.9vw, 3.4rem);
  color: var(--frost); margin: 0 0 1.4rem;
}
/* the line from the song, in the sleeve's own voice: the site's face, italic */
.song__quote {
  font-family: var(--f-display); font-style: italic; font-weight: 400;
  font-variation-settings: "opsz" 12;
  font-size: clamp(1.1rem, .95rem + .6vw, 1.55rem); line-height: 1.45;
  color: rgba(211, 227, 234, .88);
  margin: 0; max-width: 28ch;
  text-wrap: balance;
}
.song__quote[lang="bg"] { font-family: "EB Garamond", "Bodoni Moda", Georgia, serif; }
/* not chosen yet — the same type, half the light */
.song__quote.is-blank { color: var(--ash); opacity: .5; }
.song__lede {
  font-weight: 300; color: #b4c6d0; max-width: 34ch;
  font-size: clamp(.98rem, .92rem + .3vw, 1.15rem); margin: 0;
  text-wrap: balance;
}

/* the way into the lyrics: set like the mason's mark on the wall, a hairline
   cut beneath it */
.song__read, .song__soon {
  display: inline-block; margin-top: 1.8rem; position: relative;
  font-family: var(--f-mono); font-size: .6rem;
  letter-spacing: .3em; text-transform: uppercase;
  background: none; border: 0; padding: 0 0 .55rem; cursor: pointer;
  color: rgba(158, 182, 202, .78);
  transition: color .4s var(--ease);
}
.song__read::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(to right, rgba(158, 182, 202, .55), rgba(158, 182, 202, .55) 70%, transparent);
  transition: background .4s var(--ease);
}
.song__read:hover, .song__read:focus-visible { color: var(--frost); }
.song__read:hover::after { background: linear-gradient(to right, rgba(206, 230, 246, .9), rgba(206, 230, 246, .9) 70%, transparent); }
.song__soon { cursor: default; color: var(--ice-dim); letter-spacing: .22em; }
.song__soon::after { content: none; }

/* --- the falling line under the title, as on the wall --------------------- */
.song__cue { margin: 2.4rem 0 0; display: grid; justify-items: start; }
.song__cue::after {
  content: ""; width: 2px; height: 64px; border-radius: 1px;
  background:
    linear-gradient(to bottom,
      transparent 0%, transparent 33%,
      rgba(143, 199, 220, .35) 41%, #f2fbff 50%, rgba(143, 199, 220, .35) 59%,
      transparent 67%, transparent 100%),
    linear-gradient(to bottom, transparent, rgba(143, 199, 220, .32) 30%, rgba(143, 199, 220, .32) 70%, transparent);
  background-size: 100% 300%, 100% 100%;
  background-repeat: no-repeat;
  background-position: 0 100%, 0 0;
  filter: drop-shadow(0 0 5px rgba(196, 232, 246, .95)) drop-shadow(0 0 14px rgba(143, 199, 220, .6));
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
  animation: seal-glint 3.2s cubic-bezier(.45, .05, .55, .95) infinite;
}
@keyframes seal-glint {
  from { background-position: 0 100%, 0 0; }
  to   { background-position: 0 0%,   0 0; }
}

/* --- stepping by hand ------------------------------------------------------ */
/* Arrow keys do the same. The counter is the only progress the page shows. */
.song__nav {
  grid-area: 2 / 1;
  display: flex; align-items: center; gap: 1.1rem;
  margin: 2.2rem 0 0;
  font-family: var(--f-mono); font-size: .62rem;
  letter-spacing: .26em; text-transform: uppercase;
  color: var(--ash);
}
.song__count { min-width: 5.5em; }
.song__step {
  width: 2.5rem; height: 2.5rem; display: grid; place-items: center;
  background: none; border: 1px solid var(--hair); color: var(--frost);
  font: inherit; font-size: .95rem; letter-spacing: 0; cursor: pointer;
  transition: border-color .3s, color .3s, opacity .3s;
}
.song__step:hover, .song__step:focus-visible { border-color: var(--ice); color: var(--ice); }
.song__step[disabled] { opacity: .28; cursor: default; border-color: var(--hair-soft); color: var(--ash); }
/* the seal is at rest: only the way forward is offered */
.stage.is-rest .song__step--prev { visibility: hidden; }
.stage.is-past .song { opacity: 0; transition: opacity .5s var(--ease); }

/* --- the scroll ------------------------------------------------------------ */

/* The page's own content is the ledger; everything above it is distance.
   The spacers let the pointer through to the song under them. */
.flow { position: relative; z-index: 2; pointer-events: none; }
.opening { height: 100vh; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { height: 70vh; }
/* the turn where the green seal rolls in is given room to happen */
.step--roll { height: 100vh; }

.ledger { pointer-events: auto; z-index: 3; }
.ledger__head--ext { margin-top: .6rem; }

/* --- credits, as on the sleeve --------------------------------------------- */
.credits {
  width: min(560px, 100%); margin: .4rem 0 0;
  padding-top: 1.8rem; border-top: var(--rule);
  display: grid; gap: .85rem;
}
.credits div { display: grid; grid-template-columns: 11rem 1fr; gap: .2rem 1.2rem; }
.credits dt {
  font-family: var(--f-mono); font-size: .58rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ice-dim); padding-top: .25rem;
}
.credits dd { margin: 0; color: var(--ash); font-weight: 300; font-size: .86rem; line-height: 1.6; }
@media (max-width: 560px) { .credits div { grid-template-columns: 1fr; } }

/* --- phone: the seal large, the song beneath it --------------------------- */
@media (max-width: 899px) {
  body.seal {
    --d: min(82vw, 42svh);
    --cx: 50vw;
    /* anchored to the top, not the middle: a phone's toolbar resizes the
       viewport as you scroll, and the seal must not shift with it */
    --cy: calc(3.4rem + env(safe-area-inset-top, 0px) + var(--d) / 2);
    --active: 90deg;                              /* 6 o'clock, pointing at the words */
  }
  .song {
    left: var(--gut); right: var(--gut); width: auto;
    top: calc(var(--cy) + var(--d) / 2 + 2.3rem);
    transform: none;
    text-align: center; justify-items: center;
  }
  .song__n { margin-bottom: .8rem; font-size: .6rem; letter-spacing: .22em; }
  .song__title { margin-bottom: .9rem; }
  .song__quote, .song__lede { margin-inline: auto; }
  .song__quote { font-size: clamp(1.05rem, .9rem + .6vw, 1.3rem); line-height: 1.4; }
  .song__lede { font-size: .95rem; max-width: 30ch; }
  .song__read, .song__soon { margin-top: 1.1rem; }
  .song__cue { justify-items: center; margin-top: 1rem; }
  .song__cue::after { height: 40px; }
  .song__nav { justify-content: center; margin-top: 1.2rem; }
  .step { height: 76vh; }
}
@media (max-width: 899px) and (hover: none) {
  .song__step { width: 2.9rem; height: 2.9rem; }
  .song__read { padding: .6rem 0 .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  /* the steps land at once, and the words with them */
  .song__slot { transition-delay: 0s !important; }
  .song__cue::after { animation: none; background-position: 0 50%, 0 0; }
  .catch.is-hit::after { animation: none; }
}
