/* =====================================================================
   DOLLVALE — MOBILE GLOW-UP LAYER
   Loaded after css/style.php so it wins the cascade on small screens.
   Page-level inline <style> blocks are beaten with specificity +
   !important where needed.
   ===================================================================== */

/* =====================  PHONES & SMALL TABLETS  ===================== */
@media (max-width: 768px) {

    /* ---------- 1. Base & guardrails ---------- */
    html {
        -webkit-text-size-adjust: 100%;
        overflow-x: hidden;
        overflow-x: clip;
    }
    body { overflow-x: hidden; overflow-x: clip; }

    body img,
    body video,
    body iframe,
    body canvas,
    body svg {
        max-width: 100% !important;
        height: auto;
    }
    body pre,
    body code {
        white-space: pre-wrap;
        word-break: break-word;
        max-width: 100%;
    }
    body .content table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    body h1 { font-size: clamp(22px, 6vw, 28px) !important; line-height: 1.2; overflow-wrap: anywhere; }
    body h2 { font-size: clamp(19px, 5vw, 24px) !important; line-height: 1.25; overflow-wrap: anywhere; }
    body h3 { font-size: clamp(17px, 4.5vw, 20px) !important; line-height: 1.3; }

    /* 16px inputs stop iOS from zooming the page on focus */
    body input,
    body select,
    body textarea,
    body .form-control {
        font-size: 16px !important;
    }
    body .form-control,
    body input:not([type="checkbox"]):not([type="radio"]),
    body select {
        min-height: 44px;
    }

    /* Comfortable thumb targets */
    body .btn,
    body .button-group button,
    body button[type="submit"],
    body .create-thread-btn,
    body .dropdown-toggle {
        min-height: 44px;
    }
    /* ...except compact controls that must stay small */
    body .ql-toolbar button,
    body .ql-toolbar.ql-snow button {
        min-height: 0 !important;
    }
    body .close,
    body #dollCardModal .close {
        min-height: 0;
    }
    body .dropdown-item {
        padding: 12px 14px !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Edge-to-edge shell */
    body .container,
    body .container.custom-container {
        width: 100% !important;
        margin: 0 !important;
        border-left: 0 !important;
        border-right: 0 !important;
        border-radius: 0 !important;
    }

    /* ---------- 2. Header: top bar, nav, login ---------- */
    body .navbar,
    body .navbar.navbar-custom {
        padding: 10px 12px !important;
        gap: 10px !important;
    }
    .site-brand { font-size: 16px; }
    .site-brand-mark { width: 30px; height: 30px; }
    .mobile-nav-toggle { width: 44px; height: 44px; }

    /* Open nav = tidy card, one column, big tap rows */
    .primary-nav.is-open {
        margin-top: 8px;
        padding: 8px;
        border: 1px solid var(--ds-border, #d9dce5);
        border-radius: var(--ds-radius-lg, 12px);
        background: var(--ds-surface-soft, #f6f7fb);
    }
    .primary-nav .nav,
    body .primary-nav nav ul,
    .primary-nav ul {
        grid-template-columns: 1fr !important;
        gap: 2px !important;
    }
    body .primary-nav ul li a,
    body .primary-nav ul li a.nav-link,
    body .primary-nav .dropdown2 .dropdown-toggle {
        width: 100%;
        min-height: 46px;
        justify-content: flex-start !important;
        padding: 10px 14px !important;
        font-size: 15px;
    }
    /* "My Dolls" dropdown opens inline instead of floating */
    body .primary-nav .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin: 0 0 4px !important;
        padding: 2px 0 2px 10px !important;
        border: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* Utilities + search stack cleanly */
    body .nav-right {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100% !important;
    }
    body .nav-utilities { width: 100%; padding: 4px; }
    body .utility-btn,
    body .bell-btn {
        flex: 1 1 0;
        height: 42px;
        font-size: 14px;
    }
    .search-bar { width: 100%; min-width: 100%; }
    .search-bar input {
        width: 100% !important;
        max-width: none !important;
        height: 44px;
    }

    /* Verify-email alert: stack instead of jumble */
    body .alert-warning {
        display: block;
        padding: 14px !important;
    }
    body .alert-warning .resend-verification {
        display: block;
        width: 100%;
        margin: 10px 0 6px !important;
    }

    /* ---------- 3. Header main: banner + user/login card ---------- */
    body .header-main {
        padding: 12px !important;
        gap: 12px !important;
    }
    /* Cover photo first, then the user card — reads like a profile app */
    body .header-main .banner { order: -1; }
    body .header-main .banner,
    body .header-main .banner-image {
        height: 170px !important;
        min-height: 170px !important;
        max-height: 170px !important;
    }
    body .user-area {
        height: auto !important;
        min-height: 0 !important;
        padding: 16px 14px !important;
    }
    body .user-area .login-form { max-width: none; }
    body .user-area .login-form input {
        height: 44px;
        min-height: 44px;
    }
    body .user-area .button-group button,
    body .user-area .button-group .btn { min-height: 44px; }
    body .user-area .dropdown { width: 100%; }
    .edit-cover-photo {
        top: auto !important;
        bottom: 10px;
        right: 10px !important;
        padding: 6px 12px !important;
        min-height: 36px;
        font-size: 13px !important;
    }

    /* ---------- 4. Content rhythm & cards ---------- */
    body .content { padding: 16px 12px !important; }
    body .sidebar { padding: 12px !important; margin-bottom: 12px !important; }

    body .features,
    body .invitation,
    body .closing,
    body .settings-panel,
    body #settings-form,
    body #display-settings-form,
    body #signup-form,
    body .new-post,
    body .post,
    body .user-info-item,
    body .thread-post,
    body .reply-item,
    body .filter-section,
    body .filter-example,
    body .market-card,
    body .new-market-listing {
        padding: 14px !important;
    }

    /* Comments: drop the desktop indent so bubbles get full width */
    body .speech-bubble { margin: 6px 0 0 !important; }
    body .post-interactions { gap: 8px !important; }

    body .user-info-row { grid-template-columns: 1fr !important; }
    body .profile-actions .btn { flex: 1 1 auto; }

    /* Bootstrap modals & lightbox fit the screen */
    body .modal-dialog {
        max-width: calc(100vw - 16px) !important;
        width: auto !important;
        margin: 8px auto !important;
    }
    .bjd-lightbox { padding: 12px; }
    .bjd-lightbox-close { top: 10px; right: 16px; }
    #dollCardModal { padding: 12px !important; }
    #dollCardModal .doll-card-modal-content { padding: 20px 16px !important; margin-top: 4vh !important; }

    /* ---------- 5. Dolls / browse / galleries / profiles ---------- */
    /* Two tidy columns of doll cards (collection + browse) */
    body .content .doll-gallery { gap: 12px !important; padding: 0 !important; justify-content: space-between !important; }
    body .content .doll-gallery .doll-card,
    body .content .doll-gallery .doll-card-link,
    body .content .doll-gallery .doll-sort-placeholder {
        width: calc(50% - 6px) !important;
        flex: 0 0 calc(50% - 6px) !important;
        max-width: calc(50% - 6px) !important;
    }
    body .content .doll-gallery .doll-card-link .doll-card {
        width: 100% !important;
        flex-basis: auto !important;
        max-width: none !important;
    }
    body .doll-card > img { height: 190px !important; object-fit: cover; }

    /* Browse: filter chips become a swipeable row */
    body .material-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        scrollbar-width: none;
    }
    body .material-tabs::-webkit-scrollbar { display: none; }
    body .material-tab { flex: 0 0 auto; white-space: nowrap; }

    /* Gallery: two aligned columns, no stray left margin */
    body .gallery-grid {
        margin-left: 0 !important;
        gap: 12px !important;
    }
    body .gallery-item {
        flex: 0 0 calc(50% - 6px) !important;
        max-width: calc(50% - 6px);
        margin-bottom: 0 !important;
    }
    body .gallery-image { height: 44vw !important; max-height: 220px; }

    /* Doll profile header sits nicely over the cover photo */
    body .doll-header { margin-top: -60px !important; }
    body .doll-profile-image-container { width: 120px !important; height: 120px !important; }
    body .doll-favorite-row { gap: 8px; }

    /* Friends: one card per row, full-width buttons */
    body .friends-list { gap: 12px !important; }
    body .friend-item { flex: 1 1 100% !important; }
    body .friend-card { width: 100% !important; max-width: 420px; }

    /* Feedback / reviews */
    body .reviews-list { gap: 12px !important; }
    body .review-item { flex: 1 1 100% !important; }
    body .content .search-bar { flex-wrap: wrap; }
    body .content .search-bar input[type="text"],
    body .content .search-bar select {
        flex: 1 1 100%;
        width: 100% !important;
    }

    /* ---------- 6. Community / threads / chat / messages ---------- */
    body .forum-section h2 {
        font-size: 16px !important;
        padding: 12px 14px !important;
    }
    body .subforum ul li {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        padding: 14px 14px !important;
    }
    body .subforum ul li .info {
        text-align: left !important;
        white-space: normal !important;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    body .subforum ul li .info .posts-count { margin-bottom: 0 !important; }
    body .thread-list ul li { padding: 12px 14px !important; }

    /* Messages: inbox becomes a swipeable strip above the conversation */
    body .messages-wrap { flex-direction: column !important; gap: 12px !important; }
    body .msg-inbox {
        flex: none !important;
        width: 100%;
        flex-direction: row !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
    }
    body .msg-thread { flex: 0 0 auto; min-width: 210px; }
    body .msg-convo { min-height: 55vh !important; }

    /* Marketplace listing: gallery on top, details below */
    body .market-detail-layout { grid-template-columns: 1fr !important; }
    body .market-detail-price {
        justify-items: start !important;
        font-size: 24px !important;
        white-space: normal !important;
    }

    /* ---------- 7. Footer ---------- */
    body .site-footer ul {
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }
    body .site-footer ul li { margin: 0; }
    body .site-footer ul li a {
        display: block;
        padding: 10px 14px;
    }
}

/* =========================  SMALL PHONES  ========================= */
@media (max-width: 480px) {
    body .header-main .banner,
    body .header-main .banner-image {
        height: 140px !important;
        min-height: 140px !important;
        max-height: 140px !important;
    }
    body .content { padding: 14px 10px !important; }
    body .doll-card > img { height: 160px !important; }
    body .gallery-image { max-height: 190px; }
    body .profile-header { padding-left: 12px !important; padding-right: 12px !important; }
    body .post-interactions span,
    body .post-interactions .pi-btn { font-size: 12px; padding: 7px 12px; }
}
