/* ==========================================================================
   RESPONSIVE CSS — Casa Amrilla
   Breakpoints: 1540px | 1280px | 1024px | 991px | 767px | 479px
   (Mirrors the Zone source theme's full breakpoint set)
   ========================================================================== */

/* ── Extra-Large Desktop (< 1540px) ─────────────────────────────────────── */
@media (max-width: 1540px) {
    /* Container already caps at 1260px — ensure paddings are comfortable */
    :root { --container-pad: 30px; }

    /* Gallery stays 4 columns but item heights shrink gracefully */
    .gallery-grid { gap: 6px; }

    /* Hero: cap extreme height on very wide monitors */
    .hero-section { min-height: 92vh; }

    /* Footer brand column slightly narrower */
    .footer-widgets-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
}

/* ── Large Desktop (< 1280px) ───────────────────────────────────────────── */
@media (max-width: 1280px) {
    :root { --container-pad: 24px; }

    .rooms-grid        { grid-template-columns: repeat(2, 1fr); }
    .services-grid     { grid-template-columns: repeat(2, 1fr); }
    .footer-widgets-grid { grid-template-columns: 1.5fr 1fr 1fr; }
    .footer-widgets-grid .widget-col:nth-child(1) { grid-column: 1 / -1; }

    .about-section .about-grid { gap: 50px; }
    .alignwide { margin-left: -30px; margin-right: -30px; }
}

