/* ==========================================================================
   Zain OS — Login variant "Vault" (with FX layer)
   Ultra-minimal full-screen 4-digit PIN. Ambient sparks, breathing slots,
   per-key ripple/bump/reveal, cursor spotlight. Success = portal zoom,
   fail = digits fall, lockout = slots visually drain.
   Root class: .vt-root
   ========================================================================== */

#login-screen.vt-mode {
  background: #060403;
  overflow: hidden;
}

.vt-root {
  position: relative;
  width: 100%; height: 100%;
  display: grid; place-items: center;
  isolation: isolate;
  font-family: var(--font-sans);
  perspective: 1200px;
}

/* Ambient backdrop */
.vt-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 55% 80% at 50% 50%, rgba(232,97,58,0.14), transparent 62%),
    radial-gradient(ellipse 100% 50% at 50% 100%, rgba(232,97,58,0.08), transparent 72%),
    radial-gradient(ellipse 100% 50% at 50% 0%,   rgba(232,97,58,0.03), transparent 72%),
    #060403;
}
.vt-bg::after {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 8% 12%,  rgba(255,200,160,0.06), transparent),
    radial-gradient(1px 1px at 18% 32%, rgba(255,200,160,0.05), transparent),
    radial-gradient(1px 1px at 42% 18%, rgba(255,200,160,0.05), transparent),
    radial-gradient(1px 1px at 68% 32%, rgba(255,200,160,0.05), transparent),
    radial-gradient(1px 1px at 88% 14%, rgba(255,200,160,0.06), transparent),
    radial-gradient(1px 1px at 12% 64%, rgba(255,200,160,0.04), transparent),
    radial-gradient(1px 1px at 82% 72%, rgba(255,200,160,0.04), transparent);
}

/* ---------- Cursor spotlight ---------- */
.vt-spot {
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    400px 400px at var(--mx, 50%) var(--my, 50%),
    rgba(232,97,58,0.10),
    transparent 55%);
  mix-blend-mode: screen;
  transition: background 120ms linear;
}

/* ---------- Drifting sparks ---------- */
.vt-particles {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
}
.vt-p {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #FFB46B;
  box-shadow: 0 0 8px rgba(255,180,110,0.7), 0 0 20px rgba(255,150,90,0.25);
  opacity: 0.5;
  animation: vt-float 22s ease-in-out infinite;
}
.vt-p.p1 { left: 12%; top: 78%; animation-duration: 26s; animation-delay: -2s; }
.vt-p.p2 { left: 82%; top: 22%; animation-duration: 30s; animation-delay: -8s; }
.vt-p.p3 { left: 46%; top: 86%; animation-duration: 24s; animation-delay: -13s; }
.vt-p.p4 { left: 22%; top: 22%; animation-duration: 32s; animation-delay: -4s; }
.vt-p.p5 { left: 70%; top: 68%; animation-duration: 28s; animation-delay: -10s; }
@keyframes vt-float {
  0%, 100% { transform: translate(0, 0);      opacity: 0.25; }
  25%      { transform: translate(14px, -50px); opacity: 0.8; }
  50%      { transform: translate(-8px, -120px); opacity: 0.55; }
  75%      { transform: translate(22px, -80px);  opacity: 0.85; }
}

/* Stage (center group) */
.vt-stage {
  position: relative; z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  gap: 72px;
  padding: 40px;
}

/* Little header */
.vt-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #5E4E44;
  display: flex; align-items: center; gap: 12px;
}
.vt-eyebrow .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #E8613A;
  box-shadow: 0 0 10px #E8613A;
  animation: vt-pulse 2s ease-in-out infinite;
}
@keyframes vt-pulse { 0%,100%{opacity:.45; transform: scale(1)} 50%{opacity:1; transform: scale(1.2)} }

/* ---------- Slots ---------- */
.vt-slots {
  display: flex;
  gap: clamp(20px, 3vw, 44px);
  position: relative;
  transform-origin: 50% 50%;
}
.vt-slot {
  width: clamp(90px, 12vw, 160px);
  height: clamp(130px, 18vw, 220px);
  border-radius: 14px;
  background: rgba(232,97,58,0.02);
  border: 1px solid rgba(232,97,58,0.14);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  transition: background 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
  /* idle breathing by default; staggered by --slot-i */
  animation: vt-slot-idle 4s ease-in-out infinite;
  animation-delay: calc(var(--slot-i, 0) * 0.3s);
}
@keyframes vt-slot-idle {
  0%, 100% {
    border-color: rgba(232,97,58,0.14);
    box-shadow: none;
  }
  50% {
    border-color: rgba(232,97,58,0.28);
    box-shadow: 0 0 28px rgba(232,97,58,0.08);
  }
}

