@charset "UTF-8";

/**
 * Teznevisan mobile contract — checkpoint 54.
 *
 * This is intentionally a small final cascade layer. It does not create a
 * second mobile design. The actual header/menu live in theme-shell.css; this
 * file only guarantees that legacy page templates and user content cannot
 * make the visual viewport wider than the device.
 */

/* ---------- Non-negotiable viewport contract ---------- */
html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
}

body {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
}

.site-header,
#main-content,
.site-footer,
#page,
.site,
.site-content,
.site-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* The front-end admin bar is frequently present while the owner tests mobile.
   Do not let a long toolbar node become the page's scroll container. */
@media screen and (max-width: 782px) {
    #wpadminbar {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* Flex/grid min-content is the most common real overflow cause in the legacy
   templates. Apply the reset to layout descendants, not only named cards. */
#main-content :where(article, section, aside, header, footer, nav, div, form, fieldset, ul, ol, li),
.site-header :where(nav, div, ul, li),
.site-footer :where(section, nav, div, ul, ol, li) {
    min-width: 0;
}

#main-content :where(img, picture, video, canvas, svg, iframe, embed, object),
.site-header :where(img, svg),
.site-footer :where(img, svg) {
    max-width: 100%;
}

#main-content :where(img, video, canvas),
.site-header img,
.site-footer img {
    height: auto;
}

/* Dynamic content may contain URLs, emails and Latin identifiers with no RTL
   break opportunities. They must wrap instead of defining the page width. */
#main-content :where(h1, h2, h3, h4, h5, h6, p, li, dd, dt, blockquote, figcaption, a, span, strong, em, label),
.site-footer :where(h1, h2, h3, h4, p, li, a, span),
.mobile-menu :where(li, a, span) {
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Intentionally wide content scrolls inside itself; it never widens body. */
#main-content :where(.table-responsive, .wp-block-table, pre, .wp-block-code),
.services-page-wrapper .service-description table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#main-content :where(table) {
    max-width: 100%;
}

#main-content :where(input, select, textarea, button) {
    max-width: 100%;
}

/* ---------- Tablet/mobile shell ---------- */
@media (max-width: 1100px) {
    /* Decorative ::before/::after circles in many landing pages use negative
       offsets. Clip them at their section instead of clipping real content. */
    #main-content > section,
    #main-content > header,
    #main-content > div:not(.breadcrumbs),
    .site-footer {
        max-width: 100%;
        overflow-x: hidden;
    }

    .site-header .header-container.header-main {
        width: calc(100% - 1.5rem) !important;
        max-width: var(--container-width) !important;
        min-width: 0 !important;
        gap: 0.4rem !important;
    }

    .site-header .mobile-menu-toggle {
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .site-header .site-branding {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden;
    }

    .site-header .site-branding .custom-logo-link,
    .site-header .teznevisan-brand-logo {
        max-width: 100%;
        min-width: 0;
    }

    .site-header .site-branding .custom-logo {
        width: auto !important;
        max-width: min(132px, 34vw) !important;
        max-height: 40px !important;
    }

    .site-header .site-title {
        display: block;
        max-width: 100% !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .site-header .header-actions {
        flex: 0 0 auto !important;
        min-width: 0 !important;
        gap: 0.3rem !important;
    }

    .site-header :where(.search-toggle, .theme-toggle) {
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
    }

    /* Overlay itself owns all drawer overflow. Nothing is positioned outside
       the document anymore; closed state is hidden by the HTML hidden attr. */
    .mobile-menu-overlay {
        inset: 0 !important;
        top: var(--tn-adminbar-offset) !important;
        right: 0 !important;
        left: 0 !important;
        width: auto !important;
        max-width: none !important;
        overflow: hidden !important;
        contain: layout paint;
        overscroll-behavior: contain;
    }

    .mobile-menu-panel,
    .mobile-menu-wrapper {
        right: 0 !important;
        left: auto !important;
        width: min(360px, 90%) !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    html[dir="ltr"] .mobile-menu-panel,
    html[dir="ltr"] .mobile-menu-wrapper {
        right: auto !important;
        left: 0 !important;
    }

    .mobile-navigation {
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain;
    }

    .mobile-menu,
    .mobile-menu li,
    .mobile-menu a,
    .mobile-menu .sub-menu {
        width: auto !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .mobile-menu a {
        white-space: normal !important;
    }

    .search-modal {
        inset: 0 !important;
        width: auto !important;
        max-width: none !important;
        overflow-x: hidden !important;
    }

    .search-modal-inner {
        width: min(620px, calc(100% - 2rem)) !important;
        max-width: calc(100% - 2rem) !important;
        min-width: 0 !important;
    }

    #chaty-widget.chaty-widget,
    #accessibility-widget.accessibility-widget {
        max-width: calc(100vw - 1rem) !important;
    }

    #chaty-widget .chaty-channels,
    #accessibility-widget .accessibility-panel {
        max-width: calc(100vw - 1.5rem) !important;
    }
}

/* ---------- Phone layout ---------- */
@media (max-width: 768px) {
    .site-header .container,
    #main-content .container,
    .site-footer .container,
    #main-content .breadcrumbs,
    #main-content.site-main > .breadcrumbs {
        width: calc(100% - 1.5rem) !important;
        max-width: none !important;
        margin-inline: auto !important;
        padding-inline: 0 !important;
    }

    /* Old Bootstrap-style negative gutters are a direct overflow source. */
    #main-content .row {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
    }

    #main-content .row > [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding-inline: 0 !important;
    }

    /* Every legacy 300–450px minmax layout becomes one real fluid track on a
       phone. This includes pages whose class names don't end in "-grid". */
    #main-content :where(
        [class$="-grid"], [class*="-grid "],
        [class$="-layout"], [class*="-layout "],
        [class$="-columns"], [class*="-columns "],
        [class$="-row"], [class*="-row "],
        .form-row,
        .content-layout,
        .archive-layout,
        .search-layout
    ) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    /* List-view cards often retain a 300px thumbnail even after their outer
       grid collapses. Collapse the card itself, too. */
    #main-content :where(
        .posts-container.list-view .post-card,
        .posts-container.list-view .archive-post-card,
        .posts-grid.list-view .tag-post-card,
        .posts-grid.list-view .taxonomy-post-card,
        .search-result-item .result-main
    ) {
        flex-direction: column !important;
        min-width: 0 !important;
    }

    #main-content :where(
        .posts-container.list-view .post-image,
        .posts-container.list-view .post-image-wrapper,
        .posts-grid.list-view .post-image,
        .search-result-item .result-thumbnail
    ) {
        width: 100% !important;
        max-width: 100% !important;
        flex-basis: auto !important;
    }

    #main-content :where(
        [class$="-card"], [class*="-card "],
        [class$="-box"], [class*="-box "],
        [class$="-panel"], [class*="-panel "],
        [class$="-widget"], [class*="-widget "],
        [class$="-illustration"], [class*="-illustration "],
        [class$="-visual"], [class*="-visual "]
    ) {
        max-width: 100% !important;
        min-width: 0 !important;
    }

    #main-content :where(
        [class$="-actions"], [class*="-actions "],
        [class$="-buttons"], [class*="-buttons "],
        [class$="-controls"], [class*="-controls "],
        .button-group, .btn-group,
        .pagination-links, .nav-links
    ) {
        max-width: 100% !important;
        flex-wrap: wrap !important;
    }

    /* Sidebars are content blocks on phones, never sticky/fixed columns. */
    #main-content :where(
        .blog-sidebar, .privacy-sidebar, .search-sidebar, .archive-sidebar,
        .category-sidebar, .tag-sidebar, .taxonomy-sidebar,
        .enhanced-sidebar, .services-sidebar
    ) {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        inset: auto !important;
    }

    #main-content :where(.btn, .button, button, input[type="submit"], input[type="button"]) {
        min-height: 44px;
        white-space: normal;
    }

    #main-content :where(
        input:not([type="checkbox"]):not([type="radio"]),
        select,
        textarea
    ),
    .search-modal :where(input, select, textarea) {
        min-height: 44px;
        font-size: 16px !important;
    }

    .search-modal {
        align-items: flex-start !important;
        padding: calc(var(--tn-adminbar-offset) + 5rem) 0.75rem 1rem !important;
        overflow-y: auto !important;
    }

    .search-modal-inner {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem !important;
    }

    .search-modal .search-form {
        flex-direction: column !important;
    }

    .search-modal-close,
    .mobile-menu-close,
    .mobile-submenu-toggle,
    #accessibility-widget .accessibility-close {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .mobile-menu .menu-item-has-children > a {
        min-height: 48px !important;
        padding-inline-end: 3.4rem !important;
    }

    #accessibility-widget .accessibility-panel {
        width: min(300px, calc(100vw - 1.5rem)) !important;
        max-height: min(76vh, 560px) !important;
    }
}

