/**
 * Sekaira — dimensional portal travel overlay + game world environments
 */

/* —— Travel lock —— */
html.portal-travel-active,
html.portal-travel-active body {
  overflow: hidden;
}

html.portal-travel-pending,
html.portal-travel-pending body {
  overflow: hidden;
}

html.portal-travel-pending .site-header,
html.portal-travel-pending main,
html.portal-travel-pending .site-footer {
  visibility: hidden;
}

html.portal-travel-active .site-header,
html.portal-travel-active main,
html.portal-travel-active .site-footer {
  visibility: hidden;
}

/* —— Full-screen travel overlay —— */
.portal-travel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  background: var(--sekaira-bg-deep, #03040a);
  contain: strict;
}

.portal-travel__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform: translateZ(0);
}

.portal-travel__gate {
  position: fixed;
  z-index: 3;
  object-fit: contain;
  transform: translate3d(-50%, -50%, 0);
}

.portal-travel__world {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: scale3d(0.75, 0.75, 1);
}

.portal-travel__world.is-visible {
  opacity: 1;
  transform: scale3d(1.05, 1.05, 1);
}

.portal-travel__world.is-held {
  opacity: 1;
  transform: scale3d(1.04, 1.04, 1);
  animation: none !important;
}

.portal-travel.is-held {
  background: #03040a;
}

.portal-travel.is-held .portal-travel__gate {
  animation: none !important;
  opacity: 0;
}

.portal-travel.is-arriving.is-revealing {
  animation: overlayReveal 0.88s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.portal-travel.is-arriving.is-revealing .portal-travel__world {
  animation: none !important;
}

@keyframes overlayReveal {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.portal-travel__fx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.portal-travel__particles {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 70%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 65% 25%, rgba(46, 200, 255, 0.8), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(216, 76, 255, 0.65), transparent);
  opacity: 0;
}

.portal-travel.is-departing .portal-travel__particles,
.portal-travel.is-returning .portal-travel__particles {
  display: none;
}

.portal-travel__distort {
  display: none;
}

.portal-travel__flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.35) 0%, transparent 55%);
  opacity: 0;
}

.portal-travel.is-departing .portal-travel__gate {
  animation: portalExpand 0.92s cubic-bezier(0.18, 0.72, 0.22, 1) forwards;
}

.portal-travel.is-departing .portal-travel__world {
  animation: worldFill 0.88s cubic-bezier(0.18, 0.72, 0.22, 1) 0.08s forwards;
}

.portal-travel.is-departing .portal-travel__flash {
  animation: travelFlash 0.62s ease-out 0.22s forwards;
}

.portal-travel.is-departing::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at center, var(--travel-glow, rgba(46, 200, 255, 0.35)) 0%, transparent 58%);
  opacity: 0;
  animation: travelTunnel 0.92s ease-out 0.05s forwards;
}

@keyframes travelTunnel {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  35% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}

.portal-travel.is-return-departing .portal-travel__world {
  animation: worldReturnCollapse 0.92s cubic-bezier(0.45, 0.05, 0.2, 1) forwards;
}

.portal-travel.is-return-departing .portal-travel__flash {
  animation: returnFlash 0.55s ease-out 0.35s forwards;
}

.portal-travel.is-return-departing::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at center, var(--travel-glow, rgba(46, 200, 255, 0.4)) 0%, transparent 52%);
  opacity: 0;
  animation: travelTunnelReturn 0.92s ease-in 0.08s forwards;
}

.portal-travel.is-nexus-void,
.portal-travel.is-nexus-void.is-held {
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, rgba(46, 200, 255, 0.14), transparent 68%),
    radial-gradient(ellipse 55% 45% at 50% 50%, rgba(120, 60, 200, 0.1), transparent 72%),
    #03040a;
}

.portal-travel.is-nexus-void::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(42vw, 280px);
  height: min(42vw, 280px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(46, 200, 255, 0.22);
  box-shadow: 0 0 60px rgba(46, 200, 255, 0.18), inset 0 0 40px rgba(46, 200, 255, 0.08);
  opacity: 0.85;
  pointer-events: none;
  z-index: 2;
}

@keyframes worldReturnCollapse {
  0% {
    opacity: 1;
    transform: scale3d(1.04, 1.04, 1);
    filter: brightness(1);
  }
  55% {
    opacity: 0.55;
    transform: scale3d(0.22, 0.22, 1);
    filter: brightness(0.45) saturate(0.8);
  }
  100% {
    opacity: 0;
    transform: scale3d(0.04, 0.04, 1);
    filter: brightness(0.15);
  }
}

