/* ----------------------------------------------------
   CINEMATIC STORYTELLING SITE - STYLES
   ---------------------------------------------------- */

/* Design System & Custom Properties */
:root {
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Makoto Shinkai Film Inspired Theme Palette */
  --color-bg: #07060d;
  --color-text-primary: #f5f4fa;
  --color-text-secondary: #cacedb;
  --color-accent: #ff9d80;       /* Golden hour soft orange */
  --color-purple: #b98bf5;       /* Twilight purple */
  --color-blue: #4d7cff;         /* Deep sky twilight blue */
  --color-pink: #fca5a5;         /* Soft cherry blossom pink */
  --glass-bg: rgba(15, 14, 28, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.4);
}

/* Reset and Global Settings */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------
   LOADER & ENTER SCREEN
   ---------------------------------------------------- */
.loader-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #050409;
  transition: opacity 1.2s cubic-bezier(0.77, 0, 0.175, 1), visibility 1.2s;
}

.loader-container.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2.5rem;
  border-radius: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px var(--glass-shadow);
  max-width: 480px;
  width: 90%;
  transform: translateY(0);
  transition: transform 0.8s ease;
}

.loader-container.fade-out .loader-content {
  transform: translateY(-30px);
}

.loader-overtitle {
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-purple);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.loader-title {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 6vw, 4.5rem);
  font-weight: 300;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fff 30%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.loader-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 2rem;
  font-weight: 300;
}

.enter-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 2.2rem;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  outline: none;
  overflow: hidden;
  position: relative;
}

.enter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.enter-btn:hover {
  background: white;
  color: var(--color-bg);
  border-color: white;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.enter-btn:hover::before {
  transform: translateX(100%);
}

.enter-btn svg {
  transition: transform 0.3s ease;
}

.enter-btn:hover svg {
  transform: translateX(4px);
}

.loader-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 70% 30%, #1e1338 0%, #050409 70%);
  z-index: 1;
}

/* ----------------------------------------------------
   SCROLL SNAP CONTAINER
   ---------------------------------------------------- */
.scroll-container {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100vh;
  width: 100vw;
  scroll-behavior: smooth;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;     /* Firefox */
}

.scroll-container::-webkit-scrollbar {
  display: none;             /* Chrome, Safari, Opera */
}

/* ----------------------------------------------------
   STORY SECTION ARCHITECTURE
   ---------------------------------------------------- */
.story-section {
  height: 100vh;
  width: 100vw;
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
}

/* Background image & Ken Burns container */
.bg-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: hidden;
}

.bg-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transform: scale(1.04) translate(0, 0);
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* Specific background bindings */
.bg-chapter-1 { background-image: url('../assets/images/chapter1_glance.png'); }
.bg-chapter-2 { background-image: url('../assets/images/chapter2_blush.png'); }
.bg-chapter-3 { background-image: url('../assets/images/chapter3_wait.png'); }
.bg-chapter-4 { background-image: url('../assets/images/chapter4_sign.png'); }
.bg-chapter-5 { background-image: url('../assets/images/chapter5_hand.png'); }
.bg-chapter-6 { background-image: url('../assets/images/chapter6_one.png'); }

/* Cinematic Background Scrim */
.bg-scrim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background: linear-gradient(
    to bottom,
    rgba(5, 4, 9, 0.2) 0%,
    rgba(5, 4, 9, 0.4) 60%,
    rgba(5, 4, 9, 0.75) 100%
  );
  pointer-events: none;
}

/* Ken Burns effect applied only on active sections */
@keyframes kenBurnsActive {
  0% {
    transform: scale(1.04) translate(0, 0);
  }
  50% {
    transform: scale(1.11) translate(-0.8%, -0.5%);
  }
  100% {
    transform: scale(1.04) translate(0, 0);
  }
}

.story-section.active .bg-image {
  animation: kenBurnsActive 32s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

/* Content Layout Alignment & Constraints */
.content-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  padding: 2.5rem 10vw;
  pointer-events: none; /* Let scroll trigger normally */
}

/* Alignments mapping cinematic focus points */
.align-mid-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.align-mid-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}

.align-bottom-left {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding-bottom: 15vh;
}

.align-top-right {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 15vh;
  text-align: right;
}

