/*
 * cai_tutorial.css — animated tutorial overlay for Comprehension games
 * (Group 45). Self-contained styles for the 12-scene takeover; included
 * by comprehension_ai.html + the three non-AI comp surfaces.
 *
 * Visual system:
 *   .cai-tut                 — full-screen backdrop (z-index 9999)
 *   .cai-tut-card            — cream-paper panel that holds one scene
 *     .cai-tut-step-pill     — "SCENE N OF 12" chip
 *     .cai-tut-title         — big Lexend Mega scene title
 *     .cai-tut-demo          — variable mini-mockup per scene
 *     .cai-tut-narration     — caption duplicating the spoken audio
 *     .cai-tut-controls      — Skip + auto-advance progress bar
 *
 * Reusable mini-mockups inside .cai-tut-demo:
 *   .cai-mini-book           — picture book with flipping page
 *   .cai-mini-sentence       — single sentence that lights up on tap
 *   .cai-mini-canvas         — handwriting canvas with stroke trace
 *   .cai-mini-blocks         — word-block grid
 *   .cai-mini-submit         — pulsing Done button
 *   .cai-mini-eli            — Eli face frame (pose swap during grade scene)
 *
 * The "hand" puppet is a single .cai-hand element absolutely positioned
 * inside the demo; CSS classes drive each scene's tap rhythm.
 */

.cai-tut {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-family: 'Andika', 'Lexend Mega', sans-serif;
    animation: cai-tut-fade 0.3s ease-out;
}
.cai-tut.show { display: flex; }
@keyframes cai-tut-fade { from { opacity: 0 } to { opacity: 1 } }

