/* ============================================================================
   THE THRESHOLD — the loader. No spinner. The opening frame of a film:
   black, a single point of light, a count to twenty-four, then the gate opens.
   ============================================================================ */

.loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  display: grid;
  place-items: center;
  background: var(--c-void);
  overflow: hidden;
}

/* The projector gate — a point of light that swells into a frame. */
.loader__gate {
  position: relative;
  width: min(42vw, 22rem);
  aspect-ratio: 1.85 / 1;
  display: grid;
  place-items: center;
}
.loader__light {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--c-accent);
  box-shadow:
    0 0 12px 2px rgba(216, 178, 124, 0.7),
    0 0 60px 14px rgba(216, 178, 124, 0.22);
  animation: loader-breathe 2.4s var(--e-soft) infinite;
}
@keyframes loader-breathe {
  0%, 100% { transform: scale(1);   opacity: 0.7; }
  50%      { transform: scale(2.2); opacity: 1; }
}

/* The scanning line — like light through the gate, sweeping the count. */
.loader__meta {
  position: absolute;
  left: 50%;
  bottom: clamp(4rem, 14vh, 9rem);
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  color: var(--c-ink);
}
.loader__word {
  font-family: var(--f-display);
  font-weight: var(--w-thin);
  font-style: italic;
  font-size: clamp(1.4rem, 1rem + 2vw, 2.4rem);
  letter-spacing: -0.01em;
  opacity: 0.9;
}
.loader__count {
  font-family: var(--f-mono);
  font-size: var(--fs-nano);
  letter-spacing: 0.22em;
  color: var(--c-ink-mute);
}
.loader__count i { font-style: normal; opacity: 0.5; margin: 0 0.15em; }

/* The fill — a hairline that draws to full width. */
.loader__bar {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(2rem, 8vh, 4rem);
  height: 1px;
  background: var(--c-line-soft);
  overflow: hidden;
}
.loader__bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(216,178,124,0.2), var(--c-accent));
  transition: width 0.2s linear;
}

/* The gate opens: two black bars retract vertically, revealing the film. */
.loader::before,
.loader::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 50%;
  background: var(--c-void);
  z-index: 2;
  transform: translateY(0);
  transition: transform var(--d-4) var(--e-inout);
}
.loader::before { top: 0; }
.loader::after  { bottom: 0; }

.loader.is-leaving .loader__gate,
.loader.is-leaving .loader__meta,
.loader.is-leaving .loader__bar { opacity: 0; transition: opacity 0.5s ease; }
.loader.is-leaving::before { transform: translateY(-100%); }
.loader.is-leaving::after  { transform: translateY(100%); }

.loader.is-done { display: none; }

/* Reduced motion: no breathing, no sweep — a still title card that fades. */
@media (prefers-reduced-motion: reduce) {
  .loader__light { animation: none; }
  .loader.is-leaving { opacity: 0; transition: opacity 0.4s ease; }
  .loader.is-leaving::before, .loader.is-leaving::after { transform: none; }
}
