/* ---------- RESET ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", system-ui, sans-serif;
  
  /* 1. Remove blue highlight on tap */
  -webkit-tap-highlight-color: transparent;

  /* 2. Disable Long Press Context Menu (Save Image/Copy) */
  -webkit-touch-callout: none; 

  /* 3. Disable Text Selection (Highlighting) */
  -webkit-user-select: none; 
  user-select: none;
}

/* 4. Prevent dragging images (Ghost image effect) */
img {
  -webkit-user-drag: none;
  user-drag: none;
}

/* ========================================================= */
/* ======================== BASE =========================== */
/* ========================================================= */
/* FIX: STRICTLY lock scrollbars and prevent "rubber banding" on mobile */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; 
  position: fixed; 
  background: #f7fbff;
  color: #1a1a1a;
}

/* ========================================================= */
/* ================= MOVING CLOUDS ========================= */
/* ========================================================= */
#cloud-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 350px; /* Taller area for big clouds */
  pointer-events: none;
  /* Z-INDEX 1: In front of Sun (0), Behind Character */
  z-index: 6; 
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.cloud {
  position: absolute;
  opacity: 1;
  left: -300px;
  animation: floatCloud linear infinite;
}

/* Update this keyframe block */
@keyframes floatCloud {
  0% { 
    transform: translateX(0); 
  }
  100% { 
    /* Move 100% of screen width + 500px extra to cover the start offset */
    transform: translateX(calc(100vw + 500px)); 
  }
}

/* --- CLOUD VARIATIONS --- */
.c1 {
  top: 20px;
  width: 300px;
  animation-duration: 55s;
  opacity: 1;
}
.c2 {
  top: 120px;
  width: 200px;
  animation-duration: 35s;
  animation-delay: -10s; 
  opacity: 1;
}
.c3 {
  top: 10px;
  width: 150px;
  animation-duration: 70s;
  animation-delay: -30s;
  opacity: 1;
}

/* ========================================================= */
/* ======================= SCENES ========================== */
/* ========================================================= */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.scene.active {
  opacity: 1;
  pointer-events: all;
}

/* ========================================================= */
/* ==================== BACKGROUNDS ======================== */
/* ========================================================= */
#landing::before,
#chapter1::before, #chapter2::before, #chapter3::before,
#chapter4::before, #chapter5::before, #chapter6::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("assets/ocean.jpg") center / cover no-repeat;
  filter: blur(5px);
  transform: scale(1.05);
  z-index: -2;
}

#landing::before {
  filter: blur(6px);
}

/* White Fog Overlay */
#landing::after,
#chapter1::after, #chapter2::after, #chapter3::after,
#chapter4::after, #chapter5::after, #chapter6::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  z-index: -1;
}

/* ========================================================= */
/* =================== LANDING HERO ======================== */
/* ========================================================= */
#image-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  
  /* FIX: Force alignment to bottom for ALL devices */
  justify-content: flex-end; 
  
  z-index: 7; /* In front of clouds */
  transition: transform 1.2s ease;
}

#hero-image {
  height: 90vh; 
  width: auto;
  cursor: pointer;
  transition: transform 1.2s ease, opacity 1s ease;
  object-fit: contain;
  object-position: bottom; 
}

/* Float the 'click' hint above the image */
.hint {
  /* OPTIONAL: Remove display:none if you deleted HTML line */
  display: none !important; 
  position: absolute;
  bottom: 40px; 
  z-index: 2;
  font-size: 0.9rem;
  opacity: 0.6;
  text-shadow: 0 0 15px rgba(255,255,255, 0.8);
  pointer-events: none;
}

/* ========================================================= */
/* =================== LANDING TEXT ======================== */
/* ========================================================= */
#reveal {
  position: absolute;
  left: 10%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

#reveal h1 {
  font-size: 3rem;
  margin-bottom: 28px;
}

.subtitle {
  margin-bottom: 36px;
  opacity: 0.8;
}

/* ========================================================= */
/* ===================== CONTENT =========================== */
/* ========================================================= */
.content {
  max-width: 780px;
  width: 90%;
  font-size: 1.05rem;
  line-height: 1.6;
  position: relative;
  z-index: 10;
  pointer-events: none;
}

