/* ============================================
   RESPONSIVE ENHANCEMENTS - MOBILE FIRST
   CANDELARIA 2026
   ============================================ */

/* Prevent horizontal scroll globally - CRITICAL */
html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    width: 100% !important;
}

/* Prevent all elements from causing overflow */
*,
*::before,
*::after {
    box-sizing: border-box !important;
}

/* Force only main layout containers to respect viewport - NOT div */
.container,
.container-fluid,
section,
.grid,
.card,
.hero,
.hero-content,
.section-content,
.live-grid,
.live-video-col,
.live-sidebar,
.video-info-grid,
.accommodation-grid,
.gastronomy-grid {
    max-width: 100% !important;
}

/* Prevent media elements from causing overflow */
img,
iframe,
video,
table {
    max-width: 100% !important;
    height: auto;
}

table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile screens <= 400px - FORCE FIT */
@media (max-width: 400px) {
    body,
    html {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    .container,
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        max-width: 100% !important;
    }
}

/* ============================================
   MOBILE BASE (320px - 575px)
   No additional styles needed - base mobile
   styles are in main CSS files
   ============================================ */

/* ============================================
   SMALL MOBILE (320px - 374px)
   For very small devices
   ============================================ */
@media (max-width: 374px) {
    .hero-title {
        font-size: 1.5rem !important;
    }

    .hero-subtitle {
        font-size: 0.85rem;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.85rem;
    }

    .countdown-number {
        font-size: 1.25rem;
    }

    .countdown-label {
        font-size: 0.55rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .nav-logo {
        font-size: 1rem;
    }

    .nav-logo img {
        width: 28px;
        height: 28px;
    }
}

/* ============================================
   SMALL TABLET - 576px and up
   ============================================ */
@media (min-width: 576px) {
    .hero-title {
        font-size: clamp(2rem, 5vw, 3.5rem);
    }

    .section {
        padding: 3.5rem 0;
    }

    .day-title {
        font-size: 1.35rem;
    }

    .live-title {
        font-size: 1.25rem;
    }

    .countdown-title {
        font-size: 0.85rem;
    }
}

/* ============================================
   MEDIUM TABLET - 768px and up
   ============================================ */
@media (min-width: 768px) {
    /* Enhanced spacing */
    .section {
        padding: 4.5rem 0;
    }

    /* Better typography scaling */
    body {
        font-size: 17px;
    }

    /* Improved cards */
    .card {
        margin-bottom: 0;
    }

    /* Better stats layout */
    .stats .grid-4 {
        gap: 2rem;
    }

    /* Enhanced features */
    .feature {
        padding: 2rem 1.5rem;
    }

    /* Footer improvements */
    .footer-section {
        text-align: left;
    }
}

/* ============================================
   LARGE TABLET - 992px and up
   ============================================ */
@media (min-width: 992px) {
    .section {
        padding: 6rem 0;
    }

    .section-header {
        margin-bottom: 4rem;
    }

    /* Larger touch targets for desktop */
    .btn {
        padding: 16px 32px;
    }

    /* More breathing room */
    .grid {
        gap: 2.5rem;
    }
}

/* ============================================
   DESKTOP - 1200px and up
   ============================================ */
@media (min-width: 1200px) {
    .section {
        padding: 8rem 0;
    }

    .hero-title {
        font-size: clamp(3rem, 5vw, 4rem);
    }
}

/* ============================================
   LARGE DESKTOP - 1400px and up
   ============================================ */
@media (min-width: 1400px) {
    .section {
        padding: 10rem 0;
    }

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

/* ============================================
   ULTRA WIDE - 1920px and up
   ============================================ */
@media (min-width: 1920px) {
    .section {
        padding: 12rem 0;
    }

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

    .container {
        max-width: 1400px;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: 1rem 0;
    }

    .hero-title {
        font-size: 1.75rem !important;
        margin-bottom: 0.5rem;
    }

    .hero-subtitle {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .hero-cta {
        gap: 0.5rem;
    }

    .section {
        padding: 3rem 0;
    }

    .nav-container {
        height: 50px;
    }
}

/* Mobile landscape */
@media (min-width: 576px) and (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }

    .countdown-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .countdown-item {
        padding: 0.5rem;
    }

    .countdown-number {
        font-size: 1.25rem;
    }
}

/* ============================================
   HIGH DPI / RETINA DISPLAYS
   ============================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders and shadows */
    .card {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.06);
    }

    /* Thinner scrollbar */
    ::-webkit-scrollbar {
        width: 7px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */
@media (prefers-color-scheme: dark) {
    .navbar {
        background: rgba(26, 26, 46, 0.95);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .nav-link {
        color: rgba(255, 255, 255, 0.9);
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--accent-color);
    }

    .card {
        background: var(--background-dark);
        color: var(--text-light);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .card-title {
        color: var(--text-light);
    }

    .section-gray {
        background: var(--secondary-color);
    }

    .filters-container,
    .program-list,
    .sidebar-card,
    .live-container {
        background: rgba(26, 26, 46, 0.8);
        color: var(--text-light);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .search-input,
    .filter-btn {
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-light);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .search-input:focus {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================
   REDUCED MOTION PREFERENCES
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .fade-in,
    .slide-in-left,
    .slide-in-right {
        opacity: 1 !important;
        transform: none !important;
    }

    .btn::before {
        display: none;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        border-color: #000;
        color: #fff;
    }

    .btn-secondary,
    .btn-outline {
        border-width: 3px;
    }

    .nav-link:focus,
    .btn:focus,
    .search-input:focus,
    .filter-btn:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }

    .card {
        border-width: 2px;
    }

    .hero-overlay {
        background: rgba(0, 0, 0, 0.85);
    }
}

/* ============================================
    TOUCH DEVICE OPTIMIZATIONS
    ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Minimum 44x44px touch targets */
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: 14px 28px;
    }

    .nav-link {
        min-height: 48px;
        padding: 14px 1rem;
    }

    .filter-btn {
        min-height: 48px;
        min-width: 48px;
    }

    .video-control-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .go-to-top-button {
        width: 56px;
        height: 56px;
    }

    .whatsapp-float {
        width: 56px;
        height: 56px;
    }

    /* Touch targets for cards */
    .section-card,
    .why-card,
    .activity-card {
        min-height: 48px;
        min-width: 48px;
    }

    /* Touch targets for calendar navigation */
    .swiper-button-prev,
    .swiper-button-next {
        min-width: 48px;
        min-height: 48px;
    }

    .swiper-pagination-bullet {
        min-width: 16px;
        min-height: 16px;
        width: 16px;
        height: 16px;
    }

    /* Touch targets for social links */
    .footer-social a {
        min-width: 48px;
        min-height: 48px;
        padding: 12px;
    }

    /* Touch targets for contact items */
    .footer-contact-item {
        min-height: 48px;
        padding: 12px 0;
    }

    /* Touch targets for offcanvas elements */
    .offcanvas-toggle {
        width: 48px;
        height: 48px;
    }

    .offcanvas-close {
        width: 48px;
        height: 48px;
    }

    .offcanvas-menu-link {
        min-height: 48px;
        padding: 14px 1.25rem;
    }

    /* Touch targets for countdown items */
    .countdown-item {
        min-height: 80px;
        /* min-width: 80px; */ /* Removed to allow compact layout on mobile */
        padding: 12px 4px;
    }

    /* Touch targets for intro stats */
    .intro-stat {
        min-height: 96px;
        min-width: 96px;
    }

    /* Disable hover effects on touch */
    .card:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }

    .sidebar-card:hover {
        transform: none;
    }

    .section-card:hover {
        transform: none;
    }

    .why-card:hover {
        transform: none;
    }

    /* No hover transforms on mobile */
    .feature-icon:hover {
        transform: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    /* Hide interactive elements */
    .navbar,
    .mobile-toggle,
    .hero-cta,
    .btn,
    .search-container,
    .filters-container,
    .video-background,
    .video-controls,
    .volume-indicator,
    .go-to-top-button,
    .live-section,
    .sidebar-banner,
    .full-width-banner,
    .footer-social {
        display: none !important;
    }

    /* Simplify backgrounds */
    .hero {
        min-height: auto;
        background: white !important;
        color: black !important;
        padding: 2rem 0;
    }

    .hero-overlay {
        display: none;
    }

    .section {
        padding: 1.5rem 0;
        page-break-inside: avoid;
    }

    .section-dark,
    .footer {
        background: white !important;
        color: black !important;
    }

    /* Simplify cards */
    .card,
    .program-list,
    .sidebar-card {
        border: 1px solid #ccc;
        box-shadow: none;
        page-break-inside: avoid;
        background: white !important;
        color: black !important;
    }

    /* Make text readable */
    .hero-title,
    .section-title,
    .day-title,
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }

    .program-list li {
        color: #000 !important;
        background: #fff !important;
        border-left-color: #666 !important;
    }

    /* Print URLs after links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Don't print URLs for nav links */
    .nav-link[href]:after,
    .btn[href]:after {
        content: "";
    }

    /* Optimize page breaks */
    .day-section,
    .stat-card,
    .feature {
        page-break-inside: avoid;
    }

    /* Ensure readable font sizes */
    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    h1 { font-size: 24pt; }
    h2 { font-size: 20pt; }
    h3 { font-size: 16pt; }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Reduce animations on slower devices */
@media (max-width: 768px) {
    .hero::before {
        display: none;
    }

    .card,
    .btn,
    .sidebar-card {
        will-change: auto;
    }
}

/* GPU acceleration for transforms */
@media (min-width: 768px) {
    .card:hover,
    .btn:hover,
    .sidebar-card:hover {
        will-change: transform;
    }
}

/* ============================================
   SPECIAL BREAKPOINT ADJUSTMENTS
   ============================================ */

/* Between tablet and desktop */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        padding: 0 2rem;
    }

    .section {
        padding: 4rem 0;
    }

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

/* Medium desktop range */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        padding: 0 2rem;
    }
}

/* ============================================
   iOS SPECIFIC FIXES
   ============================================ */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari fixes */
    .hero {
        min-height: -webkit-fill-available;
    }

    /* Fix for iOS safe area */
    .navbar {
        padding-top: env(safe-area-inset-top);
    }

    .footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   FIREFOX SPECIFIC OPTIMIZATIONS
   ============================================ */
@-moz-document url-prefix() {
    /* Better scrollbar in Firefox */
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--accent-color) var(--background-secondary);
    }
}
