/* ============================================================
   AYARN TRUST — Mobile Responsiveness & Enhanced Card Sheet
   Breakpoints:
     xs:  ≤ 480px  (small phones)
     sm:  ≤ 576px  (standard phones)
     md:  ≤ 768px  (large phones / small tablets)
     lg:  ≤ 992px  (tablets)
   ============================================================ */

/* ────────────────────────────────────────
   GLOBAL TOUCH DELAY REMOVAL
   ──────────────────────────────────────── */
a,
button,
[role="button"],
.filter-btn,
.flip-card-wrap,
.nav-link,
.btn,
.gallery-card,
.future-plan-card {
    touch-action: manipulation;
}

/* ────────────────────────────────────────
   1. GLOBAL BASE FIXES
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .py-5 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    section.py-5 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }

    .container,
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ────────────────────────────────────────
   2. NAVBAR
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar-brand-logo {
        height: 42px !important;
        width: auto !important;
    }

    .navbar-brand-text {
        display: none !important;
    }
    .navbar-slogan {
        font-size: 0.65rem !important;
        letter-spacing: 0.03em !important;
    }

    .nav-link {
        padding: 0.65rem 1rem !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    #appNavbar .navbar-nav {
        padding: 0.5rem 0;
        gap: 0 !important;
    }

    #appNavbar .d-flex.align-items-center {
        margin-top: 0.75rem;
        padding-bottom: 0.75rem;
        gap: 1rem !important;
        flex-wrap: wrap;
    }

    .btn-donate {
        width: 100%;
        justify-content: center;
    }

    .navbar-collapse.show,
    .navbar-collapse.collapsing {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-radius: 0 0 16px 16px;
        box-shadow: 0 12px 32px rgba(0, 70, 205, 0.15);
        padding: 0.5rem 1rem 1rem;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        z-index: 1029;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .navbar-brand-logo {
        height: 36px !important;
    }
}

/* ────────────────────────────────────────
   3. HERO SECTION
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    section[style*="min-height: 85vh"] {
        min-height: 75vh !important;
    }

    section .typewriter-text,
    .hero h1 {
        font-size: clamp(1.8rem, 7vw, 2.8rem) !important;
        line-height: 1.15 !important;
    }

    section .lead.fs-4 {
        font-size: 1rem !important;
    }

    section .d-flex.gap-3.flex-wrap.mt-2 {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    section .d-flex.gap-3.flex-wrap.mt-2 .btn {
        width: 100% !important;
        justify-content: center;
        font-size: 0.9rem !important;
        padding: 0.85rem 1rem !important;
    }
}

@media (max-width: 480px) {
    section[style*="min-height: 85vh"] {
        min-height: 60vh !important;
    }
    section .typewriter-text,
    .hero h1 {
        font-size: clamp(1.6rem, 8vw, 2.4rem) !important;
    }
}

/* ────────────────────────────────────────
   4. STATS / METRIC COUNTER GRID
   ──────────────────────────────────────── */
@media (max-width: 576px) {
    .counter-value {
        font-size: 1.75rem !important;
    }
    .stat-icon-wrap i {
        font-size: 1.2rem !important;
    }
    .col-6.col-md-3 .p-3 {
        padding: 0.5rem !important;
    }
    .counter-value + span {
        font-size: 0.62rem !important;
        word-break: break-word;
    }
}

@media (max-width: 360px) {
    .counter-value {
        font-size: 1.5rem !important;
    }
    .stat-icon-wrap i {
        font-size: 1rem !important;
    }
    .col-6.col-md-3 .p-3 {
        padding: 0.35rem !important;
    }
    .counter-value + span {
        font-size: 0.55rem !important;
    }
}

/* ────────────────────────────────────────
   5. AIMS & PRIORITIES INITIATIVE CARDS (index.php)
   ──────────────────────────────────────── */
.flip-card-wrap {
    perspective: 1200px;
    height: 240px;
}

.flip-front {
    position: relative;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(0, 70, 205, 0.1);
    box-shadow: 0 8px 30px rgba(0, 70, 205, 0.06);
    padding: 24px 20px;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.flip-front::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #0046cd, #38b6ff);
    opacity: 0.8;
    transition: height 0.3s ease;
}

