/* ============================================
   THE CITY OF NOCTURA — Enhanced Stylesheet
   ============================================ */

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

:root {
  --color-bg: #0a0a1a;
  --color-surface: rgba(255, 255, 255, 0.04);
  --color-text: #e0e0ff;
  --color-accent: #00f7ff;
  --color-accent2: #a76bff;
  --color-glow: rgba(0, 247, 255, 0.3);
  --font-display: 'Cinzel', serif;
  --font-body: 'Raleway', sans-serif;
  --font-story: 'Cormorant Garamond', serif;
}

html {
  scroll-behavior: smooth;
  scrollbar-color: rgba(0,247,255,0.3) transparent;
}

/* Custom scrollbar for WebKit */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent2));
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #00f7ff, #c490ff);
}

/* Accessibility: skip to content */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--color-accent);
  color: #000;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  z-index: 100000;
  text-decoration: none;
  transition: top 0.3s ease;
}
.skip-link:focus {
  top: 0;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  overflow-x: hidden;
  transition: background-color 1.5s ease;
}

::selection {
  background: var(--color-accent2);
  color: #fff;
}

/* === CINEMATIC INTRO === */
#cinematic-intro {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.5s ease, visibility 1.5s ease;
}

#cinematic-intro.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#intro-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.intro-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.intro-subtitle {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 20px;
  animation: fadeInUp 1.5s ease 0.5s both;
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 4.5rem);
  color: #fff;
  letter-spacing: 0.15em;
  line-height: 1.2;
  margin-bottom: 5px;
}

.intro-title span {
  display: inline-block;
  opacity: 0;
  animation: letterReveal 0.6s ease forwards;
}

.intro-title span:nth-child(1)  { animation-delay: 0.8s; }
.intro-title span:nth-child(2)  { animation-delay: 0.85s; }
.intro-title span:nth-child(3)  { animation-delay: 0.9s; }
.intro-title span:nth-child(4)  { animation-delay: 0.95s; }
.intro-title span:nth-child(5)  { animation-delay: 1.0s; }
.intro-title span:nth-child(6)  { animation-delay: 1.05s; }
.intro-title span:nth-child(7)  { animation-delay: 1.1s; }
.intro-title span:nth-child(8)  { animation-delay: 1.15s; }
.intro-title span:nth-child(9)  { animation-delay: 1.2s; }
.intro-title span:nth-child(10) { animation-delay: 1.25s; }
.intro-title span:nth-child(11) { animation-delay: 1.3s; }

.intro-title-main span {
  color: var(--color-accent);
  text-shadow: 0 0 40px var(--color-accent), 0 0 80px rgba(0, 247, 255, 0.3);
}

.intro-title-main span:nth-child(1)  { animation-delay: 1.6s; }
.intro-title-main span:nth-child(2)  { animation-delay: 1.7s; }
.intro-title-main span:nth-child(3)  { animation-delay: 1.8s; }
.intro-title-main span:nth-child(4)  { animation-delay: 1.9s; }
.intro-title-main span:nth-child(5)  { animation-delay: 2.0s; }
.intro-title-main span:nth-child(6)  { animation-delay: 2.1s; }
.intro-title-main span:nth-child(7)  { animation-delay: 2.2s; }

@keyframes letterReveal {
  0% { opacity: 0; transform: translateY(30px) rotateX(90deg); filter: blur(10px); }
  100% { opacity: 1; transform: translateY(0) rotateX(0); filter: blur(0); }
}

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

/* Enter Button */
.enter-btn {
  position: relative;
  margin-top: 40px;
  padding: 16px 40px;
  border: 1px solid rgba(0, 247, 255, 0.4);
  background: transparent;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  animation: fadeInUp 1s ease 3s both;
  transition: all 0.4s ease;
}

.enter-btn:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 30px rgba(0, 247, 255, 0.3), inset 0 0 30px rgba(0, 247, 255, 0.1);
  transform: scale(1.05);
}

