/* ============================================================
   ZA SMART KIT — Popup, Button, Form, and Success Celebration
   All driven by ZA Framework CSS variables.
   ============================================================ */

/* ============================================================
   BUTTON
   ============================================================ */

.za-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    cursor: pointer;
    font-family: var(--zask-font);
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--zask-radius-md);
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity var(--zask-transition);
    line-height: 1;
    box-sizing: border-box;
    white-space: nowrap;
    letter-spacing: -0.005em;
    position: relative;
    overflow: hidden;
}

.za-btn:hover { transform: translateY(-1px); }
.za-btn:active { transform: translateY(0); }
.za-btn:focus-visible {
    outline: 2px solid var(--zask-primary);
    outline-offset: 3px;
}

.za-btn__inner {
    display: inline-flex;
    align-items: center;
    gap: var(--zask-space-2);
    position: relative;
    z-index: 1;
}

.za-btn__icon {
    display: inline-flex;
    align-items: center;
    font-size: 1.1em;
}

.za-btn__arrow {
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.za-btn:hover .za-btn__arrow { transform: translateX(3px); }

/* Sizes */
.za-btn--sm { padding: 8px 14px; font-size: 13px; }
.za-btn--md { padding: 12px 22px; font-size: 15px; }
.za-btn--lg { padding: 16px 28px; font-size: 16px; }

/* Variants */
.za-btn--primary {
    background: var(--zask-gradient);
    color: var(--zask-text-inverse);
    /* Normal state: no shadow (flat until hovered). */
    box-shadow: none;
}
.za-btn--primary:hover {
    /* Hover: a subtle 2px drop shadow + a little brand-colored glow. */
    box-shadow:
        0 2px 2px 0 rgba(0,0,0,0.18),
        0 0 26px rgba(0,212,255,0.9),
        0 0 65px rgba(0,212,255,0.55);
    box-shadow:
        0 2px 2px 0 rgba(0,0,0,0.18),
        0 0 26px color-mix(in srgb, var(--zask-primary) 90%, transparent),
        0 0 65px color-mix(in srgb, var(--zask-primary) 55%, transparent);
}

/* Subtle shimmer sweep on hover */
.za-btn--primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255,255,255,0.18) 45%,
        transparent 60%
    );
    transform: translateX(-100%);
    transition: transform 700ms cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.za-btn--primary:hover::before { transform: translateX(100%); }

.za-btn--ghost {
    background: transparent;
    color: var(--zask-primary);
}
.za-btn--ghost:hover { background: rgba(0, 212, 255, 0.08); }

.za-btn--outline {
    background: transparent;
    color: var(--zask-primary);
    box-shadow: inset 0 0 0 2px var(--zask-primary);
}
.za-btn--outline:hover {
    background: var(--zask-primary);
    color: var(--zask-text-inverse);
}

/* ============================================================
   PER-INSTANCE BUTTON OVERRIDES
   Driven by inline --zask-btn-* vars set by ButtonEngine.
   ============================================================ */
.za-btn[style*="--zask-btn-color"]            { background: var(--zask-btn-color); }
.za-btn[style*="--zask-btn-text"]             { color: var(--zask-btn-text); }
.za-btn[style*="--zask-btn-font"]             { font-size: var(--zask-btn-font); }
.za-btn[style*="--zask-btn-pad"]              { padding: var(--zask-btn-pad); }
.za-btn[style*="--zask-btn-radius"]           { border-radius: var(--zask-btn-radius); }

/* Gradient variant — both colors set via CSS vars */
.za-btn--gradient {
    background: linear-gradient(135deg,
        var(--zask-btn-color, var(--zask-primary)) 0%,
        var(--zask-btn-color2, var(--zask-secondary)) 100%) !important;
}

/* Per-button popup accent — JS sets --zask-popup-accent on #za-popup,
   the accent strip and primary buttons inside the popup pick it up. */
#za-popup[style*="--zask-popup-accent"] .za-popup__accent,
#za-popup[style*="--zask-popup-accent"] .za-popup__icon {
    background: var(--zask-popup-accent) !important;
}
#za-popup[style*="--zask-popup-accent"] .za-form__submit.za-btn--primary {
    background: var(--zask-popup-accent) !important;
}
#za-popup[style*="--zask-popup-accent"] .za-form__input:focus,
#za-popup[style*="--zask-popup-accent"] .za-form__textarea:focus {
    border-color: var(--zask-popup-accent) !important;
}

/* ============================================================
   POPUP — modal overlay with refined panel
   ============================================================ */

.za-popup {
    position: fixed;
    inset: 0;
    z-index: var(--zask-z-popup);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--zask-space-4);
    font-family: var(--zask-font);
    color: var(--zask-text);
}

