/* Cinematic intro — mirrors the product login splash (frontend/app/iam/login/page.tsx).
   Product: logo enters with fade + zoom from .92 (1s, ease-in-out), holds vivid 2200ms,
   then over 1800ms grows from the 640px box to the 900px box while dimming to 14%.
   Only transform and opacity animate here, so the motion stays on the compositor (no jitter). */
:root { --ease-io: cubic-bezier(.4, 0, .2, 1); --vivid-scale: .71; }
/* The logo PNG has transparent margins: the drawn mark is 957/1024 of the image height, so a box 1.07x the free
   height below the header still shows every part of it. Same rule in intro.js (setVividScale). */
:root { --logo-free: calc(100vh - var(--hdr, 0px) - 12px); }
html { scrollbar-gutter: stable; }

.intro { display: none; }
.intro-on body { overflow: hidden; }
.intro-on .intro {
  display: block; position: fixed; inset: 0; z-index: 1000; overflow: hidden;
  background: #000; cursor: pointer; transition: opacity .7s ease-out;
}

/* Login chrome backdrop: teal top glow, indigo corner, bottom shade. */
.intro-glow {
  position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .7s ease-out;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(20, 184, 166, .12), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(99, 102, 241, .08), transparent 50%),
    linear-gradient(to bottom, rgba(0, 0, 0, .05), rgba(0, 0, 0, .55));
}

/* Box = the product's watermark box; vivid size is the same box scaled down (scale set by intro.js). */
.intro-logo, .page-watermark { display: flex; align-items: center; justify-content: center; pointer-events: none; }
.intro-logo { position: absolute; inset: 0; opacity: 1; transform: translateY(0); transition: opacity 1.8s var(--ease-io), transform 1.8s var(--ease-io); }
.logo-stage {
  position: relative; width: min(90vw, 900px); height: min(90vh, 900px, calc(var(--logo-free) * 1.07));
  transform: scale(var(--vivid-scale)); will-change: transform;
}
/* Only the vivid-to-watermark growth animates; while vivid, a box/scale refit (--hdr arriving, resize) lands at once. */
.intro:not([data-phase="vivid"]) .logo-stage { transition: transform 1.8s var(--ease-io); }
.logo-enter { position: absolute; inset: 0; animation: introLogoIn 1s var(--ease-io) both; will-change: transform, opacity; }
@keyframes introLogoIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.logo-enter img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity 1.8s var(--ease-io); }

/* Vivid look vs watermark look, cross-faded (opacity only) instead of animating filters. */
.logo-glow { filter: blur(30px) saturate(1.6); opacity: .55; }
.logo-vivid { filter: saturate(1.5) brightness(1.12) contrast(1.08); }
.logo-mark { filter: saturate(.75) brightness(.9); opacity: 0; }

/* While it dims, the logo also settles into the space below the header, where the page watermark sits (site.js sets --hdr). */
.intro:not([data-phase="vivid"]) .intro-logo { opacity: .14; transform: translateY(calc(var(--hdr, 0px) / 2)); }
.intro:not([data-phase="vivid"]) .logo-stage { transform: none; }
.intro:not([data-phase="vivid"]) .logo-glow,
.intro:not([data-phase="vivid"]) .logo-vivid { opacity: 0; }
.intro:not([data-phase="vivid"]) .logo-mark { opacity: 1; }

/* Chrome: the login title block, fades in with zoom-95 + slide-up. */
.intro-chrome {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; padding: 0 16px; visibility: hidden;
}
.intro-chrome > div { opacity: 0; }
.intro-title { margin: 0; color: #e2e8f0; font-weight: 700; font-size: clamp(1.875rem, 5vw, 2.25rem); letter-spacing: -.025em; }
.intro-sub { margin: 8px 0 0; color: #71717a; font: .75rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .2em; }
.intro-tag { margin: 32px 0 0; color: #71717a; font-size: .875rem; font-weight: 500; }

.intro[data-phase="login"] .intro-glow, .intro[data-phase="leave"] .intro-glow { opacity: 1; }
.intro[data-phase="login"] .intro-chrome, .intro[data-phase="leave"] .intro-chrome { visibility: visible; }
.intro[data-phase="login"] .intro-chrome > div, .intro[data-phase="leave"] .intro-chrome > div { animation: introChromeIn .7s ease-out both; }
@keyframes introChromeIn { from { opacity: 0; transform: scale(.95) translateY(12px); } to { opacity: 1; transform: none; } }

/* Leave: everything but the logo fades. When the overlay is removed the identical page watermark
   takes its place in the same frame, so the logo never moves or flickers. */
.intro[data-phase="leave"] { background: transparent; transition: background .7s ease-out; }
.intro[data-phase="leave"] .intro-glow,
.intro[data-phase="leave"] .intro-chrome,
.intro[data-phase="leave"] .intro-skip { opacity: 0; transition: opacity .7s ease-out; }
.intro[data-phase="leave"] { pointer-events: none; }

.intro-skip {
  position: absolute; right: 16px; bottom: 16px; z-index: 2; min-height: 44px; padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, .15); border-radius: 999px; background: rgba(255, 255, 255, .06);
  color: #a1a1aa; font-size: .85rem; opacity: 0; animation: introSkipIn .4s ease-out .8s forwards;
}
.intro-skip:hover { color: #fff; background: rgba(255, 255, 255, .12); }
@keyframes introSkipIn { to { opacity: 1; } }

/* The page keeps the logo as a watermark in the first screen, as the login page does behind its form. */
/* Fills the screen below the header, so the mark is never covered by the menu bar nor cut at the bottom. */
.page-watermark { position: absolute; left: 0; top: var(--hdr, 0px); width: 100%; height: calc(100vh - var(--hdr, 0px)); z-index: -1; opacity: .14; }
.intro-on .page-watermark { opacity: 0; }
.page-watermark .logo-stage { transform: none; will-change: auto; }
.page-watermark img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: saturate(.75) brightness(.9); }

/* After the intro the hero arrives the way the login card does. */
.intro-reveal .hero-inner { animation: introChromeIn .7s ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .intro-on .intro { display: none; }
  .intro-on body { overflow: auto; }
}
