/* ==========================================================
   EVENT MODAL
   ========================================================== */

.modal {

    position: fixed;

    inset: 0;

    display: flex;

    align-items: center;

    justify-content: center;

    padding: max(12px, env(safe-area-inset-top)) clamp(12px, 4vw, 32px) max(12px, env(safe-area-inset-bottom));

    background: rgba(0, 0, 0, .55);

    backdrop-filter: blur(8px);

    z-index: 999;

    animation: fadeIn .22s ease;

}

.modal.hidden {

    display: none;

}

.modal-card {
    width: 100%;
    max-width: 480px;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-padding-block: 12px;

    background: var(--surface);
    border-radius: 28px;
    padding: 28px;

    box-shadow: var(--shadow);
    position: relative;
    border: 1px solid var(--border);

    animation: popup .32s cubic-bezier(.22, 1, .36, 1);
    will-change: transform, opacity;
}

.close-button {

    position: absolute;

    top: 18px;

    right: 18px;

    width: 40px;

    height: 40px;

    border: none;

    border-radius: 12px;

    background: var(--surface-2);

    color: var(--text);

    cursor: pointer;

    transition: .2s;

}

.close-button:hover {

    transform: rotate(90deg);

}

#eventCategory {

    display: inline-flex;

    align-items: center;

    gap: 8px;

    padding: 8px 14px;

    border-radius: 999px;

    background: rgba(255, 175, 119, .12);

    color: var(--primary);

    font-weight: 700;

    font-size: 13px;

    margin-bottom: 18px;

}

#eventTitle {

    font-size: 30px;

    line-height: 1.2;

    margin-bottom: 20px;

}

#eventDate,
#eventTime,
#eventPlace {

    margin-bottom: 10px;

    color: var(--text-secondary);

    font-size: 15px;

}

/* ==========================================================
   ADMIN BUTTONS
   ========================================================== */

#adminButtons {

    display: flex;

    flex-direction: column;

    gap: 12px;

    margin-top: 24px;

}

#adminButtons button {

    border: none;

    border-radius: 16px;

    padding: 14px;

    cursor: pointer;

    font-size: 15px;

    font-weight: 700;

    transition: .25s;

}

#editEvent {

    background: #e9894a;

    color: #3d2518;

}

#duplicateEvent {

    background: #0ea5e9;

    color: white;

}

#deleteEvent {

    background: #ef4444;

    color: white;

}

#adminButtons button:hover {

    transform: translateY(-2px);

}

/* ==========================================================
   EVENT LIST
========================================================== */

.event-list-modal {
    width: 100%;
    max-width: 560px;

    max-height: calc(
        100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px
    );

    padding: 12px;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.event-list-modal.event-list-fits {
    max-height: none;
}

.event-list-modal.event-list-fits #eventList {
    max-height: none;
    overflow-y: visible;
}

.event-list-header {

    display: flex;
    align-items: center;

    gap: 16px;

    padding: 6px 12px 10px;
}

#eventList {
    display: flex;
    flex-direction: column;

    gap: 16px;

    max-height: calc(
        100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 136px
    );
    min-height: 0;

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;

    padding: 4px 6px max(18px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 6px 18px;
}

.event-preview {
    width: 100%;

    overflow: hidden;
    cursor: pointer;

    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, .08);

    background:
        linear-gradient(180deg,
            rgba(255, 255, 255, .02),
            rgba(255, 255, 255, 0)),
        var(--surface);

    transition:
        transform .18s ease,
        border-color .18s ease,
        box-shadow .18s ease;
}

.modal .empty-date-modal-card {
    width: min(78vw, 340px);
    max-height: none;
    padding: 20px 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
}

.modal .empty-date-modal-card p {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

.event-preview:hover {

    transform: translateY(-2px);

    border-color: rgba(255, 175, 119, .45);

    box-shadow: 0 10px 26px rgba(0, 0, 0, .22);

}

.event-preview:active {

    transform: scale(.985);

}

.event-preview img {
    width: 100%;
    height: 105px;

    display: block;

    object-fit: cover;
    object-position: center;

    transition: transform .35s ease;
}

.event-preview:hover img {

    transform: scale(1.03);

}

.event-preview-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    padding: 12px 16px;
}

.event-preview-title {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    max-width: 100%;
    text-align: left;
    color: var(--text);
    transition: color .18s ease;
}

.event-preview:hover .event-preview-title {

    color: var(--primary);

}

.event-preview-icon {
    width: 24px;
    height: 24px;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    flex-shrink: 0;
    margin-top: 1px;
}

.event-preview-icon svg {
    width: 22px;
    height: 22px;
}

.event-preview-name {
    min-width: 0;
    color: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.33;
    text-align: left;
}

.event-preview-time {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    column-gap: 10px;
    margin-top: 8px;
    font-size: 14px;
    opacity: .75;
    text-align: left;
}

.event-preview-time-icon {
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.event-preview-time svg {
    width: 18px;
    height: 18px;
}

.event-preview--horizontal {
    position: relative;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) 24px;
    min-height: 112px;
    border-radius: 18px;
}

