/* ============================================================
 * RESPONSIVE CSS - Wikipedia Template v25
 * Breakpoints: Mobile (<640px), Tablet (640-1119px), Desktop (>=1120px)
 * Reference: WIKIPEDIA-TABLET-MOBILE (Minerva skin)
 * ============================================================ */

/* ============================================================
 * 1. MOBILE-ONLY ELEMENTS (hidden by default, shown on mobile/tablet)
 * ============================================================ */
.mobile-only,
.mobile-menu-overlay,
.mobile-nav-drawer {
    display: none !important;
}

/* ============================================================
 * 2. TABLET STYLES (640px - 1119px)
 * ============================================================ */
@media screen and (max-width: 1119px) {

    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }

    /* --- HEADER --- */
    .vector-header {
        padding: 0 16px;
        min-height: 56px;
        align-items: center;
    }

    .vector-header-start {
        flex: 1;
    }

    .vector-header-start img {
        width: 180px !important;
        filter: drop-shadow(4px 4px 6px rgba(0, 0, 0, 0.3)) !important;
    }

    /* Hide desktop header elements on tablet/mobile */
    .vector-header-end .vector-search-box-vue,
    .vector-user-links-wide,
    #vector-user-links-dropdown,
    .vector-appearance-landmark {
        display: none !important;
    }

    /* Hide Tools menu on tablet/mobile */
    .vector-page-toolbar-container,
    .vector-page-tools-landmark {
        display: none !important;
    }

    /* Mobile auth buttons (Login / Register) */
    .mobile-auth-buttons {
        display: flex !important;
        gap: 6px;
        align-items: center;
        margin-left: auto;
        order: 99;
    }

    .mobile-auth-btn {
        display: inline-block;
        padding: 3px 6px;
        font-size: 13px;
        font-weight: bold;
        text-decoration: none;
        border-radius: 4px;
        line-height: 1.5;
        white-space: nowrap;
    }

    .mobile-auth-login {
        color: #36c;
        font-weight: bold;
        background: transparent;
        border: 1px solid #36c;
    }

    .mobile-auth-register {
        color: #fff;
        font-weight: bold;
        background: transparent;
        border: 1px solid #36c;
    }

    /* Mobile menu button */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        order: -1;
        margin-right: 8px;
    }

    .mobile-menu-icon {
        display: block;
        width: 20px;
        height: 2px;
        background: #202122;
        position: relative;
    }

    .mobile-menu-icon::before,
    .mobile-menu-icon::after {
        content: '';
        display: block;
        width: 20px;
        height: 2px;
        background: #202122;
        position: absolute;
        left: 0;
    }

    .mobile-menu-icon::before {
        top: -6px;
    }

    .mobile-menu-icon::after {
        top: 6px;
    }

    /* Mobile menu overlay */
    .mobile-menu-overlay {
        display: none !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-menu-overlay.active {
        display: block !important;
    }

    /* Mobile navigation drawer */
    .mobile-nav-drawer {
        display: block !important;
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100%;
        background: #fff;
        z-index: 1000;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    }

    .mobile-nav-drawer.open {
        left: 0;
    }

    .mobile-nav-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid #eaecf0;
    }

    .mobile-nav-logo {
        width: 120px;
        height: auto;
    }

    .mobile-nav-close {
        background: none;
        border: none;
        font-size: 28px;
        cursor: pointer;
        color: #54595d;
        padding: 4px 8px;
        line-height: 1;
    }

    .mobile-nav-list {
        list-style: none;
        margin: 0;
        padding: 8px 0;
    }

    .mobile-nav-list li a {
        display: block;
        padding: 12px 16px;
        color: #202122;
        text-decoration: none;
        font-size: 16px;
        border-bottom: 1px solid #f0f0f0;
    }

    .mobile-nav-list li a:active {
        background: #eaecf0;
    }

    .mobile-nav-secondary {
        padding: 16px;
        border-top: 1px solid #eaecf0;
    }

    .mobile-nav-secondary a {
        display: block;
        padding: 8px 0;
        color: #54595d;
        text-decoration: none;
        font-size: 14px;
    }

    /* --- HIDE SIDEBAR & TOC --- */
    .vector-column-start {
        display: none !important;
    }

    .vector-column-end {
        display: none !important;
    }

    /* --- MAIN CONTENT --- */
    .mw-page-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .mw-page-container-inner {
        display: block !important;
        max-width: 100% !important;
    }

    .mw-content-container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 16px !important;
    }

    .mw-body {
        padding: 0 !important;
        border: none !important;
    }

    /* --- PAGE TITLE BAR --- */
    .vector-page-titlebar {
        flex-wrap: wrap;
    }

    #firstHeading {
        font-size: 1.8em;
        line-height: 1.2;
        margin-bottom: 8px;
    }

    /* Hide page title TOC toggle on tablet (no sidebar TOC) */
    #vector-page-titlebar-toc {
        display: none !important;
    }

    /* --- PAGE TOOLBAR (Article/Talk/Edit tabs) --- */
    .vector-page-toolbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- INFOBOX --- */
    .mw-parser-output .infobox {
        float: none !important;
        margin: 16px auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* --- STICKY HEADER --- */
    .vector-sticky-header-container {
        display: none !important;
    }

    /* --- FOOTER --- */
    #footer {
        padding: 16px !important;
    }

    #footer-info {
        font-size: 13px;
    }

    #footer-places {
        flex-wrap: wrap;
    }

    #footer-places li {
        margin-bottom: 4px;
    }

    #footer-icons {
        justify-content: center;
    }

    .mobile-footer-extra {
        padding: 16px 0;
        border-top: 1px solid #eaecf0;
        margin-top: 16px;
    }

    .mobile-footer-languages h4 {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .mobile-footer-languages p {
        font-size: 13px;
        color: #54595d;
    }
}