.enter-btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 247, 255, 0.15), transparent);
  transform: translateX(-100%);
  animation: btnGlow 3s ease infinite 3.5s;
}

@keyframes btnGlow {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* === PROGRESS BAR === */
#progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.05);
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent2), #ff6bca);
  box-shadow: 0 0 15px var(--color-accent), 0 0 30px var(--color-accent2);
  transition: width 0.1s linear;
}

/* === SPARKLE CANVAS === */
#sparkleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 998;
}

/* === MUSIC TOGGLE === */
.music-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
}

.music-toggle button {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-toggle button:hover {
  background: rgba(0, 247, 255, 0.2);
  border-color: var(--color-accent);
  box-shadow: 0 0 20px rgba(0, 247, 255, 0.3);
  transform: scale(1.1);
}

/* === NARRATOR CONTROLS === */
.narrator-controls {
  position: fixed;
  top: 20px;
  right: 75px;
  display: flex;
  gap: 6px;
  z-index: 1001;
}

.narrator-controls button {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.narrator-controls button:hover {
  background: rgba(167, 107, 255, 0.3);
  border-color: var(--color-accent2);
  box-shadow: 0 0 15px rgba(167, 107, 255, 0.4);
  transform: scale(1.1);
}

.narrator-voice {
  position: fixed;
  top: 20px;
  left: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
}

#voiceSelect {
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  max-width: 200px;
}

/* === HEADER === */
#site-header {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: 40px 20px;
}

#site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 80%, rgba(0, 247, 255, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 20%, rgba(167, 107, 255, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

.header-content {
  position: relative;
  z-index: 2;
}

.chapter-label {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.85rem;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 15px;
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 30px rgba(0, 247, 255, 0.4), 0 0 60px rgba(0, 247, 255, 0.15);
  line-height: 1.2;
  margin-bottom: 15px;
}

.tagline {
  font-family: var(--font-story);
  font-style: italic;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 2px;
}

/* Scroll Arrow Indicator */
.scroll-indicator {
  margin-top: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: float 3s ease-in-out infinite;
}

.scroll-indicator span {
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
}

.scroll-arrow {
  width: 24px;
  height: 24px;
  border-right: 2px solid rgba(0, 247, 255, 0.5);
  border-bottom: 2px solid rgba(0, 247, 255, 0.5);
  transform: rotate(45deg);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(12px); }
}

/* === STORY CONTENT === */
#story {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  position: relative;
}

/* Story Block */
.story-block {
  position: relative;
  background: var(--color-surface);
  border-radius: 24px;
  margin: 80px 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.5s ease;
  transform-style: preserve-3d;
}

.story-block:hover {
  box-shadow: 0 25px 60px rgba(0, 247, 255, 0.1),
              0 0 40px rgba(167, 107, 255, 0.08);
}

/* Scene Chapter Label */
.scene-chapter {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 3;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Image Wrapper with Shimmer */
.story-img-wrapper {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
}

.story-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.8s ease;
  filter: brightness(0.9) saturate(1.1);
}

.story-block:hover .story-img-wrapper img {
  transform: scale(1.05);
  filter: brightness(1) saturate(1.2);
}

.img-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.05) 45%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 55%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.8s ease;
}

.story-block:hover .img-shimmer {
  transform: translateX(100%);
}

/* Story Text */
.story-text {
  padding: 30px 35px 35px;
}

.story-text p {
  font-family: var(--font-story);
  font-size: 1.2rem;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.02em;
}

/* Glowing Keywords */
.glow-word {
  color: var(--color-accent);
  font-weight: 600;
  text-shadow: 0 0 10px rgba(0, 247, 255, 0.5);
  transition: text-shadow 0.3s ease;
}

.glow-word:hover {
  text-shadow: 0 0 20px rgba(0, 247, 255, 0.8), 0 0 40px rgba(0, 247, 255, 0.4);
}

/* Story Ending */
.story-ending {
  text-align: center;
  border: 1px solid rgba(0, 247, 255, 0.15);
}

.restart-story {
  margin-top: 25px;
}