.event-preview--horizontal > img {
    width: 112px;
    height: 112px;
    grid-row: 1;
    object-fit: cover;
    transition: none;
}

.event-preview--horizontal .event-preview-body {
    min-width: 0;
    padding: 12px 4px 12px 10px;
}

.event-preview--horizontal.category-bowling > img { object-position: 0% center; }
.event-preview--horizontal.category-billiard > img { object-position: 80% center; }
.event-preview--horizontal.category-coworking > img { object-position: 30% center; }
.event-preview--horizontal.category-cycling > img { object-position: 70% center; }
.event-preview--horizontal.category-poker > img { object-position: 20% center; }
.event-preview--horizontal.category-picnic > img { object-position: 20% center; }
.event-preview--horizontal.category-excursion > img { object-position: 35% center; }
.event-preview--horizontal.category-volleyball > img { object-position: 80% center; }
.event-preview--horizontal.category-karaoke > img { object-position: 90% center; }
.event-preview--horizontal.category-quest > img { object-position: 32% center; }
.event-preview--horizontal.category-running > img { object-position: 55% center; }

.event-preview-meta {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-preview--horizontal .event-preview-name {
    display: -webkit-box;
    margin-top: 6px;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.event-preview-location {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    margin-top: auto;
    padding-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.event-preview-location svg {
    width: 15px;
    height: 15px;
}

.event-preview-location span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-preview-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.event-preview-chevron svg {
    width: 18px;
    height: 18px;
}

.event-preview-favorite {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(23, 27, 38, .72);
    color: #ff747c;
    cursor: pointer;
}

.event-preview-favorite svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

.event-preview--horizontal:hover,
.event-preview--horizontal:hover img {
    transform: none;
}

@media (max-width: 380px) {
    .event-preview--horizontal {
        grid-template-columns: 96px minmax(0, 1fr) 22px;
        min-height: 96px;
    }

    .event-preview--horizontal > img {
        width: 96px;
        height: 96px;
    }
}

@media (min-width: 541px) {
    .modal-card {
        max-width: min(100%, 680px);
    }

    .event-list-modal {
        max-width: min(100%, 720px);
    }

    .event-preview--horizontal {
        grid-template-columns: 132px minmax(0, 1fr) 28px;
        min-height: 124px;
    }

    .event-preview--horizontal > img {
        width: 132px;
        height: 124px;
    }
}

@media (min-width: 600px) {
    .event-list-header {
        gap: 18px;
        padding: 10px 16px 14px;
    }

    #eventListDate {
        font-size: 26px;
    }

    #closeEventList {
        width: 44px;
        height: 44px;
    }

    .event-preview--horizontal {
        grid-template-columns: 156px minmax(0, 1fr) 34px;
        min-height: 140px;
    }

    .event-preview--horizontal > img {
        width: 156px;
        height: 140px;
    }

    .event-preview--horizontal .event-preview-body {
        padding: 15px 8px 15px 14px;
    }

    .event-preview-meta,
    .event-preview-location {
        font-size: 14px;
    }

    .event-preview--horizontal .event-preview-name {
        margin-top: 8px;
        font-size: 19px;
    }

    .event-preview-location svg {
        width: 17px;
        height: 17px;
    }

    .event-preview-chevron svg {
        width: 22px;
        height: 22px;
    }

    .event-preview-favorite {
        width: 36px;
        height: 36px;
    }
}

/* ===== Окно списка событий ===== */

#eventListDate {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

#closeEventList {
    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;
    background: #24262f;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;

    flex-shrink: 0;
}

.modal-close-image {

    width: 42px;
    height: 42px;

    border: none;
    border-radius: 12px;

    background: rgba(20, 20, 25, .55);

    color: white;

    cursor: pointer;

    backdrop-filter: blur(10px);
}

/* ==========================================================
   ANIMATIONS
   ========================================================== */
.modal.closing {
    animation: fadeOut .18s ease forwards;
}

.modal.closing .modal-card,
.modal.closing .event-list-modal,
.modal.closing .event-page {
    animation: popupOut .18s ease forwards;
}

@keyframes fadeIn {

    from {
        opacity: 0;
        backdrop-filter: blur(0);
        background: rgba(0, 0, 0, 0);
    }

    to {
        opacity: 1;
        backdrop-filter: blur(8px);
        background: rgba(0, 0, 0, .55);
    }

}

@keyframes popup {

    from {
        opacity: 0;
        transform: translateY(28px) scale(.94);
    }

    60% {
        opacity: 1;
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

}

@keyframes fadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(8px);
    }

    to {
        opacity: 0;
        backdrop-filter: blur(0);
    }
}

@keyframes popupOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(12px) scale(.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal-card,
    .modal.closing,
    .modal.closing .modal-card,
    .modal.closing .event-list-modal,
    .modal.closing .event-page {
        animation-duration: .01ms !important;
    }
}