.vt-slot::before {
  content: "";
  position: absolute; top: 0; left: 14%; right: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232,97,58,0.5), transparent);
  opacity: 0.6;
}
.vt-slot::after {
  content: "";
  position: absolute; left: 34%; right: 34%; bottom: -24px;
  height: 2px;
  background: rgba(232,97,58,0.18);
  transition: all 300ms ease;
  border-radius: 2px;
}
.vt-slot.vt-active {
  border-color: rgba(232,97,58,0.45);
  box-shadow:
    0 0 0 1px rgba(232,97,58,0.25),
    0 20px 80px rgba(232,97,58,0.18);
  transform: translateY(-6px);
  animation: none;           /* pause idle breathing when active */
}
.vt-slot.vt-active::after {
  left: 20%; right: 20%;
  background: #E8613A;
  box-shadow: 0 0 14px rgba(232,97,58,0.75);
}
.vt-slot.vt-filled {
  background: rgba(232,97,58,0.06);
  border-color: rgba(232,97,58,0.35);
  animation: none;           /* pause idle breathing when filled */
}
.vt-slot.vt-filled::after {
  background: #E8613A;
  box-shadow: 0 0 10px #E8613A;
}

/* ---------- Keystroke bump ---------- */
.vt-slot.vt-bump { animation: vt-bump 320ms cubic-bezier(0.2, 1.3, 0.3, 1); }
@keyframes vt-bump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.vt-slot.vt-active.vt-bump { animation: vt-bump-active 320ms cubic-bezier(0.2, 1.3, 0.3, 1); }
@keyframes vt-bump-active {
  0%   { transform: translateY(-6px) scale(1); }
  45%  { transform: translateY(-10px) scale(1.06); }
  100% { transform: translateY(-6px) scale(1); }
}

/* ---------- The dot ---------- */
.vt-digit {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(232,97,58,0.18);
  transition: all 300ms cubic-bezier(0.2, 0, 0, 1), opacity 140ms ease;
  position: relative;
  z-index: 3;
}
.vt-slot.vt-filled .vt-digit {
  background: #E8613A;
  box-shadow: 0 0 24px rgba(232,97,58,0.8), 0 0 60px rgba(232,97,58,0.3);
  animation: vt-digit-pop 500ms cubic-bezier(0.2, 1.4, 0.2, 1);
}
@keyframes vt-digit-pop {
  0%   { transform: scale(0.4); }
  60%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.vt-slot:not(.vt-filled):not(.vt-active) .vt-digit {
  animation: vt-empty-pulse 3.5s ease-in-out infinite;
}
@keyframes vt-empty-pulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50%      { opacity: 0.6;  transform: scale(1.08); }
}
.vt-slot.vt-active .vt-digit {
  background: rgba(232,97,58,0.4);
  box-shadow: 0 0 12px rgba(232,97,58,0.5);
  animation: vt-active-breathe 1.2s ease-in-out infinite;
}
@keyframes vt-active-breathe {
  0%, 100% { transform: scale(1);   opacity: 0.8; }
  50%      { transform: scale(1.2); opacity: 1; }
}

/* ---------- Digit reveal (iOS-style, 200ms) ---------- */
.vt-digit-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 700;
  color: #FFE6C8;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 150ms ease, transform 220ms cubic-bezier(0.2, 1.4, 0.2, 1);
  pointer-events: none;
  text-shadow: 0 0 22px rgba(232,97,58,0.55);
  z-index: 4;
  user-select: none;
}
.vt-slot.vt-reveal .vt-digit-text { opacity: 1; transform: scale(1); }
.vt-slot.vt-reveal .vt-digit       { opacity: 0; }

/* ---------- Keystroke ripple ---------- */
.vt-ripple {
  position: absolute;
  left: 50%; top: 50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(232,97,58,0.85);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  animation: vt-ripple-out 780ms cubic-bezier(0.1, 0.6, 0.3, 1) forwards;
}
@keyframes vt-ripple-out {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.4); border-width: 2px; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(18);  border-width: 0.5px; }
}

