/* ============================================================
   Visual Reality — Cinematic Intro Overlay
   Luxury brand motion intro, pure CSS (timeline classes driven
   by intro.js):
     stage-cloud  (t=0)    faint brand-text cloud + tagline
     stage-build  (t=2.1s) logo pieces converge to center
     stage-trace  (t=3.1s) neon stroke draws the emblem
     stage-lit    (t=5.5s) shine flash + wordmark reveal
     is-leaving   (t=7.1s) overlay dissolves → website reveal
   No-JS: overlay never displays. Reduced-motion: skipped.
   CSS failsafe: auto-hides after 11.5s if JS ever stalls.
   ============================================================ */

.intro-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: #0f0f0f;
  overflow: hidden;
  cursor: default;
}

/* activated pre-paint by an inline head script (JS + motion-ok only) */
html.will-intro .intro-overlay {
  display: grid;
  place-items: center;
}

/* scroll lock while the intro plays */
html.intro-lock,
html.intro-lock body {
  overflow: hidden;
}

/* hard failsafe — the show always ends, even if intro.js stalls */
@keyframes intro-failsafe {
  to { opacity: 0; visibility: hidden; pointer-events: none; }
}

html.will-intro .intro-overlay {
  animation: intro-failsafe 0.5s ease 11.5s forwards;
}

/* ---------- atmosphere ---------- */

.intro-grain {
  position: absolute;
  inset: -60%;
  z-index: 3;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.045;
  animation: intro-grain 7s steps(8) infinite;
}

@keyframes intro-grain {
  0%, 100% { transform: translate(0, 0); }
  12.5%    { transform: translate(-2.5%, 1.8%); }
  25%      { transform: translate(1.6%, -2.2%); }
  37.5%    { transform: translate(-1.8%, -1.4%); }
  50%      { transform: translate(2.4%, 1.2%); }
  62.5%    { transform: translate(-1.2%, 2.6%); }
  75%      { transform: translate(2%, -1.8%); }
  87.5%    { transform: translate(-2.6%, -0.6%); }
}

.intro-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.52) 100%);
}

.intro-glow {
  position: absolute;
  z-index: 2;
  width: 52vmin;
  height: 52vmin;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.32) 0%, rgba(13, 148, 136, 0.1) 45%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s ease;
}

.stage-build .intro-glow { opacity: 0.34; }
.stage-trace .intro-glow { opacity: 0.5; animation: glow-breathe 2.6s ease-in-out infinite; }
.stage-lit   .intro-glow { opacity: 0.42; }

@keyframes glow-breathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.62; }
}

/* ---------- STAGE 1 · the logo cloud ---------- */

.intro-cloud {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.55s ease;
}

.stage-build .intro-cloud,
.is-leaving .intro-cloud { opacity: 0; }

.intro-cloud span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: var(--s, 1rem);
  letter-spacing: var(--ls, 0.28em);
  text-transform: uppercase;
  color: #ffffff;
  white-space: nowrap;
  transform: rotate(var(--r, 0deg));
  opacity: 0;
  animation: cloud-in 0.9s ease var(--d, 0s) both;
}

@keyframes cloud-in {
  from { opacity: 0; transform: rotate(var(--r, 0deg)) translateY(10px); }
  to   { opacity: var(--o, 0.15); transform: rotate(var(--r, 0deg)) translateY(0); }
}

.intro-tagline {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 18px;
  pointer-events: none;
  animation: tag-cycle 2.1s ease both;
}

.intro-tagline::before,
.intro-tagline::after {
  content: "";
  width: 54px;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}

.intro-tagline b {
  font-family: "Inter", sans-serif;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  padding-left: 0.42em; /* optically balance tracking */
}

@keyframes tag-cycle {
  0%   { opacity: 0; transform: translate(-50%, -46%); }
  22%  { opacity: 1; transform: translate(-50%, -50%); }
  74%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -56%); }
}

/* ---------- STAGE 2 · central emblem, pieces converging ---------- */

.intro-stage {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.9s ease;
}

.is-leaving .intro-stage {
  transform: scale(1.05);
  opacity: 0.6;
  transition: transform 0.95s ease, opacity 0.95s ease;
}

.intro-logo {
  width: clamp(150px, 34vmin, 224px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  transition: filter 1s ease;
}

.stage-build .intro-logo {
  filter: drop-shadow(0 0 14px rgba(16, 185, 129, 0.22));
}

.stage-trace .intro-logo {
  filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.38))
          drop-shadow(0 0 22px rgba(16, 185, 129, 0.5))
          drop-shadow(0 0 58px rgba(13, 148, 136, 0.3));
}

.stage-lit .intro-logo {
  filter: drop-shadow(0 0 9px rgba(255, 255, 255, 0.55))
          drop-shadow(0 0 30px rgba(16, 185, 129, 0.65))
          drop-shadow(0 0 72px rgba(13, 148, 136, 0.4));
}

.is-leaving .intro-logo {
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.4));
}

/* converging pieces */
.i-top,
.i-bottom {
  opacity: 0;
}

.i-top    { transform: translateY(-74px); }
.i-bottom { transform: translateY(74px); }

.stage-build .i-top,
.stage-build .i-bottom {
  opacity: 1;
  transform: translateY(0);
  transition:
    transform 1.05s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.5s ease 0.12s;
}

