/* Responsive Overrides for Mobile Devices */

/* Logo now uses clamp() for fluid responsiveness */

/* --- General Adjustments --- */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem; /* Reduce side padding on mobile */
    }

    main {
        padding: 1rem 0; /* Reduce main content padding */
    }
}

/* --- Navbar System --- */
/* Desktop: >1024px - Keep hero navbar */
/* Tablet: 768px-1024px - Horizontal top navbar */
/* Phone: <768px - Vertical menu drawer */

/* Tablet Layout: 768px-1024px */
@media (max-width: 1024px) and (min-width: 768px) {
    /* Hide desktop navbar on tablet */
    #desktop-navbar {
        display: none;
    }

    /* Style the tablet navbar (current mobile navbar) */
    .mobile-navbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: 0.5rem 1rem;
        transition: transform 0.3s ease-in-out;
        z-index: 999;
    }
    
    .light .mobile-navbar {
        background-color: rgba(249, 249, 249, 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .dark .mobile-navbar {
        background-color: rgba(30, 30, 30, 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .mobile-navbar.hidden {
        transform: translateY(-120%);
    }

    /* Style the tablet handle */
    .mobile-navbar-handle {
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        cursor: pointer;
        z-index: 1001;
        border: none;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
        pointer-events: none;
    }

    .mobile-navbar-handle.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .light .mobile-navbar-handle {
        background-color: rgba(224, 224, 224, 0.8);
        color: #1e1e1e;
    }

    .dark .mobile-navbar-handle {
        background-color: rgba(87, 87, 87, 0.8);
        color: #e0e0e0;
    }

    /* --- Glow Button Tablet Adjustments --- */
    .mobile-navbar .glow_button {
        padding: 10px 14px;
        font-size: 0.9rem;
        border-width: 0.15rem;
        border-style: solid;
    }

    .mobile-navbar .glow_button,
    .mobile-navbar .glow_button:hover {
        transform: none !important;
        box-shadow: 0 1px hsl(0 0% 100% / 0.15) inset !important;
    }

    /* Tablet theme icon styling */
    .theme-icon {
        display: inline-block;
        width: 24px;
        height: 24px;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    .light #theme-toggle-mobile-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' height='20px' viewBox='0 -960 960 960' width='20px' fill='%23888'%3e%3cpath d='M479.77-288Q400-288 344-344.23q-56-56.22-56-136Q288-560 344.23-616q56.22-56 136-56Q560-672 616-615.77q56 56.22 56 136Q672-400 615.77-344q-56.22 56-136 56ZM216-444H48v-72h168v72Zm696 0H744v-72h168v72ZM444-744v-168h72v168h-72Zm0 696v-168h72v168h-72ZM269-642 166-742l51-55 102 104-50 51Zm474 475L642-268l49-51 103 101-51 51ZM640-691l102-101 51 49-100 103-53-51ZM163-217l105-99 49 47-98 104-56-52Z'/%3e%3c/svg%3e");
    }

    .dark #theme-toggle-mobile-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 -960 960 960' width='24px' fill='%23D6D6D6'%3e%3cpath d='M600-640 480-760l120-120 120 120-120 120Zm200 120-80-80 80-80 80 80-80 80ZM483-80q-84 0-157.5-32t-128-86.5Q143-253 111-326.5T79-484q0-146 93-257.5T409-880q-18 99 11 193.5T520-521q71 71 165.5 100T879-410q-26 144-138 237T483-80Z'/%3e%3c/svg%3e");
    }

    .dark .mobile-navbar .glow_button {
        background: var(--bg_d);
        color: var(--lm_2);
        border-color: transparent;
    }

    .light .mobile-navbar .glow_button {
        background: var(--bg_l);
        color: var(--dm_1);
        border-color: transparent;
    }
}

/* Phone Layout: <768px - Vertical Menu Drawer */
@media (max-width: 767px) {
    /* Hide desktop navbar on phone */
    #desktop-navbar {
        display: none;
    }

    /* Hide tablet horizontal navbar on phone */
    .mobile-navbar {
        display: none;
    }

    /* Show mobile-navbar-handle on phone for drawer toggle */
    .mobile-navbar-handle {
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        cursor: pointer;
        z-index: 1001;
        border: none;
        opacity: 1 !important; /* Always visible on phone */
        pointer-events: auto !important;
        transition: all 0.2s ease;
    }

    .light .mobile-navbar-handle {
        background-color: rgba(224, 224, 224, 0.8);
        color: #1e1e1e;
    }

    .dark .mobile-navbar-handle {
        background-color: rgba(87, 87, 87, 0.8);
        color: #e0e0e0;
    }

    /* Phone Menu Drawer */
    .phone-menu-drawer {
        position: fixed;
        top: 4rem; /* Start below the menu button area */
        right: -300px; /* Hidden by default */
        width: 280px;
        min-height: auto;
        max-height: calc(100vh - 5rem); /* Leave space at top and bottom */
        z-index: 1000;
        transition: right 0.3s ease-in-out, background-color 0.3s, border-color 0.3s;
        display: flex;
        flex-direction: column;
        padding: 2rem 1.5rem;
        border-radius: 16px 0 0 16px; /* Rounded left corners */
    }

    .phone-menu-drawer.open {
        right: 0; /* Slide in when open */
    }

    .light .phone-menu-drawer {
        background-color: rgba(249, 249, 249, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-left: 1px solid rgba(0, 0, 0, 0.1);
    }

    .dark .phone-menu-drawer {
        background-color: rgba(30, 30, 30, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Phone menu buttons - vertical layout */
    .phone-menu-nav {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .phone-menu-drawer .glow_button {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        text-align: center;
        border: 1px solid transparent;
        border-radius: 8px;
        transition: all 0.2s ease;
        text-decoration: none;
    }

    .light .phone-menu-drawer .glow_button {
        background: rgba(255, 255, 255, 0.8);
        color: #333;
        border-color: rgba(0, 0, 0, 0.1);
    }

    .light .phone-menu-drawer .glow_button:hover {
        background: rgba(255, 255, 255, 1);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .dark .phone-menu-drawer .glow_button {
        background: rgba(60, 60, 60, 0.8);
        color: #e0e0e0;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .dark .phone-menu-drawer .glow_button:hover {
        background: rgba(80, 80, 80, 1);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    /* Phone theme toggle - inherit from tablet styles */
    .phone-theme-toggle {
        margin-top: auto;
        display: flex;
        justify-content: center;
    }

    /* Phone theme icons - same styling as tablet icons */
    #theme-toggle-phone-icon {
        display: inline-block;
        width: 24px;
        height: 24px;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    .light #theme-toggle-phone-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' height='20px' viewBox='0 -960 960 960' width='20px' fill='%23888'%3e%3cpath d='M479.77-288Q400-288 344-344.23q-56-56.22-56-136Q288-560 344.23-616q56.22-56 136-56Q560-672 616-615.77q56 56.22 56 136Q672-400 615.77-344q-56.22 56-136 56ZM216-444H48v-72h168v72Zm696 0H744v-72h168v72ZM444-744v-168h72v168h-72Zm0 696v-168h72v168h-72ZM269-642 166-742l51-55 102 104-50 51Zm474 475L642-268l49-51 103 101-51 51ZM640-691l102-101 51 49-100 103-53-51ZM163-217l105-99 49 47-98 104-56-52Z'/%3e%3c/svg%3e");
    }

    .dark #theme-toggle-phone-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 -960 960 960' width='24px' fill='%23D6D6D6'%3e%3cpath d='M600-640 480-760l120-120 120 120-120 120Zm200 120-80-80 80-80 80 80-80 80ZM483-80q-84 0-157.5-32t-128-86.5Q143-253 111-326.5T79-484q0-146 93-257.5T409-880q-18 99 11 193.5T520-521q71 71 165.5 100T879-410q-26 144-138 237T483-80Z'/%3e%3c/svg%3e");
    }


    /* Overlay when menu is open */
    .phone-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .phone-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

@media (min-width: 1025px) {
    /* Hide mobile and tablet elements on desktop */
    .mobile-navbar,
    .mobile-navbar-handle,
    .phone-menu-drawer,
    .phone-menu-overlay,
    .hero-divider {
        display: none !important;
    }

    .footer {
        padding-bottom: 1rem;
    }
}


/* --- Hero Section --- */
@media (max-width: 767px) {
    .hero {
        position: relative; /* Ensure the hero is a positioning context */
    }

    .hero-divider {
        position: absolute;
        bottom: 0;
        left: 0;
        height: 15px; /* Increased height */
        width: 100%;
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 10; /* Ensure it's above the hero image */
    }

    .light .hero-divider {
        background-color: rgba(224, 224, 224, 0.3);
    }

    .dark .hero-divider {
        background-color: rgba(87, 87, 87, 0.3);
    }

    .hero h1 {
        font-size: 2.2rem; /* Reduce heading font size */
    }


    .hero p {
        font-size: 1.1rem; /* Reduce paragraph font size */
    }

    .hero-content {
        padding-bottom: 100px; /* Ensure space for navbar */
    }
}

/* --- Blok Component --- */
@media (max-width: 768px) {
    .blok {
        margin: 2rem 0;
        padding: 1.5rem 1rem;
    }

    .blok-inner-flex,
    .blok-inner-flex.reverse {
        flex-direction: column; /* Stack elements vertically */
    }

    .blok-foto-grid,
    .blok-foto-grid-reverse {
        grid-template-areas: /* Simplify grid for mobile */
            'x x'
            'a b'
            'c d'
            'e e';
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .action-row {
        flex-direction: column; /* Stack price and button */
        align-items: center;
        gap: 15px;
        width: 100%;
        margin-top: 1rem;
    }

    .blok-price {
        font-size: 1.3em;
    }
}

/* --- Footer --- */
@media (max-width: 768px) {
    .footer .container {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .footer-section {
        margin-bottom: 2rem;
        text-align: center;
    }

    .footer .footer-section:last-child {
        text-align: center;
        margin-left: 0;
    }

    .footer-logo {
        margin: 1.5rem 0;
        padding: 0;
    }

    .footer-logo-img {
        width: 160px;
    }

    .social-links {
        justify-content: center;
    }
}

/* --- Footer Tablet Layout (769px - 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .footer .container {
        display: grid;
        grid-template-rows: auto auto;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    /* Row 1: O nás (left) */
    .footer-section:first-child {
        grid-column: 1;
        grid-row: 1;
    }

    /* Row 1: Důležité odkazy (right) */
    .footer .footer-section:last-child {
        grid-column: 2;
        grid-row: 1;
        margin-left: 0;    /* Remove auto margin */
    }

    /* Row 2: Logo (centered, spans both columns) */
    .footer-logo {
        grid-column: 1 / -1;  /* Span all columns */
        grid-row: 2;
        padding: 0;
    }

    .footer-logo-img {
        width: 140px;
    }
}

/* --- Theme Toggle --- */
/* Phone: <768px - Show mobile toggle button */
@media (max-width: 767px) {
    .theme-switch {
        position: relative; /* Key change: bring into flow */
        top: auto;
        right: auto;
        transform: none;
    }

    .theme-switch .slider-container {
        display: none; /* Hide slider on phone */
    }

    .theme-switch .mobile-toggle-container {
        display: block; /* Show button on phone */
    }
}

/* Tablet: 768px-1024px - Show mobile toggle button */
@media (min-width: 768px) and (max-width: 1024px) {
    .theme-switch {
        position: relative; /* Key change: bring into flow */
        top: auto;
        right: auto;
        transform: none;
    }

    .theme-switch .slider-container {
        display: none; /* Hide slider on tablet */
    }

    .theme-switch .mobile-toggle-container {
        display: block; /* Show button on tablet */
    }
}

/* Desktop: >1024px - Show desktop slider */
@media (min-width: 1025px) {
    .theme-switch .slider-container {
        display: block; /* Show slider on desktop */
    }

    .theme-switch .mobile-toggle-container {
        display: none; /* Hide button on desktop */
    }
}

/* --- Scroll Behavior --- */
@media (max-width: 768px) {
    #autostany, #contact {
        scroll-margin-top: 50px;
    }
}

/* --- Lightbox --- */
@media (max-width: 768px) {
    /* Override display to flex for centering */
    .lightbox.lightbox-active {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .lightbox-content {
        order: 1; /* Image is the first item */
        max-width: 90%;
        max-height: 85%; /* Use percentage of the stable parent container */
        margin: 0;
    }

    /* All controls in one row below the image */
    .lightbox-controls {
        order: 2; /* Controls container comes after the image */
        display: flex;
        justify-content: space-between; /* [Prev] ... [Close] ... [Next] */
        align-items: center;
        width: 90%;
        padding: 0 1rem;
        margin-top: 1rem;
    }

    .prev, .next, .close {
        position: static !important;
        transform: none !important;
        font-size: 2rem;
        padding: 0.5rem;
    }

    .close {
        font-size: 2.5rem; /* Make close button slightly larger */
    }
}



/* --- Contact Section Mobile --- */
@media (max-width: 768px) {
    .contact {
        margin: 2rem 1rem;
    }

    .contact-title {
        font-size: 1.5rem;
    }

    .contact-description {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }

    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-info {
        gap: 1rem;
    }

    .contact-info-item h3 {
        font-size: 1rem;
    }

    .contact-form-wrapper {
        width: 100%;
    }
}