/* ---------- Lockout drain (per-slot fill) ---------- */
.vt-drain {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  background: linear-gradient(180deg,
    rgba(232, 97, 58, 0.22) 0%,
    rgba(232, 97, 58, 0.45) 60%,
    rgba(232, 97, 58, 0.60) 100%);
  opacity: 0;
  transition: height 800ms ease, opacity 300ms ease;
  pointer-events: none;
  z-index: 1;
}
.vt-slot.vt-lockout {
  border-color: rgba(243, 175, 146, 0.35);
  animation: none;
}
.vt-slot.vt-lockout .vt-drain { opacity: 1; }
.vt-slot.vt-lockout .vt-digit { opacity: 0; }
.vt-slot.vt-lockout::after    { opacity: 0; }

/* Hidden real input */
.vt-root .login-input {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Footer meta (4 corners) */
.vt-meta {
  position: absolute; z-index: 5;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #5A4E45;
}
.vt-meta.tl { top: 36px; left: 44px; }
.vt-meta.tr { top: 36px; right: 44px; text-align: right; display: flex; gap: 8px; align-items: center; }
.vt-meta.bl { bottom: 30px; left: 44px; }
.vt-meta.br { bottom: 30px; right: 44px; text-align: right; }
.vt-meta b { color: #E8613A; font-weight: 600; }
.vt-meta .tlive {
  width: 5px; height: 5px; border-radius: 50%;
  background: #E8613A;
  box-shadow: 0 0 10px #E8613A;
  animation: vt-pulse 2s ease-in-out infinite;
}

/* Error */
.vt-error {
  min-height: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #E8613A;
  text-align: center;
  transition: opacity 200ms ease;
}
.vt-error.lockout-text { color: #F3AF92; }

/* ---------- Wrong PIN: shake + red + DIGITS FALL ---------- */
.vt-root.vt-fail .vt-slots { animation: vt-shake 420ms ease; }
.vt-root.vt-fail .vt-slot {
  background: rgba(232, 60, 40, 0.12);
  border-color: rgba(232, 80, 50, 0.6);
  animation: none;
}
/* The dots turn red, then fall out the bottom one after another */
.vt-root.vt-fail .vt-slot.vt-filled .vt-digit {
  background: #FF5538 !important;
  box-shadow: 0 0 22px rgba(255, 85, 56, 0.85) !important;
  animation: vt-digit-fall 780ms cubic-bezier(0.45, 0, 0.85, 0.35) forwards;
}
.vt-root.vt-fail .vt-slot:nth-child(1) .vt-digit { animation-delay:   0ms; }
.vt-root.vt-fail .vt-slot:nth-child(2) .vt-digit { animation-delay:  80ms; }
.vt-root.vt-fail .vt-slot:nth-child(3) .vt-digit { animation-delay: 160ms; }
.vt-root.vt-fail .vt-slot:nth-child(4) .vt-digit { animation-delay: 240ms; }
@keyframes vt-digit-fall {
  0%   { transform: translateY(0)     scale(1);   opacity: 1; }
  30%  { transform: translateY(18px)  scale(1);   opacity: 1; }
  100% { transform: translateY(280px) scale(0.5); opacity: 0; }
}
@keyframes vt-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-14px); }
  40%, 80% { transform: translateX(14px); }
}

/* ---------- Right PIN: PORTAL ZOOM ---------- */
.vt-root.vt-success { animation: vt-root-fade 800ms ease forwards; pointer-events: none; }
@keyframes vt-root-fade {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
.vt-root.vt-success .vt-slots {
  animation: vt-portal 800ms cubic-bezier(0.5, 0, 0.3, 1) forwards;
  will-change: transform, opacity, filter;
}
@keyframes vt-portal {
  0%   { transform: scale(1);    opacity: 1; filter: blur(0); }
  50%  { transform: scale(3.5);  opacity: 1; filter: blur(2px); }
  100% { transform: scale(32);   opacity: 0; filter: blur(22px); }
}
.vt-root.vt-success .vt-eyebrow,
.vt-root.vt-success .vt-meta {
  animation: vt-chrome-fade 260ms ease forwards;
}
@keyframes vt-chrome-fade { to { opacity: 0; transform: scale(0.94); } }
.vt-root.vt-success .vt-bg { animation: vt-bg-flash 800ms ease forwards; }
@keyframes vt-bg-flash {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(1.9); }
  100% { filter: brightness(0); }
}
.vt-root.vt-success .vt-slot .vt-digit {
  background: #FFF4E1 !important;
  box-shadow: 0 0 40px #FFC88A, 0 0 80px rgba(232,97,58,0.7) !important;
}

