/* =========================================================
   home_responsive.css — CSS Nesting gốc, load SAU home.css
   Hỗ trợ: Chrome/Edge 120+, Safari 17.2+, Firefox 117+
   ========================================================= */

/* ---------------------------------------------------------
   THANG CỠ CHỮ (font-size scale)

   Vấn đề trước đây: các giá trị như 12px, 13px, 15px bị gõ
   lặp lại hàng chục lần ở 3 breakpoint bên dưới. Muốn đổi
   "chữ nhỏ" từ 12px thành 13px thì phải tìm và sửa từng chỗ.

   Cách làm: đặt tên cho mỗi cỡ chữ MỘT LẦN ở đây, chỗ nào cần
   thì dùng var(--fs-...). Muốn đổi thì chỉ sửa đúng 1 dòng.

   Tên theo kiểu size áo (2xs < xs < sm < md < lg < xl):
     --fs-2xs =  8px   tiêu đề nhỏ trong menu, chữ trong ô gacha (landscape)
     --fs-xs  = 10px   chữ mô tả dưới ảnh (text-container)
     --fs-sm  = 11px   link và chữ phụ trong footer
     --fs-md  = 12px   chữ menu, nút, ô tìm kiếm, danh sách trong modal
     --fs-lg  = 13px   chữ pagination, tiêu đề footer, ô nhập trong menu
     --fs-xl  = 15px   đoạn message, tiêu đề modal

   Ví dụ: viết font-size: var(--fs-md); là tương đương font-size: 12px;

   Lưu ý:
   - Cỡ chữ chỉ xuất hiện 1–2 lần (11.5px, 14px, 22px, 24px)
     vẫn để số thẳng, vì đặt tên cho chúng không có lợi gì.
   - Chỉ dùng trong file responsive này. Phần chữ dùng đơn vị em
     trong home.css (1em, .85em, ...) không thuộc thang này.
   --------------------------------------------------------- */
:root {
    --fs-2xs: 8px;
    --fs-xs: 10px;
    --fs-sm: 11px;
    --fs-md: 12px;
    --fs-lg: 13px;
    --fs-xl: 15px;
}

/* =========================================================
   Điện thoại dọc
   ========================================================= */
