/* =================================================================
   STORY ZONE MODULE STYLES
   Version 2.0 - December 2025
   Comprehensive story-based learning with multiple form types
   ================================================================= */

.module-story-zone {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.module-story-zone h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =================================================================
   TOP CONTROLS - Next Button
   ================================================================= */

.sz-top-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.sz-next-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
}

/* =================================================================
   CONTROLS BAR
   ================================================================= */

.sz-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sz-mode-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.sz-mode-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sz-mode-btn:hover {
    color: var(--text-primary);
}

.sz-mode-btn.active {
    background: var(--primary);
    color: white;
}

.sz-story-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

#szStoryInfo {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 120px;
    text-align: center;
}

/* =================================================================
   STORY HEADER
   ================================================================= */

.sz-story-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sz-story-header h2 {
    font-size: 20px;
    color: var(--text-primary);
    margin: 0;
}

.sz-form-indicator {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    padding: 6px 12px;
    background: var(--primary-light);
    border-radius: 6px;
}

/* =================================================================
   STORY AREA
   ================================================================= */

.sz-story-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 300px;
}

/* =================================================================
   SENTENCE ROW
   ================================================================= */

.sz-sentence {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

.sz-sentence:hover {
    box-shadow: var(--shadow-md);
}

.sz-sentence.greyed {
    opacity: 0.6;
    pointer-events: none;
}

/* Sentence Speaker Button */
.sz-sentence-speaker {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sz-sentence-speaker:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

.sz-sentence-speaker:active {
    transform: scale(0.95);
}

.sz-sentence-speaker.no-audio {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.sz-sentence-speaker.no-audio:hover {
    transform: none;
    background: #ccc;
}

/* =================================================================
   CARDS CONTAINER
   ================================================================= */

.sz-cards-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

/* =================================================================
   WORD WRAPPER - Card + Word Text
   ================================================================= */

.sz-word-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.sz-word-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    max-width: 80px;
    word-break: break-word;
}

/* =================================================================
   PICTURE CARDS - Audio Match Style (larger)
   ================================================================= */

.sz-card {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    position: relative;
    cursor: pointer;
}

.sz-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Picture Card with Flip */
.sz-card-picture {
    perspective: 1000px;
}

.sz-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

.sz-card-picture.flipped .sz-card-inner {
    transform: rotateY(180deg);
}

.sz-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.sz-card-front {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
}

.sz-card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.sz-card-back {
    background: var(--primary);
    color: white;
    transform: rotateY(180deg);
    padding: 8px;
    text-align: center;
}

.sz-card-translation {
    font-size: 12px;
    font-weight: 600;
    word-break: break-word;
}

/* Card Speaker Icon */
.sz-card-speaker {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.sz-card-speaker:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

/* =================================================================
   BLANK CARDS
   ================================================================= */

.sz-card-blank {
    background: var(--bg-tertiary);
    border: 3px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 24px;
}

.sz-card-blank:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Filled Blank Card */
.sz-card-filled {
    position: relative;
}

.sz-card-filled img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Feedback Overlays */
.sz-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border-radius: 8px;
    animation: feedbackPulse 0.5s ease;
}

.sz-feedback-correct {
    background: rgba(16, 185, 129, 0.7);
    color: white;
}

.sz-feedback-incorrect {
    background: rgba(239, 68, 68, 0.7);
    color: white;
}

@keyframes feedbackPulse {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* =================================================================
   FUNCTION WORDS
   ================================================================= */

.sz-function-word {
    padding: 8px 12px;
    background: var(--gray-100);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
    align-self: center;
}

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

.sz-submit-btn {
    align-self: center;
    padding: 8px 16px;
    font-size: 14px;
    margin-left: auto;
}

/* =================================================================
   FEEDBACK MESSAGE
   ================================================================= */

.sz-feedback {
    margin-top: 24px;
    padding: 16px 24px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.sz-feedback.correct {
    background: var(--success-light);
    color: #065F46;
}

.sz-feedback.incorrect {
    background: #FEE2E2;
    color: #DC2626;
}

.sz-feedback i {
    font-size: 24px;
}

/* =================================================================
   CARD SELECTION MODAL
   ================================================================= */

.sz-card-modal {
    max-width: 700px;
    max-height: 80vh;
}

.sz-card-modal .modal-body {
    overflow-y: auto;
    max-height: 60vh;
}

.sz-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
    padding: 8px;
}

.sz-modal-card {
    width: 100px;
    height: 100px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid var(--border-color);
    transition: all 0.2s;
    position: relative;
}

.sz-modal-card:hover {
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.sz-modal-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sz-modal-card-word {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.sz-modal-card:hover .sz-modal-card-word {
    opacity: 1;
}

/* =================================================================
   EMPTY STATE
   ================================================================= */

.module-story-zone .empty-state {
    text-align: center;
    padding: 60px 20px;
}

.module-story-zone .empty-state i {
    font-size: 48px;
    color: var(--warning);
    margin-bottom: 16px;
}

.module-story-zone .empty-state h2 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.module-story-zone .empty-state p {
    color: var(--text-secondary);
}

/* =================================================================
   SHOW TEXT BUTTON & TEXT DISPLAY (Review Mode)
   ================================================================= */

.sz-show-text-btn {
    flex-shrink: 0;
    margin-left: auto;
    padding: 8px 16px;
    font-size: 13px;
    white-space: nowrap;
}

.sz-show-text-btn.active {
    background: var(--primary);
    color: white;
}

/* =================================================================
   WORD BUBBLE STYLES (base styles for inline bubble display)
   ================================================================= */

.sz-word-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-primary);
    border: 2px solid var(--primary);
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sz-word-bubble:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    transform: translateY(-2px);
}

.sz-word-bubble.has-card {
    border-color: var(--primary);
}

.sz-word-bubble.function-word {
    background: var(--bg-tertiary);
    border-style: dashed;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.sz-word-bubble.function-word:hover {
    border-color: var(--text-secondary);
    background: var(--bg-secondary);
}

.sz-bubble-text {
    font-weight: 600;
}

/* Speaker icon in word bubbles */
.sz-bubble-speaker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--primary);
    border-radius: 50%;
    color: white;
    font-size: 11px;
    transition: all 0.2s;
}

.sz-word-bubble:hover .sz-bubble-speaker {
    background: var(--primary-dark, #4a47a3);
    transform: scale(1.1);
}

/* =================================================================
   INLINE BUBBLE LAYOUT (Word bubbles directly under cards)
   Each card has its word bubble placed directly below it
   ================================================================= */

/* Word wrapper becomes vertical flex when text is visible */
.sz-text-visible .sz-word-wrapper {
    flex-direction: column;
    align-items: center;
}

/* Inline bubble container - holds line + bubble */
.sz-inline-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 4px;
    width: 100%;
}

/* Short vertical connection line from card to bubble */
.sz-inline-line {
    width: 2px;
    height: 16px;
    background: var(--primary);
    opacity: 0.5;
    border-radius: 1px;
}

/* Word bubble styling adjustments for inline display */
.sz-inline-bubble .sz-word-bubble {
    margin-top: 4px;
    padding: 6px 10px;
    font-size: 0.85rem;
    text-align: center;
    max-width: 100%;
    word-break: break-word;
}

/* Smaller bubbles for inline display */
.sz-inline-bubble .sz-word-bubble.has-card {
    background: var(--bg-primary);
    border: 2px solid var(--primary);
}

.sz-inline-bubble .sz-word-bubble.function-word {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    padding: 4px 8px;
    font-size: 0.8rem;
}

/* Function words don't get connection lines */
.sz-inline-bubble .sz-word-bubble.function-word ~ .sz-inline-line,
.sz-word-wrapper:not(:has(.sz-card)) .sz-inline-line {
    display: none;
}

/* Speaker icon in inline bubbles */
.sz-inline-bubble .sz-bubble-speaker {
    width: 20px;
    height: 20px;
    font-size: 10px;
}

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

@media (max-width: 768px) {
    .sz-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .sz-mode-toggle {
        justify-content: center;
    }

    .sz-story-nav {
        justify-content: center;
    }

    .sz-story-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .sz-sentence {
        flex-direction: column;
        align-items: center;
    }

    .sz-cards-container {
        justify-content: center;
    }

    .sz-card {
        width: 70px;
        height: 70px;
    }

    /* Inline bubbles for tablet */
    .sz-inline-bubble .sz-word-bubble {
        font-size: 0.8rem;
        padding: 5px 8px;
    }

    .sz-word-text {
        font-size: 12px;
    }

    .sz-card-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .sz-modal-card {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .module-story-zone h1 {
        font-size: 18px;
    }

    .sz-card {
        width: 60px;
        height: 60px;
    }

    .sz-sentence-speaker {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .sz-card-speaker {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    /* Tighter gap on phones */
    .sz-cards-container {
        gap: 8px;
    }

    /* Inline bubbles for phone */
    .sz-inline-line {
        height: 12px;
    }

    .sz-inline-bubble .sz-word-bubble {
        padding: 4px 6px;
        font-size: 0.75rem;
        border-radius: 12px;
    }

    .sz-inline-bubble .sz-bubble-speaker {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sz-sentence {
    animation: fadeIn 0.3s ease;
}

.sz-card {
    animation: fadeIn 0.2s ease;
}

/* Pulse animation for blank cards */
.sz-card-blank i {
    animation: pulse 2s infinite;
}

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