/* Mobile-first overrides for the support theme.
   Keep this file loaded after style.css. */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

img,
svg,
video,
iframe {
    max-width: 100%;
    height: auto;
}

table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* =============================================
   Tablet and down (max-width: 1160px)
   ============================================= */
@media (max-width: 1160px) {
    #wrapper > * {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* --- Header / Hero --- */
    header#header {
        min-height: 130px;
        padding: 16px 20px 68px;       /* bottom = room for search overlap */
    }

    header#header .header_top {
        gap: 10px;
        min-height: auto;
        margin-bottom: 0;
    }

    header#header #site-title > a > span {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Scrollable nav row */
    header#header nav#menu {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    header#header nav#menu::-webkit-scrollbar {
        display: none;
    }

    header#header ul.menu {
        width: max-content;
        min-width: 100%;
        flex-wrap: nowrap;
        gap: 4px;
        margin: 0;
        padding-bottom: 2px;
    }

    header#header ul.menu > li > a {
        white-space: nowrap;
        padding: 9px 12px;
    }

    /* Hide the external "Go to rizer.io" link */
    header#header nav#menu a[href*="//rizer.io"] {
        display: none !important;
    }

    /* --- Search bar: pull it UP into the dark hero --- */
    #search {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        max-width: 700px;
        transform: none;
        margin: -50px auto 0;           /* negative margin = overlap onto header */
        z-index: 200;
        padding: 0 20px;
    }

    #search .top-search {
        display: none;
    }

    #search form {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 56px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
        border-radius: 12px;
    }

    #search input[type="search"] {
        width: 100%;
        min-width: 0;
        border-radius: 12px 0 0 12px;
        padding: 16px 18px;
        box-shadow: none;
    }

    #search input[type="submit"] {
        width: 56px;
        border-radius: 0 12px 12px 0;
        box-shadow: none;
    }

    #search #search-results {
        position: absolute;
        top: 58px;
        left: 20px;
        right: 20px;
        width: auto;
        max-width: none;
        margin-left: 0;
        z-index: 210;
    }

    /* --- Container / content --- */
    #container {
        background: #ffffff;
    }

    .single-post main#content {
        grid-template-columns: 1fr;
    }

    .single-post #left,
    .single-post #right {
        display: none;
    }

    .single-post #content > div:nth-of-type(2) {
        padding: 16px 16px 36px;
    }

    .single-post .entry-content,
    .single-post .article-body-content,
    .single-post article {
        min-width: 0;
    }

    .single-post .article-body-content pre,
    .single-post .article-body-content table,
    .single-post .article-body-content .wp-block-code {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .single-post .stuck {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* --- Breadcrumb (search, single, category pages) --- */
    nav[aria-label="breadcrumb"] {
        height: auto;
        padding-left: 16px;
        padding-right: 16px;
    }

    nav[aria-label="breadcrumb"] .breadcrumb {
        flex-wrap: wrap;
        gap: 4px 8px;
        padding: 10px 0;
        font-size: 13px;
        line-height: 1.4;
    }

    .home .categories_home {
        padding: 16px 16px 34px;
    }

    .home .categories_home .categories_title {
        font-size: 26px;
        margin-bottom: 20px;
    }

    .home .categories_home .categories > ul.menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 22px;
    }

    .category_page_wrapper {
        padding: 0 16px;
        flex-direction: column;
    }

    .category_page_wrapper .menu-category-sidebar-container {
        padding: 20px 16px;
    }

    .category_page_wrapper ul.menu {
        grid-template-columns: 1fr;
    }

    .category_page_wrapper ul.menu ul.sub-menu {
        margin-top: 22px;
    }

    .category_page_wrapper ul.menu ul.sub-menu li {
        padding-left: 78px;
        min-height: 72px;
    }

    .category_page_wrapper ul.menu ul.sub-menu li::before {
        width: 62px;
        height: 62px;
    }

    /* --- Search results page --- */
    body.search section {
        padding: 0 16px;
    }

    body.search h1.entry-title {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 16px;
    }

    body.search article header {
        align-items: flex-start;
        gap: 10px;
    }

    body.search .post-meta-search {
        flex-direction: column;
        gap: 0;
        font-size: 13px;
    }

    body.search .post-meta-search .post-title-again {
        white-space: normal;
    }

    /* --- Single post page --- */
    .single-post article h1.entry-title {
        font-size: 1.75rem;
        line-height: 1.25;
        margin-top: 0;
        margin-bottom: 10px;
    }

    /* --- Generic page (page.php) --- */
    body.page article {
        padding: 16px;
    }

    body.page h1.entry-title {
        font-size: 1.75rem;
        line-height: 1.25;
    }
}