/* ── Tablet Landscape (< 1024px) ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .header-topbar { display: none; }

    .header-main .container {
        justify-content: space-between;
    }

    /* Hide desktop nav, show toggle */
    .header-nav-wrap {
        position: fixed;
        top: 0;
        right: -100%;
        width: min(380px, 90vw);
        height: 100vh;
        background: var(--color-primary);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 80px 30px 40px;
        overflow-y: auto;
        transition: right var(--transition-base);
        z-index: 999;
        box-shadow: -4px 0 40px rgba(0,0,0,0.3);
    }
    .header-nav-wrap.is-open { right: 0; }
    .menu-toggle { display: flex; }

    /* Mobile nav overlay */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-base), visibility var(--transition-base);
    }
    .nav-overlay.is-open { opacity: 1; visibility: visible; }

    .primary-navigation { width: 100%; }
    .primary-navigation > ul {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }
    .primary-navigation > ul > li > a {
        padding: 14px 0;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .primary-navigation > ul > li > a::after { display: none; }
    .primary-navigation .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-top: none;
        background: rgba(0,0,0,0.15);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        border-radius: 0;
    }
    .primary-navigation li.is-open > .sub-menu { max-height: 600px; }
    .primary-navigation .sub-menu a {
        color: rgba(255,255,255,0.75);
        padding: 10px 16px;
    }
    .primary-navigation .sub-menu a:hover {
        background: rgba(255,255,255,0.08);
        color: var(--color-secondary);
    }

    /* Mobile nav: place link + submenu-toggle on the same row per list item */
    .primary-navigation > ul > li {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .primary-navigation > ul > li > a {
        flex: 1;
        border-bottom: none; /* border moved to parent li */
    }
    .primary-navigation > ul > li > .sub-menu {
        flex-basis: 100%; /* full-width row below link+toggle */
    }

    /* Submenu toggle button */
    .submenu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: rgba(255,255,255,0.65);
        cursor: pointer;
        padding: 10px 12px;
        flex-shrink: 0;
        transition: transform var(--transition-fast), color var(--transition-fast);
    }
    .submenu-toggle[aria-expanded="true"] {
        transform: rotate(180deg);
        color: var(--color-secondary);
    }

    /* Content */
    .about-section .about-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .about-image-badge { right: 10px; bottom: -20px; }
    .about-content { padding-right: 0; }

    .rooms-grid { grid-template-columns: repeat(2, 1fr); }
    .blog-grid  { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid .stat-item:nth-child(2n) { border-right: none; }
    .stats-grid .stat-item:nth-child(n+3) {
        border-top: 1px solid rgba(10,43,80,0.1);
    }

    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
    .gallery-grid .gallery-item.large { grid-column: span 1; grid-row: span 1; }

    .content-with-sidebar .container {
        grid-template-columns: 1fr;
    }
    .widget-area { margin-top: 48px; }
    .content-with-sidebar.sidebar-left .widget-area { order: -1; margin-top: 0; margin-bottom: 48px; }

    .booking-bar form {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .woocommerce ul.products { grid-template-columns: repeat(2, 1fr) !important; }

    .footer-widgets-grid {
        grid-template-columns: 1fr 1fr;
        gap: 36px;
    }
    .footer-widgets-grid .widget-col:nth-child(1) { grid-column: 1 / -1; }
}

/* ── Mid-Tablet (< 991px) ───────────────────────────────────────────────── */
/* Mirrors the Zone source theme's 991px breakpoint — booking form stack +
   gallery/services refinement between tablet-landscape and portrait. */
@media (max-width: 991px) {
    /* Booking bar: stack to single column earlier than 767px */
    .booking-bar form {
        grid-template-columns: 1fr;
    }

    /* Gallery: 3 cols becomes 2 at this width */
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery-grid .gallery-item.large { grid-column: span 1; grid-row: span 1; }

    /* Services: 2 cols is already set; ensure gap is comfortable */
    .services-grid { gap: 20px; }

    /* Rooms: stay 2 cols but tighten gap */
    .rooms-grid { gap: 20px; }

    /* Blog: 2 cols from 1024px is fine; adjust gap */
    .blog-grid { gap: 20px; }
}

/* ── Tablet Portrait (< 767px) ──────────────────────────────────────────── */
@media (max-width: 767px) {
    .section     { padding: 60px 0; }
    .section-lg  { padding: 80px 0; }

    h1 { font-size: clamp(36px, 8vw, 60px); }
    h2 { font-size: clamp(26px, 5vw, 42px); }

    .hero-section { min-height: 90vh; }
    .hero-actions { flex-direction: column; gap: 12px; }
    .hero-actions .btn { justify-content: center; width: 100%; max-width: 280px; }

    .booking-bar {
        padding: 24px 20px;
        margin-top: -30px;
    }
    .booking-bar form {
        grid-template-columns: 1fr;
    }

    .rooms-grid     { grid-template-columns: 1fr; }
    .services-grid  { grid-template-columns: 1fr 1fr; }
    .blog-grid      { grid-template-columns: 1fr; }
    .stats-grid     { grid-template-columns: repeat(2, 1fr); }

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

    .post-navigation { grid-template-columns: 1fr; }

    .section-header { margin-bottom: 36px; }

    .error-404-code { font-size: clamp(80px, 20vw, 140px); }

    .footer-widgets-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .footer-bottom .container { flex-direction: column; text-align: center; }

    .woocommerce ul.products { grid-template-columns: 1fr !important; }

    .about-image-wrapper img { height: 360px; }

    .testimonial-card { padding: 28px 22px; }
}

/* ── Mobile (< 479px) ───────────────────────────────────────────────────── */
@media (max-width: 479px) {
    :root { --container-pad: 16px; }

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

    .header-cta .btn { padding: 10px 18px; font-size: 12px; }

    .booking-bar { border-radius: 0; }

    .about-image-badge {
        width: 110px;
        height: 110px;
        bottom: -16px;
        right: 8px;
    }
    .about-image-badge .badge-number { font-size: 30px; }

    .page-hero { padding: 100px 0 40px; }

    .entry-content .alignleft,
    .entry-content .alignright {
        float: none;
        margin: 0 0 1.25em 0;
    }

    .pagination .page-numbers { width: 38px; height: 38px; font-size: 13px; }

    .footer-social a { width: 34px; height: 34px; }
    #go-to-top { bottom: 20px; right: 20px; }
}

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
    #masthead, #colophon, .booking-bar, .hero-actions,
    #go-to-top, .site-preloader, .menu-toggle { display: none !important; }
    body { font-size: 12pt; color: #000; background: #fff; }
    a { color: #000; text-decoration: underline; }
    .content-with-sidebar .container { grid-template-columns: 1fr; }
}

/* ── Accessibility: Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .hero-bg { transform: none !important; }
}

/* ── Dark Mode (optional support) ───────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    /* Theme uses dark navy as primary — already well-suited.
       Future enhancement: add full dark mode overrides here. */
}