.za-popup.is-open {
    display: flex;
    animation: za-fade-in 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.za-popup__overlay {
    position: absolute;
    inset: 0;
    background: var(--zask-bg-overlay);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}

.za-popup__panel {
    position: relative;
    background: #ffffff;
    border-radius: 18px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.6) inset,
        0 30px 80px -20px rgba(15, 23, 42, 0.45),
        0 8px 24px -8px rgba(15, 23, 42, 0.25);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 36px;
    animation: za-slide-up 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Top-edge gradient accent */
.za-popup__accent {
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 3px;
    background: var(--zask-gradient);
    border-radius: 0 0 4px 4px;
}

/* Bold visible close × — per spec, sits in the top-right corner of the
   popup form. Bordered orange ring on white. Re-tinted when a per-button
   popup color is active (#za-popup carries --zask-popup-accent). */
.za-popup__close {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: 38px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid var(--zask-popup-accent, var(--zask-primary, #F97316)) !important;
    background: #ffffff !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    color: var(--zask-popup-accent, var(--zask-primary, #F97316)) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18), 0 0 0 4px rgba(255,255,255,0.7) !important;
    transition: transform 180ms ease, color 180ms ease, background 180ms ease, box-shadow 180ms ease !important;
    z-index: 10 !important;
    line-height: 1 !important;
    padding: 0 !important;
    font-size: 22px !important;
    font-weight: 700 !important;
}
.za-popup__close:hover {
    transform: rotate(90deg) scale(1.06) !important;
    background: var(--zask-popup-accent, var(--zask-primary, #F97316)) !important;
    color: #ffffff !important;
}
.za-popup__close:focus-visible {
    outline: 3px solid #ffffff !important;
    outline-offset: 3px !important;
}
.za-popup__close svg {
    width: 16px !important;
    height: 16px !important;
}

.za-popup__header {
    margin-bottom: 24px;
}

.za-popup__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--zask-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.2) inset,
        var(--zask-shadow-glow);
}

.za-popup__title {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 700;
    color: var(--zask-text);
    letter-spacing: -0.025em;
    line-height: 1.15;
}

.za-popup__subtitle {
    margin: 0;
    color: var(--zask-text-muted);
    font-size: 15px;
    line-height: 1.55;
}

/* ============================================================
   FORM
   ============================================================ */

.za-form { display: flex; flex-direction: column; gap: 16px; }

.za-form__row { display: flex; flex-direction: column; }

.za-form__row--split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.za-form__row--consent { margin-top: 4px; }
.za-form__row--submit { margin-top: 8px; }

.za-form__field { display: flex; flex-direction: column; }

.za-form__label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--zask-text);
    letter-spacing: -0.005em;
}

.za-form__required {
    color: var(--zask-primary);
    margin-left: 2px;
}

.za-form__input,
.za-form__textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--zask-border);
    border-radius: 10px;
    background: #fafbfc;
    font-family: var(--zask-font);
    font-size: 14.5px;
    color: var(--zask-text);
    transition: border-color 150ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1),
                background 150ms cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    line-height: 1.4;
}

.za-form__input::placeholder,
.za-form__textarea::placeholder {
    color: #9aa5b9;
}

.za-form__input:hover,
.za-form__textarea:hover {
    border-color: var(--zask-border-strong);
}

.za-form__input:focus,
.za-form__textarea:focus {
    outline: 0;
    border-color: var(--zask-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.12);
}

.za-form__textarea {
    resize: vertical;
    min-height: 96px;
}

/* Honeypot — visually hidden but accessible to bots */
.za-form__honeypot {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.za-form__consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--zask-text-muted);
    line-height: 1.5;
    cursor: pointer;
}
.za-form__consent input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--zask-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.za-form__submit {
    width: 100%;
}

.za-form__feedback {
    min-height: 20px;
    font-size: 13px;
    text-align: center;
    margin-top: -4px;
}
.za-form__feedback.is-error { color: var(--zask-error); }
.za-form__feedback.is-success { color: var(--zask-success); }
.za-form__feedback.is-loading { color: var(--zask-text-muted); }

.za-form.is-submitting .za-form__submit {
    opacity: 0.6;
    pointer-events: none;
}

/* ============================================================
   GENERATEPRESS HELPERS
   ============================================================ */

.za-gp-header-cta {
    text-align: center;
    padding: var(--zask-space-3) var(--zask-space-4);
}

.za-gp-after-content {
    text-align: center;
    margin: var(--zask-space-8) 0;
}

/* ============================================================
   SUCCESS CELEBRATION — centered modal (500×600 on desktop)
   ============================================================ */

