/* Prevent flash of unstyled text */
.vocab-bubble { font-family: 'Quicksand', sans-serif; }

:root {
    /* Core brand */
    --primary: #FF1493;        /* Hot Pink - buttons, links, key actions */
    --primary-dark: #c41070;   /* Deep Pink - shadows, hover states */
    --accent: #00D4FF;         /* Neon Blue - highlights, text borders */

    /* Backgrounds */
    --bg: #240b36;             /* Cosmic Purple - page background */
    --bg-gradient: #4a148c;    /* Purple - gradient end */
    --surface: #ffffff;        /* White - cards, inputs */

    /* Text */
    --text: #333333;           /* Charcoal - body text on light */
    --text-muted: #666666;     /* Gray - secondary text */

    /* Semantic */
    --success: #00ff88;
    --error: #ff6b6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Quicksand', sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-gradient) 100%);
    color: white;
    line-height: 1.6;
}

/* --- LANDING PAGE SECTION --- */
header { padding: 2rem; text-align: center; }
.logo {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: white;
    text-decoration: none;
    text-shadow:
        -3px -3px 0 var(--accent),
        3px -3px 0 var(--accent),
        -3px 3px 0 var(--accent),
        3px 3px 0 var(--accent),
        0 -3px 0 var(--accent),
        0 3px 0 var(--accent),
        -3px 0 0 var(--accent),
        3px 0 0 var(--accent);
}

.hero { 
    max-width: 900px; 
    margin: 4rem auto; 
    text-align: center; 
    padding: 0 1rem; 
}

h1 { 
    font-family: 'Fredoka One', cursive; 
    font-size: 4rem; 
    margin-bottom: 1.5rem; 
    color: white;
    line-height: 1;
}
.highlight {
    color: white;
    text-shadow:
        -3px -3px 0 var(--accent),
        3px -3px 0 var(--accent),
        -3px 3px 0 var(--accent),
        3px 3px 0 var(--accent),
        0 -3px 0 var(--accent),
        0 3px 0 var(--accent),
        -3px 0 0 var(--accent),
        3px 0 0 var(--accent);
}

.cta-section {
    background: var(--surface) !important;
    padding: 3rem;
    border-radius: 40px;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    color: var(--text);
}

.email-form { display: flex; gap: 10px; margin-top: 1.5rem; }
input[type="email"] {
    flex: 1;
    padding: 1.2rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    background: var(--surface);
}
button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 5px 0 var(--primary-dark);
}
button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--primary-dark); }

/* --- DEMO SEPARATOR --- */
.demo-divider {
    background: color-mix(in srgb, var(--bg) 80%, black);
    padding: 6rem 1rem;
    margin-top: 6rem;
    position: relative;
    border-top: 8px solid var(--accent);
}

.demo-badge {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 10px 30px;
    border-radius: 50px;
    font-weight: 700;
    font-family: 'Fredoka One', cursive;
    box-shadow: 0 5px 15px rgba(255, 20, 147, 0.4);
}

/* --- APP MOCKUP (TABLET LANDSCAPE) --- */
.app-container {
    max-width: 1100px;
    margin: 0 auto;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    padding: 20px;
    border-radius: 35px;
    border: 12px solid #1a1a1a;
    box-shadow: 
        0 0 0 2px #0a0a0a,
        0 30px 80px rgba(0,0,0,0.7),
        0 10px 40px rgba(0,0,0,0.5),
        inset 0 1px 2px rgba(255,255,255,0.1);
    position: relative;
}


.book-spread {
    display: flex;
    background: var(--surface);
    border-radius: 25px;
    min-height: 550px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

.page-image {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Using a bright, golden character placeholder */
.page-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(1.5);
}

.energy-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 50%, var(--primary) 150%);
    pointer-events: none;
}

.page-text {
    flex: 1;
    padding: 4rem 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface);
    color: var(--text);
}

.page-text h2 {
    font-family: 'Fredoka One', cursive;
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
    line-height: 1.1;
}

.page-text p {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.8;
    color: var(--text);
}