.restart-btn {
  background: transparent;
  border: 1px solid rgba(0, 247, 255, 0.3);
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 3px;
  padding: 12px 30px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.4s ease;
}

.restart-btn:hover {
  background: rgba(0, 247, 255, 0.1);
  box-shadow: 0 0 25px rgba(0, 247, 255, 0.3);
  transform: translateY(-2px);
}

/* === DOT NAVIGATION === */
.dot-navigation {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.dot-navigation.visible {
  opacity: 1;
}

.dot {
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
}

.dot::before {
  content: attr(title);
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 0.65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0);
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
  transition: color 0.3s ease;
}

.dot:hover::before {
  color: rgba(255, 255, 255, 0.8);
}

.dot:hover {
  background: rgba(0, 247, 255, 0.5);
  transform: scale(1.4);
}

.dot.active {
  background: var(--color-accent);
  box-shadow: 0 0 12px var(--color-accent);
  transform: scale(1.3);
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: 60px 20px 40px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.3);
  position: relative;
}

.footer-credit {
  margin-bottom: 8px;
}

.footer-year {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.15);
  margin-top: 4px;
}

.footer-glow {
  width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
  margin: 0 auto 30px;
  opacity: 0.4;
}

/* === BACK TO TOP BUTTON === */
.top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: rgba(0, 247, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-accent);
  border: 1px solid rgba(0, 247, 255, 0.3);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: none;
  transition: all 0.3s ease;
  z-index: 999;
}

.top-btn:hover {
  background: rgba(0, 247, 255, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 5px 20px rgba(0, 247, 255, 0.3);
}

/* === SCROLL ANIMATIONS === */
.hidden {
  opacity: 0;
  transform: translateY(40px);
  transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Typewriter reveal for text */
.story-text.text-revealed p {
  animation: textFadeIn 1s ease forwards;
}

@keyframes textFadeIn {
  from { opacity: 0.3; filter: blur(3px); }
  to { opacity: 1; filter: blur(0); }
}

/* === PARALLAX IMAGES === */
.story-img-wrapper img.parallax-active {
  will-change: transform;
}

/* === RESPONSIVE === */
@media screen and (max-width: 768px) {
  .narrator-controls {
    top: auto;
    bottom: 20px;
    right: 50%;
    transform: translateX(50%);
  }

  .narrator-voice {
    display: none;
  }

  .dot-navigation {
    right: 10px;
    gap: 8px;
  }

  .dot {
    width: 8px;
    height: 8px;
  }

  .dot::before {
    display: none;
  }

  .story-text {
    padding: 20px 22px 25px;
  }

  .story-text p {
    font-size: 1.05rem;
    line-height: 1.7;
  }

  .scene-chapter {
    font-size: 0.65rem;
    padding: 4px 12px;
  }

  .intro-subtitle {
    font-size: 0.75rem;
    letter-spacing: 2px;
  }

  .story-block {
    margin: 50px 0;
    border-radius: 18px;
  }

  .music-toggle {
    top: 10px;
    right: 10px;
  }

  #progress-bar-container {
    height: 2px;
  }
}

@media screen and (max-width: 480px) {
  .intro-title {
    font-size: 1.8rem;
  }

  .site-title {
    font-size: 1.6rem;
  }

  .story-text p {
    font-size: 1rem;
  }
}

/* === READ FULL CHAPTER BUTTON === */
.read-full-btn {
  display: inline-block;
  margin-top: 1.2rem;
  padding: 0.6rem 1.8rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-accent);
  border: 1px solid rgba(0,247,255,0.3);
  border-radius: 30px;
  text-decoration: none;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}
.read-full-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,247,255,0.15), transparent);
  transition: left 0.6s ease;
}
.read-full-btn:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 20px rgba(0,247,255,0.3), 0 0 40px rgba(0,247,255,0.1);
  color: #fff;
  transform: translateY(-2px);
}
.read-full-btn:hover::before {
  left: 100%;
}

/* === SMOOTH BODY TRANSITIONS === */
body.intro-active {
  overflow: hidden;
}