.flip-front-icon {
    width: 60px; height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0046cd 0%, #1e68f6 100%);
    color: #ffffff;
    font-size: 1.4rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px -3px rgba(0, 70, 205, 0.35);
    margin-bottom: 16px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.flip-card-action-badge {
    display: none;
}

/* Mobile responsive card enhancements (<768px) */
@media (max-width: 767px) {
    .flip-card-wrap { height: auto !important; }
    .flip-card-wrap:hover .flip-card,
    .flip-card-wrap.flipped .flip-card { transform: rotateY(0) !important; }
    .flip-back { display: none !important; }

    .flip-front {
        position: relative !important;
        border-radius: 20px !important;
        background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%) !important;
        border: 1px solid rgba(0, 70, 205, 0.12) !important;
        box-shadow: 0 10px 28px -6px rgba(0, 70, 205, 0.1), 0 2px 8px rgba(0,0,0,0.02) !important;
        padding: 20px 16px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 14px !important;
        text-align: left !important;
    }

    .flip-front::before {
        top: 0; bottom: 0; left: 0; right: auto;
        width: 5px; height: 100%;
        background: linear-gradient(180deg, #0046cd 0%, #38b6ff 100%);
        border-radius: 20px 0 0 20px;
    }

    .flip-front-top {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    .flip-front-icon {
        width: 52px !important;
        height: 52px !important;
        min-width: 52px !important;
        border-radius: 16px !important;
        margin-bottom: 0 !important;
        font-size: 1.25rem !important;
    }

    .flip-front-text {
        flex-grow: 1;
    }

    .flip-front-title {
        font-family: 'Playfair Display', serif !important;
        font-size: 1.1rem !important;
        font-weight: 700 !important;
        color: #0a192f !important;
        margin-bottom: 4px !important;
        line-height: 1.25 !important;
    }

    .flip-front-desc-mobile {
        display: block !important;
        font-size: 0.85rem !important;
        color: #475569 !important;
        line-height: 1.5 !important;
        margin: 0 !important;
    }

    .flip-front-hint { display: none !important; }

    .flip-card-action-badge {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(0, 70, 205, 0.07);
        color: #0046cd;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        flex-shrink: 0;
        transition: all 0.25s ease;
    }

    /* Tactile Touch Feedback */
    .flip-card-wrap:active .flip-front {
        transform: scale(0.975) !important;
        box-shadow: 0 4px 16px rgba(0,70,205,0.15) !important;
    }
    .flip-card-wrap:active .flip-front-icon {
        transform: scale(1.08) rotate(-4deg) !important;
    }
    .flip-card-wrap:active .flip-card-action-badge {
        background: #0046cd !important;
        color: #ffffff !important;
        transform: translateX(3px) !important;
    }
}

/* ────────────────────────────────────────
   6. FOUNDER / TESTIMONIAL SECTION
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    .founder-section-row {
        flex-direction: column !important;
    }
    .founder-section-row .col-md-5 {
        order: 1 !important;
    }
    .founder-section-row .col-md-7 {
        order: 2 !important;
    }
    .founder-3d-card {
        margin-bottom: 1.5rem;
    }
    .border-start.border-4.border-primary {
        font-size: 0.95rem !important;
    }
}

/* ────────────────────────────────────────
   7. ABOUT US & FUTURE PLANS CARDS (about-us.php)
   ──────────────────────────────────────── */
.future-plan-card {
    border-radius: 20px !important;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%) !important;
    border: 1px solid rgba(0, 70, 205, 0.1) !important;
    box-shadow: 0 8px 24px -4px rgba(0, 70, 205, 0.07), 0 2px 6px rgba(0,0,0,0.02) !important;
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.future-plan-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #0046cd, #38b6ff);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.future-plan-card:hover,
.future-plan-card:active {
    transform: translateY(-4px) !important;
    box-shadow: 0 16px 36px -6px rgba(0, 70, 205, 0.16), 0 4px 12px rgba(0,0,0,0.03) !important;
    border-color: rgba(0, 70, 205, 0.25) !important;
}

.future-plan-card:hover::before,
.future-plan-card:active::before {
    opacity: 1;
}

.card-icon-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0046cd 0%, #1e68f6 100%);
    color: #ffffff !important;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px -3px rgba(0, 70, 205, 0.35);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.future-plan-card:hover .card-icon-badge {
    transform: scale(1.1) rotate(-3deg);
}

.plan-number-badge {
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: #0046cd;
    background: rgba(0, 70, 205, 0.08);
    border: 1px solid rgba(0, 70, 205, 0.15);
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.06em;
}

.plan-title {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #0a192f !important;
    line-height: 1.3 !important;
}

.plan-desc {
    font-size: 0.86rem !important;
    color: #475569 !important;
    line-height: 1.55 !important;
}

.plan-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px dashed rgba(0, 70, 205, 0.12);
    margin-top: 16px;
    padding-top: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #0046cd;
}

.plan-arrow {
    transition: transform 0.25s ease;
}

.future-plan-card:hover .plan-arrow {
    transform: translateX(4px);
}