/* TYPING TEXT */
#line-text,
#type-text {
  white-space: normal;
}
.line {
  display: block;
}
.line.settle {
  opacity: 0.9;
}

/* ========================================================= */
/* ===================== BUTTONS =========================== */
/* ========================================================= */
.btn {
  margin-top: 32px;
  background: #4fa3ff;
  color: #fff;
  border: none;
  padding: 10px 26px;
  border-radius: 26px;
  cursor: pointer;
  font-size: 0.9rem;
}

@keyframes breathe {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

.breathing {
  animation: breathe 3.5s ease-in-out infinite;
}
.breathing:hover {
  animation: none;
}
/* ================= CHAPTER ROW ================= */

.chapter-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

.chapter-row .btn {
  min-width: 120px;
}

.chapter-row .btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ================= CHAPTER BUTTON ROW ================= */

.chapter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  align-items: center;
}

/* Active chapter */
.chapter-link {
  text-decoration: none;
  color: inherit;
}

/* Disabled buttons */
.btn.disabled {
  opacity: 0.35;
  cursor: default;
  position: relative;
}

/* Tooltip text */
.btn.disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

/* Tooltip arrow */
.btn.disabled::before {
  content: "";
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.75);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

/* Show tooltip */
.btn.disabled:hover::after,
.btn.disabled:hover::before {
  opacity: 1;
}



/* ========================================================= */
/* ======================= MUTE ============================ */
/* ========================================================= */
#mute {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 0.75rem;
  padding: 6px 12px;
  
  /* Transparent Mute Button */
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #555;
  
  cursor: pointer;
  z-index: 6;
  border-radius: 4px;
  transition: all 0.3s ease;
}

#mute:hover {
  background: rgba(255, 255, 255, 0.9);
  color: #000;
}

/* ========================================================= */
/* ================= AMBIENT GIF (SUN) ===================== */
/* ========================================================= */
.ambient-gif {
  position: fixed;
  right: 6%;
  top: 2%;
  width: 220px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease, filter 0.5s ease, transform 0.8s ease;
  
  /* Z-INDEX 0: Behind the clouds (1) */
  z-index: 5; 
  cursor: pointer;
}

.ambient-gif.show {
  opacity: 0.7;
  pointer-events: auto;
}

/* ========================================================= */
/* =================== TEXT REVEAL ========================= */
/* ========================================================= */
.reveal {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.show {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================================= */
/* ================== CONTACT ART ========================== */
/* ========================================================= */
#contact-art {
  position: fixed;
  right: 0;
  bottom: 0;
  height: 50vh;
  display: flex;
  align-items: flex-end;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#contact-art.show {
  opacity: 1;
  pointer-events: all;
}

#contact-art img {
  height: 100%;
  width: auto;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#contact-art img:hover {
  opacity: 1;
  transform: translateY(-4px);
}

/* The Popup Bubble */
#contact-cloud {
  position: absolute;
  right: 110%;
  bottom: 20%;
  background: #1a1a1a; 
  color: #ffffff;      
  padding: 16px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  width: max-content;
}

#contact-cloud.show {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* The Triangle Tail */
#contact-cloud::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 30%;
  width: 16px;
  height: 16px;
  background: #1a1a1a; 
  transform: rotate(45deg);
}

/* ========================================================= */
/* ================= CLICK RIPPLE EFFECT =================== */
/* ========================================================= */
.click-effect {
  position: fixed;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: clickRipple 0.5s linear forwards;
  z-index: 9999;
}

@keyframes clickRipple {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

/* ========================================================= */
/* =================== NIGHT MODE ========================== */
/* ========================================================= */
body.night-mode {
  background: #050510;
  color: #e0e0e0;
}

body.night-mode [id^="chapter"]::before,
body.night-mode #landing::before {
  filter: brightness(0.6) grayscale(0.2) contrast(1.1) !important;
}

body.night-mode [id^="chapter"]::after,
body.night-mode #landing::after {
  background: rgba(0, 0, 0, 0.6) !important;
}
body.night-mode [id^="chapter"]::before,
body.night-mode #landing::before {
  filter: blur(6px) brightness(0.55) grayscale(0.25) contrast(1.1) !important;
}


