/**
 * App Signup Popup — Premium 2025 design.
 * User-type selection (child / parent) before redirecting to signup.
 * Mobile-first, no horizontal scroll (overflow-x safe).
 * Palette: orange #FFA726, #FFB74D, #FFC477; blue #64B5F6, #42A5F5, #2196F3; green #A5D6A7.
 */

/* ----- CSS custom properties ----- */
.app-popup-overlay {
    --popup-orange: #FFA726;
    --popup-orange-mid: #FFB74D;
    --popup-orange-light: #FFC477;
    --popup-blue: #2196F3;
    --popup-blue-mid: #42A5F5;
    --popup-blue-light: #64B5F6;
    --popup-green: #A5D6A7;
    --popup-white: #ffffff;
    --popup-text: #1A1A1A;
    --popup-text-soft: #555555;
}

/* ----- Overlay: full viewport, no horizontal overflow ----- */
.app-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.35s ease, opacity 0.35s ease;
}

.app-popup-overlay[aria-hidden="false"] {
    visibility: visible;
    opacity: 1;
}

body.app-popup-open {
    overflow-x: hidden !important;
    overflow-y: hidden;
    max-width: 100vw;
}

/* ----- Backdrop: blur + gradient ----- */
.app-popup-backdrop {
    position: fixed;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(33, 150, 243, 0.28) 0%,
        rgba(255, 167, 38, 0.22) 45%,
        rgba(100, 181, 246, 0.2) 100%
    );
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.app-popup-overlay[aria-hidden="false"] .app-popup-backdrop {
    opacity: 1;
}

/* ----- Wrapper: safe width, no overflow ----- */
.app-popup-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(420px, calc(100vw - 32px));
    margin: 24px 16px;
    overflow: visible;
}

/* ----- Card: glassmorphism + soft shadow ----- */
.app-popup-card {
    position: relative;
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(255, 255, 255, 0.94) 100%
    );
    border-radius: 28px;
    box-shadow:
        0 32px 64px rgba(33, 150, 243, 0.18),
        0 16px 32px rgba(255, 167, 38, 0.12),
        0 0 0 1px rgba(255, 255, 255, 0.9) inset;
    padding: clamp(24px, 5vw, 36px);
    overflow: hidden;
    transform: scale(0.88) translateY(24px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.app-popup-overlay[aria-hidden="false"] .app-popup-card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ----- Decorative glow orbs ----- */
.app-popup-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(56px);
    opacity: 0.35;
    pointer-events: none;
}

.app-popup-glow--1 {
    width: 160px;
    height: 160px;
    background: var(--popup-orange-mid);
    top: -50px;
    right: -30px;
    animation: popupGlowFloat 6s ease-in-out infinite;
}

.app-popup-glow--2 {
    width: 140px;
    height: 140px;
    background: var(--popup-blue-light);
    bottom: -40px;
    left: -20px;
    animation: popupGlowFloat 7s ease-in-out infinite 1s;
}

.app-popup-glow--3 {
    width: 80px;
    height: 80px;
    background: var(--popup-green);
    bottom: 20%;
    left: 50%;
    animation: popupGlowFloat 5s ease-in-out infinite 0.5s;
}

@keyframes popupGlowFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(8px, -8px) scale(1.08); }
}

/* ----- Close button ----- */
.app-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(26, 26, 26, 0.06);
    color: var(--popup-text);
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
    z-index: 2;
}

.app-popup-close:hover {
    background: rgba(255, 167, 38, 0.2);
    transform: scale(1.08);
}

.app-popup-close:focus-visible {
    outline: 2px solid var(--popup-orange);
    outline-offset: 2px;
}

.app-popup-close i {
    font-size: 1.2rem;
}

/* ----- Content block ----- */
.app-popup-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.app-popup-icon-wrap {
    width: 68px;
    height: 68px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--popup-orange) 0%, var(--popup-orange-mid) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(255, 167, 38, 0.4);
    animation: popupIconPulse 3s ease-in-out infinite;
}

.app-popup-icon {
    font-size: 1.9rem;
    color: var(--popup-white);
}

@keyframes popupIconPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 12px 28px rgba(255, 167, 38, 0.4); }
    50% { transform: scale(1.06); box-shadow: 0 14px 32px rgba(255, 167, 38, 0.5); }
}

.app-popup-heading {
    font-size: clamp(1.35rem, 4.2vw, 1.7rem);
    font-weight: 800;
    color: var(--popup-text);
    margin-bottom: 10px;
    line-height: 1.3;
}

.app-popup-subhead {
    font-size: clamp(0.9rem, 2.4vw, 1rem);
    color: var(--popup-text-soft);
    line-height: 1.5;
    margin-bottom: 22px;
}

