/* ==========================================================================
   Page loader — "the gate"
   A dark field in the hero film's own tone, the gold monogram rising with a
   sheen clipped to its letterforms, a gold hairline and counter that track
   real loading, then the field parts like a gate. Driven by js/loader.js.
   ========================================================================== */
.c-loader {
  --gold: #c9a45c;
  --gold-hi: #f3dca6;
  --field: #0d0f13;
  --ease-gate: cubic-bezier(0.65, 0.05, 0, 1);
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  pointer-events: auto;
  /* Failsafe: if the script never runs to completion, the loader still gets
     out of the way on its own. */
  animation: c-loader-failsafe 0.01s linear 8s forwards;
}

html.is-loading,
html.is-loading body {
  overflow: hidden;
}

/* The two halves of the gate carry the colour, so they can part. */
.c-loader__gate {
  position: absolute;
  inset-inline: 0;
  block-size: 50.5%;       /* a hair of overlap so no seam shows at rest */
  background:
    radial-gradient(90% 120% at 50% 100%, rgb(201 164 92 / 0.07), transparent 60%),
    var(--field);
  transition: transform 1.05s var(--ease-gate);
}

.c-loader__gate--a {
  inset-block-start: 0;
}

.c-loader__gate--b {
  inset-block-end: 0;
  background:
    radial-gradient(90% 120% at 50% 0%, rgb(201 164 92 / 0.07), transparent 60%),
    var(--field);
  transition-delay: 0.06s;
}

.c-loader__core {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 1.35rem;
  inline-size: min(78vw, 22rem);
  transition: opacity 0.5s ease, transform 0.8s var(--ease-gate), filter 0.6s ease;
}

/* Monogram, with a sheen masked to its own shape. */
.c-loader__mark {
  position: relative;
  inline-size: clamp(6rem, 22vw, 8.5rem);
  aspect-ratio: 240 / 142;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  filter: blur(6px);
  animation: c-loader-rise 1.1s var(--ease-gate) 0.1s forwards;
}

.c-loader__mark img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  filter: drop-shadow(0 6px 24px rgb(201 164 92 / 0.25));
}

.c-loader__sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 244 214 / 0.85) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%;
  background-position: 130% 0;
  -webkit-mask: url('../assets/img/logo-ah-mark.png') center / contain no-repeat;
          mask: url('../assets/img/logo-ah-mark.png') center / contain no-repeat;
  mix-blend-mode: screen;
  animation: c-loader-sheen 2.2s ease-in-out 0.7s infinite;
}

/* Hairline progress: grows from the centre outward, --p from 0 to 1. */
.c-loader__rule {
  position: relative;
  inline-size: 100%;
  block-size: 1px;
  background: rgb(255 255 255 / 0.1);
  overflow: hidden;
  opacity: 0;
  animation: c-loader-fade 0.6s ease 0.45s forwards;
}

.c-loader__rule span {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-hi) 50%, var(--gold) 80%, transparent);
  transform: scaleX(var(--p, 0));
  transform-origin: center;
  transition: transform 0.35s ease-out;
}

.c-loader__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  inline-size: 100%;
  margin: 0;
  font-family: 'Heebo', system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: rgb(255 255 255 / 0.5);
  direction: ltr;           /* Latin wordmark and figures read the same in both languages */
  opacity: 0;
  animation: c-loader-fade 0.6s ease 0.6s forwards;
}

.c-loader__count {
  font-variant-numeric: tabular-nums;
  color: rgb(255 255 255 / 0.85);
  letter-spacing: 0.12em;
}

/* Exit: the core lifts away, then the gate parts. */
.c-loader.is-leaving .c-loader__core {
  opacity: 0;
  transform: translateY(-18px) scale(0.98);
  filter: blur(4px);
}

.c-loader.is-leaving .c-loader__gate--a {
  transform: translateY(-100%);
  transition-delay: 0.28s;
}

.c-loader.is-leaving .c-loader__gate--b {
  transform: translateY(100%);
  transition-delay: 0.34s;
}

.c-loader.is-leaving {
  pointer-events: none;
}

@keyframes c-loader-rise {
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes c-loader-fade {
  to { opacity: 1; }
}

@keyframes c-loader-sheen {
  0%   { background-position: 130% 0; }
  55%  { background-position: -30% 0; }
  100% { background-position: -30% 0; }
}

@keyframes c-loader-failsafe {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

/* Reduced motion: no travel — the gate simply fades. */
@media (prefers-reduced-motion: reduce) {
  .c-loader__mark,
  .c-loader__rule,
  .c-loader__meta {
    animation: c-loader-fade 0.2s ease forwards;
    transform: none;
    filter: none;
  }

  .c-loader__sheen {
    animation: none;
    opacity: 0;
  }

  .c-loader__gate,
  .c-loader__core {
    transition: opacity 0.3s ease;
  }

  .c-loader.is-leaving .c-loader__gate--a,
  .c-loader.is-leaving .c-loader__gate--b {
    transform: none;
    opacity: 0;
  }
}