/* =============================================
   Phone and down (max-width: 760px)
   ============================================= */
@media (max-width: 760px) {
    h1,
    .bigtitle {
        font-size: 2rem;
        line-height: 1.2;
    }

    h2,
    .title {
        font-size: 1.5rem;
        line-height: 1.25;
    }

    h3,
    .subheading1 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    header#header {
        padding: 14px 14px 62px;
    }

    header#header .header_top {
        flex-direction: column;
        align-items: center;
    }

    .home .categories_home {
        padding: 12px 14px 28px;
    }

    .home .categories_home .categories_title {
        font-size: 24px;
        margin-bottom: 16px;
    }

    header#header #branding {
        width: 100%;
    }

    header#header #site-title > a > span {
        justify-content: center;
    }

    /* Hide nav on small phones — not enough room */
    header#header nav#menu {
        display: none;
    }

    /* Search tweaks at phone size */
    #search {
        margin-top: -65px;
        padding: 0 14px;
    }

    #search input[type="search"] {
        font-size: 16px; /* avoid iOS zoom */
        padding: 14px;
    }

    #search input[type="submit"] {
        width: 52px;
        max-height: 47px;
    }

    #search #search-results {
        top: 54px;
        left: 14px;
        right: 14px;
    }

    .home .categories_home .categories > ul.menu {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .home .categories_home .categories > ul.menu > li > a {
        margin-bottom: 12px;
    }

    /* --- Breadcrumb phone --- */
    nav[aria-label="breadcrumb"] {
        padding-left: 14px;
        padding-right: 14px;
    }

    /* --- Single post phone --- */
    .single-post #content > div:nth-of-type(2) {
        padding: 14px 14px 28px;
    }

    .single-post article h1.entry-title {
        font-size: 1.5rem;
    }

    .single-post .reading_time {
        margin-bottom: 18px;
    }

    /* --- Search results phone --- */
    body.search section {
        padding: 0 14px;
    }

    body.search h1.entry-title {
        font-size: 1.35rem;
    }

    .single-post .article-body-content figure,
    .single-post .article-body-content .wp-block-image {
        margin-left: 0;
        margin-right: 0;
    }

    .single-post .article-body-content .wp-block-image img,
    .single-post .article-body-content img {
        width: 100%;
    }

    .category_page_wrapper ul.menu ul.sub-menu {
        column-count: 1;
        column-gap: 0;
    }

    .category_page_wrapper ul.menu ul.sub-menu li {
        margin-bottom: 20px;
    }

    footer#footer #copyright {
        margin-top: 30px;
        padding: 18px 0;
        line-height: 1.4;
    }
}

/* =============================================
   Lightbox mobile reliability fixes
   ============================================= */
@media (hover: none), (pointer: coarse) {
    .single-post .article-body-content .article-image-zoom-wrap {
        width: 100%;
        display: block;
    }

    .single-post .article-body-content .article-image-zoom-wrap > a,
    .single-post .article-body-content .article-image-zoom-wrap > img {
        width: 100%;
    }

    /* Make tap target cover the image area on touch devices */
    .single-post .article-body-content .article-image-zoom-trigger {
        inset: 0;
        right: auto;
        bottom: auto;
        width: 100%;
        height: 100%;
        border-radius: 0;
        display: flex;
        justify-content: flex-end;
        align-items: flex-end;
        padding: 10px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.18), transparent 40%);
        color: #ffffff;
        box-shadow: none;
        opacity: 1;
        transform: none;
    }

    .single-post .article-body-content .article-image-zoom-trigger svg {
        width: 24px;
        height: 24px;
        background: rgba(0, 0, 0, 0.48);
        border-radius: 999px;
        padding: 4px;
        box-sizing: content-box;
    }

    .article-image-lightbox {
        z-index: 2147483000;
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        width: 100vw;
        height: 100dvh;
        min-height: 100vh;
        touch-action: none;
        overscroll-behavior: contain;
    }

    .article-image-lightbox__image {
        max-width: 96vw;
        max-height: calc(100dvh - 80px);
    }

    .article-image-lightbox__close {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        width: 48px;
        height: 48px;
        background: rgba(20, 20, 20, 0.62);
    }

    /* Prevent floating chat widgets from sitting over fullscreen image */
    body.article-image-lightbox-open .intercom-lightweight-app,
    body.article-image-lightbox-open .intercom-launcher,
    body.article-image-lightbox-open .intercom-messenger-frame,
    body.article-image-lightbox-open iframe[id*="intercom"],
    body.article-image-lightbox-open iframe[name*="intercom"] {
        display: none !important;
        pointer-events: none !important;
    }
}
