/**
 * ═══════════════════════════════════════════════════════════════════════════
 * MOBILE SAFARI OPTIMIZATION LAYER (V13)
 * ═══════════════════════════════════════════════════════════════════════════
 * Targeted fixes for iPhone Safari (iOS 16+) without breaking desktop.
 * Focuses on: safe areas, touch behavior, viewport height, button visibility.
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════
 * 1. GLOBAL TOUCH BEHAVIOR & SAFE AREAS
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Prevent body bounce scroll on iOS */
html, body {
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

/* Ensure overflow hidden prevents horizontal scroll */
body {
  overflow-x: hidden !important;
}

/* Enhanced touch-action for ALL interactive elements */
button,
[role="button"],
.rm-btn,
.rm-scene-next,
.rm-scene-restart,
.rm-music-button,
.rm-curtain__btn,
.rm-curtain__heart,
.rm-polaroid,
.rm-animal-card,
.rm-animal-solo,
.rm-highlight-eyes,
.rm-envelope,
.rm-lightbox__close,
.rm-lightbox__nav,
.rm-photo-stack__item,
.rm-btn--hold,
.rm-btn--heartburst,
.rm-btn--skip,
.rm-animals-skip,
a[href],
[tabindex]:not([tabindex="-1"]) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 2. MOBILE VIEWPORT & SAFE AREA FIXES (< 768px)
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* ─────────────────────────────────────────────────────────────────────────
   * 2.1 CORE SHELL & SCENE CONTAINER
   * ───────────────────────────────────────────────────────────────────────── */
  
  html {
    /* Fallback for older Safari */
    height: 100%;
    height: -webkit-fill-available;
  }
  
  body {
    min-height: 100%;
    min-height: -webkit-fill-available;
  }
  
  .rm-shell {
    /* Fill available space properly on iOS */
    min-height: 100%;
    min-height: -webkit-fill-available;
  }
  
  /* ─────────────────────────────────────────────────────────────────────────
   * 2.2 ALL SCENES - BASE MOBILE LAYOUT
   * ───────────────────────────────────────────────────────────────────────── */
  
  .rm-scene {
    /* Allow vertical scroll when needed */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    
    /* Safe area padding */
    padding-top: calc(var(--rm-space-4) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--rm-space-6) + env(safe-area-inset-bottom, 20px));
    padding-left: calc(var(--rm-space-3) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--rm-space-3) + env(safe-area-inset-right, 0px));
    
    /* Ensure content is centered and not cut off */
    justify-content: flex-start;
    align-items: center;
    gap: var(--rm-space-4);
  }
  
  /* Scene content container - constrain width for readability */
  .rm-scene__content {
    width: 100%;
    max-width: 100%;
    padding: var(--rm-space-2);
    gap: var(--rm-space-4);
  }
  
  /* ─────────────────────────────────────────────────────────────────────────
   * 2.3 NAVIGATION BUTTONS - ALWAYS REACHABLE
   * ───────────────────────────────────────────────────────────────────────── */
  
  .rm-scene__nav {
    width: 100%;
    margin-top: auto;
    padding-top: var(--rm-space-4);
    padding-bottom: env(safe-area-inset-bottom, 10px);
    flex-shrink: 0;
  }
  
  /* Ensure buttons are large enough to tap (min 44px) */
  .rm-btn {
    min-height: 48px;
    min-width: 160px;
    padding: 12px 20px;
    font-size: 0.95rem;
  }
  
  .rm-btn--continue {
    width: 100%;
    max-width: 320px;
  }
  
  .rm-btn--special {
    min-width: 280px;
    max-width: 100%;
    font-size: 0.9rem;
    padding: 14px 20px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 3. CURTAIN SCENE - FULLY VISIBLE ON SMALL SCREENS
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-curtain {
    /* Ensure proper safe area handling */
    padding: calc(var(--rm-space-6) + env(safe-area-inset-top, 0px)) 
             calc(var(--rm-space-4) + env(safe-area-inset-right, 0px)) 
             calc(var(--rm-space-6) + env(safe-area-inset-bottom, 20px)) 
             calc(var(--rm-space-4) + env(safe-area-inset-left, 0px));
  }
  
  .rm-curtain__content {
    max-width: 90%;
  }
  
  .rm-curtain__heart {
    font-size: 2.5rem;
  }
  
  .rm-curtain__text {
    font-size: 1.25rem;
  }
  
  .rm-curtain__hint {
    font-size: 0.85rem;
    margin-bottom: var(--rm-space-4);
  }
  
  .rm-curtain__btn {
    padding: 14px 36px;
    font-size: 1rem;
    min-height: 48px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 4. HERO SCENE - FIT CONTENT VERTICALLY
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--hero {
    justify-content: center;
    padding-top: calc(var(--rm-space-8) + env(safe-area-inset-top, 0px));
  }
  
  .rm-hero-card {
    padding: var(--rm-space-5) var(--rm-space-4);
    max-width: 100%;
  }
  
  .rm-hero-label {
    font-size: 0.8rem;
    padding: var(--rm-space-1) var(--rm-space-3);
    margin-bottom: var(--rm-space-4);
  }
  
  .rm-hero-title {
    font-size: 1.4rem;
    line-height: 1.35;
    margin-bottom: var(--rm-space-3);
  }
  
  .rm-hero-text {
    font-size: 1rem;
    margin-bottom: var(--rm-space-2);
  }
  
  .rm-hero-subtitle {
    font-size: 1.1rem;
  }
  
  /* Waiting text smaller */
  .rm-scene__waiting {
    font-size: 0.8rem;
  }
}

/* Extra small height (iPhone SE) */
@media (max-width: 767px) and (max-height: 700px) {
  .rm-scene--hero {
    justify-content: flex-start;
    padding-top: calc(var(--rm-space-4) + env(safe-area-inset-top, 0px));
  }
  
  .rm-hero-card {
    padding: var(--rm-space-4) var(--rm-space-3);
  }
  
  .rm-hero-title {
    font-size: 1.25rem;
    margin-bottom: var(--rm-space-2);
  }
  
  .rm-hero-text {
    font-size: 0.9rem;
  }
  
  .rm-hero-subtitle {
    font-size: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 5. LOVE SCENE - STACKED LAYOUT
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--love .rm-split-layout {
    flex-direction: column;
    gap: var(--rm-space-5);
  }
  
  .rm-split-layout__content {
    max-width: 100%;
    order: 1;
  }
  
  .rm-split-layout__media {
    order: 2;
    max-width: 100%;
    perspective: none;
  }
  
  .rm-content-card {
    padding: var(--rm-space-4);
  }
  
  .rm-content-card__title {
    font-size: 1.15rem;
  }
  
  .rm-content-card__text {
    font-size: 0.95rem;
  }
  
  /* Photo stack sizing */
  .rm-photo-stack {
    max-width: 280px;
    height: 220px;
    margin: 0 auto;
  }
  
  .rm-photo-stack__item {
    width: 150px;
    height: 180px;
  }
  
  /* Prevent rotated photos from causing overflow */
  .rm-photo-stack__item--back {
    transform: rotate(-4deg);
  }
  
  .rm-photo-stack__item--front {
    transform: rotate(3deg);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 6. GALLERY SCENE - CRITICAL MOBILE FIXES
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--gallery {
    /* Allow scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: calc(var(--rm-space-4) + env(safe-area-inset-top, 0px));
  }
  
  .rm-scene--gallery .rm-scene__content--gallery {
    min-height: auto;
    padding-bottom: 100px; /* Space for sticky button */
  }
  
  /* Section intro - more compact */
  .rm-scene--gallery .rm-section-intro {
    margin-bottom: var(--rm-space-3);
  }
  
  .rm-section-intro__title {
    font-size: 1.05rem;
    line-height: 1.4;
  }
  
  .rm-section-intro__label {
    font-size: 0.75rem;
  }
  
  /* Gallery grid - 2 columns, tighter spacing */
  .rm-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--rm-space-3);
    padding: 0 var(--rm-space-1);
    perspective: none; /* Disable 3D on mobile for performance */
  }
  
  /* Polaroid sizing */
  .rm-polaroid {
    max-width: 100%;
    width: 100%;
    padding: 6px;
    padding-bottom: 32px;
  }
  
  .rm-polaroid__caption {
    font-size: 0.7rem;
    bottom: 6px;
  }
  
  /* Sticky nav with gradient fade */
  .rm-scene--gallery .rm-scene__nav--gallery {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: linear-gradient(
      to top,
      rgba(34, 22, 53, 0.98) 0%,
      rgba(34, 22, 53, 0.95) 50%,
      rgba(34, 22, 53, 0) 100%
    );
    padding: var(--rm-space-6) var(--rm-space-4);
    padding-bottom: calc(var(--rm-space-4) + env(safe-area-inset-bottom, 16px));
    margin-top: var(--rm-space-4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  /* Simplify fly-in animation on mobile */
  .rm-fly-item {
    transform: none !important;
    opacity: 0;
    filter: blur(0);
  }
  
  .rm-fly-item.is-flying {
    animation: rm-polaroid-fly-in-mobile 600ms var(--rm-ease-spring) forwards;
  }
  
  .rm-fly-item.is-visible,
  .rm-fly-item.is-floating {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

/* Mobile-simplified fly-in animation */
@keyframes rm-polaroid-fly-in-mobile {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  70% {
    transform: scale(1.02) translateY(-4px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 7. DEEP FEELINGS SCENE - "GÖZLERİNİ" FIX
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--deep {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: calc(var(--rm-space-6) + env(safe-area-inset-top, 0px));
  }
  
  .rm-deep-card {
    padding: var(--rm-space-5) var(--rm-space-4);
    max-width: 100%;
  }
  
  .rm-deep-card__heading {
    font-size: 1.5rem;
    margin-bottom: var(--rm-space-4);
  }
  
  .rm-deep-card__text {
    font-size: 0.95rem;
    line-height: 1.75;
  }
  
  .rm-deep-card__text p {
    margin-bottom: var(--rm-space-3);
  }
  
  /* "Gözlerini" tap target - proper spacing on mobile */
  .rm-highlight-eyes {
    display: inline;
    padding: 2px 4px;
    margin: 0 2px;
    line-height: inherit;
    border-radius: 4px;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-decoration-color: currentColor;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 179, 198, 0.3);
    /* Ensure proper word spacing */
    white-space: nowrap;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }
  
  /* Mobile tooltip - compact card style */
  .rm-highlight-eyes.show-hint::before {
    content: "👆 Önce gözlerine dokun" !important;
    position: fixed !important;
    top: auto !important;
    bottom: 120px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    white-space: nowrap !important;
    max-width: 280px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 14px 24px;
    border-radius: 50px;
    background: rgba(255, 77, 109, 0.95) !important;
    color: #fff !important;
    box-shadow: 0 8px 32px rgba(255, 77, 109, 0.5), 0 0 0 2px rgba(255,255,255,0.2);
    z-index: 9999 !important;
    animation: rm-tooltip-bounce 0.5s ease-out !important;
  }
  
  /* Hide the arrow on mobile - using fixed position */
  .rm-highlight-eyes.show-hint::after {
    display: none !important;
  }
  
  @keyframes rm-tooltip-bounce {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.9); }
    50% { transform: translateX(-50%) translateY(-5px) scale(1.02); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  }
  
  /* Hold button - comfortable size */
  .rm-hold-container {
    margin-top: var(--rm-space-4);
  }
  
  .rm-btn--hold {
    min-height: 48px;
    padding: 14px 28px;
    font-size: 0.95rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 8. ANIMALS TIMELINE - STAGE FIT
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--animals {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: calc(var(--rm-space-4) + env(safe-area-inset-top, 0px));
  }
  
  .rm-animals-header {
    max-width: 100%;
    padding: 0 var(--rm-space-2);
    margin-bottom: var(--rm-space-3);
  }
  
  .rm-animals-header__title {
    font-size: 1.1rem;
    line-height: 1.35;
  }
  
  .rm-animals-header__text {
    font-size: 0.9rem;
  }
  
  /* Stage container - fit viewport */
  .rm-animals-stage {
    max-width: 100%;
    min-height: 260px;
    max-height: 50vh;
    padding: var(--rm-space-5);
    margin: var(--rm-space-3) 0;
  }
  
  .rm-animal-solo-container {
    min-height: 180px;
  }
  
  /* Animal image sizing */
  .rm-animal-solo__image {
    width: 90px;
    max-width: 80%;
  }
  
  .rm-animal-solo--primary .rm-animal-solo__image {
    width: 110px;
  }
  
  .rm-animal-solo--special .rm-animal-solo__image {
    width: 150px;
    max-width: 55%;
    border-radius: 16px;
  }
  
  .rm-animal-solo__name {
    font-size: 1rem;
  }
  
  /* Speech bubble - smaller and better positioned */
  .rm-animal-solo__bubble {
    max-width: 250px;
    padding: var(--rm-space-3) var(--rm-space-4);
    font-size: 0.85rem;
    bottom: calc(100% + var(--rm-space-2));
  }
  
  /* Progress indicator */
  .rm-animals-progress {
    font-size: 0.8rem;
    margin-top: var(--rm-space-3);
  }
  
  /* Skip button - larger tap target */
  .rm-btn--skip,
  .rm-animals-skip {
    min-height: 44px;
    min-width: 70px;
    padding: 10px 16px;
    font-size: 0.8rem;
  }
  
  /* Footer */
  .rm-animals-footer {
    padding: 0 var(--rm-space-2);
  }
  
  .rm-animals-footer__text {
    font-size: 0.9rem;
  }
}

/* Short height devices - more compact stage */
@media (max-width: 767px) and (max-height: 700px) {
  .rm-animals-stage {
    min-height: 220px;
    max-height: 45vh;
    padding: var(--rm-space-4);
  }
  
  .rm-animal-solo-container {
    min-height: 150px;
  }
  
  .rm-animal-solo__image {
    width: 70px;
  }
  
  .rm-animal-solo--primary .rm-animal-solo__image {
    width: 85px;
  }
  
  /* Köpüş still needs decent size on short screens */
  .rm-animal-solo--special .rm-animal-solo__image {
    width: 120px;
    max-width: 50%;
    border-radius: 12px;
  }
  
  .rm-animal-solo__bubble {
    font-size: 0.8rem;
    padding: var(--rm-space-2) var(--rm-space-3);
    max-width: 200px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 9. CLOSING SCENE - BUTTON VISIBILITY
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--closing {
    justify-content: center;
    padding-top: calc(var(--rm-space-6) + env(safe-area-inset-top, 0px));
  }
  
  .rm-closing__title {
    font-size: 1.25rem;
    line-height: 1.4;
    text-align: center;
    padding: 0 var(--rm-space-2);
  }
  
  .rm-closing__text {
    font-size: 1rem;
    text-align: center;
  }
  
  .rm-btn--heartburst {
    min-height: 48px;
    font-size: 0.9rem;
  }
  
  /* Ensure final CTA is never cut off */
  .rm-scene--closing .rm-scene__nav {
    margin-top: var(--rm-space-6);
    padding-bottom: calc(var(--rm-space-4) + env(safe-area-inset-bottom, 20px));
  }
}

/* Short screens */
@media (max-width: 767px) and (max-height: 700px) {
  .rm-closing__title {
    font-size: 1.1rem;
  }
  
  .rm-closing__text {
    font-size: 0.9rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 10. LETTER SCENE - ENVELOPE & SCROLLABLE LETTER
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-scene--letter {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  
  /* Envelope stage - ensure centered and hint visible */
  .rm-envelope-stage {
    min-height: 60vh;
    padding: var(--rm-space-6);
    gap: var(--rm-space-5);
    justify-content: center;
  }
  
  /* Envelope sizing */
  .rm-envelope {
    width: 240px;
    height: 170px;
    transform-origin: center center;
  }
  
  .rm-envelope:hover {
    transform: scale(1.02);
  }
  
  .rm-envelope__wax {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
  
  /* Hint text - CRITICAL: Must be visible fast on mobile */
  .rm-envelope__hint {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    display: block !important;
    text-align: center;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    margin-top: var(--rm-space-4);
    opacity: 0;
    animation: rm-envelope-hint-mobile 0.5s ease-out 0.3s forwards;
  }
  
  /* Letter content - scrollable */
  .rm-scene--letter .rm-scene__content--letter {
    max-height: none;
    padding: var(--rm-space-4);
    padding-bottom: calc(var(--rm-space-8) + env(safe-area-inset-bottom, 20px));
  }
  
  .rm-letter-card {
    max-height: none;
    overflow: visible;
    padding: var(--rm-space-5) var(--rm-space-4);
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .rm-letter-card__body {
    font-size: 1rem;
    line-height: 1.85;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  .rm-letter-card__body p {
    margin-bottom: 1.25em;
  }
  
  .rm-letter-card__title {
    font-size: 1.3rem;
  }
  
  .rm-letter-card__closing {
    font-size: 1.2rem !important;
  }
  
  .rm-letter-card__signature {
    font-size: 1.3rem !important;
  }
  
  /* Restart button */
  .rm-scene--letter .rm-scene__nav--final {
    padding-bottom: calc(var(--rm-space-6) + env(safe-area-inset-bottom, 20px));
  }
  
  .rm-btn--restart {
    min-height: 48px;
    font-size: 0.9rem;
  }
}

/* Envelope hint mobile animation */
@keyframes rm-envelope-hint-mobile {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Short screens - tighter letter */
@media (max-width: 767px) and (max-height: 700px) {
  .rm-envelope-stage {
    min-height: 55vh;
  }
  
  .rm-envelope {
    width: 200px;
    height: 145px;
  }
  
  .rm-letter-card__body {
    font-size: 0.95rem;
    line-height: 1.75;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 11. MUSIC BUTTON - SAFE AREA
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-music-button {
    /* Position respecting safe areas and not overlapping nav */
    bottom: calc(20px + env(safe-area-inset-bottom, 10px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  
  .rm-music-button__tooltip {
    display: none; /* Hide on mobile - not needed with touch */
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 12. LIGHTBOX - MOBILE TOUCH TARGETS
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .rm-lightbox__close {
    width: 48px;
    height: 48px;
    top: calc(var(--rm-space-3) + env(safe-area-inset-top, 10px));
    right: var(--rm-space-3);
    font-size: 1.5rem;
  }
  
  .rm-lightbox__nav {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
  }
  
  .rm-lightbox__nav--prev {
    left: var(--rm-space-2);
  }
  
  .rm-lightbox__nav--next {
    right: var(--rm-space-2);
  }
  
  .rm-lightbox__caption {
    font-size: 1rem;
    padding: 0 var(--rm-space-4);
  }
  
  .rm-lightbox__image {
    max-height: 70vh;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 13. AMBIENT LAYERS - REDUCE ON MOBILE FOR PERFORMANCE
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Reduce bokeh complexity */
  .rm-bokeh-dot {
    filter: blur(30px);
    opacity: 0.08;
  }
  
  /* Hide some bokeh dots on mobile */
  .rm-bokeh-dot--6,
  .rm-bokeh-dot--7,
  .rm-bokeh-dot--8,
  .rm-bokeh-dot--9,
  .rm-bokeh-dot--10 {
    display: none;
  }
  
  /* Reduce ambient hearts */
  .rm-ambient-heart:nth-child(n+6) {
    display: none;
  }
  
  .rm-ambient-heart {
    font-size: 14px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 14. REDUCED MOTION - MOBILE RESPECT
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .rm-fly-item,
  .rm-fly-item.is-flying {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  
  .rm-envelope__hint {
    animation: none !important;
    opacity: 1 !important;
  }
  
  .rm-gallery-scroll-indicator,
  .rm-gallery-scroll-indicator__arrow {
    animation: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 15. iOS NOTCH SPECIFIC (iPhone X and later)
 * ═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: max(0px)) {
  @media (max-width: 767px) {
    .rm-scene {
      padding-top: max(var(--rm-space-4), env(safe-area-inset-top));
      padding-bottom: max(var(--rm-space-6), calc(env(safe-area-inset-bottom) + 16px));
      padding-left: max(var(--rm-space-3), env(safe-area-inset-left));
      padding-right: max(var(--rm-space-3), env(safe-area-inset-right));
    }
    
    .rm-curtain {
      padding-bottom: max(var(--rm-space-6), calc(env(safe-area-inset-bottom) + 16px));
    }
    
    .rm-music-button {
      bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
      right: max(16px, env(safe-area-inset-right));
    }
  }
}

