/* === Background Video (all pages) === */
#bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

/* === Custom Font === */
@font-face {
  font-family: 'Ancient Medium';
  src: url('../fonts/Ancient Medium.woff2') format('woff2'),
       url('../fonts/Ancient Medium.woff') format('woff'),
       url('../fonts/Ancient Medium.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* === Navbar === */
#navbar {
  position: fixed;
  top: 0;
  right: 0;
  padding: 12px 24px;
  z-index: 10;
  background: none;
  border: none;
}

#navbar ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 20px;
}

#navbar ul li a {
  font-family: 'Ancient Medium', serif;
  font-size: 2.2rem;
  font-weight: 600;
  text-decoration: none;
  color: #c5a600;
  -webkit-text-stroke: 0.8px #000;
  paint-order: stroke fill;
  transition: color 0.6s ease-in-out, text-shadow 0.6s ease-in-out;
  animation: arrowPulse 3s infinite ease-in-out,
             electricFlicker 4s infinite;
}

#navbar ul li a:hover {
  color: #00b7ff;
  text-shadow: 0 0 10px #00b7ff;
}

/* === Shared Arrows === */
.lore-arrow {
  font-family: 'Ancient Medium', serif;
  font-size: 2.2rem;
  font-weight: 600;
  text-decoration: none;
  color: #c5a600;
  -webkit-text-stroke: 0.8px #000;
  paint-order: stroke fill;
  transition: color 0.6s ease-in-out, text-shadow 0.6s ease-in-out;
  animation: arrowPulse 3s infinite ease-in-out,
             electricFlicker 4s infinite;
}

/* === Animations === */
@keyframes arrowPulse {
  0%   { opacity: 0.7; transform: scale(1); }
  50%  { opacity: 1;   transform: scale(1.08); }
  100% { opacity: 0.8; transform: scale(1); }
}

@keyframes electricFlicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { 
    text-shadow: 
      0 0 6px #00b7ff,
      0 0 14px #00b7ff,
      0 0 22px #00b7ff;
  }
  20%, 24%, 55% { text-shadow: none; }
}

/* === Planet Pages (Lore Layout) === */
.lore-stage {
  position: absolute;
  top: 52vh;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  width: min(92vw, 980px);
  text-align: center;
  z-index: 2;
}

.lore-wrapper {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.lore-text {
  margin: 10px 0;
  font-size: 1.05em;
  line-height: 1.6;
  color: #e8e6e3;
  text-shadow:
    0 0 4px rgba(0,183,255,0.3),
    0 0 6px rgba(197,166,0,0.3);
}

.lore-text.intro,
.lore-text:first-of-type {
  font-size: 1.2em;
  font-style: italic;
  color: #d4c277;
  text-shadow:
    0 0 10px rgba(197,166,0,0.8),
    0 0 20px rgba(0,183,255,0.6);
}

.lore-text.outro,
.lore-text:last-of-type {
  font-weight: 500;
  color: #6cbdd4;
  text-shadow:
    0 0 8px rgba(0,183,255,0.8),
    0 0 14px rgba(197,166,0,0.6);
}

/* === Worlds Page Layout === */
.worlds-stage {
  position: absolute;
  top: 52vh;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: min(92vw, 960px);
  z-index: 2;
}

.worlds-wrapper {
  max-width: 720px;
  margin: 0 auto;
}

.worlds-title {
  font-family: 'Ancient Medium', serif;
  font-size: 2.5rem;
  color: #c5a600;
  -webkit-text-stroke: 0.8px #000;
  margin-bottom: 1.5rem;
}

.worlds-tabs, .world-tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3rem;
  margin: 1.5rem 0;
}

.world-tab h3 {
  font-family: 'Ancient Medium', serif;
  font-size: 2.2rem;
  font-weight: 600;
  color: #c5a600;
  -webkit-text-stroke: 0.8px #000;
  transition: color 0.6s ease-in-out, text-shadow 0.6s ease-in-out;
  animation: arrowPulse 3s infinite ease-in-out,
             electricFlicker 4s infinite;
}

.world-tab h3:hover {
  color: #00b7ff;
  text-shadow: 0 0 10px #00b7ff;
}

