/* =====================================================================
   POINT OF VIEW — "Sunset Eye" log in / sign-up transition
   ---------------------------------------------------------------------
   Behaviour: public/js/pov-login-transition.js (timings: its SETTINGS block)
   Loaded by layouts/auth (departure) and layouts/app + layouts/admin (arrival).
   1. Auth pages: the card collapses into a circle, the real logo eye opens,
      looks around, blinks, and a sunset wave fills the screen.
   2. Destination: the inline <head> snippet sets html.pov-arriving before the
      first paint → the SAME final sunset frame covers the page and fades out
      in pure CSS from that first paint (the script only tidies up).
   Only transform / opacity are animated (the collapsing card shell also
   animates left/top/width/height).
   ===================================================================== */

/* ---------------------------------------------------------------------
   THE sunset frame — single definition, shared by the departing wave and
   the arrival cover so the two pages paint exactly the same pixels.
   A circle 1.2 × the viewport diagonal, centred on the viewport.
   --------------------------------------------------------------------- */
:root {
  --pov-lt-sunset: radial-gradient(circle, #fff3dc 0%, #ffc27d 13%, #ff8a4c 28%, #ff6b35 42%, #d9441a 58%, #7a2a2a 76%, #0b132b 100%);
  --pov-lt-sun-d: calc((100vw + 100vh) * 1.2);                 /* fallback: older browsers without hypot() */
}
@supports (width: hypot(3px, 4px)) {
  :root { --pov-lt-sun-d: calc(hypot(100vw, 100vh) * 1.2); }
}
.pov-lt-sun,
html.pov-arriving::before {
  position: fixed;
  left: 50vw;
  top: 50vh;
  width: var(--pov-lt-sun-d);
  height: var(--pov-lt-sun-d);
  margin: calc(var(--pov-lt-sun-d) / -2) 0 0 calc(var(--pov-lt-sun-d) / -2);
  border-radius: 50%;
  background: var(--pov-lt-sunset);
  pointer-events: none;
}

/* ---------------------------------------------------------------------
   1. Departure stage (auth pages)
   --------------------------------------------------------------------- */
.pov-lt {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  pointer-events: auto; /* swallow clicks while the transition plays */
}
.pov-lt__dim { position: absolute; inset: 0; background: #0b132b; opacity: 0; }
/* Layer order inside the stage (independent of creation order): dim < card < eye < wave < breath < ring */
.pov-lt__dim { z-index: 0; }
.pov-lt__card { z-index: 1; }
.pov-lt__eye { z-index: 2; }
.pov-lt__wave { z-index: 3; }
.pov-lt__breath { z-index: 4; }
.pov-lt__ring { z-index: 5; }

/* Plain shell at the visible card face's rect (never a clone of the 3D flip card) */
.pov-lt__card {
  position: fixed;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
}
.pov-lt__card-inner { box-sizing: border-box; pointer-events: none; } /* inert copy of the face content, fades in 220 ms */

/* The real logo eye (cloned from [data-pov-logo] .pov-eye), centred */
.pov-lt__eye {
  position: fixed;
  left: 50vw;
  top: 50vh;
  width: 150px;
  height: 150px;
  margin: -75px 0 0 -75px;
  opacity: 0;
  pointer-events: none;
}
.pov-lt__eye .pov-eye { display: block; width: 100%; height: 100%; overflow: visible; filter: none; }

/* Sunset wave: the shared frame, scaled up from a dot (JS animates transform) */
.pov-lt__wave { opacity: 0; transform-origin: 50% 50%; will-change: transform, opacity; }

/* While waiting on the final frame: a gentle breathing glow, never frozen */
.pov-lt__breath {
  position: fixed;
  left: 50vw;
  top: 50vh;
  width: 70vmin;
  height: 70vmin;
  margin: -35vmin 0 0 -35vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 243, 220, 0.55), rgba(255, 194, 125, 0) 65%);
  opacity: 0;
  pointer-events: none;
}

/* Tiny pulsing ring: only if we are still waiting after ~3 s */
.pov-lt__ring {
  position: fixed;
  left: 50vw;
  top: 50vh;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid #fff3dc;
  border-radius: 50%;
  opacity: 0;
}
.pov-lt__ring.is-on { animation: pov-lt-pulse 1s ease-in-out infinite; }
@keyframes pov-lt-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

/* Final frame on screen: drop the scrollbar so the frame reaches the edge,
   exactly like the arrival cover (which also hides it) */
html.pov-lt-lock { overflow: hidden; }

/* ---------------------------------------------------------------------
   2. Arrival (destination page)
   html.pov-arriving is set by the inline script at the top of <head>
   (layouts/app + layouts/admin), before any CSS, so the first paint is the
   final sunset frame, which immediately starts fading. The deferred script
   removes the class when the fade ends; the inline script removes it after
   3 s anyway, and the CSS failsafe hides it at 3 s even without any script.
   --------------------------------------------------------------------- */
:root {
  --pov-lt-arrive-ms: 450ms;      /* destination: the frame fades out over this … */
  --pov-lt-arrive-delay: 70ms;    /* … starting this long after the first paint */
}
html.pov-arriving::before {
  content: "";
  z-index: 2147483000;
  will-change: opacity;
  /* Starts on the very first paint and runs on the compositor, even while the main thread builds the page.
     2nd animation: the CSS failsafe (hidden at 3 s even if no script ever runs). */
  animation:
    pov-lt-cover-out var(--pov-lt-arrive-ms) cubic-bezier(.4, 0, .2, 1) var(--pov-lt-arrive-delay) forwards,
    pov-lt-failsafe 0s linear 3s forwards;
}
@keyframes pov-lt-cover-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes pov-lt-failsafe { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  :root { --pov-lt-arrive-ms: 300ms; } /* keep the delay: the animation clock can start ~70 ms before the first paint */
}

/* Soft orange glow at the top of the page while it settles (behind the page content) */
.pov-lt-glow {
  position: fixed;
  inset: 0 0 auto 0;
  height: 70vh;
  z-index: 0;
  background: radial-gradient(60% 80% at 50% 0, rgba(255, 107, 53, 0.4), transparent 70%);
  opacity: 0;
  pointer-events: none;
}
