/* Общие сбросы */
* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

body {
    background-image: url('../page/fon.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* Логотип */
.logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 170px;
    height: auto;
    pointer-events: none;
    z-index: 10;
}

/* Заголовок сверху */
.nad3 {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font: bold 30px Arial, sans-serif;
    color: white;
    text-shadow: 2px 1px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    z-index: 10;
}

/* Базовый класс для всех центральных изображений */
.center-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
}

/* Конкретные размеры и коррекция позиции */
.rama {
    height: 750px;
    width: auto;
}

.anosov {
    height: 600px;
    width: auto;
    top: 45.6%;
    left: 49%;
}

.nad {
    height: 250px;
    width: auto;
    top: 46%;
    left: 51%;
}

.button-catalog {
    background-color: red;
    height: 70px;
    width: 300px;
    color: white;
    font: bold 30px Arial, sans-serif;
    position: absolute;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    z-index: 20;
    bottom: 10%;
}

@media (orientation: portrait) {
    .button-catalog {
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (orientation: landscape) {
    .button-catalog {
        left: 70%;
        transform: none;
        top: 65%;
        bottom: auto;
    }
}

/* Сайдбар — плавное появление */
.sidebar-left {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    transform: translateX(-100%);
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar-left.active {
    transform: translateX(0);
}

/* Шапка каталога */
.catalog-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 10px;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.back-btn:hover {
    opacity: 0.8;
}

.back-btn[hidden] {
    display: none;
}

.catalog-title {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: 24px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 50px;
    cursor: pointer;
    color: white;
    width: 50px;
    height: 50px;
    line-height: 1;
    text-align: center;
    opacity: 0.9;
    margin-left: 10px;
    flex-shrink: 0;
}

.close-btn:hover,
.close-btn:focus {
    opacity: 1;
    outline: none;
}

/* Сетка элементов каталога */
.items-grid-full {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    padding: 10px;
    justify-content: center;
    overflow-y: auto;
    flex-grow: 1;
    align-content: flex-start;
}

/* Карточка элемента — обновлённая версия */
.item {
    flex: 0 0 calc(48% - 20px);
    min-width: 200px;
    padding: 0;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    text-align: left;
    font-weight: bold;
    color: #1e3c72;
    font-size: 18px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    cursor: pointer;
    border: 2px solid transparent;
    overflow: hidden;
}

.item:hover {
    transform: scale(1.02);
    background-color: white;
    border-color: #ffaa00;
}

.item:active {
    transform: scale(0.98);
}

/* Иконка на всю ширину */
.item-icon {
  width: 100%;
  height: 180px;        /* фиксированная высота области изображения */
  object-fit: cover;    /* заполняем всю область, обрезая лишнее */
  border-radius: 12px 12px 0 0;
}

/* Текст под картинкой */
.item-name {
    flex: 1;
    font-weight: 600;
    word-break: break-word;
    padding: 15px 10px;
    text-align: center;
}

/* Оверлей (затемнение фона) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s step-end;
    pointer-events: none;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Адаптация под маленькие экраны (ширина < 600px) */
@media (max-width: 600px) {
    .item {
        flex: 0 0 100%;
        font-size: 16px;
    }
    .item-icon {
        max-height: 150px;
    }
    .item-name {
        padding: 12px 8px;
    }
}

/* Десктоп 1920x1080 */
@media (min-width: 1920px) and (max-height: 1080px) and (orientation: landscape) {
    .nad3 {
        font-size: 40px;
    }
    .button-catalog {
        width: 400px;
        height: 90px;
        font-size: 36px;
    }
    .item {
        font-size: 20px;
        flex: 0 0 calc(48% - 20px);
    }
    .item-icon {
        max-height: 220px;
    }
    .item-name {
        font-size: 22px;
        padding: 18px 12px;
    }
    .catalog-title {
        font-size: 28px;
    }
}

/* ============================================= */
/* ПОЛНАЯ АДАПТАЦИЯ ПОД ЭКРАН 1080×1920 (ПОРТРЕТ) */
/* ============================================= */
@media (max-width: 1080px) and (min-height: 1920px) and (orientation: portrait){
    .logo {
        width: 180px;
        top: 20px;
        left: 20px;
    }

    .nad3 {
        font-size: 32px;
        white-space: normal;
        text-align: center;
        max-width: 90%;
        line-height: 1.3;
        top: 15px;
        transform: translateX(-50%);
        padding: 0 10px;
    }

    .rama {
        height: 900px;
    }
    .anosov {
        height: 720px;
        top: 45.6%;
        left: 49%;
    }
    .nad {
        height: 300px;
        top: 46%;
        left: 51%;
    }

    .button-catalog {
        width: 400px;
        height: 80px;
        font-size: 32px;
        bottom: 10%;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px;
    }

    /* Шапка каталога */
    .catalog-header {
        padding: 15px 20px;
    }
    .back-btn {
        font-size: 28px;
        padding: 8px 12px;
    }
    .catalog-title {
        font-size: 28px;
    }
    .close-btn {
        font-size: 60px;
        width: 60px;
        height: 60px;
    }

    /* Элементы каталога */
    .items-grid-full {
        gap: 25px;
        padding: 15px;
    }
    .item {
        flex: 0 0 calc(22% - 25px);
        min-width: 240px;
        font-size: 22px;
        border-radius: 16px;
    }
    .item-icon {
        max-height: 240px;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }
    .item-name {
        padding: 20px 15px;
        font-size: 24px;
    }

    /* Затемнение чуть сильнее */
    .overlay {
        background-color: rgba(0, 0, 0, 0.6);
    }
      .item {
        flex: 0 0 calc(48% - 20px);
    }
}

/* ============================================= */
/* ИДЕАЛЬНАЯ АДАПТАЦИЯ ПОД ТЕЛЕФОНЫ (ДО 480px) */
/* ============================================= */
@media (max-width: 480px) {
    /* Фиксация экрана */
    body, html {
        overflow: hidden;
        height: 100%;
        width: 100%;
        position: fixed;
        overscroll-behavior: none;
    }

    /* Логотип */
    .logo {
        width: 100px;
        top: 10px;
        left: 10px;
        z-index: 15;
    }

    /* Заголовок */
    .nad3 {
        font-size: 18px;
        top: 12px;
        max-width: 65%;
        white-space: normal;
        line-height: 1.2;
        text-align: center;
        left: 55%;
        transform: translateX(-50%);
        text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    }

    /* Центральное изображение (muze.png) */
    .center-img {
        max-width: 580px;
        max-height: 70vh;       /* не занимает весь экран, оставляет место для кнопки */
        width: auto;
        height: auto;
        top: 45%;
    }

    /* Кнопка каталога */
    .button-catalog {
        width: 85%;
        max-width: 300px;
        height: 60px;
        font-size: 24px;
        bottom: 8%;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 30px;
        background-color: #d00000;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        -webkit-tap-highlight-color: transparent;
    }

    /* Сайдбар */
    .sidebar-left {
        padding: 10px;
        width: 100vw;
    }

    /* Шапка каталога */
    .catalog-header {
        padding: 5px 5px 5px 10px;
    }

    .back-btn {
        font-size: 20px;
        padding: 8px 5px;
    }

    .catalog-title {
        font-size: 20px;
        white-space: normal;
        line-height: 1.2;
        padding: 0 5px;
    }

    .close-btn {
        font-size: 44px;
        width: 44px;
        height: 44px;
        line-height: 44px;
    }

    /* Сетка каталога — одна колонка */
    .items-grid-full {
        gap: 15px;
        padding: 5px;
    }

    .item {
        flex: 0 0 100%;
        min-width: 0;
        max-width: 100%;
        font-size: 18px;
        border-radius: 16px;
    }

    .item-icon {
        max-height: 200px;
        width: 100%;
        object-fit: contain;
        background: #f5f5f5;
    }

    .item-name {
        padding: 14px 10px;
        font-size: 18px;
        line-height: 1.3;
    }

    /* Оверлей */
    .overlay {
        background-color: rgba(0, 0, 0, 0.7);
    }

    /* Убираем горизонтальный скролл */
    .sidebar-left, .overlay, body {
        overflow-x: hidden;
    }

    /* Улучшаем тач-мишени */
    .back-btn, .close-btn, .item, .button-catalog {
        touch-action: manipulation;
    }

    /* Сверхмалые экраны (до 375px) */
    @media (max-width: 375px) {
        .nad3 {
            font-size: 16px;
            max-width: 60%;
        }
        .logo {
            width: 80px;
        }
        .center-img {
            max-height: 60vh;
        }
        .button-catalog {
            height: 55px;
            font-size: 22px;
            bottom: 6%;
        }
        .item-icon {
            max-height: 160px;
        }
        .item-name {
            font-size: 16px;
            padding: 12px 8px;
        }
    }
}

/* ============================================= */
/* АДАПТАЦИЯ ПОД ПОРТРЕТНЫЙ РЕЖИМ 3:4 (ПЛАНШЕТЫ) */
/* ============================================= */
@media (orientation: portrait) and (min-aspect-ratio: 2/3) and (max-aspect-ratio: 4/5) {
    /* Логотип */
    .logo {
        width: 140px;
        top: 15px;
        left: 15px;
    }

    /* Заголовок колледжа */
    .nad3 {
        font-size: 24px;
        white-space: normal;
        max-width: 70%;
        line-height: 1.3;
        top: 15px;
    }

    /* Центральное изображение (muze.png) */
    .center-img {
        max-width: 90vw;
        max-height: 60vh;
        width: auto;
        height: auto;
        top: 45%;
    }

    /* Кнопка открытия каталога */
    .button-catalog {
        width: 300px;
        height: 70px;
        font-size: 28px;
        bottom: 8%;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 40px;
    }

    /* Сайдбар каталога */
    .sidebar-left {
        padding: 15px;
    }

    /* Заголовок каталога */
    .catalog-title {
        font-size: 22px;
    }

    /* Кнопка закрытия */
    .close-btn {
        font-size: 48px;
        width: 48px;
        height: 48px;
    }

    /* Карточки элементов каталога */
    .item {
        flex: 0 0 calc(48% - 20px);
        font-size: 18px;
    }

    .item-icon {
        max-height: 160px;
    }

    /* Кнопка "Назад" */
    .back-btn {
        font-size: 22px;
    }
}