/* App-layout: fade + scale in after the portal completes.
   `.vt-unlocked` on <html> hides the app while the portal plays; adding
   `.vt-revealed` triggers the smooth 500ms reveal. */
html.vt-unlocked #app-layout {
  opacity: 0;
  transform: scale(0.96);
  filter: blur(6px);
  transition: none;
}
html.vt-unlocked.vt-revealed #app-layout {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  transition: opacity 520ms cubic-bezier(0.2, 0, 0.1, 1),
              transform 520ms cubic-bezier(0.2, 0, 0.1, 1),
              filter 420ms cubic-bezier(0.2, 0, 0.1, 1);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .vt-slots { gap: 14px; }
  .vt-slot { width: 64px; height: 92px; border-radius: 10px; }
  .vt-digit { width: 18px; height: 18px; }
  .vt-digit-text { font-size: 32px; }
  .vt-meta { font-size: 9px; letter-spacing: 0.22em; }
  .vt-meta.tl, .vt-meta.tr { top: 20px; }
  .vt-meta.tl { left: 20px; }
  .vt-meta.tr { right: 20px; }
  .vt-meta.bl { left: 20px; bottom: 16px; }
  .vt-meta.br { right: 20px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .vt-eyebrow .dot, .vt-meta .tlive,
  .vt-slot, .vt-digit, .vt-p { animation: none !important; transition: none !important; }
  .vt-spot { display: none; }
}

/* ============================================================
   Responsive — broader breakpoints (additive only)
   The 640px block above sizes the slots. These add tablet rules
   and very-narrow (≤360px / iPhone SE) safety.
   ============================================================ */

@media (max-width: 1024px) {
  .vt-stage { gap: 56px; padding: 32px; }
  .vt-meta { font-size: 10px; letter-spacing: 0.22em; }
  .vt-meta.tl, .vt-meta.tr { top: 28px; }
  .vt-meta.tl { left: 28px; }
  .vt-meta.tr { right: 28px; }
  .vt-meta.bl { left: 28px; bottom: 22px; }
  .vt-meta.br { right: 28px; bottom: 22px; }
}

@media (max-width: 640px) {
  .vt-stage { gap: 40px; padding: 20px; width: 100%; max-width: 100%; box-sizing: border-box; }

  /* Hide top-right meta line on phones to keep eyebrow clear */
  .vt-meta.tr { display: none; }

  /* Smaller error spacing */
  .vt-error { font-size: 10px; letter-spacing: 0.16em; }
}

/* Extra-narrow phones (iPhone SE ≈ 320px): shrink slots further so they
   never exceed the viewport. */
@media (max-width: 360px) {
  .vt-stage { gap: 32px; padding: 14px; }
  .vt-slots { gap: 10px; }
  .vt-slot { width: 56px; height: 80px; }
  .vt-digit { width: 16px; height: 16px; }
  .vt-digit-text { font-size: 28px; }
  .vt-eyebrow { font-size: 10px; letter-spacing: 0.32em; }
  .vt-meta.tl, .vt-meta.bl, .vt-meta.br { font-size: 8.5px; letter-spacing: 0.18em; }
}

@media (hover: none) and (pointer: coarse) {
  /* Disable cursor spotlight on touch devices — it just flickers under the tap */
  .vt-spot { opacity: 0; }
}

/* ============================================================
   Landscape-orientation safety for phones — when iPhone is rotated
   the slots' clamp() values can push past viewport height. Force
   compact sizing so all 4 slots stay on-screen above the fold.
   ============================================================ */
@media (orientation: landscape) and (max-height: 500px) {
  .vt-stage { gap: 24px; padding: 16px; }
  .vt-eyebrow { font-size: 10px; letter-spacing: 0.32em; }
  .vt-slot { width: 60px; height: 84px; }
  .vt-digit { width: 16px; height: 16px; }
  .vt-digit-text { font-size: 28px; }
  .vt-slots { gap: 14px; }
  /* Hide corner meta in landscape — they clip into the slots area */
  .vt-meta.tl, .vt-meta.tr, .vt-meta.bl, .vt-meta.br { display: none; }
  .vt-error { font-size: 9.5px; letter-spacing: 0.14em; }
}

/* Short viewport (any orientation) — covers PWA on devices with
   small visible area after the address bar / safe areas. */
@media (max-height: 600px) and (max-width: 1024px) {
  .vt-stage { gap: 32px; padding: 18px; }
}
