/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --accent: #7b68ee;

  /* Portal color schemes */
  --fitness-a: #ff6b35;
  --fitness-b: #f7c948;
  --dance-a: #e040fb;
  --dance-b: #ff4081;
  --theatre-a: #b388ff;
  --theatre-b: #7c4dff;
  --writing-a: #64b5f6;
  --writing-b: #e1bee7;
  --art-a: #ff8a65;
  --art-b: #ef5350;
  --technique-a: #00e5ff;
  --technique-b: #1de9b6;
  --meditation-a: #80cbc4;
  --meditation-b: #a5d6a7;
  --health-a: #ef5350;
  --health-b: #ec407a;
  --nature-a: #66bb6a;
  --nature-b: #26a69a;
  --travel-a: #42a5f5;
  --travel-b: #ab47bc;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== Landing Page ===== */
#landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 4rem;
  transition: opacity 0.4s ease;
}

#landing.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
  padding-top: 2rem;
}

.title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, #7b68ee, #e040fb, #ff6b35);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease infinite;
  letter-spacing: -0.02em;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.subtitle {
  margin-top: 0.75rem;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--text-secondary);
  min-height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.subtitle-text {
  display: inline-block;
}

.cursor {
  animation: blink 1s step-end infinite;
  color: var(--accent);
  font-weight: 300;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===== Portals Grid ===== */
.portals-container {
  width: 100%;
  max-width: 800px;
}

.portals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 2rem;
  justify-items: center;
  padding: 1rem 0;
}

/* Individual Portal */
.portal {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.portal:hover,
.portal:focus-visible {
  transform: scale(1.08);
  outline: none;
}

.portal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 0deg, var(--color-a), var(--color-b), var(--color-a));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: ringRotate 4s linear infinite;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.portal:hover .portal-ring {
  opacity: 1;
}

@keyframes ringRotate {
  to { transform: rotate(360deg); }
}

.portal-inner {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: var(--bg-secondary);
  position: relative;
  z-index: 1;
  transition: box-shadow 0.3s ease, background 0.3s ease;
}

.portal:hover .portal-inner {
  box-shadow: 0 0 30px rgba(var(--glow-rgb), 0.3), inset 0 0 20px rgba(var(--glow-rgb), 0.1);
  background: #181825;
}

.portal-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.portal-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Portal color assignments */
.portal[data-world="fitness"]    { --color-a: var(--fitness-a); --color-b: var(--fitness-b); --glow-rgb: 255, 107, 53; }
.portal[data-world="dance"]      { --color-a: var(--dance-a); --color-b: var(--dance-b); --glow-rgb: 224, 64, 251; }
.portal[data-world="theatre"]    { --color-a: var(--theatre-a); --color-b: var(--theatre-b); --glow-rgb: 179, 136, 255; }
.portal[data-world="writing"]    { --color-a: var(--writing-a); --color-b: var(--writing-b); --glow-rgb: 100, 181, 246; }
.portal[data-world="art"]        { --color-a: var(--art-a); --color-b: var(--art-b); --glow-rgb: 255, 138, 101; }
.portal[data-world="technique"]  { --color-a: var(--technique-a); --color-b: var(--technique-b); --glow-rgb: 0, 229, 255; }
.portal[data-world="meditation"] { --color-a: var(--meditation-a); --color-b: var(--meditation-b); --glow-rgb: 128, 203, 196; }
.portal[data-world="health"]     { --color-a: var(--health-a); --color-b: var(--health-b); --glow-rgb: 239, 83, 80; }
.portal[data-world="nature"]     { --color-a: var(--nature-a); --color-b: var(--nature-b); --glow-rgb: 102, 187, 106; }
.portal[data-world="travel"]     { --color-a: var(--travel-a); --color-b: var(--travel-b); --glow-rgb: 66, 165, 245; }

/* Portal glow pulse on hover */
.portal::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--glow-rgb), 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.portal:hover::after {
  opacity: 1;
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ===== Transition Overlay ===== */
#transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
}

#transition-overlay.active {
  pointer-events: all;
}

#transition-overlay.zoom-in {
  animation: zoomIn 2s ease-in-out forwards;
}

#transition-overlay.zoom-out {
  animation: zoomOut 1.5s ease-in-out forwards;
}

@keyframes zoomIn {
  0% {
    opacity: 0;
    transform: scale(0);
    border-radius: 50%;
  }
  30% {
    opacity: 1;
    border-radius: 50%;
  }
  100% {
    opacity: 1;
    transform: scale(1);
    border-radius: 0;
  }
}

@keyframes zoomOut {
  0% {
    opacity: 1;
    transform: scale(1);
    border-radius: 0;
  }
  70% {
    opacity: 1;
    border-radius: 50%;
  }
  100% {
    opacity: 0;
    transform: scale(0);
    border-radius: 50%;
  }
}

/* ===== World Container ===== */
#world-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: var(--bg-primary);
}

#world-container.hidden {
  display: none;
}

#world-container.visible {
  display: block;
}

#world-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#world-title {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

#world-title.show {
  opacity: 1;
}

/* World Text Panel */
#world-text-panel {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  width: calc(100% - 3rem);
  padding: 1.2rem 1.6rem;
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
  z-index: 55;
}

#world-text-panel.show {
  opacity: 1;
}

#world-text-content {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  line-height: 1.7;
  color: rgba(232, 232, 240, 0.9);
  text-align: center;
  font-style: italic;
  letter-spacing: 0.01em;
}

/* Home Button */
#home-btn {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(18, 18, 26, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 2rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  z-index: 60;
  -webkit-tap-highlight-color: transparent;
}

#home-btn:hover {
  background: rgba(30, 30, 45, 0.95);
  border-color: rgba(255,255,255,0.2);
  transform: translateX(-50%) scale(1.05);
}

#home-btn svg {
  flex-shrink: 0;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 600px) {
  #landing {
    padding: 2rem 1rem 3rem;
  }

  header {
    margin-bottom: 2rem;
    padding-top: 1rem;
  }

  .portals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .portal {
    width: 120px;
    height: 120px;
  }

  .portal-inner {
    width: 110px;
    height: 110px;
  }

  .portal-icon {
    font-size: 1.8rem;
  }

  .portal-label {
    font-size: 0.75rem;
  }

  #home-btn {
    bottom: 1.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .portals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .portal {
    width: 110px;
    height: 110px;
  }

  .portal-inner {
    width: 100px;
    height: 100px;
  }
}

@media (min-width: 900px) {
  .portals-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: #2a2a40;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a55;
}

/* ===== Loading indicator ===== */
.loading-dots {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  z-index: 55;
}

.loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: loadBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes loadBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