.za-success {
    position: fixed;
    inset: 0;
    z-index: calc(var(--zask-z-popup) + 10);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: var(--zask-font);
    box-sizing: border-box;
}

.za-success.is-active {
    display: flex;
    animation: za-fade-in 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.za-success.is-leaving {
    animation: za-fade-out 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Backdrop — semi-transparent, blurred, behind the panel */
.za-success__bg {
    position: absolute;
    inset: 0;
    background: var(--zask-bg-overlay);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}

/* The actual panel — centered, fixed-ish dimensions, fully responsive */
.za-success__content {
    position: relative;
    z-index: 2;
    width: 500px;
    max-width: 100%;
    height: 600px;
    max-height: calc(100vh - 32px);
    background: var(--zask-gradient);
    border-radius: 20px;
    padding: 40px 32px;
    text-align: center;
    color: #ffffff;
    overflow: hidden;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.2) inset,
        0 30px 80px -20px rgba(15, 23, 42, 0.55),
        0 8px 24px -8px rgba(15, 23, 42, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: za-success-rise 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Subtle rotating accent inside the panel — adds life without distraction */
.za-success__content::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(255,255,255,0.08) 60deg,
        transparent 120deg,
        rgba(255,255,255,0.1) 240deg,
        transparent 360deg
    );
    animation: za-success-spin 12s linear infinite;
    pointer-events: none;
}

/* Soft radial highlights — depth */
.za-success__content::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.15), transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(255,255,255,0.08), transparent 60%);
    pointer-events: none;
}

/* Wrap inner text/icon above the rotating accent */
.za-success__check,
.za-success__title,
.za-success__message {
    position: relative;
    z-index: 3;
}

.za-success__check {
    width: 120px;
    height: 120px;
    margin-bottom: 28px;
    color: #ffffff;
}

.za-success__check svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.za-success__ring {
    fill: none;
    stroke: #ffffff;
    stroke-width: 1.5;
    transform-origin: center;
    transform: scale(0);
    opacity: 0;
}

.za-success.is-active .za-success__ring--1 {
    animation: za-ring-expand 800ms cubic-bezier(0.16, 1, 0.3, 1) 100ms forwards;
}

.za-success.is-active .za-success__ring--2 {
    animation: za-ring-expand 800ms cubic-bezier(0.16, 1, 0.3, 1) 200ms forwards;
}

.za-success.is-active .za-success__ring--3 {
    animation: za-ring-expand-fill 700ms cubic-bezier(0.16, 1, 0.3, 1) 350ms forwards;
}

.za-success__tick {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
}

.za-success.is-active .za-success__tick {
    animation: za-tick-draw 500ms cubic-bezier(0.65, 0, 0.35, 1) 750ms forwards;
}

.za-success__title {
    margin: 0 0 12px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: #ffffff;
    text-shadow: 0 2px 16px rgba(0,0,0,0.12);
    opacity: 0;
    transform: translateY(10px);
    padding: 0 8px;
}

.za-success__message {
    margin: 0;
    font-size: 16px;
    line-height: 1.55;
    color: rgba(255,255,255,0.95);
    opacity: 0;
    transform: translateY(10px);
    padding: 0 8px;
    max-width: 90%;
}

.za-success.is-active .za-success__title {
    animation: za-text-rise 600ms cubic-bezier(0.16, 1, 0.3, 1) 900ms forwards;
}

.za-success.is-active .za-success__message {
    animation: za-text-rise 600ms cubic-bezier(0.16, 1, 0.3, 1) 1050ms forwards;
}

/* Confetti dots — float upward inside the panel area */
.za-success__confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
    border-radius: 20px;
}

.za-success__confetti span {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    bottom: -20px;
    opacity: 0;
}

