/* First-entry loading reveal for the five "instrument" pages (Opening Library,
   Endgames Vault, Game Review, Blunder Override, Repertoire Builder).

   The veil is the SAME animation /puzzles uses (see .puzzle-loading in
   style_puzzles.css): a board-shaped shimmering skeleton + a spinning ring on
   a blurred glass veil that fades out, followed by a staggered rise of the
   content underneath.

   The veil is self-expiring even without JS: the keyframe below fades it out
   ~1.4s after load no matter what, so a failed script can never trap the page.
   page_reveal.js only needs to retime that to the snappier ~0.6s and add the
   entrance class. */
[data-page-reveal] {
  position: relative;
}

/* Blunder Override's root carries its own om-fade-in entrance that starts the
   root at opacity 0 for ~350ms; the veil is a child and would inherit that
   opacity, hiding it for most of the hold. Suspend the root's own entrance
   while the veil system is active — the children still rise via pre-revel-in
   once the veil clears. */
.mistakes-root[data-page-reveal] {
  animation: none !important;
}

.page-reveal-veil {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* First viewport only. Covering the whole main (a 100-course library is
     tens of thousands of px tall) would leave the centred watch below the
     fold; 100vh keeps the skeleton in the visible area on every page. */
  height: 100vh;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 20px;
  /* Starts transparent and is faded in (page_reveal.js adds .is-showing one
     frame after load) so the veil melts over the already-painted page instead
     of popping in over it — the smoothness the puzzles page gets for free by
     being the first paint. */
  opacity: 0;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  animation: pre-revel-expire 0.01s linear 1.4s forwards;
}
.page-reveal-veil.is-showing {
  opacity: 1;
  visibility: visible;
}
.page-reveal-veil.is-leaving {
  opacity: 0;
  visibility: hidden;
  animation: none;
}
@keyframes pre-revel-expire {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* The same board-shaped shimmer skeleton as the puzzles page. */
.page-reveal-veil::before {
  content: "";
  width: min(44vh, 300px);
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background:
    linear-gradient(100deg,
      var(--bg-2) 30%,
      color-mix(in srgb, var(--gold) 7%, var(--bg-2)) 50%,
      var(--bg-2) 70%);
  background-size: 220% 100%;
  animation: pre-revel-shimmer 1.4s linear infinite;
  opacity: 0.75;
}
@keyframes pre-revel-shimmer {
  from { background-position: 135% 0; }
  to { background-position: -85% 0; }
}

/* The same spinner ring as the puzzles page. */
.page-reveal-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: pre-revel-spin 1s linear infinite;
}
@keyframes pre-revel-spin {
  to { transform: rotate(360deg); }
}

/* The same careful text style as the puzzles page's "Loading puzzles". */
.page-reveal-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}

/* Content entrance — a short rise + fade, staggered per column, exactly like
   the puzzles page. The veil itself and anything hidden at load are excluded. */
[data-page-reveal].is-revealed > :not(.page-reveal-veil):not([hidden]) {
  animation: pre-revel-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
[data-page-reveal].is-revealed > :nth-child(2):not(.page-reveal-veil):not([hidden]) {
  animation-delay: 60ms;
}
[data-page-reveal].is-revealed > :nth-child(3):not(.page-reveal-veil):not([hidden]) {
  animation-delay: 120ms;
}
@keyframes pre-revel-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .page-reveal-veil::before,
  .page-reveal-spinner,
  [data-page-reveal].is-revealed > :not(.page-reveal-veil):not([hidden]) {
    animation: none;
  }
}