@media screen and (max-width: 780px) and (orientation: portrait) {
    :root {
        --screen-height: 753px;
        --screen-width: 100%;
        --time: 0.2s;
    }

    * {
        &::-webkit-scrollbar {
            width: 0;
        }
    }

    /* ---------- HEADER ---------- */
    .header {
        height: fit-content;
        padding: 1px 5px;
        width: var(--screen-width);

        .button-div {
            padding: 18px;

            h1.button-open {
                position: relative;
                font-size: 22px;
                padding: 0;
                transform: scaleX(1.6);
            }
        }

        .title-div {
            padding: 16px 24px;
            margin-left: 10px;

            h1.title {
                font-size: 24px;
            }

            h1 img {
                height: 24px;
            }
        }

        .search-div {
            display: none;

            .result-box {
                display: none;
            }
        }
    }

    /* ---------- MENU ---------- */
    .menu {
        transition: var(--time-fast);
        --width: var(--screen-width);
        height: 100%;
        top: 0;
        padding-bottom: 100px;
        opacity: .92;

        .menu-item {
            font-size: var(--fs-md);

            &.close-menu-button {
                display: block;
            }

            &:hover {
                background-color: var(--bg2);
                color: var(--text-color);
            }
        }

        .title {
            font-size: var(--fs-2xs);
            margin: 10px 5px;
        }

        .hidden-list {
            input[type="text"] {
                font-size: var(--fs-lg);
                padding: 10px 15px;
            }

            .sub-item {
                font-size: var(--fs-md);

                .hover:hover {
                    text-decoration: none;
                }
            }
        }
    }

    /* ---------- CONTENT ---------- */
    .content {
        --number-col: 2;
        --content-cols: 0 var(--screen-width) 0;
        grid-template-columns: var(--content-cols);
        transition: grid-template-columns 0s;

        html.openMenu>body & {
            --number-col: 2;
            grid-template-columns: var(--content-cols);
        }

        .grid-container {
            grid-row-gap: 1px;
            grid-column-gap: 1px;
            padding: 1px;

            .grid-item {
                border-radius: var(--radius-sm);

                /* "html:not(.openMenu)" để ghi đè rule cùng độ ưu tiên trong home.css */
                &,
                html:not(.openMenu)>body & {
                    padding: 10px 5px;
                }

                .info-button {
                    display: none;
                }

                .flex-container .text-container {
                    margin-top: 8px;

                    &,
                    html:not(.openMenu)>body & {
                        font-size: var(--fs-xs);
                    }
                }
            }
        }
    }

    .cv {
        font-weight: normal;
    }

    .hidden-info {
        display: none !important;
        width: 0;
        height: 0;
        padding: 0;
        margin: 0;
        background-color: transparent;
    }

    /* ---------- MODEL ---------- */
    .model-container {
        .model-body {
            height: 90%;
            margin-top: -40px;

            .model-header {
                height: 7%;

                h3 {
                    font-size: var(--fs-xl);
                }
            }

            .model-footer .model-btn {
                padding: 5px 40px;
                font-size: var(--fs-md);
                border-radius: var(--radius-sm);

                &.x10btn {
                    border: 1px solid var(--tag-color);
                    border-image: none;
                    box-shadow: 0 1px 8px var(--tag-color);
                    border-radius: var(--radius-sm);
                }
            }
        }

        .close-model-btn {
            width: 25px;
            height: 25px;
            top: 24px;
            right: 25px;
        }
    }

    .gacha-modal-body {
        height: 86%;
        padding: 4px 2px;
        margin: 0 5px;
        border-radius: var(--radius-sm);

        .gacha-grid-container {
            grid-template-columns: repeat(2, minmax(0, 1fr));
            grid-row-gap: 4px;
            grid-column-gap: 2px;

            .grid-item {
                border-radius: var(--radius-xs);
                padding: 4px;
                max-width: 100%;
                min-height: 180px;
                max-height: 185px;

                .flex-container .text-container {
                    margin-top: 10px;
                    font-size: var(--fs-xs);
                }
            }
        }
    }

    .modal-footer {
        height: 7%;
        padding: 4px;
        justify-content: space-between;
    }

    /* Nút Gacha */
    .special-button {
        padding: 17px 65px;
        font-size: var(--fs-md);
    }

    .sub-special-button {
        &::before {
            right: -2px;
        }

        &.left::before {
            left: -2px;
        }

        &::after {
            right: -4px;
        }

        &.left::after {
            left: -4px;
        }
    }

    /* ---------- PAGINATION ---------- */
    .pagination {
        margin: 0;
        min-height: calc(var(--screen-height) * .1);

        .pagination-body {
            font-size: var(--fs-lg);

            a {
                border-radius: var(--radius-sm);
                width: 35.5px;
                height: 35px;
                padding: 10px 0;
                margin: 1.5px;

                &:not(#none-link, .active):hover {
                    background-color: var(--bg);
                    color: var(--text-color);
                    border: 0 solid;
                }
            }
        }
    }

    /* ---------- FOOTER ---------- */
    .footer {
        padding: 8px 15px;
        line-height: 1.25;

        h1.title {
            font-size: var(--fs-xl);
        }

        .footer-content {
            --row-footer: 3;
            display: grid;
            grid-template-columns: 1fr;
            grid-auto-rows: auto;

            .grid-item {
                margin: 0;
                padding: 10px 20px;
                height: fit-content;

                a {
                    font-size: var(--fs-sm);
                    margin-left: 20px;

                    &:hover {
                        color: var(--text-color);
                    }
                }

                h2 {
                    font-size: var(--fs-lg);
                    margin: 0 0 10px 0;
                }
            }
        }

        .c {
            font-size: var(--fs-sm);
        }
    }

    html.openMenu>body :is(.footer, .pagination) {
        margin-left: 0;
        width: var(--screen-width);
    }

    /* ---------- BODY ---------- */
    body {
        width: 100vw;
    }

    html.openMenu>body {
        overflow: hidden;
    }

    body p.message,
    html.openMenu>body p.message {
        display: block;
        font-size: var(--fs-xl);
        padding: 10px;
        margin: calc(var(--screen-width) * .02);
    }

    /* ---------- MODAL MỚI ---------- */
    .sub-rank-list a.item,
    .accordion-header,
    .search,
    .select-box :is(select, option, label) {
        font-size: var(--fs-md);
    }

    .sub-rank-list a.item {
        padding-block: 7px;
    }

    .select-box,
    .search {
        margin-bottom: 0;
    }

    .border-spin-special-box {
        width: 99%;
        height: 99%;
    }

    .modal-header {
        height: 10%;
        font-size: var(--fs-xl);
        padding-inline: 10px;
    }

    .modal-body {
        height: calc(90% - 10px);

        &.rank-list {
            grid-template-columns: repeat(1, minmax(0, 1fr));
            grid-template-rows: repeat(3, min-content);
            overflow-y: auto;
        }
    }
}