@keyframes returnFlash {
  0% { opacity: 0; }
  35% { opacity: 0.55; }
  100% { opacity: 0; }
}

@keyframes travelTunnelReturn {
  0% {
    opacity: 0;
    transform: scale(1.8);
  }
  35% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: scale(0.05);
  }
}

.portal-travel--return.is-returning .portal-travel__world {
  animation: worldShrink 0.68s cubic-bezier(0.55, 0.06, 0.25, 1) forwards;
}

.portal-travel--lite.is-departing .portal-travel__world {
  animation: worldFillLite 0.62s ease-in-out forwards;
}

.portal-travel--lite.is-departing .portal-travel__flash {
  animation: travelFlash 0.45s ease-out 0.15s forwards;
}

@keyframes portalExpand {
  0% {
    transform: translate3d(-50%, -50%, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate3d(-50%, -50%, 0) scale(3.2);
    opacity: 0;
  }
}

@keyframes worldFill {
  0% {
    opacity: 0;
    transform: scale3d(0.96, 0.96, 1);
  }
  100% {
    opacity: 1;
    transform: scale3d(1.04, 1.04, 1);
  }
}

@keyframes worldFillLite {
  0% {
    opacity: 0;
    transform: scale3d(1.02, 1.02, 1);
  }
  100% {
    opacity: 1;
    transform: scale3d(1.04, 1.04, 1);
  }
}

@keyframes worldShrink {
  0% {
    opacity: 1;
    transform: scale3d(1.04, 1.04, 1);
  }
  100% {
    opacity: 0;
    transform: scale3d(1.04, 1.04, 1);
  }
}

@keyframes travelFlash {
  0% { opacity: 0; }
  40% { opacity: 0.45; }
  100% { opacity: 0; }
}

@keyframes travelParticles {
  0% { opacity: 0; }
  30% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* Theme tints during travel */
.portal-travel.gate--block { --travel-glow: rgba(46, 200, 255, 0.5); }
.portal-travel.gate--wasteland { --travel-glow: rgba(255, 140, 60, 0.45); }
.portal-travel.gate--fantasy { --travel-glow: rgba(216, 76, 255, 0.5); }

html.portal-travel-returning .site-header,
html.portal-travel-returning main,
html.portal-travel-returning .site-footer {
  visibility: hidden;
}

html.portal-travel-returning,
html.portal-travel-returning body {
  overflow: hidden;
}

body.is-nexus-returned .nexus-hero,
body.is-nexus-returned .nexus-live {
  animation: nexusReturnIn 0.85s cubic-bezier(0.22, 0.61, 0.36, 1) 0.12s both;
}

@keyframes nexusReturnIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Legacy pulse — disabled when seamless return handles reveal */
html.portal-travel-returned::before {
  display: none;
}

/* —— Game world destination —— */
.is-game-world main {
  background: transparent;
  width: 100%;
  max-width: none;
  padding: 0;
  margin-bottom: 0;
  backdrop-filter: none;
}

.is-game-world .site-atmosphere {
  display: none;
}

.game-world {
  position: relative;
  margin: 0 calc(50% - 50vw);
  min-height: calc(100vh - 8rem);
}

.game-world__backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.game-world__backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  filter: saturate(1.05) brightness(0.88);
  transform: scale3d(1.04, 1.04, 1);
}

.game-world__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(5, 6, 12, 0.02), rgba(5, 6, 12, 0.38) 75%),
    linear-gradient(180deg, rgba(5, 6, 12, 0.12) 0%, rgba(5, 6, 12, 0.52) 100%);
}

/* Per-world atmosphere tuning */
.game-world.gate--block .game-world__backdrop img {
  object-position: center 40%;
  filter: saturate(1.12) brightness(0.92) hue-rotate(-4deg);
}

.game-world.gate--block .game-world__veil {
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(5, 6, 12, 0), rgba(5, 6, 12, 0.32) 75%),
    linear-gradient(180deg, rgba(5, 6, 12, 0.08) 0%, rgba(5, 6, 12, 0.48) 100%);
}

.game-world.gate--wasteland .game-world__backdrop img {
  object-position: center 45%;
  filter: saturate(0.95) brightness(0.82) sepia(0.08);
}

.game-world.gate--wasteland .game-world__veil {
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(5, 6, 12, 0.03), rgba(5, 6, 12, 0.42) 75%),
    linear-gradient(180deg, rgba(5, 6, 12, 0.14) 0%, rgba(5, 6, 12, 0.55) 100%);
}

