/* =====================================================================
   Evelyn Dunlap Foundation – Mobile‑first enhancements
   Add this file AFTER the main <style> block or bundle it via <link> so
   that these rules override previous declarations.
   ===================================================================== */

/* ---------- 1. Safer full‑viewport hero on iOS & Android ---------- */
.hero {
  /* 100svh fixes Safari tool‑bar jump, falls back to 100vh elsewhere */
  min-height: 100svh;
  min-height: 100dvh;
}

@supports (height: 100lvh) {
  .hero {
    /* Let hero bleed under iOS browser UI */
    min-height: 100lvh;
  }
}

/* ---------- 2. Mobile hero fallback (keep video, add background color) */
@media (max-width: 768px) {
  .hero { background: var(--dark-bg); }

  /* Stronger tint for better mobile text contrast */
  .hero-tint {
    opacity: 0.95;
  }

  .hero-light-scatter {
    opacity: 0.45;
    filter: blur(48px);
  }

  .hero-overlay {
    opacity: 1;
    background:
      radial-gradient(circle at 20% 20%, rgba(52, 84, 209, 0.2), transparent 55%),
      radial-gradient(circle at 80% 75%, rgba(229, 169, 188, 0.14), transparent 60%),
      linear-gradient(180deg,
        rgba(10, 12, 21, 0.95) 0%,
        rgba(10, 12, 21, 0.85) 55%,
        rgba(10, 12, 21, 0.98) 100%);
  }

  /* Darker video for readability */
  .hero-video {
    filter: brightness(0.28) saturate(0.78) contrast(1.18) hue-rotate(4deg);
  }
}

/* ---------- 3. Header & navigation scale‑down --------------------- */
@media (max-width: 768px) {
  header { padding: 0.75rem 0; }
  .header-logo-img { height: 92px; }
  .nav-list { gap: 1.25rem; }
  header.scrolled { padding: 0.75rem 0; }
}

/* ---------- 4. Typography – readable sizes & tighter line‑height ---- */
@media (max-width: 576px) {
  h1, .hero-title { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  p  { font-size: 1rem; line-height: 1.6; }

  .hero-title {
    max-width: 16ch;
    letter-spacing: -0.015em;
    line-height: 1.12;
  }

  .section-title {
    max-width: 20ch;
    letter-spacing: -0.01em;
  }
}

/* ---------- 4b. Quote legibility on mobile ------------------------- */
@media (max-width: 768px) {
  .section.quote-section {
    padding: clamp(1.5rem, 4vh, 2.5rem) 0;
  }

  .elegance-quote {
    color: #f8f9ff;
    background: linear-gradient(
      135deg,
      rgba(10, 12, 21, 0.88),
      rgba(20, 24, 42, 0.82)
    );
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    line-height: 1.75;
    font-weight: 500;
    font-size: clamp(1.05rem, 4.2vw, 1.35rem);
    padding: 1.75rem 1.4rem;
  }

  .elegance-quote::before,
  .elegance-quote::after {
    opacity: 0.12;
  }
}

/* ---------- 5. Grid collapses for narrow viewports ------------------ */
@media (max-width: 768px) {
  .donation-methods,
  .partners-grid,
  .team-grid,
  .testimonials-grid,
  .grid,
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr !important; }

  .impact-stats { grid-template-columns: 1fr; }
}

/* ---------- 6. Touch‑friendly hit‑areas ---------------------------- */
button,
.btn,
.mobile-nav-link { min-height: 48px; }

/* ---------- 7. Disable heavy parallax on mobile -------------------- */
@media (max-width: 768px) {
  .decorative-element { transform: none !important; filter: blur(45px); }
}

/* ---------- 8. Respect user motion & accessibility preferences ------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .hero { background: var(--dark-bg); }
}

/* ---------- 9. Safe‑area padding for iPhone Notch ------------------ */
body {
  padding-top: env(safe-area-inset-top); /* constant() fallback removed per spec */
}

/* ---------- 10. Subtle glow opacity tweak on OLED dark‑mode -------- */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .decorative-element { opacity: 0.08; }
}

/* ---------- 11. Touch feedback for iPhone-class devices ---------- */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .payment-button,
  .mobile-toggle,
  .nav-link,
  .mobile-nav-link {
    -webkit-tap-highlight-color: transparent;
  }

  .btn:active,
  .payment-button:active,
  .rsvp-button:active,
  .application-btn:active {
    transform: scale(0.98);
  }

  .card:active,
  .glass-card:active,
  .partner-card:active,
  .event-card:active,
  .donation-method:active {
    transform: translateY(-3px);
  }

  .team-member:active .member-img-container {
    border-color: var(--soft-pink);
    box-shadow: 0 12px 28px rgba(229, 169, 188, 0.35);
  }
}

