/**
 * ===================================================================
 * BLOOM 2.0 — Comprehensive Mobile-First & Phone Optimization Styles
 * ===================================================================
 * 
 * Optimized for:
 * - iPhone SE / Mini (360px - 375px)
 * - iPhone standard / Pro (390px - 393px)
 * - iPhone Pro Max / Pixel (412px - 430px)
 * - iPads / Tablets (768px - 1024px)
 * - Modern Desktops & Laptops (1440px+)
 * - Orientation changes & dynamic viewport height
 * - Accessibility (Reduced motion)
 */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@supports (padding-top: env(safe-area-inset-top)) {
  .audio-control-pill {
    top: calc(0.9rem + var(--safe-top));
    right: calc(0.9rem + var(--safe-right));
  }

  .scene-progress-container {
    bottom: calc(1rem + var(--safe-bottom));
  }
}

/* ===================================================================
   MOBILE DEVICES (Phones: <= 768px)
   =================================================================== */

@media (max-width: 768px) {
  .custom-cursor-dot,
  .custom-cursor-ring {
    display: none !important;
  }

  body {
    cursor: auto !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .experience-viewport {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .scene {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh;
    min-height: -webkit-fill-available;
    padding: calc(3.6rem + var(--safe-top)) 1.2rem calc(4.6rem + var(--safe-bottom)) 1.2rem;
    justify-content: center;
  }

  .audio-control-pill {
    top: calc(0.85rem + var(--safe-top));
    right: calc(0.85rem + var(--safe-right));
    padding: 0.5rem 0.9rem;
    font-size: 0.7rem;
    min-height: 42px;
  }

  .btn-primary-bloom {
    padding: 1rem 2rem;
    font-size: 1.12rem;
    width: 100%;
    max-width: 320px;
    min-height: 52px;
    margin-top: 1.3rem;
    touch-action: manipulation;
  }

  .btn-secondary-bloom {
    padding: 0.85rem 1.8rem;
    font-size: 0.85rem;
    width: 100%;
    max-width: 300px;
    min-height: 48px;
    margin-top: 1.1rem;
    touch-action: manipulation;
  }

  .scene-progress-container {
    bottom: calc(0.85rem + var(--safe-bottom));
  }

  .progress-dots {
    padding: 0.35rem 0.7rem;
    gap: 0.45rem;
  }

  .progress-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    min-height: 6px;
  }

  /* Scene 01 — Signature Title */
  .s1-container { max-width: 440px; padding: 0 0.8rem; }
  .s1-lily-silhouette { width: 280px; height: 280px; }
  .s1-signature-title-wrap { gap: 0.75rem; margin-bottom: 0.4rem; }
  .s1-main-title {
    font-size: clamp(2.6rem, 10vw, 4.2rem);
    letter-spacing: clamp(0.2em, 2vw, 0.32em);
    padding-left: clamp(0.2em, 2vw, 0.32em);
  }
  .s1-flanking-petal { width: 28px; height: 28px; }
  .s1-subtitle { font-size: clamp(1.15rem, 4.2vw, 1.55rem); margin: 0.2rem 0 0.9rem 0; }
  .s1-film-divider { max-width: 220px; margin-bottom: 0.9rem; }
  .s1-supporting { font-size: clamp(0.85rem, 3.2vw, 1rem); margin-bottom: 1.6rem; letter-spacing: 0.1em; }

  /* Scene 02 — The First Bloom */
  .s2-flower-stage {
    width: clamp(220px, 58vw, 280px);
    height: clamp(220px, 58vw, 280px);
    margin-bottom: 0.8rem;
  }
  .s2-poetry-block { min-height: 65px; }
  .s2-line { font-size: clamp(1.3rem, 4.6vw, 1.7rem); }
  .lily-variety-pills {
    gap: 0.5rem;
    margin-top: 0.8rem;
  }
  .lily-pill {
    padding: 0.45rem 0.85rem;
    font-size: 0.72rem;
  }
  .s2-flower-desc {
    font-size: 0.82rem;
    max-width: 320px;
  }

  /* Scene 03 — The Blooming Garden */
  .s3-garden-backdrop {
    top: 0;
    left: -15%;
    width: 130%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
  }
  .s3-content-overlay {
    padding: 1.8rem 1.2rem;
    margin: 0 0.5rem;
  }

  /* Scene 04 — Little Things */
  .little-things-title {
    font-size: clamp(1.6rem, 5.5vw, 2.2rem);
    margin-bottom: 1.4rem;
  }
  .little-things-cards {
    width: 100%;
    min-height: 190px;
  }
  .little-card {
    padding: 1.8rem 1.4rem;
  }
  .card-text {
    font-size: clamp(1.15rem, 4vw, 1.4rem);
  }

  /* Scene 05 — A Thousand Petals (Interactive Sanctuary) */
  .sanctuary-title {
    font-size: clamp(1.6rem, 5.5vw, 2.2rem);
  }
  .sanctuary-hint {
    font-size: clamp(0.7rem, 2.6vw, 0.8rem);
    margin-bottom: 1.1rem;
  }
  .interactive-lilies-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
    width: 100%;
    max-width: 340px;
    margin: 0.4rem auto 0.9rem auto;
  }
  .interactive-lily-node {
    width: 100%;
    min-height: 120px;
    padding: 0.6rem 0.4rem 0.45rem 0.4rem;
    border-radius: 18px;
  }
  .node-img-wrapper {
    height: 72px;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.35rem;
  }
  .mini-cluster-img {
    width: 86px;
    height: 86px;
    max-width: none;
    max-height: none;
    transform: scale(1.35) translateZ(0);
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(244, 183, 200, 0.5));
  }
  .node-flower-name {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #FFF9F7;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  }
  .hidden-discovery-box {
    padding: 0.85rem 1.3rem;
    max-width: 340px;
    margin-bottom: 1.1rem;
  }
  .discovery-text {
    font-size: 1.02rem;
  }

  /* Scene 06 — The Almost Confession */
  .s6-whisper-line {
    font-size: clamp(1.15rem, 4vw, 1.5rem);
    margin-bottom: 0.6rem;
  }
  .s6-whisper-line.highlight-whisper {
    font-size: clamp(1.45rem, 5.4vw, 1.95rem);
  }

  /* Scene 07 — The Little Letter */
  .s7-container { height: 100%; max-width: 440px; }
  .envelope-stage { width: clamp(280px, 88vw, 380px); }
  .envelope-wrapper { height: 240px; }
  .letter-sheet {
    top: 50%;
    left: 50%;
    width: 92vw;
    max-width: 440px;
    max-height: 72vh;
    max-height: 72dvh;
    padding: 2rem 1.3rem;
    transform: translate(-50%, -45%) scale(0.92);
  }
  .envelope-stage.envelope-open .letter-sheet {
    transform: translate(-50%, -50%) scale(1);
  }
  .letter-header { font-size: 1.6rem; }
  .letter-body { font-size: 1.08rem; line-height: 1.7; }

  /* Scene 08 — Words Left Unsaid (SECTION 8) */
  .s8-text-reveal-container {
    padding: 1.6rem 1.2rem;
    max-width: 440px;
  }
  .s8-reveal-title {
    font-size: clamp(1.6rem, 5.5vw, 2.3rem);
    margin-bottom: 1.4rem;
  }
  .s8-reveal-line {
    font-size: clamp(1.05rem, 3.8vw, 1.35rem);
    line-height: 1.6;
    margin-bottom: 0.8rem;
  }
  .s8-reveal-line.highlight-line {
    font-size: clamp(1.2rem, 4.4vw, 1.55rem);
    margin-top: 1.1rem;
  }

  /* Scene 09 — The Indirect Proposal (SECTION 9) */
  .s9-proposal-card {
    padding: 1.8rem 1.2rem;
    max-width: 440px;
    border-radius: 20px;
  }
  .proposal-main-heading {
    font-size: clamp(1.5rem, 5.2vw, 2.2rem);
    margin-bottom: 0.8rem;
  }
  .proposal-supporting-text {
    font-size: clamp(0.95rem, 3.4vw, 1.15rem);
    line-height: 1.6;
    margin-bottom: 1.1rem;
  }
  .proposal-question-highlight {
    font-size: clamp(1.15rem, 4.2vw, 1.45rem);
    margin-bottom: 1.3rem;
  }
  .proposal-choices-group {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  .btn-proposal-choice {
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-size: 1rem;
  }
  .proposal-response-box {
    padding: 1rem 1.2rem;
    margin-top: 1.1rem;
  }
  .response-text {
    font-size: 1.05rem;
  }

  /* Scene 10 — Make a Wish (SECTION 10) */
  .s10-wish-container {
    padding: 1.5rem 1rem;
    max-width: 440px;
  }
  .s10-wish-title {
    font-size: clamp(1.6rem, 5.5vw, 2.3rem);
    margin-bottom: 0.4rem;
  }
  .s10-wish-hint {
    font-size: clamp(0.9rem, 3.2vw, 1.05rem);
    margin-bottom: 1rem;
  }
  .s10-wish-flower-stage {
    width: clamp(210px, 56vw, 270px);
    height: clamp(210px, 56vw, 270px);
    margin-bottom: 0.8rem;
  }
  .s10-wish-svg {
    width: 100%;
    height: 100%;
  }
  .wish-reveal-box {
    padding: 1rem 1.2rem;
    max-width: 340px;
    margin-top: 0.9rem;
  }
  .wish-message-text {
    font-size: clamp(1rem, 3.6vw, 1.2rem);
  }

  /* Scene 11 — Developer Signature (SECTION 11) */
  .s11-signature-container {
    padding: 1.8rem 1.2rem;
    max-width: 440px;
  }
  .s10-main-heading {
    font-size: clamp(1.5rem, 5.2vw, 2.1rem);
  }
  .s10-supporting-text {
    font-size: clamp(0.95rem, 3.2vw, 1.15rem);
    margin-bottom: 1.2rem;
  }
  .s10-author-name {
    font-size: clamp(1.35rem, 4.6vw, 1.75rem);
  }
  .s10-social-links {
    flex-direction: column;
    gap: 0.7rem;
    width: 100%;
  }
  .dev-social-pill {
    width: 100%;
    justify-content: center;
  }
}

/* ===================================================================
   ULTRA-COMPACT PHONES (<= 375px)
   =================================================================== */

@media (max-width: 375px) {
  .scene {
    padding: calc(3rem + var(--safe-top)) 0.8rem calc(4rem + var(--safe-bottom)) 0.8rem;
  }

  .s1-container { max-width: 320px; }
  .s1-signature-title-wrap { gap: 0.5rem; }
  .s1-main-title { font-size: 2.35rem; letter-spacing: 0.18em; padding-left: 0.18em; }
  .s1-flanking-petal { width: 22px; height: 22px; }
  .s1-eyebrow { font-size: 0.65rem; letter-spacing: 0.16em; padding: 0.35rem 0.8rem; }
  .s1-subtitle { font-size: 1.05rem; }
  .s1-supporting { font-size: 0.82rem; margin-bottom: 1.3rem; }
  .s2-flower-stage { width: 200px; height: 200px; }
  .lily-pill { padding: 0.4rem 0.75rem; font-size: 0.7rem; }
  .interactive-lilies-grid { max-width: 285px; gap: 0.65rem; margin: 0.3rem auto 0.6rem auto; }
  .interactive-lily-node { width: 100%; min-height: 102px; padding: 0.45rem 0.3rem 0.35rem 0.3rem; }
  .node-img-wrapper { height: 62px; }
  .mini-cluster-img { width: 72px; height: 72px; transform: scale(1.3) translateZ(0); }
  .node-flower-name { font-size: 0.6rem; letter-spacing: 0.06em; }
  .envelope-stage { width: 260px; }
  .envelope-wrapper { height: 210px; }
  .letter-sheet { padding: 1.6rem 0.95rem; }
  .s8-reveal-title { font-size: 1.5rem; }
  .s8-reveal-line { font-size: 1rem; }
  .s9-proposal-card { padding: 1.4rem 1rem; }
  .proposal-main-heading { font-size: 1.4rem; }
  .s10-wish-flower-stage { width: 190px; height: 190px; }
  .s11-signature-container { padding: 1.4rem 1rem; }
}

/* ===================================================================
   MOBILE LANDSCAPE ORIENTATION
   =================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
  .scene { padding: 1rem 2rem; }
  .audio-control-pill { top: 0.6rem; right: 0.8rem; }
  .scene-progress-container { bottom: 0.5rem; }
  .s1-lily-silhouette { width: 180px; height: 180px; }
  .s2-flower-stage { width: 150px; height: 150px; }
  .envelope-wrapper { height: 170px; }
  .s10-wish-flower-stage { width: 150px; height: 150px; }
}

/* ===================================================================
   ACCESSIBILITY: PREFERS REDUCED MOTION
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  #particleCanvas { display: none !important; }

  .scene {
    transition: none !important;
    transform: none !important;
    filter: none !important;
  }
}