body.night-mode .ambient-gif {
  filter: grayscale(1) brightness(4.5); 
  transform: translateY(-50%) rotate(180deg);
}

body.night-mode .btn {
  background: #2a2a40;
  border: 1px solid #4fa3ff;
}
body.night-mode .btn:hover {
  background: #4fa3ff;
}

/* Clouds become dark at night */
body.night-mode .cloud {
  filter: brightness(0.5) grayscale(1) contrast(1.2);
  opacity: 0.4;
}

/* Ripple becomes blue at night */
body.night-mode .click-effect {
  background: rgba(79, 163, 255, 0.5);
  box-shadow: 0 0 10px rgba(79, 163, 255, 0.5);
}
body.night-mode #mute {
  color: #fff;
}

/* ========================================================= */
/* ============= ANIMATION RULES (ADD THIS) ================ */
/* ========================================================= */

/* 1. DESKTOP: Move image to the right */
@media (min-width: 769px) {
  #image-container.open {
    transform: translateX(35vw); /* Slide right */
  }
}
/* ========================================================= */
/* ================= RESPONSIVE (MOBILE) =================== */
/* ========================================================= */

@media (max-width: 768px) {

  /* ---------------- LANDING PAGE ---------------- */
  #image-container {
    transform: translateX(0);
    justify-content: flex-end;
  }

  #hero-image {
    height: 85vh;
    width: auto;
    object-fit: contain;
    object-position: bottom;
  }

  #reveal {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
  }

  #reveal h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
  }

  #reveal .subtitle {
    margin-bottom: 25px;
  }

  #reveal .btn {
    margin: 0 auto;
    display: block;
  }

  /* ---------------- CHARACTER ANIMATION ---------------- */
  #image-container.open #hero-image {
    transform: translateY(-20vh) scale(0.95);
    opacity: 0.2;
  }

  /* ---------------- CONTENT ---------------- */
  .content {
    max-width: 92%;
    font-size: 1rem;
    padding-bottom: 120px;
  }

  /* ---------------- SUN (AMBIENT GIF) ---------------- */
  .ambient-gif {
    width: 80px;
    bottom: 40px;
    top: auto;
    left: 20px;
    right: auto;
  }

  /* ---------------- NIGHT MODE SUN REACTION ---------------- */
  body.night-mode #chapter1 .btn {
    transform: translateX(65px);
  }

  #chapter1 .btn {
    transition: transform 0.6s ease;
  }

  /* ---------------- MUTE BUTTON ---------------- */
  #mute {
    bottom: 40px;
  }

  /* ---------------- CLOUDS ---------------- */
  .c1 { width: 200px; top: 30px; }
  .c2 { width: 140px; top: 100px; }
  .c3 { display: none; }

  /* ---------------- CONTACT ART ---------------- */
  #contact-art {
    height: 25vh;
    bottom: 0;
    right: -10px;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }

  #contact-art.show {
    opacity: 0.8;
    pointer-events: all;
  }

  #contact-cloud {
    right: 15px;
    bottom: 100%;
    width: 180px;
    text-align: center;
  }

  #contact-cloud::after {
    right: 40px;
    bottom: -8px;
  }
}

/* ========================================================= */
/* ============= FORCE BUTTONS TO WORK (FINAL) ============= */
/* ========================================================= */

/* 1. Make sure the container lets clicks pass through */
.content {
  pointer-events: none !important;
}

/* 2. Enable clicks for buttons in the ACTIVE scene */
.scene.active .content .btn, 
.scene.active .content p,
.scene.active .content h1,
.scene.active .content span {
  pointer-events: auto !important;
  position: relative;
  z-index: 100;       
}

/* 3. SUPER SPECIFIC RULE (The Bug Fix) */
/* This overrides the rule above. If a button is hidden, it stays DEAD. */
.scene.active .content .btn.hidden {
  pointer-events: none !important;
  cursor: default;
  opacity: 0; /* Ensure it's invisible */
}

