@import url(variables.css);

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

main {
    width: 60%;
}

.tickets-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ticket {
    display: flex;
    gap: 30px;
    height: 180px; /* фиксированная высота */
}

.info-movie {
    display: flex;
    flex: 1;
    border-radius: 41px;
    background-color: var(--elem-bg-color);
    overflow: hidden;
}

.ticket-cover {
    width: 53%;
    /* убрали height: 100% */
    align-self: stretch;
    border-radius: 0;
    position: relative;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.ticket-cover::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to right, rgba(0,0,0,0) 0%, #2f2f2f 100%);
}

.ticket-info {
    width: 47%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 30px;
    border-radius: 0 41px 41px 0;
}

.qr-block {
    background-color: white;
    border-radius: 41px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    /* убрали height: 100% */
    flex-shrink: 0;
    transition: transform 0.2s ease-in-out;
}

.qr-block img {
    width: 90%;
    height: 90%;
    transition: transform 0.2s ease-in-out;
}

.qr-block:hover, .return:hover {
    transform: scale(1.02);
    cursor: pointer;
}

.return {
    width: 10%;
    background-color: #2f2f2f;
    border-radius: 41px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

/* ======== ДЛЯ ЗАТЕМНЕНИЯ И БОЛЬШОГО QR КОДА ======== */
.qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9998;
    display: none;
    cursor: pointer;
}

.qr-modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: none;
    cursor: pointer;
    max-width: 90vw;
    max-height: 90vh;
}

.qr-modal-container img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    transform: scale(2);
}

.qr-modal-overlay.show,
.qr-modal-container.show {
    display: block;
    animation: transform 0.3s ease-in;
}

.qr-modal-container.show {
    display: flex;
    align-items: center;
    justify-content: center;
}


.ticket-info h2,
.ticket-info h3,
.ticket-info p {
    margin: 0;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticket-info h2 {
    font-size: 18px;
    margin-bottom: 6px;
}

.ticket-info p {
    font-size: 14px;
    margin-bottom: 6px;
}

.ticket-info h3 {
    font-size: 15px;
    margin-bottom: 6px;
}


/* ======== АДАПТИВ ======== */

/* Планшет */
@media (max-width: 1024px) {
    main {
        width: 90%;
    }

    .ticket {
        gap: 16px;
        height: 160px;
    }

    .ticket-info {
        padding: 16px 16px 16px 20px;
    }

    .ticket-info h2 {
        font-size: 16px;
    }

    .ticket-info p {
        font-size: 13px;
    }

    .ticket-info h3 {
        font-size: 14px;
    }
}

/* Мобилка */
@media (max-width: 640px) {
    main {
        width: 95%;
    }

    .ticket {
        flex-direction: column;
        height: auto;
        gap: 12px; /* отступ между билетом и блоком с QR/кнопкой */
    }

    /* Контейнер для QR и кнопки возврата */
    .ticket {
        position: relative;
    }

    /* Блок с информацией о фильме */
    .info-movie {
        flex-direction: column;
        border-radius: 24px;
        width: 100%;
    }

    .ticket-cover {
        width: 100%;
        height: 140px;
        align-self: auto;
        border-radius: 0;
    }

    /* градиент сверху вниз на мобилке */
    .ticket-cover::after {
        background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, #2f2f2f 100%);
    }

    .ticket-info {
        width: 100%;
        padding: 16px 20px 20px 20px;
        border-radius: 0 0 24px 24px;
    }

    .ticket-info h2,
    .ticket-info h3,
    .ticket-info p {
        white-space: normal;
    }

    /* QR и кнопка возврата — в ряд под билетом */
    /* Нам нужно обернуть QR и return в общий контейнер, но так как HTML не меняем,
       используем flex-обертку через сам .ticket */
    .ticket {
        display: flex;
        flex-direction: column;
    }

    /* Делаем обертку для QR и return */
    .qr-block,
    .return {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Стили для контейнера, который объединяет QR и return */
    /* Так как они идут подряд в .ticket, применяем стили к ним как к flex-элементам */
    .qr-block {
        position: static;
        /* width: calc(50% - 6px); /* половина ширины минус половина gap */
        height: 80px;
        border-radius: 24px;
        margin-top: 0;
        order: 1;
    }

    .return {
        width: auto;
        height: 80px;
        padding: 0;
        border-radius: 24px;
        order: 2;
    }

    /* Размещаем QR и return в одной строке */
    .ticket {
        flex-direction: column;
    }

    /* Но чтобы они были в одной строке, нужно чтобы они шли друг за другом в HTML,
       а .ticket был flex-container'ом с wrap? Нет, проще обернуть их в JS или CSS-грид */
    
    /* Используем CSS Grid для .ticket, чтобы разместить info-movie, потом в одной строке qr и return */
    .ticket {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Создаем неявную сетку для двух элементов после info-movie */
    .info-movie {
        grid-column: 1 / -1;
    }

    /* QR и return размещаем в одной строке с помощью display: flex у их родителя? */
    /* Так как они находятся на одном уровне с info-movie в DOM, используем такой трюк: */
    .ticket {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .info-movie {
        width: 100%;
        flex: 0 0 100%;
    }

    .qr-block {
        flex: 1;
        min-width: 120px;
        height: 80px;
        border-radius: 24px;
    }

    .return {
        flex: 1;
        min-width: 120px;
        height: 80px;
        border-radius: 24px;
        background-color: #2f2f2f;
    }

    /* Убираем лишние отступы и делаем иконку по центру */
    .return img {
        width: 32px;
        height: 32px;
        display: block;
    }

    /* QR-код изображение внутри блока */
    .qr-block img {
        width: 90%;
        height: 90%;
        object-fit: contain;
    }
}

/* ======== МОДАЛКА (оставляем без изменений) ======== */
.qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9998;
    display: none;
    cursor: pointer;
}

.qr-modal-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: none;
    cursor: pointer;
    max-width: 90vw;
    max-height: 90vh;
}

.qr-modal-container img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    transform: scale(2);
}

.qr-modal-overlay.show,
.qr-modal-container.show {
    display: block;
    animation: transform 0.3s ease-in;
}

.qr-modal-container.show {
    display: flex;
    align-items: center;
    justify-content: center;
}