/* Popups: bottom sheets on phones, centred dialogs on larger screens */
.popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(4, 6, 14, 0.7);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: popup-fade 0.2s ease both;
}

.popup-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    max-height: 92dvh;
    margin: 0;
    padding: 8px 18px calc(18px + var(--sc-safe-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--sc-line-strong);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    background: linear-gradient(180deg, var(--sc-surface-2), var(--sc-surface) 120px);
    color: var(--sc-text);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
    /* Fills backwards only, so nested popups position against the viewport once the sheet is up */
    animation: popup-sheet-up 0.35s var(--sc-ease-out) backwards;
}

/* The sheet scrolls as a whole, so its sections must keep their size */
.popup-content > * {
    flex-shrink: 0;
}

.popup-content.h-100 {
    height: 92vh !important;
    height: 92dvh !important;
}

.popup-handle {
    flex-shrink: 0;
    width: 40px;
    height: 5px;
    margin: 0 auto 2px;
    border-radius: 999px;
    background: var(--sc-line-strong);
}

.close-button-container {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: flex-end;
    height: 0;
}

.close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-top: -4px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--sc-surface-3);
    color: var(--sc-text);
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease;
}

.close-button:active {
    transform: scale(0.9);
}

/* Cards placed inside a sheet shouldn't look like a card on a card */
.popup-content > .card {
    border: none;
    background: transparent;
    box-shadow: none;
}

.popup-content > .card > .card-header {
    padding: 4px 0 12px;
    font-size: 20px;
}

.popup-content > .card > .card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0 0;
}

/* Small confirmation sheets */
.confirm-sheet {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 8px 0 4px;
    text-align: center;
}

.confirm-sheet-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sc-gold-soft);
    color: var(--sc-gold);
    font-size: 28px;
    box-shadow: 0 0 0 6px rgba(255, 200, 61, 0.06);
}

.confirm-sheet-icon.is-warning {
    background: rgba(255, 159, 67, 0.16);
    color: var(--sc-warning);
}

.confirm-sheet-text {
    margin: 0;
    color: var(--sc-text-muted);
}

.confirm-sheet-text strong {
    color: var(--sc-text);
}

.confirm-sheet-cost {
    font-variant-numeric: tabular-nums;
}

.confirm-sheet-warning {
    margin: 0;
    color: var(--sc-danger);
    font-size: 13px;
    font-weight: 600;
}

@media (min-width: 640px) {
    .popup-overlay {
        align-items: center;
        padding: 24px;
    }

    .popup-content {
        max-width: 480px;
        max-height: 88vh;
        padding-bottom: 18px;
        border-bottom: 1px solid var(--sc-line-strong);
        border-radius: 24px;
        animation-name: popup-pop;
    }

    .popup-handle {
        display: none;
    }
}

@keyframes popup-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popup-sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes popup-pop {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