/* 4. Ensure the Landing Page button works */
#reveal .btn {
  
  cursor: pointer;
}

@media (max-width: 768px) {

  #image-container.open {
    pointer-events: none;
  }

  #image-container.open #hero-image {
    pointer-events: none;
  }

  #reveal {
    z-index: 20;
    
  }
}


#reveal h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 3.6rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.subtitle {
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  opacity: 0.5;
  letter-spacing: 0.2em;
}

/* === FIX: Allow chapter row content to show & work === */
.scene.active .content .chapter-row {
  pointer-events: auto !important;
  position: relative;
  z-index: 100;
}
/* ========================================================= */
/* =================== LAST CHAPTER FIX ==================== */
/* ========================================================= */

/* Layout for chapter row */
.chapter-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
}

/* Base button grounding */
#chapter6 .chapter-row .btn {
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  opacity: 1;
}

/* Active (Chapter 1) */
#chapter6 .chapter-row .btn.primary {
  background: rgba(79, 163, 255, 0.85);
  color: #fff;
}

#chapter6 .chapter-row .btn.primary:hover {
  background: rgba(79, 163, 255, 1);
}

/* Locked chapters */
#chapter6 .chapter-row .btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ========================================================= */
/* ============== FIX: CHAPTER 1 INTERACTION =============== */
/* ========================================================= */

/* 1. The Container: Must be invisible to clicks so we can touch the Sun behind it */
.scene.active#chapter1 .content {
  pointer-events: none !important;
}

/* 2. The Text: We explicitly turn clicks back ON for the text only */
.scene.active#chapter1 .content p {
  pointer-events: auto !important;
  position: relative;
  z-index: 100;
}
/* ========================================================= */
/* ============== FIX: CHAPTER 6 BUTTONS (FINAL) =========== */
/* ========================================================= */

/* 1. CRITICAL FIX: Only enable clicks when Chapter 6 has the 'active' class */
#chapter6.active .chapter-row {
  position: relative; 
  z-index: 200 !important;
  pointer-events: auto !important;
}

/* 2. Ensure the buttons themselves are clickable */
#chapter6.active .chapter-row .btn {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* 3. Keep the disabled ones unclickable */
#chapter6.active .chapter-row .btn.disabled {
  pointer-events: none !important;
  cursor: default !important;
}
/* ================= SUN LAYER FIX ================= */

/* Sun stays decorative */
.ambient-gif {
  z-index: 2;          /* background layer */
  opacity: 0.6;
  pointer-events: auto;
}

/* Chapter buttons always above sun */
.chapter-list,
#chapter6.active .content {
  position: relative;
  z-index: 20;
}
/* ================= CONTACT POPUP RESET ================= */

#contact-cloud {
  opacity: 0;
  pointer-events: none;
  background: #0f172a;   /* solid */
  color: #ffffff;
  backdrop-filter: none;
  z-index: 50;           /* ABOVE buttons */
}
#contact-cloud.show {
  opacity: 1;
  pointer-events: auto;
}
#contact-cloud::after {
  background: #0f172a;
}
#contact-art {
  z-index: 30;
}
/* ========================================================= */
/* =============== FINAL LAYER OVERRIDE ==================== */
/* ========================================================= */

/* Clouds always above sun */
#cloud-layer {
  z-index: 6;
}

/* Sun always below clouds */
.ambient-gif {
  z-index: 4 !important;
}

/* Content above sun */
.scene.active .content {
  z-index: 20;
}
.cloud {
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.4));
}
/* === FIX: READ BUTTON ON LAST PAGE === */
#chapter6.active .content {
  pointer-events: auto !important;
  position: relative;
  z-index: 50;
}

#chapter6.active .content .btn {
  pointer-events: auto !important;
  opacity: 1;
}
/* ================= LAST PAGE CENTERING ================= */

#chapter6.active .end-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;

  height: 100%;
  pointer-events: auto !important;
  z-index: 50;
}

#chapter6.active .end-content .btn {
  margin-top: 40px;
}
/* ================= SUN INTERACTION FIX ================= */

.ambient-gif.show {
  pointer-events: auto;
  cursor: pointer;
  z-index: 4; /* stays below content */
}