/* Vocabulary word with definition bubble */
.vocab-word {
    position: relative;
    display: inline-block;
    background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 15%, transparent) 0%, color-mix(in srgb, var(--accent) 15%, transparent) 100%);
    padding: 2px 6px;
    border-radius: 6px;
    border-bottom: 2px solid var(--primary);
    cursor: pointer;
    transition: background 0.2s, border-bottom-color 0.2s;
}
.vocab-word:hover {
    background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 25%, transparent) 0%, color-mix(in srgb, var(--accent) 25%, transparent) 100%);
    border-bottom-color: var(--accent);
}
.vocab-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 160px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10;
    display: none;
    opacity: 0;
    transition: opacity 0.2s;
    /* Reset inherited styles */
    font-size: 0.8rem !important;
    line-height: 1.35 !important;
    font-weight: 400 !important;
}
.vocab-word.active .vocab-bubble {
    display: block;
    opacity: 1;
}
.vocab-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--accent);
}
.vocab-bubble .word-title {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}
.vocab-bubble .word-text {
    font-family: 'Fredoka One', cursive !important;
    font-size: 0.95rem !important;
    color: var(--primary);
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-weight: 400 !important;
}
.vocab-bubble .audio-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    margin: 0;
    box-shadow: none;
    transition: transform 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
}
.vocab-bubble .audio-btn:hover {
    transform: scale(1.2);
}
.vocab-bubble .audio-btn:active {
    transform: scale(0.95);
}
.vocab-bubble .definition {
    font-family: 'Quicksand', sans-serif !important;
    font-size: 0.8rem !important;
    color: var(--text-muted);
    font-weight: 400 !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Text generation prompt styling */
.text-generation-prompt {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(0, 0, 0, 0.05);
}

.prompt-input {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 10%, transparent) 0%, color-mix(in srgb, var(--accent) 10%, transparent) 100%);
    border: 2px solid transparent;
    border-image: linear-gradient(120deg, var(--primary), var(--accent)) 1;
    border-radius: 16px;
    padding: 14px 18px;
    position: relative;
    overflow: hidden;
}

.prompt-input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 5%, transparent), color-mix(in srgb, var(--accent) 5%, transparent));
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.prompt-icon {
    font-size: 1.3rem;
    animation: sparkle 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes sparkle {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% { 
        transform: scale(1.2) rotate(10deg);
        opacity: 0.8;
    }
}

.prompt-text-input {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Quicksand', sans-serif;
    position: relative;
    z-index: 1;
}

.prompt-text-input::selection {
    background: var(--primary);
    color: white;
}

.prompt-text-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    pointer-events: none;
}

.typing-indicator::before,
.typing-indicator::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator::before {
    animation-delay: 0s;
}

.typing-indicator::after {
    animation-delay: 0.2s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.kpop-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 5px 15px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 700;
}

.app-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 1.5rem;
    position: relative;
    z-index: 10;
}