/* ============================================================
 * 3. MOBILE STYLES (<640px)
 * ============================================================ */
@media screen and (max-width: 639px) {

    /* --- HEADER --- */
    .vector-header {
        padding: 0 8px;
        min-height: 48px;
    }

    .vector-header-start img {
        width: 140px !important;
    }

    /* --- PAGE TITLE --- */
    #firstHeading {
        font-size: 1.5em;
        word-wrap: break-word;
    }

    /* --- MAIN CONTENT --- */
    .mw-content-container {
        padding: 0 12px !important;
    }

    /* --- INFOBOX (full width on mobile, like Minerva) --- */
    .mw-parser-output .infobox {
        width: 100% !important;
        max-width: 100% !important;
        margin: 12px 0 !important;
        font-size: 14px;
    }

    .mw-parser-output .infobox img {
        max-width: 100%;
        height: auto;
    }

    /* --- TYPOGRAPHY --- */
    .mw-body-content {
        font-size: 16px;
        line-height: 1.65;
    }

    .mw-body-content p {
        margin-bottom: 12px;
    }

    /* --- CATEGORIES --- */
    #catlinks {
        font-size: 13px;
        padding: 12px 0;
    }

    #mw-normal-catlinks ul {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    /* --- ARTICLE TABS (scrollable) --- */
    .vector-menu-tabs .vector-menu-content-list {
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- TOOLBAR --- */
    .vector-page-toolbar-container {
        flex-wrap: wrap;
    }

    #right-navigation {
        width: 100%;
        overflow-x: auto;
    }

    /* --- TABLES (overflow scroll for wide tables) --- */
    .mw-parser-output table:not(.infobox) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* --- FOOTER --- */
    #footer {
        padding: 12px !important;
    }

    #footer-info li {
        margin-bottom: 8px;
    }

    #footer-places {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* --- IMAGES --- */
    .mw-parser-output .mw-file-element {
        max-width: 100%;
        height: auto;
    }

    /* --- REFS & CITATIONS --- */
    .reflist {
        font-size: 13px;
    }

    .refbegin {
        font-size: 13px;
    }

    /* --- COLLAPSIBLE BEHAVIOR HINT (sections) --- */
    .mw-heading2 {
        cursor: pointer;
        position: relative;
        padding-right: 30px;
    }

    .mw-heading2::after {
        content: '';
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 6px solid transparent;
        border-right: 6px solid transparent;
        border-top: 6px solid #54595d;
        transition: transform 0.2s ease;
    }

    .mw-heading2.section-open::after {
        transform: translateY(-50%) rotate(180deg);
    }
}

/* ============================================================
 * 4. SECTION STYLES: Related Articles Cards
 * ============================================================ */