@media (max-width: 768px) {
    section[style*="min-height: 80vh"] {
        min-height: 70vh !important;
    }
    section .typewriter-text.display-3,
    .display-3 {
        font-size: clamp(1.8rem, 8vw, 2.8rem) !important;
        line-height: 1.2 !important;
    }
    section .fs-4.text-white-50 {
        font-size: 0.95rem !important;
    }
    section .fs-5.text-white {
        font-size: 0.9rem !important;
    }
    section .btn.magnetic-btn.btn-lg {
        width: 100% !important;
        justify-content: center;
        font-size: 0.9rem !important;
    }
    .rounded-4[style*="aspect-ratio: 4/5"] {
        aspect-ratio: 16/9 !important;
        max-height: 280px;
    }
}

@media (max-width: 576px) {
    .display-5 {
        font-size: clamp(1.6rem, 7vw, 2.2rem) !important;
    }
    .display-4 {
        font-size: clamp(1.7rem, 7vw, 2.4rem) !important;
    }
    .text-center.mt-5.p-5 {
        padding: 1.5rem !important;
    }
    .future-plan-card {
        padding: 1.25rem !important;
    }
    .future-plan-card:active {
        transform: scale(0.975) !important;
    }
}

/* ────────────────────────────────────────
   8. JOURNEY TIMELINE
   ──────────────────────────────────────── */
@media (max-width: 576px) {
    .roadmap-item {
        padding-left: 28px !important;
        padding-right: 0 !important;
    }
    .roadmap-card {
        padding: 16px !important;
    }
    .roadmap-card .d-flex.flex-column.flex-md-row {
        gap: 1rem !important;
    }
    .journey-hero-stats {
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px !important;
    }
    .journey-stat-pill {
        width: fit-content !important;
        justify-content: center !important;
    }
}

/* ────────────────────────────────────────
   9. FOOTER
   ──────────────────────────────────────── */
@media (max-width: 576px) {
    footer form.d-flex {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    footer form.d-flex input {
        border-radius: 12px !important;
        padding-right: 1rem !important;
    }
    footer form.d-flex button {
        position: static !important;
        width: 100% !important;
        height: 44px !important;
        border-radius: 12px !important;
        justify-content: center;
    }
    footer .pt-5 {
        padding-top: 2rem !important;
    }
    footer .pb-4 {
        padding-bottom: 1.5rem !important;
    }
}

@media (max-width: 480px) {
    footer form.d-flex {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    footer form.d-flex input {
        padding-right: 1rem !important;
        border-radius: 12px !important;
    }
    footer form.d-flex button {
        position: static !important;
        width: 100% !important;
        min-height: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* ────────────────────────────────────────
   10. BACK TO TOP BUTTON
   ──────────────────────────────────────── */
@media (max-width: 576px) {
    #back-to-top {
        bottom: 16px !important;
        right: 16px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 0.85rem !important;
    }
}

/* ────────────────────────────────────────
   11. GALLERY PAGE
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    .gallery-hero {
        padding: 60px 16px 70px !important;
    }
}
@media (max-width: 480px) {
    .gallery-hero {
        padding: 48px 16px 56px !important;
    }
}

@media (max-width: 576px) {
    .gallery-filters-wrap {
        padding: 24px 0 0 !important;
        overflow: hidden;
    }
    .gallery-filters {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 14px !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 6px 12px !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        box-shadow: 0 4px 20px rgba(0,70,205,0.07),
                    inset -20px 0 10px -10px rgba(255,255,255,0.9) !important;
    }
    .gallery-filters::-webkit-scrollbar {
        display: none;
    }
    .filter-btn {
        flex-shrink: 0 !important;
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
    }
    .gallery-section {
        padding: 20px 12px 48px !important;
    }
    .row.g-3 .col-md-4,
    .row.g-4 .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ────────────────────────────────────────
   12. CONTACT PAGE
   ──────────────────────────────────────── */
@media (max-width: 992px) {
    .row.justify-content-center.g-4 > .col-lg-7,
    .row.justify-content-center.g-4 > .col-lg-5 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 576px) {
    nav.bg-white.p-3.rounded-4 a.btn {
        font-size: 0.75rem !important;
        padding: 0.35rem 0.6rem !important;
    }
    nav.bg-white.p-3.rounded-4 {
        gap: 4px !important;
        padding: 0.5rem !important;
    }
    .col-md-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* ────────────────────────────────────────
   13. TABLET (768px – 992px)
   ──────────────────────────────────────── */
@media (min-width: 577px) and (max-width: 992px) {
    .py-5 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    .navbar-brand-logo {
        height: 44px !important;
    }
    .typewriter-text {
        font-size: clamp(2rem, 4vw, 3rem) !important;
    }
    .col-lg-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ────────────────────────────────────────
   14. ACCESSIBILITY — Focus Outline
   ──────────────────────────────────────── */
@media (max-width: 768px) {
    a:focus, button:focus {
        outline: 2px solid #0046cd;
        outline-offset: 2px;
    }
}