.nav-button {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-button:hover {
    transform: scale(1.1);
}

.nav-button:active {
    transform: scale(0.95);
}

/* --- RESPONSIVE LOGIC --- */
@media (max-width: 900px) {
    .book-spread {
        flex-direction: column;
        aspect-ratio: auto;
    }
    .page-image { height: 400px; }
    h1 { font-size: 2.8rem; }
    .logo { font-size: 2rem; }
    .app-container {
        border-radius: 25px;
        border-width: 8px;
        padding: 15px;
    }
    .prompt-input {
        padding: 12px 14px;
    }
    .prompt-text-input {
        font-size: 0.9rem;
    }
    /* Fix CTA section on mobile */
    .cta-section {
        padding: 2rem 1.5rem;
        border-radius: 30px;
    }
    .email-form {
        flex-direction: column;
        gap: 12px;
    }
    button {
        width: 100%;
        padding: 1.2rem;
    }
    /* Fix hero section padding */
    .hero {
        padding: 0 1.5rem;
        margin: 2rem auto;
    }
    /* Adjust page text padding */
    .page-text {
        padding: 2.5rem 2rem;
    }
    /* Move navigation higher on mobile to avoid home button */
    .app-nav {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }
    .nav-button {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

footer { text-align: center; padding: 4rem 2rem; color: rgba(255,255,255,0.5); font-weight: 600; }

/* --- SURVEY STEP --- */
.survey-step {
    display: none;
}
.survey-step.active {
    display: block;
}
.email-step.hidden {
    display: none;
}
.thank-you-step {
    display: none;
    text-align: center;
    padding: 2rem 0;
    position: relative;
}
.thank-you-step.active {
    display: block;
}
.thank-you-step .tada {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: tada 0.8s ease-out;
}
.thank-you-step h3 {
    color: var(--primary);
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.lock-wrapper {
    position: relative;
    display: inline-block;
}
.lock-icon {
    display: inline-block;
}
.lock-icon.unlocked {
    animation: lock-pop 0.4s ease;
}
.key-icon {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
}
.key-icon.fly-in {
    animation: key-fly-in 0.6s ease-out forwards;
}
.key-icon.turn {
    opacity: 1;
    right: 2px;
    animation: key-turn 0.5s ease-in-out forwards;
}
.key-icon.hide {
    opacity: 0;
    transition: opacity 0.2s;
}
@keyframes key-fly-in {
    0% {
        opacity: 0;
        right: -30px;
        transform: translateY(-50%) rotate(-30deg);
    }
    100% {
        opacity: 1;
        right: 2px;
        transform: translateY(-50%) rotate(0deg);
    }
}
@keyframes key-turn {
    0% { transform: translateY(-50%) rotate(0deg); }
    40% { transform: translateY(-50%) rotate(-45deg); }
    70% { transform: translateY(-50%) rotate(-90deg); }
    100% { transform: translateY(-50%) rotate(-90deg) scale(0.8); }
}
@keyframes lock-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
@keyframes tada {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(10deg); }
    70% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.tada-wrapper {
    position: relative;
    display: inline-block;
}
.confetti-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    overflow: visible;
    pointer-events: none;
}
.confetti {
    position: absolute;
    opacity: 0;
}
.confetti.burst {
    animation: confetti-burst 2s ease-out forwards;
}
@keyframes confetti-burst {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(0.5);
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) rotate(1080deg) scale(1.2);
    }
}
/* Falling confetti from top */
.falling-confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9998;
}
.confetti.falling {
    animation: confetti-fall 3s ease-in forwards;
}
@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(1440deg);
    }
}
.survey-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 1fr;
    gap: 12px;
    margin: 1.5rem 0;
}
.survey-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 80px;
}
.survey-option:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
}
.survey-option:active {
    transform: translateY(0);
}
.survey-option .option-letter {
    font-size: 1.8rem;
    margin-bottom: 6px;
    transition: transform 0.3s ease;
}
.survey-option:hover .option-letter {
    animation: wiggle 0.5s ease-in-out;
}
@keyframes wiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-12deg) scale(1.1); }
    50% { transform: rotate(12deg) scale(1.2); }
    75% { transform: rotate(-8deg) scale(1.1); }
}
.survey-option .option-text {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.3;
}
.survey-option.selected {
    background: var(--primary);
    border-color: var(--primary);
}
.survey-option.selected .option-text {
    color: white;
}
.other-feedback {
    display: none;
    margin-top: 1rem;
    animation: fadeIn 0.3s ease;
}
.other-feedback.visible {
    display: flex;
    gap: 10px;
}
.other-feedback input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Quicksand', sans-serif;
    outline: none;
}
.other-feedback input:focus {
    border-color: var(--primary);
}
.other-feedback button {
    padding: 12px 24px;
    font-size: 0.9rem;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- COLOR PICKER PANEL (only visible on /test) --- */
.color-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: #1a1a2e;
    border-left: 3px solid var(--accent);
    padding: 20px;
    overflow-y: auto;
    z-index: 9999;
    font-family: 'Quicksand', sans-serif;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
}
.color-panel.visible {
    display: block;
}
.color-panel h3 {
    color: white;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}
.color-panel-section {
    margin-bottom: 20px;
}
.color-panel-section h4 {
    color: var(--accent);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.color-input-group label {
    flex: 1;
    color: #ccc;
    font-size: 0.85rem;
    font-weight: 600;
}
.color-input-group input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}
.color-input-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}
.color-input-group input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
}
.color-input-group .hex-value {
    width: 70px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: white;
    font-size: 0.75rem;
    padding: 4px 6px;
    text-transform: uppercase;
    font-family: monospace;
}
.color-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.color-panel-actions button {
    padding: 10px 15px;
    font-size: 0.85rem;
    border-radius: 8px;
}
.btn-reset {
    background: transparent !important;
    border: 2px solid var(--error) !important;
    color: var(--error) !important;
    box-shadow: none !important;
}
.btn-copy {
    background: var(--accent) !important;
    color: #000 !important;
    box-shadow: none !important;
}
.btn-copy:hover {
    opacity: 0.9;
}
.color-panel-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(255, 20, 147, 0.4);
    font-size: 1.5rem;
    color: white;
}
.color-panel-toggle.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}
body.test-mode {
    margin-right: 280px;
}
@media (max-width: 900px) {
    .color-panel {
        width: 100%;
        height: auto;
        max-height: 50vh;
        top: auto;
        bottom: 0;
        border-left: none;
        border-top: 3px solid var(--accent);
    }
    body.test-mode {
        margin-right: 0;
        margin-bottom: 50vh;
    }
}