/* =========================================================
   Màn hình trung bình (780px – 1400px)
   ========================================================= */
@media screen and (min-width: 780px) and (max-width: 1400px) {
    :root {
        --vh: 100vh;
        --vw: 100vw;
        --screen-height: 339px;
        --screen-width: 100%;
        --screen-width2: 800px;
        --time: 0s;
    }

    * {
        &::-webkit-scrollbar {
            width: 0;
        }
    }

    /* ---------- HEADER ---------- */
    .header {
        position: relative;
        overflow: visible;
        height: calc(var(--screen-height) * .24);
        padding: 1px;
        width: var(--screen-width);

        .button-div h1.button-open {
            position: relative;
        }

        .title-div {
            margin-left: -20px;

            h1.title {
                font-size: 24px;
            }

            h1 img {
                height: 26px;
            }
        }

        .search-div {
            margin-left: 20px;
            position: relative;
            overflow: visible;

            .result-box {
                position: absolute;
                top: calc(var(--screen-height) * .2);
                width: calc(var(--screen-width2) * .53);
                max-height: calc(var(--screen-height) * .6);
                font-size: var(--fs-md);

                a {
                    padding: 5px 10px;

                    &:hover {
                        background-color: inherit;
                    }
                }
            }

            .search-div2 {
                input[type="text"].search-input {
                    width: calc(var(--screen-width2) * .47);
                    font-size: 14px;
                }

                .search-icon {
                    padding: 6.75px 10px;

                    h1 {
                        font-size: 22px;
                    }
                }
            }
        }
    }

    /* ---------- MENU ---------- */
    .menu {
        transition: var(--time-fast);
        --width: calc(var(--screen-width) * .4);
        height: 100%;
        top: 0;
        padding-bottom: 100px;
        opacity: .92;

        .menu-item {
            font-size: var(--fs-lg);

            &.close-menu-button {
                display: block;
            }

            &:hover {
                background-color: var(--bg2);
                color: var(--text-color);
            }
        }

        .title {
            font-size: var(--fs-2xs);
            margin: 10px 5px;
        }

        .hidden-list {
            input[type="text"] {
                font-size: var(--fs-lg);
                padding: 10px 15px;
            }

            .sub-item {
                font-size: var(--fs-lg);

                .hover:hover {
                    text-decoration: none;
                }
            }
        }
    }

    /* ---------- CONTENT ---------- */
    .content {
        --number-col: 4;
        --content-cols: calc(var(--screen-width) * 0.02) calc(var(--screen-width) * 0.96) calc(var(--screen-width) * 0.02);
        grid-template-columns: var(--content-cols);
        transition: grid-template-columns 0s;

        html.openMenu>body & {
            grid-template-columns: var(--content-cols);
        }

        .grid-container {
            grid-row-gap: 10px;
            grid-column-gap: 5px;

            .grid-item {
                border-radius: var(--radius-sm);

                &,
                html:not(.openMenu)>body & {
                    padding: 10px 8px;
                }

                .info-button {
                    display: none;
                }

                .flex-container .text-container {
                    margin-top: 8px;

                    &,
                    html:not(.openMenu)>body & {
                        font-size: var(--fs-lg);
                    }
                }
            }
        }
    }

    .cv {
        font-weight: normal;
    }

    .hidden-info {
        display: none !important;
        width: 0;
        height: 0;
        padding: 0;
        margin: 0;
        background-color: transparent;
    }

    /* ---------- PAGINATION ---------- */
    .pagination {
        margin: 10px 0;

        .pagination-body {
            font-size: var(--fs-lg);

            a {
                border-radius: var(--radius-sm);
                width: 35.5px;
                height: 35px;
                padding: 10px 0;
                margin: 1.5px;

                &:not(#none-link, .active):hover {
                    background-color: var(--bg);
                    border: 0 solid;
                }
            }
        }
    }

    /* ---------- FOOTER ---------- */
    .footer {
        padding: 8px 15px;
        font-size: var(--fs-sm);
        line-height: 1.25;

        h1.title {
            font-size: var(--fs-lg);
        }

        .footer-content .grid-item {
            margin: 0;
            padding: 20px;

            a:hover {
                color: var(--text-color);
            }

            h2 {
                font-size: var(--fs-md);
                margin: 0 0 10px 0;
            }
        }
    }

    html.openMenu>body :is(.footer, .pagination) {
        margin-left: 0;
        width: var(--screen-width);
    }

    /* ---------- BODY ---------- */
    body {
        width: 100vw;

        p.message {
            display: block;
            padding: 10px;
            margin-left: calc(var(--screen-width) * .02);
        }
    }

    html.openMenu>body p.message {
        margin-left: calc(var(--screen-width) * .02);
    }
}

