/**
 * Mobile-First Responsive Enhancements
 * Optimized for iPhone 14 Pro (390×844px) and similar devices
 */

/* =================================================================
   NAVIGATION & HEADER
   ================================================================= */

/* Mobile: Reduce brand size and improve spacing */
@media (max-width: 767px) {
    .main-nav h2 {
        font-size: 2rem !important;
        margin-left: 0.25rem !important;
        margin-bottom: -0.25rem !important;
    }

    .main-nav-rule {
        margin-top: 0.25rem !important;
    }

    /* Improve navbar toggle button visibility */
    .navbar-toggler {
        border: 1px solid #999;
        padding: 0.5rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .navbar-toggler-icon {
        width: 1.25em;
        height: 1.25em;
    }

    /* Mobile menu styling */
    .navbar-collapse {
        margin-top: 0.5rem;
        padding: 0 !important;
    }

    .navbar-nav {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100%;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 0 !important;
        width: 100%;
        border-bottom: 1px solid #eee;
    }

    .navbar-nav .nav-item:first-child .nav-link {
        padding-left: 0 !important;
    }

    /* Dropdown menu mobile improvements */
    .dropdown-menu {
        border: none;
        box-shadow: none;
        padding-left: 1rem;
        margin-top: 0 !important;
    }

    .dropdown-item {
        padding: 0.5rem 0;
        font-size: 0.9rem;
    }
}

/* =================================================================
   HOME PAGE - HERO/MASTHEAD
   ================================================================= */

@media (max-width: 767px) {
    /* Reduce hero height on mobile */
    .masthead {
        min-height: 70vh !important;
        padding: 4rem 1rem !important;
    }

    .masthead h1 {
        font-size: 2.5rem !important;
        line-height: 1.2 !important;
        letter-spacing: 0.15em !important;
        margin-bottom: 1rem !important;
    }

    .masthead h2 {
        font-size: 1rem !important;
        margin-bottom: 2rem !important;
    }

    .masthead .btn {
        font-size: 0.9rem !important;
        padding: 0.75rem 2rem !important;
    }
}

/* iPhone 14 Pro specific (390px) */
@media (max-width: 390px) {
    .masthead h1 {
        font-size: 2.25rem !important;
        letter-spacing: 0.1em !important;
    }
}

/* =================================================================
   HOME PAGE - CONTENT SECTIONS
   ================================================================= */

@media (max-width: 767px) {
    /* Fix columns for mobile - stack everything */
    .row.g-0 > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Remove side margins/gutters on mobile */
    .row.g-0 > .col-2 {
        display: none !important;
    }

    /* Text sections - adjust padding */
    section .p-4 {
        padding: 2rem 1.5rem !important;
    }

    /* Section headings */
    section h2 {
        font-size: 1.75rem !important;
    }

    section p {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }

    /* Printer image - reduce scale on mobile */
    section img[src*="Canon-8300-Printer"] {
        transform: scale(1.05) !important;
        margin-bottom: -50px !important;
    }

    /* Contact cards at bottom - stack vertically */
    section .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    section .card {
        flex: 1 1 100% !important;
        margin-bottom: 0 !important;
    }

    /* Adjust contact cards section - clear image by 1rem */
    section[style*="margin-top: -22rem"] {
        margin-top: 1rem !important;
        padding-top: 0 !important;
        position: static !important;
    }
}

/* =================================================================
   GALLERIES PAGE
   ================================================================= */

@media (max-width: 767px) {
    .galleries-index {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .page-header {
        padding: 2rem 1rem !important;
        margin-bottom: 2rem !important;
    }

    .page-header h1 {
        font-size: 2rem !important;
        margin-bottom: 1rem !important;
    }

    .page-header .lead {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .page-header {
        text-align: center !important;
    }

    .page-header .col-lg-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    }

    .page-header .mx-auto {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Mosaic strip - reduce tile size and center */
    .image-mosaic-strip {
        justify-content: center !important;
        margin: 0 auto !important;
        text-align: center !important;
        display: flex !important;
        gap: 0.5rem !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }

    .mosaic-tile {
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0 !important;
    }

    /* Hide excess tiles on mobile - show only 5 tiles to fit 390px width */
    .mosaic-tile:nth-child(n+6) {
        display: none !important;
    }

    /* Gallery cards - ensure single column on mobile */
    .gallery-card {
        margin-bottom: 1.5rem;
    }

    /* Masonry Gallery - Center on mobile */
    /* Reset all container padding for gallery page */
    .gallery-header {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

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

    .masonry-gallery {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
    }

    .masonry-gallery-item {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .gallery-card .card-img-top {
        height: 250px !important;
    }

    .gallery-card .card-title {
        font-size: 1.25rem !important;
    }

    .gallery-card .card-text {
        font-size: 0.9rem !important;
    }
}

/* iPhone 14 Pro specific */
@media (max-width: 390px) {
    .page-header h1 {
        font-size: 1.75rem !important;
    }

    .gallery-card .card-img-top {
        height: 220px !important;
    }
}

/* =================================================================
   IMAGE DISPLAY PAGE
   ================================================================= */

@media (max-width: 767px) {
    .image-container {
        min-height: 40vh !important;
        padding: 1rem 0 !important;
    }

    .main-image img {
        max-height: 60vh !important;
    }

    /* Navigation arrows - make smaller and more accessible */
    .nav-arrow {
        padding: 0.75rem 0.5rem !important;
        font-size: 1.25rem !important;
    }

    .nav-arrow i {
        font-size: 1.25rem !important;
    }

    .nav-prev {
        margin-left: 0.5rem !important;
    }

    .nav-next {
        margin-right: 0.5rem !important;
    }

    .nav-gallery {
        bottom: 0.5rem !important;
        font-size: 0.9rem !important;
    }

    /* Toggle buttons */
    .clean-mode-toggle,
    .fullscreen-toggle {
        top: 0.5rem !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }

    .fullscreen-toggle {
        right: 2.75rem !important;
    }

    /* Image info section */
    .image-info {
        padding: 1.5rem 1rem !important;
    }

    .image-info h1 {
        font-size: 1.75rem !important;
    }

    .image-info h2 {
        font-size: 1.25rem !important;
    }

    .image-info p,
    .image-info .lead {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }
}

/* =================================================================
   FOOTER
   ================================================================= */

@media (max-width: 767px) {
    footer {
        padding: 3rem 0 !important;
    }

    footer h5 {
        font-size: 1.125rem !important;
        margin-bottom: 1rem !important;
    }

    footer p,
    footer li {
        font-size: 0.875rem !important;
    }

    footer .col-md-4 {
        margin-bottom: 2rem !important;
    }

    footer .col-md-4:last-child {
        margin-bottom: 0 !important;
    }
}

/* =================================================================
   GENERAL MOBILE IMPROVEMENTS
   ================================================================= */

@media (max-width: 767px) {
    /* Container padding */
    .container,
    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Typography scale */
    .display-1 {
        font-size: 2.5rem !important;
    }

    .display-2 {
        font-size: 2rem !important;
    }

    .display-3 {
        font-size: 1.75rem !important;
    }

    .display-4 {
        font-size: 1.5rem !important;
    }

    .display-5 {
        font-size: 1.25rem !important;
    }

    .display-6 {
        font-size: 1.125rem !important;
    }

    /* Lead text */
    .lead {
        font-size: 1rem !important;
    }

    /* Buttons */
    .btn {
        padding: 0.5rem 1.25rem !important;
        font-size: 0.9rem !important;
    }

    .btn-lg {
        padding: 0.75rem 2rem !important;
        font-size: 1rem !important;
    }

    /* Cards */
    .card-body {
        padding: 1rem !important;
    }

    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Remove excessive margins on mobile */
    .mb-5, .my-5 {
        margin-bottom: 2rem !important;
    }

    .mt-5, .my-5 {
        margin-top: 2rem !important;
    }

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

/* =================================================================
   TOUCH IMPROVEMENTS
   ================================================================= */

/* Increase touch target sizes */
@media (max-width: 767px) and (hover: none) {
    .btn,
    .nav-link,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Remove hover effects on touch devices */
    .hover-lift:hover {
        transform: none;
    }

    /* Tap instead of hover for dropdowns */
    .dropdown-toggle {
        pointer-events: auto;
    }
}

/* =================================================================
   SAFE AREA ADJUSTMENTS (for notch/Dynamic Island)
   ================================================================= */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .masthead,
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

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

@media (max-width: 844px) and (orientation: landscape) {
    .masthead {
        min-height: 90vh !important;
    }

    .main-image img {
        max-height: 75vh !important;
    }

    /* Reduce vertical spacing in landscape */
    .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* =================================================================
   IMAGE PAGE - INFO SIDEBAR & OVERLAYS
   ================================================================= */

/* Hide mobile touch shortcuts on desktop */
.mobile-touch-shortcuts,
.mobile-touch-shortcuts-collapse {
    display: none;
}

@media (max-width: 767px) {
    /* Hide desktop keyboard shortcuts section on mobile */
    .keyboard-shortcuts-collapse {
        display: none !important;
    }

    /* Show mobile touch shortcuts on mobile */
    .mobile-touch-shortcuts-collapse {
        display: block !important;
    }

    /* Style mobile touch gestures section */
    .touch-gestures i {
        font-size: 1.4rem;
        color: #999;
    }

    .touch-gestures span {
        font-size: 1.2rem;
    }

    /* Hide desktop welcome overlay - not relevant for touch devices */
    .welcome-overlay {
        display: none !important;
    }

    /* Show mobile welcome overlay */
    .welcome-overlay-mobile {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        background: rgba(0, 0, 0, 0.92) !important;
        backdrop-filter: blur(10px) !important;
        color: white !important;
        padding: 1.5rem 2rem !important;
        border-radius: 1rem !important;
        z-index: 1000 !important;
        opacity: 1 !important;
        transition: opacity 1s ease !important;
        pointer-events: none !important;
        max-width: 90vw !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
        display: block !important;
    }

    .welcome-overlay-mobile.fade-out {
        opacity: 0 !important;
    }

    .welcome-overlay-mobile.hidden,
    .welcome-overlay.hidden {
        display: none !important;
    }

    .welcome-content-mobile h4 {
        font-weight: 400;
        color: white;
        font-size: 1.25rem;
        text-align: center;
    }

    .welcome-content-mobile ul {
        margin-bottom: 0;
    }

    .welcome-content-mobile li {
        margin-bottom: 0.75rem;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
    }

    .welcome-content-mobile li:last-child {
        margin-bottom: 0;
    }

    .welcome-content-mobile i {
        color: rgba(255, 255, 255, 0.8);
    }

    /* Add margin to inline icons within text */
    .welcome-content-mobile li i:not(:first-child) {
        margin-left: 0.25rem;
        margin-right: 0.25rem;
        display: inline-block;
        white-space: nowrap;
    }

    /* Prevent awkward line breaks - keep text flowing naturally */
    .welcome-content-mobile li {
        white-space: normal;
        word-wrap: break-word;
    }

    /* Mobile-friendly info sidebar - full width bottom sheet style */
    .image-info {
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        transform: translateY(100%) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3) !important;
    }

    .image-info.show {
        transform: translateY(0) !important;
    }

    /* Info sidebar content adjustments */
    .image-info-content {
        padding: 1rem !important;
        padding-bottom: 2rem !important;
    }

    .image-info h4 {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .image-info .lead {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .image-info p {
        font-size: 1.2rem !important;
        line-height: 1.5 !important;
    }

    .image-info .small {
        font-size: 1rem !important;
    }

    /* Collapse sections default closed on mobile to save space */
    .technical-details-collapse,
    .print-sizes-collapse {
        margin-top: 0.5rem !important;
    }

    .technical-details-collapse[open],
    .print-sizes-collapse[open] {
        margin-bottom: 0.5rem !important;
    }

    /* Info close header */
    .image-info-close {
        padding: 0.75rem 1rem !important;
        border-radius: 1rem 1rem 0 0 !important;
    }

    .image-info-close h6 {
        font-size: 0.9rem !important;
    }

    /* Adjust button spacing for mobile */
    .image-info .btn {
        font-size: 1.2rem !important;
        padding: 0.75rem 1rem !important;
    }

    /* Info toggle button - reposition for mobile */
    .info-toggle {
        bottom: 1rem !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: rgba(0, 0, 0, 0.6) !important;
        padding: 0.75rem 1.5rem !important;
        border-radius: 2rem !important;
    }

    .info-toggle:hover {
        transform: translateX(-50%) !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }

    .image-container.show-controls .info-toggle {
        opacity: 1 !important;
    }

    /* Adjust other controls for mobile */
    .slideshow-toggle {
        top: auto !important;
        bottom: 1rem !important;
        left: 1rem !important;
        transform: none !important;
        background: rgba(0, 0, 0, 0.6) !important;
        padding: 0.75rem 1rem !important;
        border-radius: 2rem !important;
    }

    .slideshow-toggle:hover {
        transform: scale(1.05) !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }

    .fullscreen-toggle {
        top: auto !important;
        bottom: 1rem !important;
        right: 1rem !important;
        left: auto !important;
        background: rgba(0, 0, 0, 0.6) !important;
        padding: 0.75rem 1rem !important;
        border-radius: 2rem !important;
    }

    .fullscreen-toggle:hover {
        transform: scale(1.05) !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }
}

/* =================================================================
   BLOG & TEXT CONTENT
   ================================================================= */

@media (max-width: 767px) {
    .blog-post h1 {
        font-size: 1.75rem !important;
    }

    .blog-post h2 {
        font-size: 1.25rem !important;
    }

    .blog-post p {
        font-size: 1rem !important;
        line-height: 1.7 !important;
    }

    .blog-panel {
        padding: 1rem !important;
    }
}

/* =================================================================
   FLASH MESSAGES & ALERTS
   ================================================================= */

@media (max-width: 767px) {
    .alert {
        font-size: 0.9rem !important;
        padding: 0.75rem 1rem !important;
        margin-bottom: 1rem !important;
    }

    .alert .btn-close {
        padding: 0.5rem !important;
    }
}

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

/* Reduce animations on mobile to improve performance */
@media (max-width: 767px) {
    * {
        transition-duration: 0.2s !important;
    }

    /* Disable parallax/complex effects */
    .hover-lift {
        transition: none !important;
    }

    /* Optimize image rendering */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}
