/*
 * Responsive layout for Themolio 2.3+
 * The layout is intentionally based on viewport width instead of wp_is_mobile().
 */

/* Tablets: prevent 3/4-column grids from becoming too narrow. */
@media (min-width: 769px) and (max-width: 1024px) {
    .wrapper {
        width: 100%;
        max-width: 100%;
    }

    header[role="banner"] {
        padding-left: 20px;
        padding-right: 20px;
    }

    #content .wrapper {
        padding: 20px;
    }

    .grid-col-3,
    .grid-col-4 {
        width: 48%;
    }

    .grid-horizontal-col-3,
    .grid-horizontal-col-4 {
        width: 44%;
    }
}

/* Phones and small tablets: one column, full viewport width. */
@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .wrapper {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    #content .wrapper {
        display: block;
        padding: 12px;
    }

    .container,
    .fullcontainer,
    .widget-area {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .widget-area {
        margin-top: 20px;
    }

    /* Header becomes fluid instead of using the old fixed 130px table layout. */
    header[role="banner"],
    header[role="banner"] .wrapper,
    header[role="banner"] .tablayout {
        height: auto;
        min-height: 0;
    }

    header[role="banner"] {
        padding: 14px 12px;
    }

    header[role="banner"] .tablayout,
    header[role="banner"] .tablayout tbody,
    header[role="banner"] .tablayout tr,
    header[role="banner"] .tablayout td {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto;
        text-align: center !important;
    }

    header[role="banner"] .tablayout td + td {
        margin-top: 10px;
    }

    .custom-logo {
        width: auto;
        max-width: min(100%, 120px);
        height: auto;
    }

    .site-title {
        font-size: clamp(32px, 11vw, 45px);
        overflow-wrap: anywhere;
    }

    header[role="banner"] #s,
    header[role="banner"] #searchsubmit {
        width: 100%;
        max-width: 100%;
        margin-top: 6px;
    }

    /* Primary menu: readable stacked menu instead of a fixed desktop row. */
    nav .wrapper {
        padding: 0;
    }

    .main-menu {
        overflow: visible;
    }

    .main-menu ul,
    .main-menu ul ul {
        width: 100%;
        position: static;
        visibility: visible;
    }

    .main-menu ul li,
    .main-menu ul ul li {
        float: none;
        display: block;
        width: 100%;
    }

    .main-menu ul li a {
        width: 100%;
        padding: 12px 14px;
    }

    .main-menu ul ul a {
        padding-left: 28px;
    }

    .main-menu ul ul ul a {
        padding-left: 42px;
    }

    /* Every grid configuration becomes one column on phones. */
    .grid-col,
    .grid-col-1,
    .grid-col-2,
    .grid-col-3,
    .grid-col-4 {
        float: none;
        width: 100%;
        margin: 0;
    }

    .post-grid-horizontal,
    .grid-horizontal-col-1,
    .grid-horizontal-col-2,
    .grid-horizontal-col-3,
    .grid-horizontal-col-4 {
        display: block;
        width: 100%;
        min-height: 0;
        margin: 0 0 16px;
    }

    .grid-col article.post {
        width: 100%;
        margin: 0 0 16px;
    }

    /* Square featured-image behaviour from 2.2.0 is retained. */
    .grid-thumb {
        width: 100%;
        aspect-ratio: 1 / 1;
    }

    .grid-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    article.post,
    article.page,
    article.type-attachment {
        padding: 14px;
    }

    .entry-title,
    .grid-title {
        overflow-wrap: anywhere;
    }

    .entry-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
    }

    .alignleft,
    .alignright,
    img.alignleft,
    img.alignright {
        float: none;
        display: block;
        margin: 10px auto !important;
    }

    /* Sidebar remains available, but follows the content. */
    .widget-area {
        clear: both;
    }

    footer .tablayout,
    footer .tablayout tbody,
    footer .tablayout tr,
    footer .tablayout td {
        display: block;
        width: 100%;
        text-align: center !important;
    }

    footer .tablayout td + td {
        margin-top: 10px;
    }
}

/* Galaxy S10-class widths and other narrow phones. */
@media (max-width: 400px) {
    #content .wrapper {
        padding: 10px;
    }

    article.post,
    article.page,
    article.type-attachment,
    .widget {
        padding: 12px;
    }

    .site-title {
        font-size: clamp(28px, 10vw, 38px);
    }
}
