/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Mobile: use native/default scrollbars (remove custom styling) */
    html {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
    .scrollbar-thin {
        scrollbar-width: auto !important;
        scrollbar-color: auto !important;
    }
    html::-webkit-scrollbar,
    .scrollbar-thin::-webkit-scrollbar {
        width: initial !important;
        height: initial !important;
    }
    html::-webkit-scrollbar-track,
    .scrollbar-thin::-webkit-scrollbar-track {
        background: initial !important;
        border-radius: initial !important;
    }
    html::-webkit-scrollbar-thumb,
    .scrollbar-thin::-webkit-scrollbar-thumb {
        background: initial !important;
        border-radius: initial !important;
        border: initial !important;
    }
    html::-webkit-scrollbar-thumb:hover,
    .scrollbar-thin::-webkit-scrollbar-thumb:hover {
        background: initial !important;
    }

    /* When secondary header is visible, fade out the primary header shadow */
    .nav-container.secondary-active {
        box-shadow: none;
        transition: box-shadow 0.35s ease, background-color 0.3s ease;
    }

    .text-box.expanded {
        width: 95vw !important;
        height: 80vh !important;
        border-radius: 16px !important;
    }

    .text-box.expanded .text-box-content {
        padding: 30px 20px !important;
    }

    .text-box.expanded .text-box-title {
        font-size: 28px !important;
        margin-bottom: 15px !important;
    }

    .text-box.expanded .text-box-description :not(p, b, .text-box-dropdown, .text-box-dropdown-menu, .text-box-dropdown-item) {
        margin-top: 15px !important;
        padding-right: 12px;
    }

    /* "Plain text" (direct text nodes) is wrapped by JS into spans.
       Include the dropdown trigger (summary.text-box-cta) since it's not an <a>. */
    .text-box.expanded .text-box-description .plain-text,
    .text-box.expanded .text-box-description b,
    .text-box.expanded .text-box-description a,
    .text-box.expanded .text-box-description li,
    .text-box.expanded .text-box-dropdown > summary.text-box-cta {
        font-size: max(18px, 2vh) !important;
    }
    

    .text-box.expanded .text-box-description p {
        font-size: max(20px, 2.3vh) !important;
    }

    .text-box-cta-row {
        gap: 10px;
        margin: 16px 0;
    }

    .text-box-divider {
        display: flex;
        align-items: center;
        gap: 1.2vh;
        margin: 2vh 0;
        line-height: 0;
    }

    .text-box-divider-leaf {
        width: 4vh;
        height: 4vh;
        display: block;
        align-self: center;
        position: relative;
        top: -5px;
    }

    .text-box-divider-leaf::after {
        top: calc(50%);
    }

    .text-box-cta {
        width: 100%;
        padding: 12px 14px;
        border-radius: 12px;
    }

    .text-box-dropdown {
        width: 100%;
    }

    .text-box-dropdown-menu {
        display: none;
        position: static;
        min-width: 0;
        width: 100%;
        margin-top: 10px;
    }

    .text-box-dropdown[open] .text-box-dropdown-menu {
        display: block;
    }

    .text-box-dropdown-item {
        border-radius: 10px;
        padding: 12px 14px;
        font-size: max(14px, 4vw);
    }

    /* Safari renders paragraph text smaller - use larger vw value */
    .is-safari .text-box.expanded .text-box-description p b {
        font-size: max(20px, 5vw) !important;
    }

    .close-button {
        top: 0 !important;
        right: 0 !important;
        width: 35px !important;
        height: 35px !important;
        font-size: 20px !important;
    }
    /* Remove extra red outline on mobile taps */
    .close-button:focus-visible {
        outline: none !important;
        outline-offset: 0 !important;
    }

    /* Mobile: remove focus rings/boxes (tap/keyboard) */
    a:focus,
    a:focus-visible,
    button:focus,
    button:focus-visible,
    summary:focus,
    summary:focus-visible,
    input:focus,
    input:focus-visible,
    select:focus,
    select:focus-visible,
    textarea:focus,
    textarea:focus-visible,
    [tabindex]:focus,
    [tabindex]:focus-visible {
        outline: none !important;
        box-shadow: none !important;
    }

    /* Also remove iOS/Android tap highlight flash */
    a,
    button,
    summary {
        -webkit-tap-highlight-color: transparent;
    }

    .scroll-hint {
        position: fixed;
        bottom: 7vh;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        font-weight: 700;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        font-size: max(16px, 5vw);
        letter-spacing: 1px;
        transition: opacity 0.6s ease, transform 0.6s ease;
    }
    
    .scroll-hint.hidden {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    
    .scroll-hint::before,
    .scroll-hint::after {
        content: '↓';
        font-size: 18px;
        color: var(--primary-color);
        animation: expandArrow 1.5s ease-in-out infinite;
        animation-delay: 0s;
        transform-origin: top center;
    }
    
    @keyframes expandArrow {
        0% {
            opacity: 0;
            transform: scaleY(0);
        }
        50% {
            opacity: 1;
            transform: scaleY(1);
        }
        100% {
            opacity: 0;
            transform: scaleY(1);
        }
    }
    
    /* Keep scroll hint text on a single line on mobile */
    .scroll-hint span {
        white-space: nowrap;
    }
    
    /* Top scroll hint hidden on mobile */
    .top-scroll-hint {
        display: none;
    }
    
    .scroll-arrow {
        font-size: max(14px, 4vw);
    }

    .click-indicator {
        font-size: 11px;
        padding: 5px 10px;
        top: -30px;
    }

    /* Secondary header (mobile-only) */
    #secondaryHeader.secondary-header {
        position: fixed !important;
        top: 1.4vh !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9997 !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;
        padding: 1.7vh;
        height: calc(3vh + 3.4vh);
        margin: 0 1.4vh;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        transform: translateY(0);
        transition: transform 0.35s ease, opacity 0.35s ease;
        pointer-events: none;
        opacity: 0;
        /* Sharp top corners, true half-circle bottom starting at top corners */
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: 50% 100%; /* x-radius 50% of width, y-radius 100% of height */
        border-bottom-right-radius: 50% 100%;
    }
    
    /* When shown at end of scroll */
    #secondaryHeader.secondary-header.show {
        transform: translateY(6.2vh);
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Restore glass effect when shown */
    #secondaryHeader.secondary-header.show .liquidGlass-tint {
        background: rgba(174, 187, 170, 0.65);
    }
    
    #secondaryHeader.secondary-header.show .liquidGlass-effect {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    
    #secondaryHeader.secondary-header.show .liquidGlass-shine {
        box-shadow: inset -1px -1px 1px rgba(0, 0, 0, 0.12),
                          0 3px 14px rgba(0, 0, 0, 0.12);
    }
    /* Glass layers for secondary header to match main header */
    .secondary-header.liquidGlass-wrapper .liquidGlass-effect {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: 50% 100%;
        border-bottom-right-radius: 50% 100%;
    }
    .secondary-header.liquidGlass-wrapper .liquidGlass-tint {
        background: rgba(174, 187, 170, 0.65);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: 50% 100%;
        border-bottom-right-radius: 50% 100%;
    }
    .secondary-header.liquidGlass-wrapper .liquidGlass-shine {
        box-shadow: inset 2px 2px 2px rgba(255, 255, 255, 0.4),
                    inset -1px -1px 1px rgba(0, 0, 0, 0.12),
                          0 3px 14px rgba(0, 0, 0, 0.12);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-left-radius: 50% 100%;
        border-bottom-right-radius: 50% 100%;
    }
    .secondary-header.liquidGlass-wrapper .liquidGlass-text {
        position: relative;
        z-index: 1;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    /* Restore glass effect layers when shown */
    .secondary-header.show .liquidGlass-tint {
        background: rgba(174, 187, 170, 0.65);
    }
    
    .secondary-header.show .liquidGlass-effect {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    
    .secondary-header.show .liquidGlass-shine {
        box-shadow: inset -1px -1px 1px rgba(0, 0, 0, 0.12),
                          0 3px 14px rgba(0, 0, 0, 0.12);
    }
    .secondary-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-weight: 600;
        letter-spacing: 0.2px;
        text-decoration: none;
        color: var(--primary-color);
        padding: 10px 14px;
        transform: translateY(-10%);
        line-height: 1.05;
        transition: transform 0.15s ease;
        background: none !important;
        white-space: nowrap;
        font-size: max(14px, 4vw);
    }

    .logo-container {
        width: 90vw;
        height: 90vw
    }

    .text-box {
        width: 50vw;
        aspect-ratio: 1.8;
        padding: 1vw !important;
    }

    .text-box-title {
        font-size: max(16px, 5vw) !important;
    }

    .text-box.expanded {
        height: 75vh !important;
    }

    .click-text {
        font-size: max(14px, 4vw);
        pointer-events: none;
        cursor: default;
    }

    .logo-click-indicator.show .click-text {
        pointer-events: auto;
        cursor: pointer;
    }

    /* Stack ordering: mobile nav should sit above text boxes but below header */
    .mobile-nav {
        z-index: var(--z-mobile-nav);
    }

    /* Ensure front text boxes sit just under the mobile nav when on small viewports */
    .text-box.is-front {
        z-index: calc(var(--z-mobile-nav) - 1);
    }

    /* Re-affirm no-wrap on very small screens */
    .scroll-hint span {
        white-space: nowrap;
    }
    
    /* Top scroll hint for very small screens */
    .top-scroll-hint {
        font-size: max(13px, 3.5vw);
        letter-spacing: 0.5px;
    }
    
    .top-scroll-hint span {
        white-space: nowrap;
    }

    .text-box-nav {
        display: none;
    }

    .site-credit-desktop {
        display: none;
    }
    
    body > .site-credit {
        display: none;
    }
    
    .text-box-nav {
        display: none;
    }

    .cookie-text {
        font-size: max(15px, 3.4vw);
    }
    .cookie-accept {
        font-size: max(15px, 3.4vw);
        padding: 1vw;
    }
    .cookie-popup {
        padding: 1vw !important;
        bottom: 2vw;
        right: 2vw;
        gap: 1vw;
    }

    /* When cookie popup is visible, add extra scroll room so bottom content
       can be scrolled above the fixed popup. */
    html.cookie-popup-visible body,
    html.cookie-popup-visible .scroll-wrapper {
        padding-bottom: 5vh;
        box-sizing: border-box;
    }

    .site-credit {
        font-size: max(12px, 1.5vh);
    }

    /* Ensure reasonable text-box travel distance */
    :root {
        --text-box-max-travel: 200px;
        --border-radius: 1.5vw !important;
    }
}