/* =========================================================
   Điện thoại ngang
   ========================================================= */
@media screen and (max-width: 780px) and (orientation: landscape) {
    :root {
        --vh: 100vh;
        --vw: 100vw;
        --screen-height: 339px;
        --screen-width: 100%;
        --screen-width2: 685px;
        --time: 0s;
    }

    * {
        &::-webkit-scrollbar {
            width: 0;
        }
    }

    /* ---------- HEADER ---------- */
    .header {
        position: relative;
        overflow: visible;
        height: calc(var(--screen-height) * .24);
        padding: 1px;
        width: var(--screen-width);

        .button-div h1.button-open {
            position: relative;
        }

        .title-div {
            margin-left: -20px;

            h1.title {
                font-size: 24px;
            }

            h1 img {
                height: 26px;
            }
        }

        .search-div {
            margin-left: 20px;
            position: relative;
            overflow: visible;

            .result-box {
                position: absolute;
                top: calc(var(--screen-height) * .2);
                width: calc(var(--screen-width2) * .53);
                max-height: calc(var(--screen-height) * .6);
                font-size: var(--fs-md);

                a {
                    padding: 5px 10px;

                    &:hover {
                        background-color: inherit;
                    }
                }
            }

            .search-div2 {
                input[type="text"].search-input {
                    width: calc(var(--screen-width2) * .47);
                    font-size: 14px;
                }

                .search-icon {
                    padding: 6.75px 10px;

                    h1 {
                        font-size: 22px;
                    }
                }
            }
        }
    }

    /* ---------- MENU ---------- */
    .menu {
        transition: var(--time-fast);
        --width: calc(var(--screen-width) * .4);
        height: 100%;
        top: 0;
        padding-bottom: 100px;
        opacity: .92;

        .menu-item {
            font-size: var(--fs-md);

            &.close-menu-button {
                display: block;
            }

            &:hover {
                background-color: var(--bg2);
                color: var(--text-color);
            }
        }

        .title {
            font-size: var(--fs-2xs);
            margin: 10px 5px;
        }

        .hidden-list {
            input[type="text"] {
                font-size: var(--fs-lg);
                padding: 10px 15px;
            }

            .sub-item {
                font-size: var(--fs-md);

                .hover:hover {
                    text-decoration: none;
                }
            }
        }
    }

    /* ---------- CONTENT ---------- */
    .content {
        --number-col: 4;
        --content-cols: calc(var(--screen-width) * 0.02) calc(var(--screen-width) * 0.96) calc(var(--screen-width) * 0.02);
        grid-template-columns: var(--content-cols);
        transition: grid-template-columns 0s;

        html.openMenu>body & {
            grid-template-columns: var(--content-cols);
        }

        .grid-container {
            grid-row-gap: 10px;
            grid-column-gap: 5px;

            .grid-item {
                border-radius: var(--radius-sm);

                &,
                html:not(.openMenu)>body & {
                    padding: 10px 8px;
                }

                .info-button {
                    display: none;
                }

                .flex-container .text-container {
                    margin-top: 8px;

                    &,
                    html:not(.openMenu)>body & {
                        font-size: var(--fs-xs);
                    }
                }
            }
        }
    }

    .cv {
        font-weight: normal;
    }

    .hidden-info {
        display: none !important;
        width: 0;
        height: 0;
        padding: 0;
        margin: 0;
        background-color: transparent;
    }

    /* ---------- MODEL ---------- */
    .model-container {
        .model-body {
            height: 98%;

            .model-header {
                height: 10%;

                h3 {
                    font-size: var(--fs-lg);
                }
            }

            .model-footer .model-btn {
                padding: 3px 55px;
                font-size: var(--fs-xs);
                border-radius: var(--radius-sm);

                &.x10btn {
                    border: 1px solid var(--tag-color);
                    border-image: none;
                    box-shadow: 0 1px 8px var(--tag-color);
                    border-radius: var(--radius-sm);
                }
            }
        }

        .close-model-btn {
            width: 25px;
            height: 25px;
            top: 6.5px;
            right: 37px;
        }
    }

    .gacha-modal-body {
        height: 80%;
        padding: 4px 2px;
        margin: 0 5px;
        border-radius: var(--radius-sm);

        .gacha-grid-container {
            grid-template-columns: repeat(5, minmax(0, 1fr));
            grid-row-gap: 4px;
            grid-column-gap: 2px;

            .grid-item {
                border-radius: var(--radius-xs);
                padding: 4px;
                max-width: 100%;
                min-height: 150px;
                max-height: 160px;

                .flex-container .text-container {
                    margin-top: 5px;
                    font-size: var(--fs-2xs);
                }
            }
        }
    }

    .modal-footer {
        height: 10%;
        padding: 7px;
        justify-content: space-between;
    }

    /* Nút Gacha */
    .special-button {
        padding: 17px 65px;
        font-size: var(--fs-md);
    }

    .sub-special-button {
        &::before {
            right: -2px;
        }

        &.left::before {
            left: -2px;
        }

        &::after {
            right: -4px;
        }

        &.left::after {
            left: -4px;
        }
    }

    /* ---------- PAGINATION ---------- */
    .pagination {
        margin: 10px 0;

        .pagination-body {
            font-size: var(--fs-lg);

            a {
                border-radius: var(--radius-sm);
                width: 35.5px;
                height: 35px;
                padding: 10px 0;
                margin: 1.5px;

                &:not(#none-link, .active):hover {
                    background-color: var(--bg);
                    border: 0 solid;
                }
            }
        }
    }

    /* ---------- FOOTER ---------- */
    .footer {
        padding: 8px 15px;
        font-size: var(--fs-sm);
        line-height: 1.25;

        h1.title {
            font-size: var(--fs-md);
        }

        .footer-content .grid-item {
            margin: 0;
            padding: 20px;

            a {
                font-size: var(--fs-sm);

                &:hover {
                    color: var(--text-color);
                }
            }

            h2 {
                font-size: 11.5px;
                margin: 0 0 10px 0;
            }
        }

        .c {
            font-size: var(--fs-sm);
        }
    }

    html.openMenu>body :is(.footer, .pagination) {
        margin-left: 0;
        width: var(--screen-width);
    }

    /* ---------- BODY ---------- */
    body {
        width: 100vw;
    }

    body p.message,
    html.openMenu>body p.message {
        display: block;
        font-size: var(--fs-xl);
        padding: 10px;
        margin: calc(var(--screen-width) * .02);
    }

    /* ---------- MODAL MỚI ---------- */
    .sub-rank-list a.item,
    .accordion-header,
    .search,
    .select-box :is(select, option, label) {
        font-size: var(--fs-md);
    }

    .sub-rank-list a.item {
        padding-block: 7px;
    }

    .select-box,
    .search {
        margin-bottom: 0;
    }

    .border-spin-special-box {
        width: 99%;
        height: 99%;
    }

    .modal-header {
        height: 18%;
        font-size: var(--fs-xl);
        padding-inline: 10px;
    }

    .modal-body {
        height: calc(82% - 10px);

        &.rank-list {
            grid-template-columns: repeat(1, minmax(0, 1fr));
            grid-template-rows: repeat(3, min-content);
            overflow-y: auto;
        }
    }
}