.align-center-center {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Typography elements container */
.text-block {
  max-width: 650px;
  background: rgba(5, 4, 9, 0.3);
  padding: 2.5rem;
  border-radius: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.align-center-center .text-block {
  max-width: 750px;
  background: rgba(5, 4, 9, 0.4);
  padding: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Typography styles */
.over-title {
  display: block;
  font-family: var(--font-sans);
  font-size: clamp(0.75rem, 1.6vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--color-purple);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  
  /* Animation states */
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 0.15s;
}

.main-title {
  font-family: var(--font-serif);
  font-size: clamp(3.2rem, 7vw, 6.2rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  color: white;
  
  /* Animation states */
  opacity: 0;
  transform: translateY(35px);
  transition: opacity 1.1s cubic-bezier(0.25, 1, 0.5, 1), transform 1.1s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 0.35s;
}

/* Highlighting chapter 6 */
.font-highlight {
  background: linear-gradient(135deg, white 40%, var(--color-accent) 70%, var(--color-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none !important;
}

.subtitle {
  font-family: var(--font-sans);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 300;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  
  /* Animation states */
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 0.75s;
}

.story-paragraph {
  font-family: var(--font-sans);
  font-size: clamp(0.8rem, 1.8vw, 0.95rem);
  font-weight: 300;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-top: 1.2rem;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 1s cubic-bezier(0.25, 1, 0.5, 1), transform 1s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 1.1s;
  letter-spacing: 0.03em;
}

.story-meta {
  font-family: var(--font-sans);
  font-size: clamp(0.6rem, 1.4vw, 0.72rem);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 0.6rem;
  font-weight: 600;
  display: block;
  
  /* Animation states */
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  transition-delay: 0.05s;
}

/* Active slide states for typography */
.story-section.active .over-title,
.story-section.active .main-title,
.story-section.active .subtitle,
.story-section.active .story-paragraph,
.story-section.active .story-meta {
  opacity: 1;
  transform: translateY(0);
}

.story-section.active .text-block .story-meta {
  opacity: 0.75;
}

/* ----------------------------------------------------
   FIXED UI LAYERS
   ---------------------------------------------------- */

/* Progress bar (top indicator) */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.05);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-purple), var(--color-accent));
  transition: width 0.1s ease-out;
  box-shadow: 0 0 10px rgba(255, 157, 128, 0.5);
}

/* Fixed Footer Link */
.fixed-footer {
  position: fixed;
  bottom: 2rem;
  left: 4vw;
  z-index: 500;
  pointer-events: none;
}

.fixed-footer span {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  opacity: 0.5;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  transition: all 0.3s ease;
  pointer-events: auto;
}

.fixed-footer span:hover {
  opacity: 0.9;
  color: var(--color-accent);
}

/* Main Fixed Header Container */
.fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 2rem 4vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 500;
  pointer-events: none; /* Permit clicks through header to elements behind */
}

.logo {
  pointer-events: auto;
}

.logo-serif {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  font-weight: 400;
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Audio toggle control */
.audio-control {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px var(--glass-shadow);
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.audio-control:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.audio-status-text {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--color-text-secondary);
  transition: color 0.3s ease;
}

.audio-control:hover .audio-status-text {
  color: white;
}

/* Animated visualizer soundbars */
.visualizer-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
  width: 21px;
}

.visualizer-bars .bar {
  width: 3px;
  height: 100%;
  background-color: var(--color-text-secondary);
  border-radius: 2px;
  transform-origin: bottom;
  transform: scaleY(0.15);
  transition: transform 0.3s ease, background-color 0.3s ease;
}

/* Animation playing class */
.audio-control.playing .visualizer-bars .bar {
  background-color: var(--color-accent);
  animation: barBounce 1.2s ease-in-out infinite;
}

.audio-control.playing .visualizer-bars .bar:nth-child(1) { animation-delay: 0.15s; }
.audio-control.playing .visualizer-bars .bar:nth-child(2) { animation-delay: 0.4s; }
.audio-control.playing .visualizer-bars .bar:nth-child(3) { animation-delay: 0.25s; }
.audio-control.playing .visualizer-bars .bar:nth-child(4) { animation-delay: 0.55s; }

@keyframes barBounce {
  0%, 100% { transform: scaleY(0.2); }
  50% { transform: scaleY(1.0); }
}

/* ----------------------------------------------------
   SIDE DOTS NAVIGATION
   ---------------------------------------------------- */
.side-nav {
  position: fixed;
  right: 4vw;
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
}

.side-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-dot-container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
  cursor: pointer;
}

