/* ===========================
   МОБИЛЬНАЯ ВЕРСИЯ
   =========================== */

/* Скрываем мобильные элементы на десктопе */
.mobile-header,
.mobile-bottom-nav,
.mobile-menu-overlay,
.hero-arrow-mobile {
    display: none;
}

/* Медиа-запрос для мобильных устройств (до 768px) */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .hmanhwa-main {
        padding-left: 16px;
        padding-right: 16px;
    }

    .block-grid .manga-grid {
        margin-left: 0;
        margin-right: 0;
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Скрываем десктопный хедер */
    .site-header {
        display: none !important;
    }

    /* Показываем мобильные элементы */
    .mobile-header,
    .mobile-bottom-nav {
        display: block;
    }

    .mobile-menu-overlay {
        display: block;
    }

    /* Отступ для контента с учетом фиксированных элементов */
    .site-main {
        padding-top: 60px;
        padding-bottom: 80px;
        padding-left: 0;
        padding-right: 0;
    }

    /* ===========================
       МОБИЛЬНЫЙ ХЕДЕР (поиск сверху)
       =========================== */

    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(2, 7, 6, 0.98);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding: 10px 16px;
    }

    .mobile-search form {
        position: relative;
        display: flex;
        align-items: center;
        background: rgba(15, 23, 42, 0.9);
        border: 1px solid rgba(var(--accent-rgb), 0.15);
        border-radius: 20px;
        padding: 0 12px;
        overflow: visible;
        width: 95%;
    }

    .mobile-search__input {
        flex: 1;
        background: transparent;
        border: none;
        color: #f5f7f6;
        font-size: 14px;
        padding: 10px 8px;
    outline: none;
    box-sizing: border-box;
}

    .mobile-search__input::placeholder {
        color: rgba(245, 247, 246, 0.5);
    }

    .mobile-search__button {
        background: transparent;
        border: none;
        color: var(--accent);
        cursor: pointer;
        padding: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ===========================
       НИЖНЯЯ НАВИГАЦИЯ
       =========================== */

    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(2, 7, 6, 0.98);
        backdrop-filter: blur(14px);
        border-top: 1px solid rgba(255, 255, 255, 0.04);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 8px 12px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    }

    .mobile-bottom-nav__item {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: #8c909c;
        text-decoration: none;
        font-size: 11px;
        transition: color 0.2s;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px 8px;
        min-width: 60px;
    }

    .mobile-bottom-nav__item svg {
        flex-shrink: 0;
    }

    .mobile-bottom-nav__item:active,
    .mobile-bottom-nav__item.active {
        color: #79ff6b;
    }

    .mobile-bottom-nav__item--logo {
        transform: translateY(-8px);
        background: radial-gradient(
            circle at top left,
            rgba(121, 255, 107, 0.2),
            #050908
        );
        border: 1px solid rgba(121, 255, 107, 0.3);
        border-radius: 50%;
        width: 56px;
        height: 56px;
        padding: 12px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    }

    .mobile-logo {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .mobile-logo--mask {
        background-color: var(--accent);
        -webkit-mask-image: var(--logo-url);
        mask-image: var(--logo-url);
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-size: contain;
        mask-size: contain;
        -webkit-mask-position: center;
        mask-position: center;
    }

    .mobile-logo-text {
        font-size: 12px;
        font-weight: 700;
        color: #79ff6b;
    }

    .mobile-bottom-nav__badge {
        position: absolute;
        top: 0;
        right: 8px;
        background: #ff6b6b;
        color: #fff;
        font-size: 9px;
        font-weight: bold;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        border: 2px solid #020706;
    }

    /* ===========================
       БУРГЕР-МЕНЮ
       =========================== */

    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        background: rgba(0, 0, 0, 0.8);
        opacity: 0;
        visibility: hidden;
        transition:
            opacity 0.3s,
            visibility 0.3s;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-menu {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 75%;
        max-width: none;
        background: linear-gradient(135deg, #0a0e12 0%, #0f1318 100%);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        border-left: 1px solid rgba(var(--accent-rgb), 0.15);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.6);
    }

    .mobile-menu-overlay.active .mobile-menu {
        transform: translateX(0);
    }

    .mobile-menu__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid rgba(var(--accent-rgb), 0.1);
        background: linear-gradient(
            135deg,
            rgba(var(--accent-rgb), 0.05),
            transparent
        );
    }

    .mobile-menu__header h3 {
        margin: 0;
        font-size: 20px;
        color: var(--text-main);
        font-weight: 700;
    }

    .mobile-menu__close {
        background: transparent;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu__close:active {
        color: var(--text-main);
    }

    .mobile-menu__content {
        flex: 1;
        padding: 20px;
    }

    .mobile-menu__user {
        display: flex;
        gap: 16px;
        padding: 18px;
        background: linear-gradient(
            135deg,
            rgba(var(--accent-rgb), 0.08),
            rgba(var(--accent-rgb), 0.03)
        );
        border: 1px solid rgba(var(--accent-rgb), 0.15);
        border-radius: 16px;
        margin-bottom: 28px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .mobile-menu__avatar img {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid rgba(var(--accent-rgb), 0.2);
    }

    .mobile-menu__user-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
    }

    .mobile-menu__username {
        font-weight: 700;
        color: var(--text-main);
        font-size: 16px;
    }

    .mobile-menu__profile-link {
        color: var(--accent);
        text-decoration: none;
        font-size: 14px;
        transition: color 0.2s;
    }

    .mobile-menu__profile-link:hover {
        color: var(--accent);
        opacity: 0.85;
    }

    .mobile-menu__18-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 18px;
        background: rgba(var(--accent-rgb), 0.05);
        border: 1px solid rgba(var(--accent-rgb), 0.12);
        border-radius: 14px;
        margin-bottom: 28px;
    }

    .mobile-menu__18-label {
        color: var(--text-main);
        font-size: 15px;
        font-weight: 600;
    }

    .mobile-menu__18-switch {
        position: relative;
        width: 52px;
        height: 28px;
        background: rgba(255, 255, 255, 0.12);
        border-radius: 14px;
        cursor: pointer;
        transition: background 0.3s;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mobile-menu__18-switch.active {
        background: var(--accent);
        border-color: rgba(var(--accent-rgb), 0.5);
    }

    .mobile-menu__18-slider {
        position: absolute;
        top: 3px;
        left: 3px;
        width: 22px;
        height: 22px;
        background: var(--text-main);
        border-radius: 50%;
        transition: transform 0.3s;
        border: 1px solid rgba(var(--accent-rgb), 0.28);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    }

    .mobile-menu__18-switch.active .mobile-menu__18-slider {
        transform: translateX(24px);
    }

    .mobile-menu__section {
        margin-bottom: 28px;
    }

    .mobile-menu__section-title {
        font-size: 13px;
        font-weight: 700;
        color: var(--accent);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        margin-bottom: 16px;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(var(--accent-rgb), 0.15);
    }

    .mobile-menu__item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        color: #f5f7f6;
        text-decoration: none;
        border-radius: 12px;
        transition: all 0.2s ease;
        font-size: 15px;
        margin-bottom: 6px;
        border: 1px solid transparent;
    }

    .mobile-menu__item:hover,
    .mobile-menu__item:active {
        background: rgba(var(--accent-rgb), 0.1);
        border-color: rgba(var(--accent-rgb), 0.2);
        color: var(--accent);
        transform: translateX(4px);
    }

    .mobile-menu__item svg {
        flex-shrink: 0;
        opacity: 0.8;
        width: 20px;
        height: 20px;
        transition: opacity 0.2s;
    }

    .mobile-menu__item:hover svg {
        opacity: 1;
    }

    .mobile-menu__item--logout {
        color: #ff6b6b;
        margin-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 20px;
    }

    .mobile-menu__item--logout:hover {
        background: rgba(255, 107, 107, 0.1);
        border-color: rgba(255, 107, 107, 0.2);
        color: #ff6b6b;
    }

    .mobile-menu__auth {
        text-align: center;
        padding: 40px 20px;
        background: rgba(var(--accent-rgb), 0.03);
        border-radius: 16px;
        border: 1px solid rgba(var(--accent-rgb), 0.1);
    }

    .mobile-menu__auth p {
        color: var(--text-muted);
        margin-bottom: 20px;
        font-size: 15px;
        line-height: 1.5;
    }

    .mobile-menu__auth .btn-primary {
        padding: 12px 24px;
        font-size: 16px;
        border-radius: 12px;
    }

    .mobile-menu__section--themes .mobile-menu__section-title {
        margin-bottom: 12px;
    }

    .mobile-theme-menu {
        display: grid;
        grid-template-columns: repeat(4, 32px);
        gap: 10px;
        padding: 12px;
        border-radius: 16px;
        background: rgba(var(--accent-rgb), 0.08);
        border: 1px solid rgba(var(--accent-rgb), 0.18);
    }

    .mobile-theme-menu .header-theme-menu__item {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        padding: 0;
        border: 1px solid rgba(var(--accent-rgb), 0.25);
        background: transparent;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-theme-menu .header-theme-menu__item.is-active {
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.18);
    }

    .mobile-theme-menu .header-theme-menu__swatch {
        width: 22px;
        height: 22px;
        border-radius: 50%;
    }

    /* ===========================
       АДАПТАЦИЯ СЛАЙДЕРА
       =========================== */

    .hmanhwa-hero {
        padding: 0 0 16px;
    }

    .hero-slide {
        height: auto !important;
        min-height: auto !important;
    }

    /* Убираем фоновое изображение на мобильных */
    .hero-bg {
        opacity: 0.3 !important;
    }

    .hero-overlay {
        position: relative;
        height: auto !important;
        min-height: auto !important;
    }

    .hero-inner {
        display: grid !important;
        grid-template-columns: 110px 1fr !important;
        grid-template-rows: auto auto !important;
        column-gap: 16px !important;
        row-gap: 16px !important;
        padding: 20px !important;
        padding-bottom: 80px !important;
        height: auto !important;
        min-height: auto !important;
        align-items: start !important;
    }

    /* Обложка слева */
    .hero-cover {
        grid-column: 1 / 2 !important;
        grid-row: 1 / 2 !important;
    }

    .hero-cover img {
        width: 110px !important;
        height: 165px !important;
        object-fit: cover !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7) !important;
    }

    /* Контент справа от обложки */
    .hero-content {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 2 !important;
        display: block !important;
        min-width: 0 !important;
    }

    /* Скрываем десктопную кнопку на мобильных */
    .hero-desktop-button {
        display: none !important;
    }

    /* Показываем мобильную кнопку только на мобильных */
    .hero-mobile-button {
        display: block !important;
    }

    .hero-tags {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        margin-bottom: 8px !important;
        max-width: 100% !important;
    }

    .chip {
        font-size: 10px !important;
        padding: 3px 6px !important;
        max-width: 100% !important;
    }

    .chip-genre {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ===========================
       Главная: грид 3 в ряд + компактно
       =========================== */

    body.home .manga-catalog-rem__grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
        overflow: visible;
        padding: 0;
    }

    body.home .manga-card-rem__genres,
    body.home .manga-card-rem__rating {
        display: none;
    }

    body.home .manga-card-rem__body {
        display: flex;
        flex-direction: column;
        gap: 6px;
        flex: 1;
    }

    body.home .manga-card-rem__title {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
        overflow-wrap: anywhere;
        line-height: 1.25;
        min-height: calc(1.25em * 2);
    }

    body.home .manga-card-rem__read {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-top: auto;
        justify-content: center;
        min-height: 36px;
    }

    /* Жанры теперь используют `.manga-catalog-rem__grid` и карточки каталога (`manga-card-rem`). */

    .hero-title {
        font-size: 18px !important;
        line-height: 1.3 !important;
        margin: 0 0 10px 0 !important;
        font-weight: 700 !important;
    }

    /* Показываем описание на мобильных, но ограничиваем 2 строками */
    .hero-description {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        font-size: 13px !important;
        width: 90%;
        line-height: 1.4 !important;
        margin: 8px 0 0 0 !important;
        color: var(--text-muted) !important;
    }

    /* Скрываем статистику на мобильных */
    .hero-stats,
    .hero-stats-row {
        display: none !important;
    }

    /* Контейнер для мобильной кнопки */
    .hero-mobile-button {
        grid-column: 1 / -1 !important;
        margin-top: 16px !important;
        display: block !important;
        padding: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Кнопка "Читать" на полную ширину под обложкой и названием */
    .hero-mobile-button .btn-primary,
    .hero-mobile-button .btn-long {
        width: 100% !important;
        margin: 0 !important;
        padding: 14px 16px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        display: block !important;
        text-align: center !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
        background: var(--accent) !important;
        color: #050608 !important;
        text-decoration: none !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.3) !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .hero-mobile-button .btn-primary:hover,
    .hero-mobile-button .btn-long:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 0 26px rgba(var(--accent-rgb), 0.4) !important;
    }

    /* Ограничиваем высоту слайдера */
    .hero-slide .container {
        max-height: none !important;
    }

    /* Убираем лишние отступы */
    .hero-inner.container {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* Навигация слайдера - встроенные стрелки */
    .hero-nav {
        display: none !important;
    }

    /* Мобильные стрелки внизу слайда */
    .hero-arrow-mobile {
        display: flex !important;
        position: absolute;
        bottom: 16px;
        background: rgba(10, 14, 18, 0.95);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(var(--accent-rgb), 0.4);
        color: #b4ff3b;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        font-weight: 300;
        line-height: 1;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 25;
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.7),
            0 0 20px rgba(var(--accent-rgb), 0.15);
    }

    .hero-arrow-mobile.hero-arrow-prev {
        left: 16px;
    }

    .hero-arrow-mobile.hero-arrow-next {
        right: 16px;
    }

    .hero-arrow-mobile:hover {
        background: rgba(var(--accent-rgb), 0.1);
        border-color: rgba(var(--accent-rgb), 0.6);
        box-shadow:
            0 6px 20px rgba(0, 0, 0, 0.8),
            0 0 24px rgba(var(--accent-rgb), 0.25);
        transform: translateY(-1px);
    }

    .hero-arrow-mobile:active {
        background: rgba(var(--accent-rgb), 0.2);
        border-color: rgba(var(--accent-rgb), 0.7);
        transform: scale(0.95);
    }

    /* Скрываем обычную навигацию */
    .hero-dots {
        display: none !important;
    }

    .hero-arrow {
        display: none !important;
    }

    .hero-dot {
        display: none !important;
    }
    .chapters-load-more {
        margin-right: 25px;
    }
}

/* Для очень маленьких экранов (до 375px) */
@media (max-width: 375px) {
    .mobile-bottom-nav__item {
        font-size: 10px;
        min-width: 50px;
        padding: 4px 4px;
    }

    .mobile-bottom-nav__item svg {
        width: 20px;
        height: 20px;
    }

    .mobile-bottom-nav__item--logo {
        width: 48px;
        height: 48px;
    }

    .mobile-menu {
        width: 85%;
    }

    .hero-stats-row {
        grid-template-columns: 1fr;
    }

    /* Дополнительные настройки для очень маленьких экранов */
    .hero-inner {
        padding: 16px !important;
        padding-bottom: 70px !important;
    }

    .hero-cover img {
        width: 100px !important;
        height: 150px !important;
    }

    .hero-title {
        font-size: 16px !important;
    }

    .hero-mobile-button .btn-primary,
    .hero-mobile-button .btn-long {
        padding: 12px 14px !important;
        font-size: 15px !important;
    }
}
