/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --burgundy: #8b1a3a;
    --burgundy-deep: #6B1D3A;
    --gold: #c8943e;
    --gold-light: #C9A84C;
    --cream: #fdf8f5;
    --cream-warm: #FDF6EC;
    --rose: #E8D5D0;
    --dark: #3d2026;
    --dark-text: #2D1A1A;
    --muted: #7A6565;
    --white: #ffffff;
    --shadow: 0 4px 24px rgba(61, 32, 38, 0.08);
    --shadow-lg: 0 8px 40px rgba(61, 32, 38, 0.12);
    --radius: 16px;
    --radius-sm: 12px;
    --transition: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--cream);
    color: var(--dark-text);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Subtle paper texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3 { font-family: 'Playfair Display', serif; font-weight: 700; line-height: 1.3; }
.italic { font-style: italic; }

/* ===== LAYOUT ===== */
.container {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rose);
    z-index: 100;
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    transition: width 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
    border-radius: 0 2px 2px 0;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    min-height: 100dvh;
    padding: 40px 0;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== WELCOME SCREEN ===== */
.welcome {
    text-align: center;
    padding: 60px 0 40px;
}

.welcome__badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    background: rgba(200, 148, 62, 0.1);
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 24px;
}

.welcome h1 {
    font-size: 2rem;
    color: var(--burgundy);
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.welcome__subtitle {
    font-size: 1.05rem;
    color: var(--muted);
    margin-bottom: 32px;
    font-style: italic;
    font-family: 'Playfair Display', serif;
}

.welcome__social-proof {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 40px;
}

.welcome__social-proof strong {
    color: var(--dark-text);
}

.welcome__flame {
    font-size: 3rem;
    display: block;
    margin-bottom: 24px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 16px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn--primary {
    background: linear-gradient(135deg, var(--burgundy), var(--burgundy-deep));
    color: var(--white);
    box-shadow: 0 4px 20px rgba(139, 26, 58, 0.3);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(139, 26, 58, 0.4);
}

.btn--primary:active {
    transform: translateY(0);
}

.btn--secondary {
    background: var(--white);
    color: var(--burgundy);
    border: 2px solid var(--rose);
}

.btn--secondary:hover {
    border-color: var(--burgundy);
}

.btn--gold {
    background: linear-gradient(135deg, var(--gold), #d4a54a);
    color: var(--white);
    box-shadow: 0 4px 20px rgba(200, 148, 62, 0.3);
}

.btn--whatsapp {
    background: #25D366;
    color: var(--white);
}

.btn--outline {
    background: transparent;
    color: var(--dark-text);
    border: 2px solid var(--rose);
}

.btn--full { width: 100%; }

.btn--sm {
    font-size: 0.9rem;
    padding: 12px 24px;
}

/* ===== EMAIL SCREEN ===== */
.email-screen {
    text-align: center;
}

.email-screen h2 {
    font-size: 1.5rem;
    color: var(--burgundy);
    margin-bottom: 8px;
}

.email-screen p {
    color: var(--muted);
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.email-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input {
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    padding: 16px 20px;
    border: 2px solid var(--rose);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--dark-text);
    outline: none;
    transition: border-color var(--transition);
    text-align: center;
}

.input:focus {
    border-color: var(--gold);
}

.input::placeholder {
    color: #b8a8a8;
}

.email-screen__privacy {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 8px;
}

/* ===== QUESTION SCREEN ===== */
.question {
    padding-top: 24px;
}

.question__counter {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    text-align: center;
}

.question__text {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    color: var(--burgundy);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.4;
}

/* ===== ANSWER CARDS ===== */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 32px;
}

.card {
    background: var(--white);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(200, 148, 62, 0.05), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.card:hover {
    border-color: var(--rose);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card:hover::before { opacity: 1; }

.card.selected {
    border-color: var(--gold);
    background: linear-gradient(135deg, rgba(200, 148, 62, 0.06), rgba(253, 248, 245, 1));
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(200, 148, 62, 0.15);
}

.card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 700;
}

.card__emoji {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 10px;
}

.card__text {
    font-size: 0.85rem;
    color: var(--dark-text);
    line-height: 1.4;
    position: relative;
}

/* Stagger animation */
.cards-grid .card {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
}

.cards-grid.animate .card {
    animation: cardIn 0.4s ease-out forwards;
}

.cards-grid.animate .card:nth-child(1) { animation-delay: 0ms; }
.cards-grid.animate .card:nth-child(2) { animation-delay: 80ms; }
.cards-grid.animate .card:nth-child(3) { animation-delay: 160ms; }
.cards-grid.animate .card:nth-child(4) { animation-delay: 240ms; }

@keyframes cardIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== NEXT BUTTON (appears after selection) ===== */
.next-btn-wrap {
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease-out;
    pointer-events: none;
}

.next-btn-wrap.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ===== RESULT SCREEN ===== */
.result {
    text-align: center;
    padding: 40px 0 60px;
}

.result__emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
    animation: emojiIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes emojiIn {
    from { opacity: 0; transform: scale(0.5) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.result__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.result__name {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--burgundy);
    margin-bottom: 12px;
}

.result__tagline {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 28px;
    line-height: 1.5;
}

.result__divider {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 0 auto 28px;
}

.result__description {
    font-size: 0.95rem;
    color: var(--dark-text);
    line-height: 1.7;
    margin-bottom: 24px;
    text-align: left;
}

.result__description p {
    margin-bottom: 16px;
}

.result__advice {
    background: linear-gradient(135deg, rgba(200, 148, 62, 0.08), rgba(200, 148, 62, 0.03));
    border-left: 3px solid var(--gold);
    padding: 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 32px;
    text-align: left;
}

.result__advice-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.result__advice-text {
    font-size: 0.9rem;
    color: var(--dark-text);
    font-style: italic;
    line-height: 1.6;
}

/* ===== CTA SECTION ===== */
.cta-section {
    background: linear-gradient(135deg, var(--burgundy), var(--burgundy-deep));
    color: var(--white);
    padding: 28px 24px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    text-align: left;
}

.cta-section__icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
    display: block;
}

.cta-section__text {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
    opacity: 0.9;
}

.cta-section .btn {
    width: 100%;
}

/* ===== SHARE SECTION ===== */
.share-section {
    margin-top: 8px;
}

.share-section__title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 16px;
}

.share-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--dark-text);
    color: var(--white);
    padding: 14px 24px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease-out;
    z-index: 200;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== LOADING ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    text-align: center;
}

.loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--rose);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading__text {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ===== OPEN QUESTIONS ===== */
.open-textarea {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--cream-dark, #e8d5c4);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text, #3d2026);
    background: var(--cream-light, #fdf8f5);
    resize: vertical;
    transition: border-color 0.3s;
    box-sizing: border-box;
}
.open-textarea:focus {
    outline: none;
    border-color: var(--burgundy, #8b1a3a);
}
.open-textarea::placeholder {
    color: #b0a0a0;
    font-style: italic;
}
.char-count {
    text-align: right;
    font-size: 12px;
    color: #b0a0a0;
    margin-top: 4px;
    margin-bottom: 16px;
}
.btn--ghost {
    background: transparent;
    color: var(--muted, #8b7070);
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    margin-top: 4px;
}
.btn--ghost:hover {
    color: var(--burgundy, #8b1a3a);
}

/* ===== CALCULATING SCREEN ===== */
.calculating {
    text-align: center;
}

.calculating__emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.calculating h2 {
    font-size: 1.4rem;
    color: var(--burgundy);
    margin-bottom: 8px;
}

.calculating p {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 640px) {
    .container { max-width: 560px; padding: 0 32px; }
    .welcome h1 { font-size: 2.4rem; }
    .question__text { font-size: 1.5rem; }
    .cards-grid { gap: 16px; }
    .card { padding: 24px 18px; }
    .card__emoji { font-size: 2.6rem; }
    .card__text { font-size: 0.9rem; }
    .result__name { font-size: 2rem; }
}

@media (min-width: 1024px) {
    .container { max-width: 600px; }
}

/* ===== ERROR ===== */
.error-msg {
    color: #c44d2b;
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: center;
}

/* Required field shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ===== MOBILE SCROLL FIXES ===== */

/* Question and result screens: allow scroll when content > viewport */
#question-screen.active,
#result-screen.active {
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Extra bottom padding so continue button never hides behind browser chrome */
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

/* On small phones, reduce top padding so cards + button fit better */
@media (max-height: 700px) {
    #question-screen .question {
        padding-top: 12px;
    }
    #question-screen .question__text {
        font-size: 1.15rem;
        margin-bottom: 20px;
    }
    #question-screen .cards-grid {
        gap: 8px;
        margin-bottom: 20px;
    }
    #question-screen .card {
        padding: 14px 10px;
    }
    #question-screen .card__emoji {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }
}

/* Result screen: ensure container padding doesn't clip rounded corners */
#result-screen .container {
    padding-left: 20px;
    padding-right: 20px;
    /* Prevent shadow/border-radius from being clipped by body overflow-x hidden */
    overflow: visible;
}

/* CTA and advice sections: add horizontal breathing room on very small screens */
@media (max-width: 380px) {
    .cta-section {
        padding: 20px 16px;
        border-radius: 12px;
    }
    .result__advice {
        padding: 16px;
    }
    .result__name {
        font-size: 1.5rem;
    }
}

/* Safe area for notched iPhones (bottom bar) */
#question-screen .next-btn-wrap.show {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Result screen top padding when scrollable (not centered) */
#result-screen.active .container.result {
    padding-top: 48px;
}

/* Prevent horizontal overflow clipping box-shadows/radii in result */
#result-screen {
    overflow-x: hidden;
}