/* ----- User type choice cards ----- */
.app-popup-choices {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.app-popup-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 20px;
    text-align: right;
    text-decoration: none;
    color: var(--popup-text);
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(33, 150, 243, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                border-color 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.app-popup-choice::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-popup-choice--child::before {
    background: linear-gradient(135deg, rgba(255, 167, 38, 0.08) 0%, rgba(255, 183, 77, 0.06) 100%);
}

.app-popup-choice--parent::before {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(66, 165, 245, 0.06) 100%);
}

.app-popup-choice:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.app-popup-choice:hover::before {
    opacity: 1;
}

.app-popup-choice--child:hover {
    border-color: rgba(255, 167, 38, 0.35);
}

.app-popup-choice--parent:hover {
    border-color: rgba(33, 150, 243, 0.35);
}

.app-popup-choice:active {
    transform: translateY(-1px) scale(0.99);
}

.app-popup-choice__icon-wrap {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
}

.app-popup-choice--child .app-popup-choice__icon-wrap {
    background: linear-gradient(135deg, var(--popup-orange) 0%, var(--popup-orange-light) 100%);
    color: var(--popup-white);
    box-shadow: 0 8px 20px rgba(255, 167, 38, 0.3);
}

.app-popup-choice--parent .app-popup-choice__icon-wrap {
    background: linear-gradient(135deg, var(--popup-blue) 0%, var(--popup-blue-light) 100%);
    color: var(--popup-white);
    box-shadow: 0 8px 20px rgba(33, 150, 243, 0.3);
}

.app-popup-choice__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.app-popup-choice__label {
    font-weight: 700;
    font-size: clamp(1rem, 2.8vw, 1.15rem);
    display: block;
    margin-bottom: 2px;
    position: relative;
    z-index: 1;
}

.app-popup-choice__sublabel {
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    color: var(--popup-text-soft);
    position: relative;
    z-index: 1;
}

.app-popup-choice__arrow {
    margin-right: auto;
    font-size: 0.95rem;
    color: var(--popup-text-soft);
    opacity: 0.7;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.app-popup-choice:hover .app-popup-choice__arrow {
    transform: translateX(-4px);
}

.app-popup-choice--child:hover .app-popup-choice__arrow {
    color: var(--popup-orange);
}

.app-popup-choice--parent:hover .app-popup-choice__arrow {
    color: var(--popup-blue);
}

/* Staggered entrance for choice cards */
.app-popup-choice--child {
    opacity: 0;
    transform: translateY(16px);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.08s,
                opacity 0.4s ease 0.08s,
                box-shadow 0.3s ease,
                border-color 0.3s ease;
}

.app-popup-choice--parent {
    opacity: 0;
    transform: translateY(16px);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.16s,
                opacity 0.4s ease 0.16s,
                box-shadow 0.3s ease,
                border-color 0.3s ease;
}

.app-popup-overlay[aria-hidden="false"] .app-popup-choice--child,
.app-popup-overlay[aria-hidden="false"] .app-popup-choice--parent {
    opacity: 1;
    transform: translateY(0);
}

.app-popup-overlay[aria-hidden="false"] .app-popup-choice--child:hover,
.app-popup-overlay[aria-hidden="false"] .app-popup-choice--parent:hover {
    transform: translateY(-3px) scale(1.02);
}

/* ----- Mobile: extra safe widths, no horizontal scroll ----- */
@media (max-width: 480px) {
    .app-popup-wrap {
        max-width: calc(100vw - 24px);
        margin: 16px 12px;
    }

    .app-popup-card {
        padding: 22px 18px;
        border-radius: 24px;
    }

    .app-popup-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .app-popup-icon-wrap {
        width: 60px;
        height: 60px;
        margin-bottom: 14px;
    }

    .app-popup-icon {
        font-size: 1.65rem;
    }

    .app-popup-choice {
        padding: 14px 16px;
        gap: 12px;
    }

    .app-popup-choice__icon-wrap {
        width: 46px;
        height: 46px;
        font-size: 1.3rem;
    }
}

/* ----- Focus visible for accessibility ----- */
.app-popup-choice:focus-visible {
    outline: 2px solid var(--popup-orange);
    outline-offset: 2px;
}

/* ----- Reduce motion ----- */
@media (prefers-reduced-motion: reduce) {
    .app-popup-overlay,
    .app-popup-backdrop,
    .app-popup-card,
    .app-popup-glow--1,
    .app-popup-glow--2,
    .app-popup-glow--3,
    .app-popup-icon-wrap {
        animation: none;
    }

    .app-popup-card {
        transition-duration: 0.15s;
    }

    .app-popup-choice--child,
    .app-popup-choice--parent {
        transition-duration: 0.15s;
    }
}
