/**
 * EasyQuiz for WooCommerce — Frontend Styles
 * Author: Oladipupo Isreal | wa.me/2348056334682
 */

/* ── CSS VARIABLES (overridden dynamically by JS from settings) ── */
:root {
    --thatsip-primary:    #268c43;
    --thatsip-btn-bg:     #268c43;
    --thatsip-btn-text:   #ffffff;
    --thatsip-primary-10: rgba(38,140,67,0.10);
    --thatsip-primary-20: rgba(38,140,67,0.20);
    --thatsip-radius:     16px;
    --thatsip-radius-sm:  10px;
    --thatsip-shadow:     0 24px 64px rgba(0,0,0,0.18);
    --thatsip-font:       inherit;
    --thatsip-transition: 0.22s ease;
}

/* ── NO SCROLL ON BODY ── */
body.thatsip-no-scroll { overflow: hidden; }

/* ── OVERLAY ── */
.thatsip-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99998;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 1;
    transition: opacity var(--thatsip-transition);
}
.thatsip-overlay--hidden {
    opacity: 0;
    pointer-events: none;
}

/* ── POPUP SHELL ── */
.thatsip-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    width: min(600px, 94vw);
    max-height: 90vh;
    background: #ffffff;
    border-radius: var(--thatsip-radius);
    box-shadow: var(--thatsip-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity var(--thatsip-transition), transform var(--thatsip-transition);
}
.thatsip-popup--hidden {
    opacity: 0;
    transform: translate(-50%, -48%);
    pointer-events: none;
}

/* ── CLOSE BUTTON ── */
.thatsip-close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 10;
    background: rgba(0,0,0,0.07);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--thatsip-transition);
}
.thatsip-close:hover { background: rgba(0,0,0,0.14); }

/* ── PROGRESS ── */
.thatsip-progress-wrap {
    width: 100%;
    background: #f0f0f0;
    position: relative;
    flex-shrink: 0;
}
.thatsip-progress-bar {
    height: 5px;
    background: var(--thatsip-primary);
    transition: width 0.35s ease;
    border-radius: 0 3px 3px 0;
}
.thatsip-progress-label {
    position: absolute;
    right: 14px;
    top: 8px;
    font-size: 11px;
    color: #888;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* ── INNER SCROLL ── */
.thatsip-inner {
    overflow-y: auto;
    flex: 1;
    padding: 36px 36px 28px;
    scroll-behavior: smooth;
}
@media (max-width: 480px) {
    .thatsip-inner { padding: 28px 20px 20px; }
}

/* ── STEPS ── */
/* All steps sit in the same space and crossfade via opacity only.
   No display:none toggle = no blink. */
.thatsip-step {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}
.thatsip-step.active {
    position: relative;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0s;
}
.thatsip-step.exiting {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

/* ── INTRO ── */
.thatsip-intro {
    text-align: center;
    padding: 16px 0 8px;
}
.thatsip-intro-icon {
    font-size: 52px;
    margin-bottom: 14px;
    display: block;
}
.thatsip-title {
    font-size: 26px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 12px;
    line-height: 1.25;
}
.thatsip-subtitle {
    font-size: 15px;
    color: #666;
    margin: 0 0 28px;
    line-height: 1.6;
}

/* ── QUESTION ── */
.thatsip-question-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--thatsip-primary);
    margin: 0 0 10px;
}
.thatsip-question {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 22px;
    line-height: 1.4;
}

/* ── OPTIONS ── */
.thatsip-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.thatsip-option {
    width: 100%;
    text-align: left;
    background: #fafafa;
    border: 2px solid #ebebeb;
    border-radius: var(--thatsip-radius-sm);
    padding: 13px 18px;
    font-size: 15px;
    font-family: var(--thatsip-font);
    color: #2a2a2a;
    cursor: pointer;
    transition: border-color var(--thatsip-transition),
                background var(--thatsip-transition),
                transform 0.12s ease;
    line-height: 1.45;
}
.thatsip-option:hover {
    border-color: var(--thatsip-primary);
    background: var(--thatsip-primary-10);
    transform: translateX(3px);
}
.thatsip-option.selected {
    border-color: var(--thatsip-primary);
    background: var(--thatsip-primary-20);
    color: #111;
    font-weight: 600;
}

/* ── EMAIL GATE ── */
.thatsip-email-gate { text-align: center; }
.thatsip-email-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}
.thatsip-field-group {
    margin: 20px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.thatsip-input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--thatsip-radius-sm);
    font-size: 15px;
    font-family: var(--thatsip-font);
    color: #222;
    outline: none;
    transition: border-color var(--thatsip-transition);
    box-sizing: border-box;
}
.thatsip-input:focus { border-color: var(--thatsip-primary); }
.thatsip-privacy {
    font-size: 12px;
    color: #aaa;
    margin: 4px 0 0;
}