@media (max-width: 430px) {
    .site-header .header-container.header-main {
        width: calc(100% - 0.75rem) !important;
        gap: 0.2rem !important;
    }

    .site-header .site-branding .custom-logo {
        max-width: min(102px, 30vw) !important;
        max-height: 36px !important;
    }

    .mobile-menu-panel,
    .mobile-menu-wrapper {
        width: min(340px, 94%) !important;
    }

    #chaty-widget.chaty-widget {
        right: 0.65rem !important;
    }

    #accessibility-widget.accessibility-widget {
        left: 0.65rem !important;
    }
}

@media (max-width: 340px) {
    .site-header .header-container.header-main {
        width: calc(100% - 0.5rem) !important;
    }

    .site-header .site-branding .custom-logo {
        max-width: 78px !important;
    }

    .site-header :where(.search-toggle, .theme-toggle),
    .site-header .mobile-menu-toggle {
        flex-basis: 42px !important;
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .search-modal {
        padding-top: calc(var(--tn-adminbar-offset) + 0.75rem) !important;
    }

    .mobile-menu-header {
        min-height: 54px !important;
        padding-block: 0.45rem !important;
    }

    #accessibility-widget .accessibility-panel {
        max-height: calc(100vh - 1rem) !important;
    }
}

/* viewport-fit=cover is used by header.php; reserve the real safe area. */
@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 1100px) {
        body:not(.admin-bar) {
            padding-top: calc(var(--header-height) + env(safe-area-inset-top)) !important;
        }

        body:not(.admin-bar) .site-header {
            height: calc(var(--header-height) + env(safe-area-inset-top)) !important;
            padding-top: env(safe-area-inset-top) !important;
        }

        .mobile-menu-header,
        .mobile-navigation {
            padding-left: max(0.9rem, env(safe-area-inset-left)) !important;
            padding-right: max(0.9rem, env(safe-area-inset-right)) !important;
        }

        .search-modal {
            padding-left: max(0.75rem, env(safe-area-inset-left)) !important;
            padding-right: max(0.75rem, env(safe-area-inset-right)) !important;
            padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
        }

        #chaty-widget.chaty-widget {
            right: max(0.65rem, env(safe-area-inset-right)) !important;
        }

        #accessibility-widget.accessibility-widget {
            left: max(0.65rem, env(safe-area-inset-left)) !important;
        }
    }
}

html.mobile-menu-open,
html.search-modal-open {
    overflow: hidden !important;
}