.cai-tut-card {
    background: #FFFDF9;
    border: 5px solid #1e293b;
    border-radius: 24px;
    box-shadow: 12px 12px 0 #1e293b;
    width: min(640px, 100%);
    max-height: 95vh;
    overflow-y: auto;
    padding: 1.2rem 1.4rem 1.4rem;
    position: relative;
    animation: cai-card-pop 0.4s cubic-bezier(0.4, 0, 0.2, 1.2);
}
@keyframes cai-card-pop {
    from { transform: scale(0.88); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.cai-tut-step-pill {
    display: inline-block;
    background: #f59e0b;
    color: white;
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}
.cai-tut-title {
    font-family: 'Lexend Mega';
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    color: #0369a1;
    line-height: 1.15;
    margin-bottom: 0.8rem;
}
.cai-tut-demo {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 3px dashed #94a3b8;
    border-radius: 16px;
    min-height: 220px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.cai-tut-narration {
    font-weight: 700;
    font-size: 1rem;
    color: #334155;
    margin-top: 0.85rem;
    margin-bottom: 0.85rem;
    line-height: 1.45;
    text-align: center;
    min-height: 2.5em;
}

/* Auto-advance progress bar — slim amber wedge under the controls. */
.cai-tut-progress {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.6rem;
}
.cai-tut-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    width: 0%;
    transition: width 0.1s linear;
}

.cai-tut-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.7rem;
}
.cai-tut-btn {
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.85rem;
    padding: 0.6rem 1.1rem;
    border-radius: 11px;
    border: 3px solid #1e293b;
    cursor: pointer;
    transition: transform 0.06s;
    text-transform: uppercase;
}
.cai-tut-btn:active { transform: translate(2px, 2px); }
.cai-tut-btn.skip { background: white; color: #475569; box-shadow: 3px 3px 0 #1e293b; }
.cai-tut-btn.next { background: #fbbf24; color: #1e293b; box-shadow: 3px 3px 0 #1e293b; flex: 1; max-width: 220px; }
.cai-tut-btn.final { background: #10b981; color: white; }

/* ========================================================
   The hand puppet — single shared element that moves around
   ======================================================== */
.cai-hand {
    position: absolute;
    font-size: 2.6rem;
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 5;
}
.cai-hand.tap-down { animation: cai-hand-tap-down 0.4s ease-out; }
@keyframes cai-hand-tap-down {
    0%, 100% { transform: scale(1)   translateY(0); }
    50%      { transform: scale(0.8) translateY(8px); }
}

/* ========================================================
   Mini book (scenes 2, 3, 4, 5)
   ======================================================== */
.cai-mini-book {
    width: 320px; height: 200px;
    background: var(--cai-book-bg, #dbeafe);
    border: 4px solid #1e293b;
    border-radius: 14px;
    box-shadow: 5px 5px 0 #1e293b;
    position: relative;
    perspective: 1200px;
    transform-style: preserve-3d;
    overflow: hidden;
}
.cai-mini-book-cover,
.cai-mini-book-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.8rem;
    background: var(--cai-book-bg, #dbeafe);
    transform-origin: left center;
    backface-visibility: hidden;
}
.cai-mini-book-cover-title {
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 1.1rem;
    color: #1e293b;
    background: rgba(255,255,255,0.92);
    padding: 6px 14px;
    border-radius: 10px;
    border: 2px solid #1e293b;
    margin-top: 6px;
}
.cai-mini-book-cover-emoji {
    font-size: 4rem;
    margin-bottom: 4px;
}
.cai-mini-book-open-btn {
    margin-top: 10px;
    background: #fbbf24;
    border: 2px solid #1e293b;
    border-radius: 8px;
    padding: 5px 12px;
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.75rem;
    color: #1e293b;
}
.cai-mini-book.opening .cai-mini-book-cover {
    animation: cai-cover-flip 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cai-cover-flip {
    0%   { transform: rotateY(0);     opacity: 1; }
    100% { transform: rotateY(-150deg); opacity: 0; }
}
.cai-mini-book-page {
    background: var(--cai-book-bg, #dbeafe);
    font-family: 'Andika';
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.4;
    color: #1e293b;
}
.cai-mini-book-page.flipping {
    animation: cai-page-flip 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes cai-page-flip {
    0%   { transform: rotateY(0); }
    100% { transform: rotateY(-160deg); opacity: 0; }
}
.cai-mini-book-page-num {
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 700;
}
.cai-mini-book-next {
    position: absolute;
    bottom: -36px;
    right: 0;
    background: white;
    border: 3px solid #1e293b;
    box-shadow: 3px 3px 0 #1e293b;
    border-radius: 10px;
    padding: 5px 14px;
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.8rem;
    color: #1e293b;
}

/* ========================================================
   Tap-to-hear sentence (scene 4)
   ======================================================== */
.cai-mini-sentence-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}
.cai-mini-sentence {
    font-family: 'Andika';
    font-weight: 700;
    font-size: 1.1rem;
    background: white;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    border: 3px solid #1e293b;
    box-shadow: 3px 3px 0 #1e293b;
    color: #1e293b;
    max-width: 360px;
}
.cai-mini-sentence.glow {
    background: #fef3c7;
    animation: cai-sentence-glow 1.2s ease-out;
}
@keyframes cai-sentence-glow {
    0%   { box-shadow: 3px 3px 0 #1e293b, 0 0 0 0 rgba(245,158,11,0.7); }
    50%  { box-shadow: 3px 3px 0 #1e293b, 0 0 0 18px rgba(245,158,11,0); }
    100% { box-shadow: 3px 3px 0 #1e293b, 0 0 0 0 rgba(245,158,11,0); background: white; }
}
.cai-mini-speaker {
    display: inline-block;
    font-size: 1.6rem;
    transition: transform 0.2s ease;
}
.cai-mini-speaker.bouncing {
    animation: cai-speaker-bounce 1s ease-in-out 2;
}
@keyframes cai-speaker-bounce {
    0%, 100% { transform: translateY(0)    scale(1); }
    25%      { transform: translateY(-8px) scale(1.2); }
    50%      { transform: translateY(0)    scale(1); }
    75%      { transform: translateY(-4px) scale(1.1); }
}

/* ========================================================
   Question card (scene 6)
   ======================================================== */
.cai-mini-question {
    font-family: 'Andika';
    font-weight: 700;
    font-size: 1.3rem;
    color: #0369a1;
    background: white;
    padding: 1.2rem 1.5rem;
    border-radius: 14px;
    border: 4px solid #1e293b;
    box-shadow: 4px 4px 0 #1e293b;
    text-align: center;
    max-width: 380px;
}
.cai-mini-question.glow {
    animation: cai-q-glow 1.4s ease-out;
}
@keyframes cai-q-glow {
    0%   { box-shadow: 4px 4px 0 #1e293b, 0 0 0 0 rgba(56,189,248,0.7); }
    60%  { box-shadow: 4px 4px 0 #1e293b, 0 0 0 22px rgba(56,189,248,0); }
}

/* ========================================================
   Word blocks (scenes 7, 9)
   ======================================================== */
.cai-mini-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    max-width: 360px;
}
.cai-mini-block {
    font-family: 'Andika';
    font-weight: 700;
    font-size: 1rem;
    background: white;
    padding: 0.55rem 0.9rem;
    border: 3px solid #1e293b;
    border-radius: 10px;
    box-shadow: 2px 2px 0 #1e293b;
    color: #1e293b;
    transition: transform 0.18s, background 0.2s;
}
.cai-mini-block.tapped {
    background: #fef9c3;
    transform: scale(0.92);
}
.cai-mini-block.long-pressed {
    background: #fbbf24;
    animation: cai-block-pulse 0.8s ease-out;
}
@keyframes cai-block-pulse {
    0%   { box-shadow: 2px 2px 0 #1e293b, 0 0 0 0 rgba(251,191,36,0.7); }
    100% { box-shadow: 2px 2px 0 #1e293b, 0 0 0 16px rgba(251,191,36,0); }
}
.cai-mini-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 0.6rem;
    min-height: 36px;
}
.cai-mini-chip {
    background: #1e3a8a;
    color: white;
    font-family: 'Andika';
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    border: 2px solid #1e293b;
    animation: cai-chip-pop 0.3s cubic-bezier(0.4, 0, 0.2, 1.4);
}
@keyframes cai-chip-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ========================================================
   Drawing canvas (scene 8)
   ======================================================== */
.cai-mini-canvas {
    width: 340px;
    height: 140px;
    background: #FFFDF9;
    border: 3px solid #1e293b;
    border-radius: 10px;
    box-shadow: 3px 3px 0 #1e293b;
    position: relative;
    overflow: hidden;
}
.cai-mini-canvas .guide {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 1px;
}
.cai-mini-canvas .guide.top { top: 22%; background: #cbd5e1; }
.cai-mini-canvas .guide.mid { top: 55%; border-top: 1px dashed #93c5fd; }
.cai-mini-canvas .guide.bot { top: 85%; background: #94a3b8; height: 1.5px; }
.cai-mini-canvas svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.cai-mini-canvas svg path {
    fill: none;
    stroke: #1e3a8a;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}
.cai-mini-canvas.tracing svg path {
    animation: cai-trace 3s ease-in-out forwards;
}
@keyframes cai-trace {
    0%   { stroke-dashoffset: 2000; }
    85%  { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}
.cai-mini-add-word {
    margin-top: 0.6rem;
    background: #10b981;
    color: white;
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.85rem;
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    border: 3px solid #1e293b;
    box-shadow: 3px 3px 0 #1e293b;
}

/* ========================================================
   Submit button (scene 10)
   ======================================================== */
.cai-mini-submit {
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 1.1rem;
    background: #fbbf24;
    color: #1e293b;
    padding: 0.9rem 1.8rem;
    border-radius: 14px;
    border: 4px solid #1e293b;
    box-shadow: 6px 6px 0 #1e293b;
    animation: cai-submit-pulse 1.6s ease-in-out infinite;
}
@keyframes cai-submit-pulse {
    0%, 100% { transform: scale(1);    box-shadow: 6px 6px 0 #1e293b, 0 0 0 0 rgba(251,191,36,0.7); }
    50%      { transform: scale(1.07); box-shadow: 6px 6px 0 #1e293b, 0 0 0 20px rgba(251,191,36,0); }
}

/* ========================================================
   Eli grading reveal (scene 11)
   ======================================================== */
.cai-mini-eli-frame {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 5px solid #f59e0b;
    box-shadow: 0 8px 24px rgba(245,158,11,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7rem;
    position: relative;
    animation: cai-eli-bob 1.4s ease-in-out infinite;
}
@keyframes cai-eli-bob {
    0%, 100% { transform: translateY(0)   rotate(-3deg); }
    50%      { transform: translateY(-8px) rotate(3deg); }
}
.cai-mini-eli-bubble {
    position: absolute;
    top: -10px;
    right: -120px;
    background: white;
    border: 3px solid #1e293b;
    box-shadow: 3px 3px 0 #1e293b;
    border-radius: 12px;
    padding: 0.5rem 0.9rem;
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 0.9rem;
    color: #047857;
    animation: cai-bubble-pop 0.4s cubic-bezier(0.4, 0, 0.2, 1.4) 0.6s both;
}
@keyframes cai-bubble-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ========================================================
   Final scene (12) — sparkles + "Let's go!"
   ======================================================== */
.cai-mini-final {
    text-align: center;
}
.cai-mini-final-emoji {
    font-size: 5rem;
    animation: cai-final-bounce 1.4s ease-in-out infinite;
}
@keyframes cai-final-bounce {
    0%, 100% { transform: scale(1)    translateY(0); }
    50%      { transform: scale(1.15) translateY(-10px); }
}
.cai-mini-final-text {
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 1.6rem;
    color: #f59e0b;
    margin-top: 0.5rem;
    text-shadow: 2px 2px 0 #1e293b;
}

/* Welcome scene (1) — Eli waves */
.cai-mini-welcome {
    text-align: center;
}
.cai-mini-welcome-eli {
    font-size: 6rem;
    display: inline-block;
    animation: cai-wave 1.2s ease-in-out infinite;
    transform-origin: bottom center;
}
@keyframes cai-wave {
    0%, 100% { transform: rotate(-8deg); }
    50%      { transform: rotate(8deg); }
}
.cai-mini-welcome-text {
    font-family: 'Lexend Mega';
    font-weight: 900;
    font-size: 1.3rem;
    color: #0369a1;
    margin-top: 0.5rem;
}

/* ========================================================
   Floating Help button on the quiz screen
   ======================================================== */
.cai-help-btn {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fbbf24;
    border: 4px solid #1e293b;
    box-shadow: 4px 4px 0 #1e293b;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.cai-help-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #1e293b;
}