.za-success.is-active .za-success__confetti span {
    animation: za-confetti-burst 2.2s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* Spread confetti horizontally across the panel; each piece has unique delay/rotation */
.za-success__confetti span:nth-child(1)  { left:  6%; background: rgba(255,255,255,0.95); animation-delay: 850ms; transform: rotate(15deg); }
.za-success__confetti span:nth-child(2)  { left: 12%; background: rgba(255,255,255,0.7);  animation-delay: 950ms; transform: rotate(-20deg); }
.za-success__confetti span:nth-child(3)  { left: 18%; background: rgba(255,255,255,0.95); animation-delay: 1050ms; transform: rotate(45deg); }
.za-success__confetti span:nth-child(4)  { left: 25%; background: rgba(255,255,255,0.85); animation-delay: 900ms; transform: rotate(-10deg); }
.za-success__confetti span:nth-child(5)  { left: 32%; background: rgba(255,255,255,0.95); animation-delay: 1150ms; }
.za-success__confetti span:nth-child(6)  { left: 38%; background: rgba(255,255,255,0.75); animation-delay: 950ms; transform: rotate(30deg); }
.za-success__confetti span:nth-child(7)  { left: 45%; background: rgba(255,255,255,0.95); animation-delay: 1100ms; transform: rotate(-25deg); }
.za-success__confetti span:nth-child(8)  { left: 52%; background: rgba(255,255,255,0.9);  animation-delay: 1200ms; }
.za-success__confetti span:nth-child(9)  { left: 58%; background: rgba(255,255,255,0.95); animation-delay: 880ms; transform: rotate(15deg); }
.za-success__confetti span:nth-child(10) { left: 64%; background: rgba(255,255,255,0.8);  animation-delay: 1000ms; transform: rotate(-30deg); }
.za-success__confetti span:nth-child(11) { left: 70%; background: rgba(255,255,255,0.95); animation-delay: 1180ms; transform: rotate(40deg); }
.za-success__confetti span:nth-child(12) { left: 76%; background: rgba(255,255,255,0.7);  animation-delay: 920ms; }
.za-success__confetti span:nth-child(13) { left: 82%; background: rgba(255,255,255,0.95); animation-delay: 1080ms; transform: rotate(-15deg); }
.za-success__confetti span:nth-child(14) { left: 88%; background: rgba(255,255,255,0.85); animation-delay: 1130ms; transform: rotate(20deg); }
.za-success__confetti span:nth-child(15) { left: 94%; background: rgba(255,255,255,0.95); animation-delay: 980ms; }
.za-success__confetti span:nth-child(16) { left:  9%; background: rgba(255,255,255,0.75); animation-delay: 1250ms; transform: rotate(-40deg); }
.za-success__confetti span:nth-child(17) { left: 28%; background: rgba(255,255,255,0.95); animation-delay: 1300ms; transform: rotate(35deg); }
.za-success__confetti span:nth-child(18) { left: 48%; background: rgba(255,255,255,0.9);  animation-delay: 1220ms; }
.za-success__confetti span:nth-child(19) { left: 68%; background: rgba(255,255,255,0.95); animation-delay: 1280ms; transform: rotate(-15deg); }
.za-success__confetti span:nth-child(20) { left: 90%; background: rgba(255,255,255,0.8);  animation-delay: 1340ms; transform: rotate(45deg); }

/* ============================================================
   ANIMATIONS
   ============================================================ */

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

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

@keyframes za-slide-up {
    from { transform: translateY(16px) scale(0.97); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes za-ring-expand {
    0%   { transform: scale(0); opacity: 0; }
    50%  { opacity: 0.7; }
    100% { transform: scale(1); opacity: 0.4; }
}

@keyframes za-ring-expand-fill {
    0%   { transform: scale(0); opacity: 0; fill: rgba(255,255,255,0); }
    100% { transform: scale(1); opacity: 1; fill: rgba(255,255,255,0.18); }
}

@keyframes za-tick-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes za-text-rise {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes za-success-rise {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes za-confetti-burst {
    0%   { opacity: 0; bottom: -20px; }
    10%  { opacity: 1; }
    100% { opacity: 0; bottom: 110%; }
}

@keyframes za-confetti-fall {
    0%   { opacity: 0; top: -20px; }
    10%  { opacity: 1; }
    100% { opacity: 0; top: 105vh; }
}

@keyframes za-success-spin {
    to { transform: rotate(360deg); }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    .za-popup.is-open,
    .za-popup__panel,
    .za-success.is-active *,
    .za-success__confetti span {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
    .za-popup__panel {
        padding: 28px 22px;
        border-radius: 14px;
    }
    .za-form__row--split {
        grid-template-columns: 1fr;
    }
    .za-popup__title {
        font-size: 22px;
    }

    /* Success modal — fluid on mobile, capped at 600px tall and 95vw wide */
    .za-success {
        padding: 12px;
    }
    .za-success__content {
        width: 100%;
        height: auto;
        min-height: 480px;
        max-height: calc(100vh - 24px);
        padding: 36px 24px;
        border-radius: 16px;
    }
    .za-success__title {
        font-size: 24px;
    }
    .za-success__message {
        font-size: 15px;
    }
    .za-success__check {
        width: 96px;
        height: 96px;
        margin-bottom: 20px;
    }
}

@media (max-width: 380px) {
    .za-success__content {
        padding: 28px 20px;
        min-height: 440px;
    }
    .za-success__title {
        font-size: 22px;
    }
    .za-success__check {
        width: 84px;
        height: 84px;
        margin-bottom: 16px;
    }
}
