/* ==========================================================================
   Sofly LifeStyle · Cinematic intros
   - PUBLIC  : "The Horizon"  → gold planet rim, crown + wordmark, doors open
   - CLIENT  : "The Private Key" → Face ID scan, lock opens, iris reveal
   Everything is hidden unless <html> has .intro-pending (set by intro-head.ejs).
   ========================================================================== */

:root {
  --intro-ease: cubic-bezier(.16, .84, .3, 1);
  --intro-ease-io: cubic-bezier(.76, 0, .18, 1);
  --intro-bg: #0b0b0a;
  --intro-gold: #d4ad67;
  --intro-gold-hi: #f0d293;
  --intro-gold-deep: #9a7334;
}

@property --iris { syntax: '<length>'; inherits: true; initial-value: -90px; }

/* ───────── Base ───────── */
.intro { display: none; }
html.intro-pending { overflow: hidden; background: var(--intro-bg); }
html.intro-pending .intro { display: block; }

.intro {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  color: #f5efe5;
  font-family: var(--sans, 'DM Sans', system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
}
.intro *, .intro *::before, .intro *::after { box-sizing: border-box; }
.intro.is-skip { opacity: 0; transition: opacity .45s ease; pointer-events: none; }
.intro.is-open { pointer-events: none; }

/* iOS-style glass pill */
.intro-skip {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px));
  transform: translate(-50%, 8px);
  padding: 11px 20px 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(240, 210, 147, .28);
  background: rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  color: rgba(245, 239, 229, .78);
  font: 600 .64rem/1 var(--sans, 'DM Sans', system-ui, sans-serif);
  letter-spacing: .22em;
  text-transform: uppercase;
  opacity: 0;
  cursor: pointer;
  transition: opacity .6s ease .9s, transform .6s var(--intro-ease) .9s, background .2s, color .2s, border-color .2s;
}
.intro.is-playing .intro-skip { opacity: 1; transform: translate(-50%, 0); }
.intro-skip:hover { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(240, 210, 147, .55); }
.intro-skip:focus-visible { outline: 2px solid var(--intro-gold-hi); outline-offset: 3px; }
.intro.is-leave .intro-skip, .intro.is-open .intro-skip { opacity: 0; transition-delay: 0s; }

/* ==========================================================================
   PUBLIC — "The Horizon"
   ========================================================================== */
.intro-public { background: transparent; }

/* The two doors */
.ip-door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.2%;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(212, 173, 103, .06), transparent 30%, transparent 70%, rgba(212, 173, 103, .08)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .02) 0 1px, transparent 1px 46px),
    var(--intro-bg);
  transition: transform 1.35s var(--intro-ease-io);
  will-change: transform;
}
.ip-door-l { left: 0; }
.ip-door-r { right: 0; }
.ip-door::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(255, 244, 214, .95) 18%, rgba(255, 244, 214, .95) 82%, transparent);
  box-shadow: 0 0 22px 3px rgba(240, 210, 147, .55);
  opacity: 0;
  transition: opacity .5s ease;
}
.ip-door-l::after { right: 0; }
.ip-door-r::after { left: 0; }
.intro-public.is-leave .ip-door::after { opacity: 1; }
.intro-public.is-open .ip-door-l { transform: translate3d(-101%, 0, 0); }
.intro-public.is-open .ip-door-r { transform: translate3d(101%, 0, 0); }

/* Light that floods through the gap */
.ip-spill {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: radial-gradient(38% 120% at 50% 50%, #fff6dc 0%, #f0d293 18%, rgba(212, 173, 103, .55) 40%, rgba(212, 173, 103, 0) 72%);
}
.intro-public.is-open .ip-spill { animation: ipSpill 1.9s var(--intro-ease) forwards; }
@keyframes ipSpill {
  0%   { opacity: 0; transform: scaleX(.2); }
  25%  { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(2.2); }
}

/* Scene (sits on top of the doors) */
.ip-scene { position: absolute; inset: 0; z-index: 3; overflow: hidden; transition: opacity .3s ease; }
.intro-public.is-open .ip-scene { opacity: 0; }

.ip-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(55% 45% at 50% 62%, rgba(240, 210, 147, .26), rgba(212, 173, 103, .08) 45%, transparent 72%);
}
.intro-public.is-playing .ip-glow { animation: ipFadeIn 2.4s ease .2s forwards; }
@keyframes ipFadeIn { to { opacity: 1; } }

