/* Olens Productions - page loader styled as a camera viewfinder.
   The black backdrop paints instantly (it matches the site background, so a fast load looks like nothing happened);
   the viewfinder content only fades in if the page is still loading after ~0.3s. */

@property --hole { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

.loader {
  --hole: 0%;
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center;
  background:
    radial-gradient(60% 50% at 50% 45%, rgba(255, 193, 0, .10), transparent 70%),
    #050505;
  color: #f5f5f5; font-family: 'DM Sans', sans-serif;
  /* the hole in this mask grows on exit, so the page is revealed like a lens iris opening */
  -webkit-mask-image: radial-gradient(circle at 50% 45%, transparent var(--hole), #000 calc(var(--hole) + .5%));
          mask-image: radial-gradient(circle at 50% 45%, transparent var(--hole), #000 calc(var(--hole) + .5%));
  /* failsafe: if the script never runs, the loader still gets out of the way */
  animation: ld-failsafe 0s linear 8s forwards;
}
@keyframes ld-failsafe { to { visibility: hidden; opacity: 0; } }

/* film grain */
.loader::before {
  content: ""; position: absolute; inset: -50%; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: ld-grain .6s steps(3) infinite;
}
@keyframes ld-grain { 0% { transform: translate(0, 0); } 33% { transform: translate(-4%, 3%); } 66% { transform: translate(3%, -4%); } }

.ld-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* everything visible fades in late, so quick page loads never show it */
.ld-frame, .ld-center { opacity: 0; animation: ld-show .5s ease .3s forwards; }
.loader.is-instant .ld-frame, .loader.is-instant .ld-center { animation-delay: 0s; animation-duration: .25s; }
@keyframes ld-show { to { opacity: 1; } }

/* ---- viewfinder frame ---- */
.ld-frame { position: absolute; inset: clamp(16px, 4vw, 40px); pointer-events: none; font: 600 12px/1 'DM Sans', sans-serif; letter-spacing: .14em; color: rgba(255, 255, 255, .75); }
.ld-corner { position: absolute; width: clamp(22px, 4vw, 40px); height: clamp(22px, 4vw, 40px); border: 2px solid rgba(255, 255, 255, .55); }
.ld-corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.ld-corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.ld-corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.ld-corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.ld-rec, .ld-tc, .ld-meta, .ld-iso { position: absolute; }
.ld-rec { top: clamp(14px, 2.4vw, 22px); left: clamp(34px, 6vw, 60px); display: inline-flex; align-items: center; gap: 8px; color: #fff; }
.ld-rec i { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 12px #ff3b30; animation: ld-blink 1s steps(1) infinite; }
@keyframes ld-blink { 50% { opacity: .15; } }
.ld-tc { top: clamp(14px, 2.4vw, 22px); right: clamp(34px, 6vw, 60px); font-variant-numeric: tabular-nums; color: #fff; }
.ld-meta { bottom: clamp(14px, 2.4vw, 22px); left: clamp(34px, 6vw, 60px); }
.ld-iso { bottom: clamp(14px, 2.4vw, 22px); right: clamp(34px, 6vw, 60px); }

/* ---- center: aperture + progress ring + brand ---- */
.ld-center { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 24px; transform: translateY(-2vh); }
.ld-iris { width: clamp(112px, 22vw, 150px); height: auto; overflow: visible; }
.ld-track { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 2; }
.ld-ring {
  fill: none; stroke: #FFC100; stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0));
  transform: rotate(-90deg); transform-origin: 60px 60px;
  filter: drop-shadow(0 0 6px rgba(255, 193, 0, .55));
}
.ld-blades { fill: #FFC100; stroke: #050505; stroke-width: 1.6; stroke-linejoin: round; transform-origin: 60px 60px; animation: ld-iris 3.2s cubic-bezier(.6, 0, .4, 1) infinite; }
.ld-blades path:nth-child(odd) { fill: #e0a800; }
/* blades turn and "breathe" like an aperture adjusting */
@keyframes ld-iris {
  0% { transform: rotate(0) scale(1); }
  50% { transform: rotate(60deg) scale(.86); }
  100% { transform: rotate(120deg) scale(1); }
}
.ld-logo { width: clamp(150px, 26vw, 190px); height: auto; margin-top: 26px; }
.ld-pct { margin-top: 18px; font: 700 clamp(28px, 6vw, 38px)/1 'Outfit', sans-serif; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: #fff; }
.ld-pct .ld-num { display: inline-block; min-width: 2ch; text-align: right; }
.ld-msg { margin: 10px 0 0; min-height: 1.4em; color: rgba(255, 255, 255, .6); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; transition: opacity .3s; }
.ld-msg.is-swap { opacity: 0; }

/* ---- exit: iris opens from the center ---- */
.loader.is-out {
  --hole: 110%; pointer-events: none;
  transition: --hole .9s cubic-bezier(.7, 0, .2, 1), opacity .5s ease .55s; opacity: 0;
}
.loader.is-out .ld-center { transition: transform .6s cubic-bezier(.7, 0, .2, 1), opacity .4s; transform: scale(1.25); opacity: 0; }
.loader.is-gone { display: none; }

/* ---- leaving for another page: show the loader immediately ---- */
.loader.is-enter { --hole: 0%; visibility: visible; opacity: 1; animation: none; transition: opacity .25s ease; }
.loader.is-enter.is-pre { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .loader::before, .ld-blades, .ld-rec i { animation: none; }
  .loader.is-out { --hole: 0%; transition: opacity .3s ease; }
  .loader.is-out .ld-center { transition: none; transform: none; }
}
