/* ===================================
   MOBILE COMPATIBILITY ENHANCEMENTS
   Additional responsive improvements
   =================================== */

/* ===================================
   ENHANCED TOUCH INTERACTIONS
   =================================== */

/* Ensure all interactive elements are touch-friendly (minimum 44x44px) */
@media (max-width: 768px) {
    /* Buttons */
    button, 
    .btn, 
    .card-btn, 
    .tab-btn,
    .nav-link,
    a.button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 16px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(132, 24, 24, 0.3);
    }

    /* Links - Make them easier to tap */
    a {
        padding: 4px 0;
        display: inline-block;
    }

    /* Navigation Links */
    .nav-link {
        padding: 16px 20px;
        font-size: 18px;
        width: 100%;
        text-align: left;
    }

    /* Card flip indicators */
    .flip-indicator,
    .flip-hint {
        font-size: 16px;
        padding: 12px;
    }
}

/* ===================================
   PREVENT HORIZONTAL SCROLL
   =================================== */

@media (max-width: 768px) {
    html {
        overflow-x: hidden;
        width: 100%;
    }

    body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    /* Ensure containers don't overflow */
    .container,
    .events-grid-flip,
    .coordinators-grid,
    .contact-grid {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Videos should be responsive */
    video {
        max-width: 100%;
        height: auto;
    }

    /* Images should be responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Prevent wide content from breaking layout */
    * {
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Fix for fixed position elements */
    .navbar {
        width: 100%;
        max-width: 100vw;
    }
}

/* ===================================
   IMPROVED READABILITY ON MOBILE
   =================================== */

@media (max-width: 768px) {
    /* Ensure text is readable (minimum 16px) */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    p, 
    li, 
    span,
    .event-description,
    .about-text,
    .coordinator-phone,
    .coordinator-email {
        font-size: 16px !important;
        line-height: 1.6;
    }

    /* Headings proportional scaling */
    h1 {
        font-size: 2rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    h4 {
        font-size: 1.25rem;
        line-height: 1.4;
    }

    /* Improve spacing for readability */
    p {
        margin-bottom: 1em;
    }
}

/* ===================================
   ENHANCED FLIP CARDS FOR MOBILE
   =================================== */

@media (max-width: 768px) {
    /* Make cards easier to interact with */
    .playing-card,
    .flip-card {
        margin-bottom: 20px;
        cursor: pointer;
    }

    /* Ensure card height is appropriate */
    .flip-card {
        min-height: 400px;
        height: auto;
    }

    /* Card content padding */
    .card-content,
    .flip-card-front,
    .flip-card-back {
        padding: 20px;
    }

    /* Event card titles */
    .card-title,
    .event-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }

    /* Back of card buttons */
    .back-buttons,
    .card-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }

    .back-buttons a,
    .card-btn {
        width: 100%;
        text-align: center;
        padding: 14px 20px;
        font-size: 16px;
    }
}

/* ===================================
   IMPROVED FORMS ON MOBILE
   =================================== */

@media (max-width: 768px) {
    /* Form inputs should be touch-friendly */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 4px;
        -webkit-appearance: none;
        appearance: none;
    }

    /* Labels */
    label {
        font-size: 16px;
        margin-bottom: 8px;
        display: block;
    }

    /* Form groups */
    .form-group {
        margin-bottom: 20px;
    }
}

/* ===================================
   FOOTER MOBILE OPTIMIZATION
   =================================== */

@media (max-width: 768px) {
    .footer {
        padding: 40px 0 20px;
        text-align: center;
    }

    .footer-branding {
        text-align: center;
        margin-bottom: 30px;
    }

    .footer-logos {
        justify-content: center;
        flex-wrap: wrap;
        gap: 20px;
    }

    .footer-ex-logo,
    .footer-dept-logo {
        max-height: 50px;
        width: auto;
    }

    .footer-tagline {
        font-size: 1.1rem;
        margin: 15px 0;
    }

    .footer-motto {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* Social media icons */
    .footer-social {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin: 25px 0;
    }

    .footer-social a {
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .footer-social svg {
        width: 24px;
        height: 24px;
    }

    /* Contact information */
    .footer-contact {
        margin: 20px 0;
    }

    .footer-contact-card {
        padding: 20px;
        margin-bottom: 15px;
    }

    .footer-contact-email,
    .footer-contact-phone {
        font-size: 16px;
        padding: 10px 0;
        display: block;
    }
}

/* ===================================
   NAVIGATION MOBILE IMPROVEMENTS
   =================================== */

@media (max-width: 768px) {
    /* Hamburger menu */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 24px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
    }

    .mobile-menu-toggle .bar {
        width: 100%;
        height: 3px;
        background-color: var(--color-white);
        transition: all 0.3s ease;
        border-radius: 2px;
    }

    /* Mobile menu */
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.98);
        width: 100%;
        padding: 30px;
        transition: left 0.3s ease;
        z-index: 1000;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        margin: 0;
        width: 100%;
    }

    .nav-link {
        padding: 18px 20px;
        width: 100%;
        display: block;
        border-bottom: 1px solid rgba(132, 24, 24, 0.2);
    }

    /* Logo adjustments */
    .christ-logo,
    .ex-logo {
        height: 40px;
        max-height: 40px;
    }

    .logo-text {
        display: none;
    }
}

/* ===================================
   HERO SECTION MOBILE
   =================================== */