.ip-dust { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-public.is-leave .ip-dust { animation: ipFadeOut .9s ease .15s forwards; }
@keyframes ipFadeOut { to { opacity: 0; } }

/* Planet horizon rising from below */
.ip-horizon {
  position: absolute;
  left: 50%;
  top: 100%;
  width: max(150vw, 120vh);
  height: max(150vw, 120vh);
  margin-left: calc(max(150vw, 120vh) / -2);
  border-radius: 50%;
  background: radial-gradient(closest-side, #0b0b0a 80%, #15110a 100%);
  box-shadow:
    0 -2px 0 0 rgba(255, 244, 214, .95),
    0 -12px 38px 0 rgba(240, 210, 147, .55),
    0 -46px 150px 10px rgba(212, 173, 103, .28),
    inset 0 3px 18px rgba(255, 236, 190, .55);
  will-change: transform;
  transition: opacity .7s ease .1s;
}
.intro-public.is-playing .ip-horizon { animation: ipRise 2.3s cubic-bezier(.16, .84, .3, 1) forwards; }
@keyframes ipRise { to { transform: translate3d(0, -36vh, 0); } }
.intro-public.is-leave .ip-horizon { opacity: 0; }

/* Lockup */
.ip-lockup {
  position: absolute;
  left: 0;
  right: 0;
  top: 41%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 5vw;
}
.intro-public.is-leave .ip-lockup { animation: ipPush .9s cubic-bezier(.55, 0, .85, .35) forwards; }
@keyframes ipPush { to { transform: translateY(-50%) scale(2.6); opacity: 0; filter: blur(10px); } }

.ip-crown {
  width: clamp(64px, 9vw, 104px);
  height: auto;
  margin-bottom: clamp(8px, 1.6vh, 18px);
  overflow: visible;
}
.ip-crown .ip-c {
  fill: none;
  stroke: url(#ipGold);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.ip-crown .ip-fill { fill: url(#ipGold); opacity: 0; }
.ip-crown .ip-j { fill: #f0d293; opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0); }
.intro-public.is-crown .ip-c { animation: ipDraw 1.15s var(--intro-ease) forwards; }
.intro-public.is-crown .ip-c:nth-of-type(2) { animation-delay: .25s; }
.intro-public.is-crown .ip-fill { animation: ipFillIn 1.2s ease .7s forwards; }
.intro-public.is-crown .ip-j { animation: ipJewel .7s var(--intro-ease) forwards; }
.intro-public.is-crown .ip-j:nth-of-type(1) { animation-delay: .55s; }
.intro-public.is-crown .ip-j:nth-of-type(2) { animation-delay: .75s; }
.intro-public.is-crown .ip-j:nth-of-type(3) { animation-delay: .65s; }
.intro-public.is-crown .ip-crown { animation: ipCrownGlow 2.6s ease forwards; }
@keyframes ipDraw { to { stroke-dashoffset: 0; } }
@keyframes ipFillIn { to { opacity: .2; } }
@keyframes ipJewel { 0% { opacity: 0; transform: scale(0); } 60% { opacity: 1; transform: scale(1.7); } 100% { opacity: 1; transform: scale(1); } }
@keyframes ipCrownGlow {
  0%   { filter: drop-shadow(0 0 0 rgba(240, 210, 147, 0)); }
  45%  { filter: drop-shadow(0 0 22px rgba(255, 236, 190, .85)); }
  100% { filter: drop-shadow(0 0 12px rgba(240, 210, 147, .4)); }
}

.ip-word {
  display: flex;
  justify-content: center;
  padding-left: .16em;
  font-family: var(--serif, 'Cormorant Garamond', Georgia, serif);
  font-weight: 600;
  font-size: clamp(3.6rem, 15vw, 9rem);
  line-height: 1;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.ip-word span {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, .4em, 0) scale(1.1);
  filter: blur(16px);
  background: linear-gradient(180deg, #fff7e0 0%, #f0d293 34%, #d4ad67 60%, #8f6a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.intro-public.is-word .ip-word span {
  animation: ipLetter 1.25s var(--intro-ease) forwards, ipGlint 1.5s ease forwards;
  animation-delay: calc(var(--i) * 95ms), calc(1.1s + var(--i) * 110ms);
}
@keyframes ipLetter { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes ipGlint {
  0%   { filter: brightness(1); }
  35%  { filter: brightness(1.7) drop-shadow(0 0 22px rgba(255, 236, 190, .85)); }
  100% { filter: brightness(1) drop-shadow(0 0 14px rgba(240, 210, 147, .35)); }
}

.ip-sub {
  margin: .9em 0 0;
  padding-left: .9em;
  font: 600 clamp(.62rem, 1.3vw, .86rem)/1 var(--sans, 'DM Sans', system-ui, sans-serif);
  letter-spacing: .9em;
  text-transform: uppercase;
  color: #c9b27c;
  opacity: 0;
}
.intro-public.is-tag .ip-sub { animation: ipSub 1.6s var(--intro-ease) forwards; }
@keyframes ipSub { from { opacity: 0; letter-spacing: 1.5em; } to { opacity: 1; letter-spacing: .9em; } }

.ip-tag {
  margin: 1.5em 0 0;
  font: italic 500 clamp(1.15rem, 2.4vw, 1.7rem)/1.2 var(--serif, 'Cormorant Garamond', Georgia, serif);
  letter-spacing: .04em;
  color: #e9dcc0;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(6px);
}
.intro-public.is-tag .ip-tag { animation: ipTag 1.3s var(--intro-ease) .25s forwards; }
@keyframes ipTag { to { opacity: 1; transform: none; filter: blur(0); } }

/* Site reveal behind the doors (shared by every intro) */
html.intro-reveal .site-header { animation: ipHeader 1.1s var(--intro-ease) .5s both; }
html.intro-reveal body > section:first-of-type { animation: ipRiseIn 1.4s var(--intro-ease) .3s both; }
@keyframes ipHeader { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: none; } }
@keyframes ipRiseIn { from { opacity: 0; transform: scale(1.045) translateY(18px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   CLIENT — "The Private Key"
   ========================================================================== */
.intro-client { background: transparent; }

/* Dark world with a hole that grows (the iris) */
.ic-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--intro-bg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent var(--iris), #000 calc(var(--iris) + 2px));
  mask-image: radial-gradient(circle at 50% 50%, transparent var(--iris), #000 calc(var(--iris) + 2px));
}
.ic-bg::before {
  content: '';
  position: absolute;
  inset: -25%;
  opacity: 0;
  background:
    radial-gradient(40% 40% at 30% 32%, rgba(212, 173, 103, .30), transparent 70%),
    radial-gradient(45% 45% at 74% 68%, rgba(154, 115, 52, .34), transparent 70%),
    radial-gradient(28% 28% at 62% 18%, rgba(255, 244, 214, .12), transparent 70%);
  will-change: transform;
}
.intro-client.is-playing .ic-bg::before { animation: icAuroraIn 1.6s ease forwards, icAurora 16s linear infinite; }
@keyframes icAuroraIn { to { opacity: 1; } }
@keyframes icAurora { from { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } to { transform: rotate(360deg) scale(1); } }

/* Glowing edge of the iris */
.ic-rim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%,
    transparent calc(var(--iris) - 2px),
    rgba(255, 240, 200, .95) var(--iris),
    rgba(212, 173, 103, .35) calc(var(--iris) + 16px),
    transparent calc(var(--iris) + 70px));
}

.intro-client.is-open { animation: icIris 1.5s var(--intro-ease-io) forwards; }
@keyframes icIris { from { --iris: -90px; } to { --iris: 160vmax; } }

.ic-stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  text-align: center;
}
.intro-client.is-open .ic-stage { animation: icStageOut .8s cubic-bezier(.5, 0, .8, .4) forwards; }
@keyframes icStageOut { to { opacity: 0; transform: scale(1.14); } }

/* Face-ID style icon */
.ic-faceid { position: relative; width: clamp(120px, 34vw, 168px); aspect-ratio: 1; }
.ic-faceid > * { position: absolute; }

.ic-rings { inset: 0; }
.ic-rings i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(240, 210, 147, .5);
  opacity: 0;
  transform: scale(.4);
}
.intro-client.is-playing .ic-rings i { animation: icRing 3.2s var(--intro-ease) infinite; }
.ic-rings i:nth-child(2) { animation-delay: 1s !important; }
.ic-rings i:nth-child(3) { animation-delay: 2s !important; }
@keyframes icRing { 0% { opacity: 0; transform: scale(.5); } 15% { opacity: .55; } 100% { opacity: 0; transform: scale(3.4); } }

.ic-ring { inset: -8%; width: 116%; height: 116%; transform: rotate(-90deg); overflow: visible; }
.ic-ring circle { fill: none; stroke-linecap: round; }
.ic-ring-track { stroke: rgba(240, 210, 147, .14); stroke-width: 1.5; }
.ic-ring-bar { stroke: url(#icGold2); stroke-width: 2.6; stroke-dasharray: 1; stroke-dashoffset: 1; filter: drop-shadow(0 0 6px rgba(240, 210, 147, .6)); }
.intro-client.is-playing .ic-ring-bar { animation: icFill 1.55s cubic-bezier(.65, 0, .35, 1) .45s forwards; }
@keyframes icFill { to { stroke-dashoffset: 0; } }

.ic-brackets { inset: 0; width: 100%; height: 100%; overflow: visible; }
.ic-brackets path {
  fill: none;
  stroke: #f0d293;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(0 0 5px rgba(240, 210, 147, .55));
}
.intro-client.is-playing .ic-brackets path { animation: icDraw .8s var(--intro-ease) .15s forwards; }
.intro-client.is-playing .ic-brackets { animation: icBreathe 2.2s ease-in-out .9s infinite; }
@keyframes icDraw { to { stroke-dashoffset: 0; } }
@keyframes icBreathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(.955); } }
.intro-client.is-success .ic-brackets { animation: icBracketsOut .7s var(--intro-ease) forwards; }
@keyframes icBracketsOut { to { transform: scale(1.4); opacity: 0; } }

.ic-scan {
  left: 12%;
  right: 12%;
  top: 14%;
  height: 2px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, #fff4d6, transparent);
  box-shadow: 0 0 18px 4px rgba(240, 210, 147, .55);
}
.intro-client.is-playing .ic-scan { animation: icScan 1.7s ease-in-out .5s forwards; }
@keyframes icScan {
  0%   { opacity: 0; top: 14%; }
  12%  { opacity: 1; }
  50%  { top: 84%; }
  88%  { opacity: 1; }
  100% { opacity: 0; top: 14%; }
}

.ic-pulse {
  inset: -8%;
  border-radius: 50%;
  border: 2px solid #f0d293;
  opacity: 0;
  box-shadow: 0 0 30px rgba(240, 210, 147, .5);
}
.intro-client.is-success .ic-pulse { animation: icPulse 1.1s var(--intro-ease) forwards; }
@keyframes icPulse { 0% { opacity: .95; transform: scale(1); } 100% { opacity: 0; transform: scale(2.5); } }

.ic-halo {
  inset: -60%;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(closest-side, rgba(240, 210, 147, .32), transparent);
}
.intro-client.is-success .ic-halo { animation: icHalo 1.6s ease forwards; }
@keyframes icHalo { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: .35; } }

/* Padlock */
.ic-lock { left: 50%; top: 50%; width: 46%; height: 46%; margin: -23% 0 0 -23%; overflow: visible; opacity: 0; transform: scale(.8); }
.intro-client.is-playing .ic-lock { animation: icLockIn .9s var(--intro-ease) .1s forwards; }
.intro-client.is-success .ic-lock { animation: icLockBounce .7s var(--intro-ease) forwards; opacity: 1; }
@keyframes icLockIn { to { opacity: 1; transform: none; } }
@keyframes icLockBounce { 0% { transform: none; } 40% { transform: scale(1.14); } 100% { transform: none; } }
.ic-lock .ic-shackle,
.ic-lock .ic-body { stroke: url(#icGold); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.ic-lock .ic-body { fill: url(#icGold); fill-opacity: .07; }
.ic-lock .ic-key { stroke: #f0d293; fill: #f0d293; stroke-width: 3; stroke-linecap: round; }
.ic-lock .ic-shackle { transform-box: view-box; transform-origin: 22px 28px; }
.intro-client.is-success .ic-shackle { animation: icUnlock .8s var(--intro-ease) forwards; }
.intro-client.is-success .ic-body { animation: icBodyFill .6s ease .1s forwards; }
.intro-client.is-success .ic-key { stroke: #17130d; fill: #17130d; transition: all .3s ease .15s; }
@keyframes icUnlock { 0% { transform: none; } 40% { transform: translateY(-7px); } 100% { transform: translateY(-7px) rotate(-24deg); } }
@keyframes icBodyFill { to { fill-opacity: .95; } }

/* Copy under the icon */
.ic-copy { position: relative; width: 100%; max-width: 760px; min-height: 9rem; margin-top: 38px; }
.ic-scanning,
.ic-welcome { position: absolute; left: 0; right: 0; top: 0; }
.ic-scanning {
  font: 600 .66rem/1.4 var(--sans, 'DM Sans', system-ui, sans-serif);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #bfae86;
  opacity: 0;
}
.intro-client.is-playing .ic-scanning { animation: icFadeUp .9s var(--intro-ease) .5s forwards; }
.intro-client.is-success .ic-scanning { animation: icFadeAway .45s ease forwards; }
@keyframes icFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes icFadeAway { from { opacity: 1; } to { opacity: 0; transform: translateY(-6px); } }

.ic-eyebrow {
  margin: 0 0 14px;
  font: 700 .66rem/1 var(--sans, 'DM Sans', system-ui, sans-serif);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--intro-gold);
  opacity: 0;
}
.intro-client.is-text .ic-eyebrow { animation: icFadeUp .9s var(--intro-ease) forwards; }

.ic-title {
  margin: 0;
  font-family: var(--serif, 'Cormorant Garamond', Georgia, serif);
  font-weight: 500;
  font-size: clamp(2.5rem, 8vw, 4.6rem);
  line-height: 1;
  letter-spacing: -.03em;
  color: #faf5eb;
}
.ic-title em { color: var(--intro-gold-hi); font-style: italic; }
.ic-title .w { display: inline-block; opacity: 0; transform: translateY(.5em); filter: blur(10px); }
.intro-client.is-text .ic-title .w { animation: icWord 1.1s var(--intro-ease) forwards; animation-delay: calc(.12s + var(--i) * 120ms); }
@keyframes icWord { to { opacity: 1; transform: none; filter: blur(0); } }

/* Reveal of the portal behind the iris */
html.intro-reveal .login-card { animation: icCard 1.1s var(--intro-ease) .25s both; }
html.intro-reveal .client-hero { animation: icCard 1.1s var(--intro-ease) .3s both; }
html.intro-reveal .client-summary article { animation: icCard 1s var(--intro-ease) both; }
html.intro-reveal .client-summary article:nth-child(1) { animation-delay: .45s; }
html.intro-reveal .client-summary article:nth-child(2) { animation-delay: .55s; }
html.intro-reveal .client-summary article:nth-child(3) { animation-delay: .65s; }
html.intro-reveal .client-section { animation: icCard 1.1s var(--intro-ease) .75s both; }
@keyframes icCard { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }

/* Small screens */
@media (max-width: 520px) {
  .ic-copy { margin-top: 30px; }
  .ip-sub { letter-spacing: .6em; padding-left: .6em; }
  @keyframes ipSub { from { opacity: 0; letter-spacing: 1em; } to { opacity: 1; letter-spacing: .6em; } }
}