.game-world.gate--fantasy .game-world__backdrop img {
  object-position: center 35%;
  filter: saturate(1) brightness(0.86) hue-rotate(6deg);
}

.game-world.gate--fantasy .game-world__veil {
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, rgba(5, 6, 12, 0.02), rgba(5, 6, 12, 0.36) 75%),
    linear-gradient(180deg, rgba(5, 6, 12, 0.1) 0%, rgba(5, 6, 12, 0.5) 100%);
}

.game-world__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--content-wide, min(1400px, calc(100% - 2rem)));
  margin-inline: auto;
  padding: 0 clamp(1rem, 2.5vw, 2.5rem) 2rem;
}

.game-world.is-entering .game-world__backdrop img {
  animation: none;
  opacity: 0;
  transform: scale3d(1.04, 1.04, 1);
}

.game-world.is-revealed .game-world__backdrop img,
.game-world.is-arrived .game-world__backdrop img {
  opacity: 1;
  transform: scale3d(1.04, 1.04, 1);
  transition: opacity 0.55s ease 0.12s;
}

.game-world.is-revealed .game-world__veil,
.game-world.is-arrived .game-world__veil {
  opacity: 1;
  transition: opacity 0.65s ease 0.18s;
}

.game-world.is-entering .game-world__veil {
  animation: veilSettle 0.75s ease-out both;
}

.game-world.is-entering .game-world__content {
  animation: worldContentIn 0.75s cubic-bezier(0.22, 0.61, 0.36, 1) 0.08s both;
}

.game-world.is-exiting .game-world__backdrop img {
  animation: worldExit 0.68s ease-in forwards;
}

@keyframes worldContentIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes veilSettle {
  from {
    opacity: 0.65;
  }
  to {
    opacity: 1;
  }
}

@keyframes worldExit {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.game-world .page-hero {
  padding-top: 1.5rem;
}

.game-world .page-hero--world {
  display: block;
  min-height: auto;
  grid-template-columns: 1fr;
}

.game-world .page-hero-art {
  display: none;
}

.game-world .page-hero-copy h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.game-world .section {
  position: relative;
}

.game-world .filter-panel {
  padding: 1.15rem;
}

.game-world .section-head {
  padding: 0.5rem 0;
  background: transparent;
  border: 0;
  backdrop-filter: none;
  box-shadow: none;
}

.nexus-return-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--sekaira-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease, gap 0.2s ease;
}

.nexus-return-link:hover {
  color: var(--sekaira-text);
  gap: 0.5rem;
}

/* —— Enhanced portal hover (travel gates) —— */
.world-gate[data-portal-travel] {
  cursor: pointer;
}

.world-gate[data-portal-travel]:hover,
.world-gate[data-portal-travel]:focus-visible {
  transform: scale(1.06) translateY(-8px);
  z-index: 8;
}

.world-gate[data-portal-travel]:hover .world-gate__spill,
.world-gate[data-portal-travel]:focus-visible .world-gate__spill {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.15);
}

.world-gate[data-portal-travel]:hover .world-gate__particles,
.world-gate[data-portal-travel]:focus-visible .world-gate__particles {
  opacity: 0.75;
  animation-duration: 2s;
}

.world-gate[data-portal-travel]:hover .world-gate__distort,
.world-gate[data-portal-travel]:focus-visible .world-gate__distort {
  opacity: 0.45;
  animation: gateDistortPulse 2.5s ease-in-out infinite;
}

.world-gate.is-traveling {
  opacity: 0;
  pointer-events: none;
}

@keyframes gateDistortPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.03); }
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .game-world__backdrop {
    position: absolute;
    inset: 0;
    min-height: 100%;
  }

  .game-world__backdrop img {
    position: absolute;
    inset: 0;
    transform: scale3d(1.04, 1.04, 1);
  }

  .game-world.is-entering .game-world__content {
    animation-duration: 0.55s;
  }

  html.portal-travel-returned::before {
    animation: none !important;
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-travel__gate,
  .portal-travel__world,
  .portal-travel__particles,
  .portal-travel__distort,
  .portal-travel__flash,
  .game-world__backdrop img,
  .dimensional-portal__body,
  .dimensional-portal__particles {
    animation: none !important;
  }

  .world-gate[data-portal-travel]:hover .world-gate__distort,
  .dimensional-portal[data-portal-travel]:hover,
  .dimensional-portal[data-portal-travel]:focus-visible {
    animation: none !important;
  }
}