/* ---------- 12. Premium Touch Feedback ---------- */
/* Touch-optimized haptic-style feedback */
@media (hover: none) and (pointer: coarse) {
  .btn:active,
  .payment-button:active {
    transform: scale(0.96) translateY(-2px);
    filter: brightness(1.15);
    box-shadow:
      0 8px 35px rgba(52, 84, 209, 0.4),
      inset 0 2px 10px rgba(255, 255, 255, 0.2);
    transition: all 0.15s ease-out;
  }

  .glass-card:active,
  .scholarship-card:active {
    transform: scale(0.98);
    filter: brightness(1.1);
    box-shadow:
      0 12px 45px rgba(52, 84, 209, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }

  /* Elegant ripple effect on tap */
  .btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
      circle at center,
      rgba(255, 255, 255, 0.35),
      transparent 70%
    );
    opacity: 0;
    transform: scale(0);
    border-radius: inherit;
    transition: opacity 0.4s, transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
  }

  .btn:active::after {
    opacity: 1;
    transform: scale(2);
  }
}

/* ---------- 13. iOS safe-area adjustments ---------- */
@supports (-webkit-touch-callout: none) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    -webkit-font-smoothing: antialiased;
  }

  .mobile-nav {
    -webkit-overflow-scrolling: touch;
  }

  .hero-scroll {
    bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .back-to-top {
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    right: calc(1.2rem + env(safe-area-inset-right));
  }

  .mobile-nav {
    height: 100dvh;
    min-height: 100svh;
    padding-top: calc(6rem + env(safe-area-inset-top));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }

  .hero-video {
    filter: none !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    object-position: center 35%;
  }

  .soiree-media,
  .soiree-video {
    filter: brightness(0.34) saturate(0.85) contrast(1.12);
    transform: translate3d(-50%, -50%, 0);
    -webkit-transform: translate3d(-50%, -50%, 0);
    backface-visibility: hidden;
    width: 100%;
    height: 100%;
    object-position: center;
  }

  .hero-aurora {
    opacity: 0.4;
    filter: blur(38px) saturate(1.15);
  }

  .hero-mesh {
    opacity: 0.24;
    filter: blur(44px) saturate(1.05);
  }

  .hero-orbs {
    opacity: 0.18;
    filter: blur(28px) saturate(1.02);
  }

  .hero-title::before {
    opacity: 0.32;
    filter: blur(34px);
  }

  .donation-card {
    text-align: left;
    padding: 1.5rem;
    gap: 1.2rem;
  }

  .donation-impact--hero {
    padding: 1.5rem;
    gap: 1.25rem;
  }

  .donation-impact--hero .impact-stats {
    grid-template-columns: 1fr;
  }

  .donation-impact--hero .impact-stat {
    padding: 1rem 1.1rem;
  }

  .donation-widget {
    padding: 1.5rem;
    gap: 1.4rem;
  }

  .donation-widget-subtitle {
    font-size: 0.95rem;
  }

  .donation-flow {
    gap: 1.5rem;
  }

  .donation-tabs {
    padding: 1rem;
  }

  .donation-tablist {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .donation-tab {
    flex-direction: column;
    font-size: 0.72rem;
    gap: 0.35rem;
    padding: 0.6rem 0.45rem;
  }

  .donation-panel-note {
    font-size: 0.82rem;
  }

  .donation-details {
    padding: 0.85rem 1rem;
  }

  .donation-card-title {
    font-size: 1.3rem;
  }

  .donation-card-tag {
    letter-spacing: 1.6px;
    font-size: 0.7rem;
  }

  .donation-card-description {
    font-size: 0.98rem;
  }

  .donation-info-item dd {
    font-size: 0.98rem;
  }

  .donation-note {
    font-size: 0.85rem;
  }

  .donation-card-footnote {
    font-size: 0.82rem;
  }

  .donation-action {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 0.75rem;
  }

  .donation-accepted img {
    max-width: 170px;
  }

  .donation-paypal-form {
    max-width: 100%;
  }

  .donation-support-grid .donation-card {
    padding: 1.4rem;
  }

  .donation-steps li {
    padding-left: 1.85rem;
  }

  .hero-overlay {
    opacity: 0.88;
  }

  /* iOS-specific donation banner fixes */
  .donation-banner {
    /* Force hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    /* Ensure banner color renders consistently on iOS */
    background-color: #3454d1;
    background-image: linear-gradient(135deg,
      rgba(52, 84, 209, 0.98) 0%,
      rgba(78, 107, 230, 0.98) 50%,
      rgba(90, 126, 240, 0.98) 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;

    /* Ensure proper rendering */
    will-change: transform;
    -webkit-font-smoothing: antialiased;

    /* Safe area handled via content padding */
    top: 0;
  }

  .donation-banner-content {
    /* Add safe area padding for notched devices */
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0));
    padding-left: max(1rem, env(safe-area-inset-left, 1rem));
    padding-right: max(1rem, env(safe-area-inset-right, 1rem));
  }

  .section {
    scroll-margin-top: calc(7rem + 52px + env(safe-area-inset-top, 0));
  }

  body.banner-collapsed .section {
    scroll-margin-top: calc(7rem + env(safe-area-inset-top, 0));
  }

  #applicationForm {
    scroll-margin-top: calc(7rem + 52px + env(safe-area-inset-top, 0));
  }

  body.banner-collapsed #applicationForm {
    scroll-margin-top: calc(7rem + env(safe-area-inset-top, 0));
  }

  /* Adjust header for iOS safe area when banner is visible */
  header {
    top: calc(52px + env(safe-area-inset-top, 0));
  }

  /* When banner is hidden */
  .donation-banner.hidden ~ header,
  .donation-banner.scroll-hidden ~ header {
    top: env(safe-area-inset-top, 0);
  }

  body.banner-collapsed header {
    top: env(safe-area-inset-top, 0);
  }

  .donation-banner-content {
    /* Better text rendering on iOS */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .donation-banner-text {
    /* Prevent text from being too small on iOS */
    -webkit-text-size-adjust: 100%;
  }

  .donation-banner-btn {
    /* Better tap target for iOS */
    -webkit-tap-highlight-color: transparent;
    /* Force hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  .donation-banner-close {
    /* Better tap target for iOS */
    -webkit-tap-highlight-color: transparent;
    /* Force GPU rendering */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  /* Fix for iOS backdrop-filter bug */
  .donation-banner::before {
    /* Ensure shimmer works on iOS */
    -webkit-transform: translateX(-100%);
    will-change: transform;
  }

  .btn:not(.btn-alt):not(.btn-gold) {
    background-color: #3454d1;
    background-image: linear-gradient(135deg,
      rgba(52, 84, 209, 0.98) 0%,
      rgba(78, 107, 230, 0.98) 50%,
      rgba(90, 126, 240, 0.98) 100%);
  }
}

/* ---------- 14. Mobile Donation Banner Optimization ---------- */
@media (max-width: 768px) {
  /* Simplified layout for mobile */
  .donation-banner {
    box-shadow:
      0 4px 16px rgba(0, 0, 0, 0.2),
      0 1px 4px rgba(0, 0, 0, 0.1);
  }

  /* Better contrast for mobile */
  .donation-banner-message {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }

  /* Ensure icon is visible */
  .donation-banner-icon {
    filter: drop-shadow(0 1px 4px rgba(255, 107, 157, 0.6));
  }

  /* Better button visibility */
  .donation-banner-btn {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.2),
      0 1px 3px rgba(0, 0, 0, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .donation-banner-content {
    padding: 0.7rem 0.6rem;
  }

  .donation-banner-text {
    gap: 0.35rem;
  }

  .donation-banner-icon {
    font-size: 1.1rem;
  }

  .paypal-logo {
    height: 16px;
  }

  .donation-banner-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.65rem;
    letter-spacing: 0.3px;
  }

  .donation-banner-close {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
  }

  .donation-banner-close svg {
    width: 14px;
    height: 14px;
  }
}

/* ---------- 15. Premium Smooth Scrolling ---------- */
/* Premium scroll experience for mobile */
@media (max-width: 768px) {
  html {
    scroll-behavior: smooth;
  }

  body {
    -webkit-overflow-scrolling: touch;
  }

  input,
  select,
  textarea,
  .form-control,
  .footer-newsletter-input {
    font-size: 16px;
  }

  /* Momentum-based smooth scrolling */
  .section {
    scroll-snap-align: start;
  }

  /* Elegant fade on scroll for hero */
  .hero-content {
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  }

  /* Enhanced text gradient animation */
  .text-gradient {
    background-size: 200% 100%;
    animation: shimmer 8s linear infinite;
  }
}