/* ── BUTTONS ── */
.thatsip-btn {
    display: inline-block;
    padding: 13px 28px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--thatsip-font);
    cursor: pointer;
    border: 2px solid transparent;
    text-decoration: none;
    text-align: center;
    transition: opacity var(--thatsip-transition),
                transform 0.12s ease,
                background var(--thatsip-transition);
    line-height: 1;
}
.thatsip-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.thatsip-btn:active { transform: translateY(0); }

.thatsip-btn--primary {
    background: var(--thatsip-btn-bg);
    color: var(--thatsip-btn-text);
    width: 100%;
    padding: 15px 28px;
}
.thatsip-btn--ghost {
    background: transparent;
    color: #888;
    border-color: transparent;
    font-size: 13px;
    width: 100%;
    margin-top: 6px;
}
.thatsip-btn--ghost:hover { color: #333; opacity: 1; }
.thatsip-btn--outline {
    background: transparent;
    color: var(--thatsip-primary);
    border-color: var(--thatsip-primary);
    width: 100%;
}

/* ── LOADING ── */
.thatsip-loading {
    text-align: center;
    padding: 60px 0;
    color: #888;
    font-size: 15px;
}
.thatsip-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--thatsip-primary-20);
    border-top-color: var(--thatsip-primary);
    border-radius: 50%;
    animation: thatsip-spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
@keyframes thatsip-spin {
    to { transform: rotate(360deg); }
}

/* ── RESULTS HEADER ── */
.thatsip-results-header {
    text-align: center;
    margin-bottom: 26px;
}
.thatsip-results-icon { font-size: 42px; display: block; margin-bottom: 8px; }
.thatsip-results-header h3 {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 14px;
}
.thatsip-result-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.thatsip-tag {
    background: var(--thatsip-primary-10);
    color: var(--thatsip-primary);
    border: 1px solid var(--thatsip-primary-20);
    border-radius: 50px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.thatsip-tag--stage {
    background: #f5f5f5;
    color: #666;
    border-color: #e0e0e0;
}

/* ── PRODUCT CARDS ── */
.thatsip-products-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
@media (max-width: 500px) {
    .thatsip-products-grid { grid-template-columns: 1fr; }
}
.thatsip-product-card {
    border: 2px solid #ebebeb;
    border-radius: var(--thatsip-radius);
    padding: 18px;
    position: relative;
    background: #fafafa;
    transition: border-color var(--thatsip-transition);
}
.thatsip-product-card--primary {
    border-color: var(--thatsip-primary);
    background: #fff;
}
.thatsip-product-badge {
    display: inline-block;
    background: var(--thatsip-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 50px;
    padding: 4px 10px;
    margin-bottom: 12px;
}
.thatsip-product-badge--secondary {
    background: #888;
}
.thatsip-drink-img {
    width: 100%;
    max-width: 160px;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.thatsip-product-img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: var(--thatsip-radius-sm);
    margin-bottom: 12px;
    background: #f0f0f0;
}
.thatsip-product-emoji {
    font-size: 64px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: var(--thatsip-radius-sm);
    background: var(--thatsip-primary-10);
}
.thatsip-product-name {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 6px;
    line-height: 1.3;
}
.thatsip-product-desc {
    font-size: 12px;
    color: #888;
    margin: 0 0 10px;
    line-height: 1.5;
}
.thatsip-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--thatsip-primary);
    margin-bottom: 12px;
}
.thatsip-product-price .woocommerce-Price-amount { font-size: inherit; }
.thatsip-product-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.thatsip-product-actions .thatsip-btn {
    font-size: 13px;
    padding: 10px 16px;
}

/* ── RETAKE ── */
.thatsip-retake { margin-top: 4px; }

/* ── ERROR ── */
.thatsip-error {
    text-align: center;
    padding: 48px 0;
    color: #888;
}

/* ── SHAKE ANIMATION ── */
@keyframes thatsip-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
.thatsip-shake { animation: thatsip-shake 0.4s ease; border-color: #e53e3e !important; }

/* ── TRIGGER BUTTON (shortcode) ── */
.thatsip-open-btn,
#thatsip-trigger-btn {
    background: var(--thatsip-btn-bg);
    color: var(--thatsip-btn-text);
    border: none;
    border-radius: 50px;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.12s ease;
    font-family: inherit;
}
.thatsip-open-btn:hover,
#thatsip-trigger-btn:hover {
    opacity: 0.88;
    transform: translateY(-2px);
}

/* ---------------------------------------------------------------
   INLINE MODE WRAPPER
--------------------------------------------------------------- */
.thatsip-inline-wrap {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    position: relative;
}

.thatsip-inner--inline {
    position: relative;
    overflow: hidden;
    min-height: 320px;
}

.thatsip-progress-wrap--inline {
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

/* Remove popup-specific chrome when inline */
.thatsip-inline-wrap .thatsip-close {
    display: none !important;
}