.world-description {
  max-width: 720px;
  margin: 1.5rem auto 0;
  font-size: 1.05em;
  line-height: 1.6;
  color: #e8e6e3;
  -webkit-text-stroke: 0.4px #fff;
  text-shadow:
    0 0 4px rgba(0,183,255,0.3),
    0 0 6px rgba(197,166,0,0.3);
}

/* === Gradient Text Animation (welcome/worlds) === */
@property --k {
  syntax: '<number>';
  initial-value: 0;
  inherits: false;
}

.world-description p {
  background: linear-gradient(
      90deg,
      hsl(calc(var(--k) * 1turn), 80%, 65%),
      hsl(calc(var(--k) * 1turn + 120deg), 80%, 55%),
      hsl(calc(var(--k) * 1turn + 240deg), 80%, 70%)
    ) text;
  color: transparent;
  font: 500 clamp(0.9em, 2vw, 1.3em) 'Georgia', 'Times New Roman', serif;
  text-align: center;
  line-height: 1.7;
  margin: 1.2rem 0;
  animation: k 6s linear infinite;
}

@keyframes k { to { --k: 1; } }

/* === Shooting Stars Background === */
.stars-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.stars-bg span {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow:
    0 0 4px rgba(255, 255, 255, 0.2),
    0 0 8px rgba(255, 255, 255, 0.15),
    0 0 16px rgba(0, 183, 255, 0.2);
  animation: animate 3s linear infinite;
}

.stars-bg span::before {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 250px;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.5),
    rgba(255,255,255,0.2),
    transparent
  );
}

@keyframes animate {
  0%   { transform: rotate(315deg) translateX(0); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: rotate(315deg) translateX(-1000px); opacity: 0; }
}

/* === Responsive Tweaks === */

/* Tablets */
@media (max-width: 900px) {
  .lore-arrow,
  #navbar ul li a,
  .world-tab h3 {
    font-size: 1.8rem;
    -webkit-text-stroke: 0.6px #000;
  }

  .lore-wrapper,
  .worlds-wrapper {
    max-width: 460px;
    padding: 0 1rem;
  }

  .world-tabs {
    flex-wrap: wrap;
    gap: 2rem;
  }

  .world-description {
    font-size: 1em;
    line-height: 1.5;
  }
}

/* Phones */
@media (max-width: 600px) {
  body {
    font-size: clamp(14px, 3.5vw, 18px);
    overflow-x: hidden;
  }

  h1, .worlds-title {
    font-size: clamp(1.4rem, 7vw, 2rem);
    line-height: 1.3;
  }

  #navbar {
    top: 10px;
    right: 10px;
  }

  #navbar ul {
    flex-direction: column;
    align-items: flex-end;
    background: rgba(0,0,0,0.6);
    padding: 8px 12px;
    border-radius: 6px;
    gap: 6px;
  }

  #navbar ul li a {
    font-size: 1.2rem;
    -webkit-text-stroke: 0.3px #000;
    padding: 4px 6px;
  }

  .lore-arrow {
    font-size: 1.6rem;
    -webkit-text-stroke: 0.4px #000;
  }

  .world-tabs {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .world-tab img {
    width: clamp(100px, 35vw, 160px);
    height: auto;
  }

  .lore-wrapper,
  .worlds-wrapper {
    max-width: 380px;
    padding: 0 0.5rem;
  }

  .lore-text,
  .world-description {
    font-size: 0.95em;
    line-height: 1.5;
    -webkit-text-stroke: 0.2px #000;
  }

  .stars-bg span {
    opacity: 0.6;
    transform: scale(0.8);
  }
  .stars-bg span:nth-child(n+6) {
    display: none;
  }
}

/* === Collapsible Text (for long sections) === */
@media (max-width: 600px) {
  .collapsible-text {
    max-height: 35vh;
    overflow: hidden;
    position: relative;
    transition: max-height 0.4s ease;
  }

  .collapsible-text.expanded {
    max-height: 100vh;
  }

  .collapsible-text::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .collapsible-text.expanded::after {
    opacity: 0;
  }

  .read-more-btn {
    display: block;
    margin: 12px auto 0;
    text-align: center;
    font-size: 1em;
    font-family: 'Ancient Medium', serif;
    color: #00b7ff;
    text-shadow: 0 0 6px #00b7ff;
    cursor: pointer;
  }
}