@media (max-width: 768px) {
    .hero-section {
        min-height: 100vh;
        padding: 100px 0 60px;
    }

    .hero-title {
        font-size: 2.5rem;
        letter-spacing: 4px;
        margin-bottom: 15px;
    }

    .hero-tagline {
        font-size: 1.1rem;
        margin-bottom: 25px;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        align-items: center;
    }

    .hero-buttons .btn {
        width: 100%;
        max-width: 300px;
    }

    /* Countdown */
    .countdown {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .time-box {
        min-width: 75px;
        padding: 12px;
    }

    .time-value {
        font-size: 28px;
    }

    .time-label {
        font-size: 11px;
    }
}

/* ===================================
   EVENT GRID MOBILE
   =================================== */

@media (max-width: 768px) {
    .events-grid,
    .events-grid-flip {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0;
    }

    /* Event tabs/filters */
    .event-tabs {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .tab-btn {
        padding: 10px 20px;
        font-size: 14px;
        flex: 1 1 auto;
        min-width: 120px;
    }
}

/* ===================================
   CONTACT/COORDINATORS GRID
   =================================== */

@media (max-width: 768px) {
    .coordinators-grid,
    .contact-grid,
    .contact-grid-compact {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    .coordinator-card,
    .contact-card,
    .contact-card-compact {
        padding: 25px;
        text-align: center;
    }

    .coordinator-name,
    .contact-name {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .coordinator-phone,
    .coordinator-email,
    .contact-phone,
    .contact-email {
        font-size: 16px;
        padding: 8px 0;
        display: block;
    }
}

/* ===================================
   TABLET SPECIFIC (768px - 1024px)
   =================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .events-grid-flip {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .coordinators-grid,
    .contact-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===================================
   VERY SMALL DEVICES (< 375px)
   =================================== */

@media (max-width: 375px) {
    .container {
        padding: 0 15px;
    }

    .hero-title {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .hero-tagline {
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .time-box {
        min-width: 65px;
        padding: 10px;
    }

    .time-value {
        font-size: 24px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .footer-ex-logo,
    .footer-dept-logo {
        max-height: 40px;
    }
}

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

@media (max-width: 896px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding: 80px 0 40px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-tagline {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .countdown {
        margin-bottom: 20px;
    }

    .time-box {
        padding: 8px 12px;
    }

    /* Hide scroll indicator in landscape */
    .scroll-indicator {
        display: none;
    }

    /* Reduce navbar height */
    .navbar {
        padding: 8px 0;
    }

    .christ-logo,
    .ex-logo {
        height: 35px;
    }
}

/* ===================================
   LOADING PERFORMANCE
   =================================== */

@media (max-width: 768px) {
    /* Note: Use loading="lazy" attribute in HTML, not CSS */
    video {
        object-fit: cover;
    }

    /* Reduce animation complexity on mobile */
    .floating-suits,
    .particle-web,
    .cipher-glyph {
        animation-duration: 20s; /* Slower = less CPU */
    }

    /* Reduce motion for battery saving */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ===================================
   iOS SPECIFIC FIXES
   =================================== */

@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    
    /* Fix for 100vh including URL bar */
    .hero-section,
    .coming-soon-body {
        min-height: -webkit-fill-available;
    }

    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Better tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(132, 24, 24, 0.2);
    }
}

/* ===================================
   ACCESSIBILITY IMPROVEMENTS
   =================================== */

@media (max-width: 768px) {
    /* Focus states for keyboard navigation */
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--color-red);
        outline-offset: 2px;
    }

    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--color-red);
        color: white;
        padding: 8px 16px;
        text-decoration: none;
        z-index: 10000;
    }

    .skip-to-content:focus {
        top: 0;
    }
}

/* ===================================
   PRINT OPTIMIZATION
   =================================== */

@media print {
    /* Hide unnecessary elements */
    .navbar,
    .mobile-menu-toggle,
    .hero-video,
    .events-video,
    video,
    .footer-social,
    .scroll-indicator {
        display: none !important;
    }

    /* Optimize for print */
    body {
        background: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    /* Show link URLs after links */
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* ===================================
   MOBILE NAVIGATION ENHANCEMENTS
   =================================== */

@media (max-width: 768px) {
    /* Ensure mobile menu toggle is always visible and clickable */
    .mobile-menu-toggle {
        position: relative;
        z-index: 1001;
        cursor: pointer;
        padding: 12px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Make nav menu fully accessible when open */
    .nav-menu {
        pointer-events: none;
    }

    .nav-menu.active {
        pointer-events: auto;
    }

    /* Keep Christ logo visible and clickable on mobile */
    .logo-right {
        position: relative;
        z-index: 1000;
    }

    .logo-right a {
        display: block;
        padding: 8px;
        touch-action: manipulation;
    }

    .christ-logo {
        max-height: 45px;
        width: auto;
    }

    /* Ensure tel: links are properly styled and accessible */
    a[href^="tel:"] {
        color: var(--color-red, #841818);
        text-decoration: none;
        font-weight: 500;
        display: inline-block;
        padding: 8px 12px;
        border-radius: 4px;
        transition: all 0.3s ease;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(132, 24, 24, 0.2);
    }

    a[href^="tel:"]:active {
        background: rgba(132, 24, 24, 0.1);
        transform: scale(0.98);
    }

    /* Contact card mobile optimization */
    .contact-card {
        padding: 20px;
        margin: 16px 0;
    }

    .contact-item {
        padding: 12px 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .contact-number {
        font-size: 1.1rem;
        padding: 10px 16px;
        background: rgba(132, 24, 24, 0.05);
        border-radius: 8px;
        width: 100%;
        text-align: center;
    }
}