/* Related Articles Cards (mobile/tablet only â€” already has .mobile-only class) */
.read-more-container {
    padding: 16px 0;
    border-top: 1px solid #eaecf0;
}

.read-more-container-heading {
    font-size: 18px;
    font-weight: normal;
    color: #54595d;
    margin-bottom: 12px;
    border: none;
}

.read-more-container-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.read-more-container-card-list li {
    margin-bottom: 12px;
}

.read-more-container-card-list a {
    text-decoration: none;
    color: inherit;
}

.cdx-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}

.cdx-card__thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    background: #eaecf0;
    border-radius: 2px;
    overflow: hidden;
}

.cdx-thumbnail__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cdx-thumbnail__placeholder__icon {
    display: block;
    width: 24px;
    height: 24px;
    background: #c8ccd1;
    border-radius: 2px;
}

.cdx-card__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cdx-card__text__title {
    font-size: 16px;
    font-weight: bold;
    color: #3366cc;
}

.cdx-card__text__description {
    font-size: 14px;
    color: #54595d;
}

/* ============================================================
 * CTA Buttons (full-width, stacked â€” all viewports)
 * ============================================================ */
#cta-buttons {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    margin: 24px 0;
    padding: 0;
}

#cta-buttons .mobile-auth-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    line-height: 1.4;
    box-sizing: border-box;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

#cta-buttons .mobile-auth-login {
    color: #36c;
    background: #fff;
    border: 2px solid #36c;
}

#cta-buttons .mobile-auth-login:hover {
    background: #f0f4ff;
}

#cta-buttons .mobile-auth-register {
    color: #fff;
    background: #36c;
    border: 2px solid #36c;
}

#cta-buttons .mobile-auth-register:hover {
    background: #2a4b8d;
    border-color: #2a4b8d;
}

/* References & Works Cited sections â€” responsive adjustments */
@media screen and (max-width: 639px) {
    .mw-references-wrap {
        column-count: 1 !important;
        column-width: auto !important;
    }

    .refbegin-columns {
        column-count: 1 !important;
        column-width: auto !important;
    }

    .mw-references-wrap ol {
        padding-left: 1.5em;
        font-size: 13px;
    }

    .refbegin ul {
        padding-left: 1em;
        font-size: 13px;
    }
}

/* ============================================================
 * 5. FORCE LIGHT THEME (override night/OS dark mode)
 * The Vector 2022 skin's load.css defines dark variables under
 * html.skin-theme-clientpref-night and @media(prefers-color-scheme:dark).
 * The JS in index.php can swap skin-theme-clientpref-day to -night via cookie.
 * We force light theme to prevent dark backgrounds.
 * ============================================================ */
html.skin-theme-clientpref-night,
html.skin-theme-clientpref-os {
    --background-color-base: #fff !important;
    --background-color-base-fixed: #fff !important;
    --background-color-neutral: #eaecf0 !important;
    --background-color-neutral-subtle: #f8f9fa !important;
    --background-color-interactive: #eaecf0 !important;
    --background-color-interactive-subtle: #f8f9fa !important;
    --background-color-interactive-subtle--hover: #eaecf0 !important;
    --color-base: #202122 !important;
    --color-base--hover: #404244 !important;
    --color-emphasized: #000 !important;
    --color-subtle: #54595d !important;
    --color-placeholder: #72777d !important;
    --color-inverted: #fff !important;
    --color-progressive: #36c !important;
    --color-destructive: #d73333 !important;
    --color-link: #3366cc !important;
    --color-link--visited: #795cb2 !important;
    --border-color-base: #a2a9b1 !important;
    --border-color-subtle: #c8ccd1 !important;
    --border-color-muted: #dadde3 !important;
    color-scheme: light !important;
}

/* Mobile nav drawer â€” always light */
.mobile-nav-drawer {
    background: #fff !important;
}

.mobile-nav-list li a {
    color: #202122 !important;
}

.mobile-nav-close {
    color: #54595d !important;
}

.mobile-menu-icon,
.mobile-menu-icon::before,
.mobile-menu-icon::after {
    background: #202122 !important;
}

/* ============================================================
 * 6. PRINT: Restore desktop-like layout
 * ============================================================ */
@media print {
    .mobile-only {
        display: none !important;
    }
}