/* ---------- STAGE 3 · neon stroke drawing ---------- */

.intro-logo .draw {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
}

/* draw-in choreography (pathLength="100" normalises every path) */
.stage-trace .i-leaf       { stroke-dashoffset: 0; transition: stroke-dashoffset 0.95s cubic-bezier(0.6, 0.05, 0.3, 1) 0.1s; }
.stage-trace .i-vein-main  { stroke-dashoffset: 0; transition: stroke-dashoffset 0.5s  cubic-bezier(0.6, 0.05, 0.3, 1) 0.72s; }
.stage-trace .i-vein-v     { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s cubic-bezier(0.6, 0.05, 0.3, 1) 0.95s; }
.stage-trace .i-vein-h     { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s cubic-bezier(0.6, 0.05, 0.3, 1) 1.07s; }
.stage-trace .i-node       { stroke-dashoffset: 0; transition: stroke-dashoffset 0.3s  ease-out 1.22s; }
.stage-trace .i-badge      { stroke-dashoffset: 0; transition: stroke-dashoffset 0.85s cubic-bezier(0.6, 0.05, 0.3, 1) 0.95s; }
.stage-trace .i-dot-a      { stroke-dashoffset: 0; transition: stroke-dashoffset 0.4s  ease-out 1.5s; }
.stage-trace .i-dot-b      { stroke-dashoffset: 0; transition: stroke-dashoffset 0.4s  ease-out 1.62s; }
.stage-trace .i-ring       { stroke-dashoffset: 0; transition: stroke-dashoffset 0.8s  cubic-bezier(0.6, 0.05, 0.3, 1) 1.55s; }
.stage-trace .i-sat        { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s ease-out 1.78s; }

/* orbit ring only exists during the trace */
.i-ring-group { opacity: 0; }
.stage-trace .i-ring-group { opacity: 1; transition: opacity 0.4s ease 1.5s; }

/* faint ghost outlines — make the convergence visible, then hand over
   to the neon trace which draws on top and dissolves them */
.intro-logo .ghost {
  fill: none;
  stroke: rgba(255, 255, 255, 0.26);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.stage-build .ghost {
  opacity: 1;
  transition: opacity 0.55s ease 0.15s;
}

.stage-trace .ghost,
.is-leaving .ghost {
  opacity: 0;
  transition: opacity 0.7s ease 0.35s;
}

/* shine flash when the tracing completes */
.stage-lit .intro-logo { animation: logo-flash 0.6s ease 1; }

@keyframes logo-flash {
  0%   { filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 44px rgba(52, 211, 153, 0.8)); }
  100% { filter: drop-shadow(0 0 9px rgba(255, 255, 255, 0.55)) drop-shadow(0 0 30px rgba(16, 185, 129, 0.65)) drop-shadow(0 0 72px rgba(13, 148, 136, 0.4)); }
}

/* ---------- wordmark reveal (with the shine) ---------- */

.intro-word {
  margin-top: 30px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.iw-line {
  width: 58px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55));
  transform: scaleX(0);
}

.iw-line:last-child {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.55), transparent);
}

.stage-lit .iw-line {
  transform: scaleX(1);
  transition: transform 1.05s cubic-bezier(0.16, 1, 0.3, 1) 0.35s;
}

.iw-text {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: clamp(1.02rem, 4.6vw, 1.5rem);
  color: #ffffff;
  white-space: nowrap;
  opacity: 0;
  letter-spacing: 0.62em;
  padding-left: 0.62em; /* balance the tracking */
  text-indent: 0.62em;
}

.iw-text em {
  font-style: normal;
  background: linear-gradient(90deg, #34d399, #2dd4bf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stage-lit .iw-text {
  opacity: 1;
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  text-indent: 0.34em;
  transition:
    opacity 0.9s ease 0.1s,
    letter-spacing 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}

.intro-tag2 {
  margin: 14px 0 0;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: clamp(0.6rem, 2.4vw, 0.72rem);
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
  opacity: 0;
  transform: translateY(8px);
}

.stage-lit .intro-tag2 {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s ease 0.75s, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.75s;
}

/* ---------- skip intro ---------- */

.intro-skip {
  position: absolute;
  z-index: 5;
  right: 28px;
  bottom: 26px;
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 11px 20px 11px 24px;
  cursor: pointer;
  opacity: 0;
  animation: skip-in 0.7s ease 0.9s forwards;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

@keyframes skip-in {
  to { opacity: 1; }
}

.intro-skip:hover,
.intro-skip:focus-visible {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.06);
}

.intro-skip:focus-visible {
  outline: 2px solid rgba(52, 211, 153, 0.8);
  outline-offset: 3px;
}

.is-leaving .intro-skip {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .intro-cloud span { font-size: calc(var(--s, 1rem) * 0.78); }
  .intro-tagline { gap: 12px; }
  .intro-tagline::before, .intro-tagline::after { width: 34px; }
  .intro-tagline b { font-size: 0.72rem; }
  .intro-word { gap: 14px; margin-top: 24px; }
  .iw-line { width: 34px; }
  .intro-skip { right: 16px; bottom: 18px; padding: 9px 14px 9px 18px; font-size: 0.62rem; }
}

/* ---------- reduced motion: no intro at all ---------- */

@media (prefers-reduced-motion: reduce) {
  .intro-overlay { display: none !important; }
}
