/* Popup modal (#popup) – obsah z $variables[popup] */

#popup {
    --popup-bg: #ffffff;
    --popup-text: #1f2328;
    --popup-muted: #5b6470;
    --popup-accent: #c8102e;
    --popup-accent-hover: #a50d26;
    --popup-radius: 18px;
    --popup-shadow: 0 24px 60px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.12);
    --popup-max-width: 720px;

    padding: 0 !important;
}

/* Tmavé pozadí za modalem */
.modal-backdrop.show {
    opacity: 1;
    background-color: rgba(15, 18, 22, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* Dialog – vycentrovaná karta místo fullscreenu */
#popup .modal-dialog,
#popup .modal-dialog.modal-fullscreen {
    width: auto;
    max-width: var(--popup-max-width);
    height: auto;
    min-height: calc(100% - 2rem);
    margin: 1rem auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
}

/* Animace otevření */
#popup.fade .modal-dialog {
    transform: translateY(24px) scale(0.97);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

#popup.show .modal-dialog {
    transform: none;
    opacity: 1;
}

/* Karta */
#popup .modal-content {
    position: relative;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    border: 0;
    border-radius: var(--popup-radius);
    background: var(--popup-bg);
    color: var(--popup-text);
    box-shadow: var(--popup-shadow);
}

/* Zavírací tlačítko */
#popup .close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    float: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #ff5f1e;
    font-size: 0;
    font-weight: 400;
    line-height: 0;
    text-shadow: none;
    opacity: 1;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

#popup .close:hover,
#popup .close:focus-visible {
    background: transparent;
    color: #e64d0f;
    transform: rotate(90deg);
    opacity: 1;
}

#popup .close:focus {
    outline: none;
}

#popup .close:focus-visible {
    outline: 3px solid rgba(255, 95, 30, 0.4);
    outline-offset: 2px;
}

/* Znak × má v písmu posunutou účaří – vycentrováno přes pevný box */
#popup .close span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 36px;
    line-height: 1;
    transform: translateY(-2px);
}

/* Obsah */
#popup .modal-body {
    max-height: calc(100vh - 2rem);
    padding: 40px 36px 36px;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

#popup .modal-body > :first-child {
    margin-top: 0;
}

#popup .modal-body > :last-child {
    margin-bottom: 0;
}

#popup .modal-body h1,
#popup .modal-body h2,
#popup .modal-body h3 {
    margin: 0 0 0.6em;
    padding-right: 40px;
    color: var(--popup-text);
    font-weight: 700;
    line-height: 1.25;
}

#popup .modal-body h1 { font-size: 1.9rem; }
#popup .modal-body h2 { font-size: 1.6rem; }
#popup .modal-body h3 { font-size: 1.3rem; }

#popup .modal-body p {
    margin: 0 0 1em;
    color: var(--popup-muted);
}

#popup .modal-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 1.25em;
    border-radius: calc(var(--popup-radius) - 8px);
}

#popup .modal-body a {
    color: var(--popup-accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#popup .modal-body a:hover {
    color: var(--popup-accent-hover);
}

/* Odkaz s třídou .btn jako tlačítko */
#popup .modal-body a.btn,
#popup .modal-body .btn {
    display: inline-block;
    padding: 12px 28px;
    border: 0;
    border-radius: 999px;
    background: var(--popup-accent);
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#popup .modal-body a.btn:hover,
#popup .modal-body .btn:hover {
    background: var(--popup-accent-hover);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Mobil */
@media (max-width: 575.98px) {
    #popup .modal-dialog,
    #popup .modal-dialog.modal-fullscreen {
        min-height: calc(100% - 1rem);
        margin: 0.5rem auto;
    }

    #popup .modal-content,
    #popup .modal-body {
        max-height: calc(100vh - 1rem);
    }

    #popup .modal-body {
        padding: 32px 20px 24px;
    }

    #popup .modal-body h1 { font-size: 1.5rem; }
    #popup .modal-body h2 { font-size: 1.35rem; }
    #popup .modal-body h3 { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
    #popup.fade .modal-dialog,
    #popup .close {
        transition: none;
    }
}