/* Dot hover label */
.nav-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.nav-dot-container:hover .nav-label {
  opacity: 1;
  transform: translateX(0);
  color: white;
}

/* Main Dot Indicator */
.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  outline: none;
  padding: 0;
  transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav-dot-container:hover .nav-dot {
  border-color: white;
  transform: scale(1.2);
}

/* Active slide dot state */
.nav-dot-container.active .nav-dot {
  background: var(--color-accent);
  border-color: var(--color-accent);
  transform: scale(1.4);
  box-shadow: 0 0 10px var(--color-accent);
}

.nav-dot-container.active .nav-label {
  opacity: 0.7;
  transform: translateX(0);
  color: var(--color-accent);
}

.nav-dot-container.active:hover .nav-label {
  opacity: 1;
  color: white;
}

/* ----------------------------------------------------
   SCROLL PROMPT ARROW
   ---------------------------------------------------- */
.scroll-prompt {
  position: fixed;
  bottom: 4vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 1;
  transition: opacity 0.8s ease, visibility 0.8s;
  pointer-events: none;
}

.scroll-prompt.fade-out {
  opacity: 0;
  visibility: hidden;
}

.prompt-text {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  font-weight: 500;
  opacity: 0.8;
  text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.scroll-arrow {
  color: white;
  animation: floatBounce 2s infinite ease-in-out;
}

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

/* ----------------------------------------------------
   RESPONSIVE SCALING (MOBILE & TABLETS)
   ---------------------------------------------------- */
@media (max-width: 1024px) {
  .content-wrapper {
    padding: 2.5rem 6vw;
  }
}

@media (max-width: 768px) {
  .scroll-container {
    -webkit-overflow-scrolling: touch; /* Butter-smooth iOS scroll snap */
  }

  .fixed-header {
    padding: 1.2rem 5vw;
  }
  
  .logo-serif {
    font-size: 1.4rem;
  }
  
  .audio-status-text {
    display: none; /* Hide label text on mobile to save space */
  }
  
  .audio-control {
    width: 44px; /* WCAG AAA standard 44px touch target size */
    height: 44px;
    padding: 0;
    border-radius: 50%; /* Make fully circular button */
    display: inline-flex;
    justify-content: center;
    align-items: center;
  }

  .visualizer-bars {
    justify-content: center;
  }
  
  .side-nav {
    display: none; /* Hide side dots to prevent accidental swipes, snap handles nav */
  }

  .content-wrapper {
    padding: 1.5rem 4vw;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .text-block {
    max-width: 100%;
    width: 100%;
    padding: 1.6rem 1.2rem;
    background: rgba(5, 4, 9, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
  }

  .story-meta {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.4rem;
  }

  .over-title {
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.2rem;
  }

  .main-title {
    font-size: clamp(2rem, 7.5vw, 2.8rem);
    margin-bottom: 0.5rem;
    line-height: 1.15;
  }

  .subtitle {
    font-size: clamp(0.85rem, 3vw, 1.05rem);
    letter-spacing: 0.08em;
  }

  .story-paragraph {
    font-size: clamp(0.78rem, 2.5vw, 0.88rem);
    line-height: 1.5;
    margin-top: 0.8rem;
    opacity: 0.9;
  }

  .scroll-prompt {
    bottom: 2.8vh;
  }

  .prompt-text {
    font-size: 0.62rem;
    letter-spacing: 0.15em;
  }

  .fixed-footer {
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
  }

  .fixed-footer span {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
  }
}

/* Landscape Mobile Tweaks to prevent text clipping */
@media (max-width: 896px) and (orientation: landscape) {
  .text-block {
    max-height: 85vh;
    overflow-y: auto;
    padding: 1rem 1.5rem;
  }

  .main-title {
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    margin-bottom: 0.25rem;
  }

  .story-paragraph {
    margin-top: 0.5rem;
  }
}
