/* Phone overrides only. Desktop styles remain in the existing templates. */
.mobile-gallery-thumbnails, .mobile-tour-booking { display: none; }

@media (max-width: 767px) {
    main:has(> #hero-section) { display: flex; flex-direction: column; }
    main:has(> #hero-section) > section { order: 3; }
    main:has(> #hero-section) > #hero-section { order: 0; }
    main:has(> #hero-section) > #tours-section { order: 1; }
    main:has(> #hero-section) > #local-values-section { order: 2; }
    .tour-body #trip-information { padding: 16px; border-radius: 18px; }
    #trip-information > h3 { font-size: 16px; margin-bottom: 14px; padding-bottom: 12px; }
    .trip-info-grid { gap: 12px; }
    .trip-info-grid .trip-info-item { padding: 0; border: 0; border-radius: 0; background: transparent; gap: 10px; }
    .trip-info-item .trip-info-icon { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
    .trip-info-item .trip-info-label { font-size: 12px; line-height: 1.35; margin-bottom: 2px; }
    .trip-info-item .trip-info-value { font-size: 11px; line-height: 1.5; }
    body:has(.tour-detail-page) { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
    body:has(.tour-detail-page) > .bg-\[\#F8F9FA\] { display: none; }
    body:has(.tour-detail-page) #back-to-top { bottom: calc(106px + env(safe-area-inset-bottom, 0px)); }
    .tour-detail-page { display: flex; flex-direction: column; }
    .tour-detail-page > * { order: 2; }
    .tour-detail-page #tour-banner-container { order: 0; width: calc(100% - 32px); max-width: calc(100% - 32px); min-width: 0; margin: 12px 16px 0; border-radius: 16px; box-sizing: border-box; }
    .tour-detail-page .tour-intro { order: 1; background: white; border: 0; padding: 12px 0 20px; }
    .tour-intro nav, .tour-heading > div:last-child, .tour-heading > div:first-child > span { display: none; }
    .tour-intro .tour-heading { display: block; text-align: center; }
    .tour-intro .tour-heading h1 { font-size: 21px; line-height: 1.3; color: #17324d; }
    .tour-intro .tour-meta { margin-top: 12px; padding-top: 0; border: 0; justify-content: center; gap: 12px; }
    .tour-meta > div:not(:first-child) { display: none; }
    .tour-gallery #tour-banner-track { height: clamp(288px, calc(100vw - 32px), 440px); aspect-ratio: auto; }
    .tour-gallery .tour-gallery-slide { min-width: 0; max-width: 100%; overflow: hidden; }
    .tour-gallery.has-multiple-images .tour-gallery-slide { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 2fr) minmax(0, 1fr); gap: 5px; }
    .tour-gallery .tour-gallery-slide > img { width: 100%; max-width: 100%; min-width: 0; min-height: 0; box-sizing: border-box; padding: 0; object-fit: cover; object-position: center; background: #f5f5f4; }
    .tour-gallery:not(.has-multiple-images) #tour-banner-track { height: auto; align-items: flex-start; }
    .tour-gallery:not(.has-multiple-images) .tour-gallery-slide { height: auto; }
    .tour-gallery:not(.has-multiple-images) .tour-gallery-slide > img { display: block; height: auto; padding: 8px; }
    .tour-gallery > .relative { position: absolute; right: 8px; bottom: 8px; padding: 0; background: transparent; }
    .tour-gallery .mobile-gallery-thumbnails { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; min-height: 0; }
    .mobile-gallery-thumbnails img { width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 0; object-fit: cover; background: #f5f5f4; }
    .tour-gallery #slider-dots { display: none; }
    .tour-gallery .slider-dot { flex-shrink: 0; height: 10px; min-height: 0; padding: 0; background-color: #94a3b8; }
    .tour-gallery .slider-dot.bg-\[\#28B5A4\] { background-color: #17786c; }
    .tour-gallery #slider-prev-btn, .tour-gallery #slider-next-btn { width: 34px; height: 34px; top: 26px; }
    .tour-gallery > .absolute.bottom-5:not(#slider-dots) { bottom: auto; top: 10px; right: 10px; }
    .tour-gallery > .absolute.bottom-5:not(#slider-dots) button { font-size: 11px; padding: 8px 10px; }
    .tour-tabs { display: none; }
    .tour-body { padding-top: 0; background: white; }
    .tour-body #overview { padding: 0 0 24px; border: 0; border-radius: 0; box-shadow: none; }
    #overview > .mobile-description-title { display: block; }
    #overview > .mobile-description-title + div { display: none; }
    #overview > div { text-align: left; color: #17324d; }
    .mobile-tour-booking {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        background: white; border: 1px solid #e5e7eb; border-radius: 20px 20px 0 0;
        box-shadow: 0 -3px 16px #17324d14;
    }
    .mobile-tour-price { display: flex; flex-direction: column; min-width: 0; color: #17324d; }
    .mobile-tour-price span { font-size: 11px; }
    .mobile-tour-price strong { font-size: 14px; overflow-wrap: anywhere; }
    .mobile-tour-booking-button { display: flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 46px; padding: 10px 18px; border-radius: 28px; background: #17786c; color: white; font-size: 13px; font-weight: 800; }
}

@media (max-width: 767px) {
    .site-header > div:first-child > div { height: 64px; }
    .site-logo { min-width: 0; gap: 8px; }
    .site-logo > img { width: 48px; height: 48px; }
    .site-logo > div { min-width: 0; }
    .site-logo span { overflow-wrap: anywhere; }
    .site-logo span:first-child { font-size: 16px; }
    .site-logo span:last-child { font-size: 8px; letter-spacing: 0.04em; }
    .header-actions { flex-shrink: 0; gap: 6px; margin-left: 8px; }
    .header-actions > * { margin-left: 0; }
    .header-actions .header-customize { display: none; }
    #mobile-menu .mobile-customize { display: block; }
    #mobile-menu {
        max-height: calc(100dvh - 64px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    #mobile-menu a { overflow-wrap: anywhere; }

    main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
    main select, main textarea, #search-modal input {
        min-width: 0;
        max-width: 100%;
        font-size: 16px; /* Avoid automatic zoom when focusing fields on iOS. */
    }
    main input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    main select { min-height: 44px; }

    #hero-section { min-height: 0; }
    #hero-section > .relative { padding-top: 32px; padding-bottom: 32px; }
    #hero-section .hero-copy { display: grid; min-height: 0; }
    #hero-section .hero-text-slide {
        grid-area: 1 / 1;
        position: relative;
        inset: auto;
        min-width: 0;
    }
    #hero-section h1 { font-size: clamp(26px, 7vw, 36px); line-height: 1.2; overflow-wrap: anywhere; }
    #hero-section .hero-search { grid-template-columns: minmax(0, 1fr); }
    .hero-search > div { grid-column: auto; border-right: 0; padding-right: 0; }
    .hero-search > div:last-child { flex-wrap: wrap; }
    .hero-search > div:last-child > div { flex-basis: 100%; }
    .hero-search button[type="submit"] { width: 100%; min-height: 44px; justify-content: center; }
    #hero-prev-btn, #hero-next-btn { display: none; }

    main .tab-link { flex-shrink: 0; white-space: nowrap; }
    main .sticky.top-16 { top: 64px; }
    main [id] { scroll-margin-top: 136px; }
    #search-modal { padding-top: 24px; padding-bottom: 24px; overflow-y: auto; }
    #wishlist-modal { overflow-y: auto; }
    #flash-alert { left: 16px; right: 16px; bottom: 16px; overflow-wrap: anywhere; }
    footer a { overflow-wrap: anywhere; }
}

@media (max-width: 374px) {
    .header-actions { gap: 4px; margin-left: 4px; }
    .header-actions > button, .header-actions > a { width: 36px; height: 40px; }
    .site-logo span:first-child { font-size: 14px; }
    #hero-section > .relative { padding-left: 16px; padding-right: 16px; }
}

/* Reading and touch controls for phones, including iOS safe areas. */
html { -webkit-text-size-adjust: 100%; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 3px solid #17786c; outline-offset: 3px; }
@media (max-width: 767px) {
    .site-topbar { display: none; }
    .site-header { padding-top: env(safe-area-inset-top, 0px); }
    .site-header .header-actions > a, .site-header .header-actions > button { min-width: 44px; min-height: 44px; }
    #mobile-menu a, #mobile-menu button { min-height: 44px; }
    main button:not(.slider-dot), main [role="button"], .site-footer a { min-height: 44px; }
    .site-footer a { display: inline-flex; align-items: center; }
    .tour-intro .tour-heading h1 { font-size: 23px; line-height: 1.35; }
    .tour-gallery #slider-prev-btn, .tour-gallery #slider-next-btn,
    [data-wishlist-id] { min-width: 44px; min-height: 44px; }
    .tour-intro .tour-short-intro { font-size: 14px; line-height: 1.75; text-align: left; }
    .trip-info-item .trip-info-value { font-size: 14px; line-height: 1.55; }
    .trip-info-item .trip-info-label { color: #586779; }
    .tour-detail-page #tour-article > .tour-tabs { padding: 4px 0; }
    .tour-tabs nav { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
    .tour-tabs .tab-link { flex: 0 0 auto; min-height: 44px; font-size: 13px; padding: 10px 12px; }
    #booking-widget { padding: 20px; }
    #tour-enquiry-form label, .transfer-fields label { font-size: 14px; }
    #tour-enquiry-form input, #tour-enquiry-form select, #tour-enquiry-form textarea,
    #customized-tour-form input, #customized-tour-form select, #customized-tour-form textarea { scroll-margin-top: 130px; }
    #tour-enquiry-form button[type="submit"], #customized-tour-form button[type="submit"] { width: 100%; min-height: 52px; }
    body.mobile-keyboard-open .mobile-tour-booking,
    body:has(#mobile-menu:not(.hidden)) .mobile-tour-booking,
    body:has(#search-modal:not(.hidden)) .mobile-tour-booking { visibility: hidden; }
    #tours-section .tour-destination-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; overscroll-behavior-x: contain; }
    #tours-section .tour-destination-tabs a { min-height: 44px; display: inline-flex; align-items: center; flex-shrink: 0; }
    #tours-section .popular-trips-toolbar { padding: 8px; }
    .blog-article-page { padding-top: 24px; padding-bottom: 32px; }
    .blog-article-page article > header h1 { font-size: 26px; line-height: 1.3; }
    .blog-article-page article > .blog-meta { flex-wrap: wrap; gap: 8px 12px; line-height: 1.6; }
    .blog-article-page .article-content { font-size: 16px; line-height: 1.85; }
    .blog-article-page .researched-guide h2 { font-size: 22px; }
    .blog-article-page .researched-guide th, .blog-article-page .researched-guide td { padding: 12px; }
    .blog-article-page aside, .blog-listing-page aside { display: none; }
    .blog-listing-page { padding-top: 24px; padding-bottom: 32px; }
    .blog-listing-page article h3 { font-size: 19px; line-height: 1.45; }
    .blog-listing-page article p { font-size: 14px; line-height: 1.75; }
    .blog-mobile-search { display: flex; gap: 8px; margin-bottom: 24px; }
    .blog-mobile-search input { width: 100%; min-width: 0; padding: 12px; border: 1px solid #d1d5db; border-radius: 12px; }
    .blog-mobile-search button { min-width: 48px; border-radius: 12px; color: white; background: #17786c; }
}
@media (min-width: 768px) { .blog-mobile-search { display: none; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
