/* ============================================================
   PORTAL EXPERIENCE SYSTEM — CINEMATIC SERVICE EXPANSIONS
   ============================================================ */

/* --- Overlay Shell --- */
.portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease, visibility 0s 0.8s;
}

.portal-overlay.is-open {
  pointer-events: all;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.1s ease, visibility 0s 0s;
}

/* Hide EVERYTHING behind the overlay */
body.portal-locked .bg-system,
body.portal-locked .arc-container,
body.portal-locked .lens-glow,
body.portal-locked .nav,
body.portal-locked #particleCanvas {
  opacity: 0 !important;
  transition: opacity 0.6s ease;
}

/* Darkening backdrop */
.portal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 1, 6, 0);
  transition: background 1s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 0;
}

.portal-overlay.is-open .portal-backdrop {
  background: rgba(2, 1, 6, 1);
}

/* Close button */
.portal-close-btn {
  position: absolute;
  top: 32px;
  right: 36px;
  z-index: 100;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8) rotate(-90deg);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-overlay.is-open .portal-close-btn {
  opacity: 1;
  transform: scale(1) rotate(0deg);
  transition-delay: 0.6s;
}

.portal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(192, 132, 252, 0.3);
  color: white;
  transform: scale(1.1) rotate(0deg) !important;
}

.portal-close-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Portal Worlds --- */
.portal-world {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020106;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 0.6s;
}

.portal-world.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s 0s;
}

.pw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.pw-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  width: 100%;
  max-width: 1200px;
  padding: 0 40px;
}

.pw-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(32px, 5vw, 60px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
  opacity: 0;
  transform: translateY(40px);
  transition: all 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-world.is-revealed .pw-title {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.4s;
}

.pw-subtitle {
  font-size: 15px;
  font-weight: 300;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.5);
  max-width: 500px;
  margin-top: 16px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-world.is-revealed .pw-subtitle {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.6s;
}

/* ============================================================
   WEB EXPERIENCES WORLD
   ============================================================ */
#pwWeb .pw-content {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 60px;
}

#pwWeb .pw-text-side {
  flex: 0 0 auto;
  text-align: left;
}

/* Assembling Website Mockup */
.pw-assembler {
  position: relative;
  width: 480px;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(50px) scale(0.9);
  transition: all 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.portal-world.is-revealed .pw-assembler {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition-delay: 0.6s;
}

.as-browser {
  border-radius: 14px;
  background: rgba(10, 7, 20, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.12);
  overflow: hidden;
  box-shadow:
    0 0 80px rgba(168, 85, 247, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.5);
}

.as-chrome {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.as-chrome span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.as-chrome span:nth-child(1) { background: #ff5f57; }
.as-chrome span:nth-child(2) { background: #febc2e; }
.as-chrome span:nth-child(3) { background: #28c840; }

.as-viewport {
  padding: 16px;
  min-height: 280px;
  position: relative;
}

/* Pieces of the assembling site */
.as-piece {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.as-piece.built {
  opacity: 1;
  transform: translateY(0);
}

.as-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.as-nav-logo {
  width: 50px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #a78bfa, #e879f9);
  opacity: 0.6;
}

.as-nav-links {
  display: flex;
  gap: 10px;
}

.as-nav-link {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.as-hero-section {
  margin-bottom: 16px;
}

.as-hero-badge {
  width: 60px;
  height: 14px;
  border-radius: 7px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.15);
  margin-bottom: 10px;
}

.as-hero-h1 {
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.15);
  margin-bottom: 6px;
}

.as-hero-h1:first-of-type { width: 80%; }
.as-hero-h1:last-of-type { width: 55%; }

.as-hero-p {
  height: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  width: 70%;
  margin-top: 10px;
}

.as-hero-cta {
  width: 70px;
  height: 22px;
  border-radius: 11px;
  background: linear-gradient(135deg, #9333ea, #7e22ce);
  margin-top: 12px;
}

.as-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.as-card-block {
  height: 50px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.as-card-block:nth-child(1) { background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(232,121,249,0.04)); }
.as-card-block:nth-child(2) { background: linear-gradient(135deg, rgba(129,140,248,0.06), rgba(168,85,247,0.03)); }

.as-section-bar {
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  margin-top: 10px;
}

/* Orbiting tech labels */
.pw-orbit-ring {
  position: absolute;
  width: 600px;
  height: 600px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
  animation: orbitSpin 30s linear infinite;
}

.portal-world.is-revealed .pw-orbit-ring {
  opacity: 1;
  transition-delay: 1s;
}

@keyframes orbitSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.pw-tech {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 6px 16px;
  border-radius: 100px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.15);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  color: rgba(192, 132, 252, 0.8);
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--angle))) translateX(260px) rotate(calc(var(--angle)));
  /* Counter-rotate to keep text upright, already handled by double rotate trick */
}

/* ============================================================
   AI SYSTEMS WORLD (canvas-driven)
   ============================================================ */
#pwAI .pw-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================================
   BRAND IDENTITY WORLD (canvas-driven)
   ============================================================ */
#pwBrand .pw-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================================
   CUSTOM DEV WORLD (canvas-driven)
   ============================================================ */
#pwDev .pw-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================================
   EXPANSION ANIMATION
   ============================================================ */
/* Origin card phantom — animated from card position to full screen */
.portal-phantom {
  position: fixed;
  z-index: 19999;
  border-radius: 24px;
  background: rgba(10, 7, 20, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.15);
  backdrop-filter: blur(20px);
  pointer-events: none;
  transition: all 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow:
    0 0 60px rgba(168, 85, 247, 0.1),
    0 30px 80px rgba(0, 0, 0, 0.5);
}

.portal-phantom.expanded {
  border-radius: 0;
  border-color: transparent;
  background: rgba(2, 1, 6, 0.95);
}

/* Body lock */
body.portal-locked {
  overflow: hidden;
}

/* Source card highlight on click */
.portal.is-activating {
  z-index: 19998;
}

.portal.is-activating .portal-frame {
  box-shadow: 0 0 100px rgba(168, 85, 247, 0.3);
  border-color: rgba(192, 132, 252, 0.4);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .portal-close-btn {
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }

  .pw-title {
    font-size: clamp(26px, 7vw, 40px);
  }

  .pw-content {
    padding: 0 20px;
  }

  #pwWeb .pw-content {
    flex-direction: column;
    gap: 30px;
  }

  .pw-assembler {
    width: 100%;
    max-width: 340px;
  }

  .pw-orbit-ring {
    width: 320px;
    height: 320px;
  }

  .pw-tech {
    transform: translate(-50%, -50%) rotate(calc(-1 * var(--angle))) translateX(130px) rotate(calc(var(--angle)));
    font-size: 9px;
    padding: 4px 10px;
  }
}

@media (max-width: 480px) {
  .pw-content {
    padding: 0 16px;
  }

  .pw-orbit-ring {
    width: 260px;
    height: 260px;
  }

  .pw-tech {
    transform: translate(-50%, -50%) rotate(calc(-1 * var(--angle))) translateX(110px) rotate(calc(var(--angle)));
    font-size: 8px;
    padding: 3px 8px;
  }
}
