/**
 * Interactive Story Page Styles
 * Additional CSS for story pages with read-aloud and word highlighting
 */

/* Reading Controls Panel */
.reading-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(46, 125, 50, 0.1) 100%);
    border-radius: 15px;
    margin: 30px auto;
    max-width: 900px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.reading-controls button,
.reading-controls select {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #4CAF50;
    border-radius: 10px;
    background: white;
    color: #4CAF50;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
}

.reading-controls button#pauseReadBtn {
    display: none; /* Hidden until reading starts */
}

.reading-controls select#voiceSelect {
    min-width: 220px;
    font-size: 14px;
}

.reading-controls button:hover,
.reading-controls select:hover {
    background: #4CAF50;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.reading-controls button.active {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    border-color: #2E7D32;
}

.reading-controls select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234CAF50' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* Story Content Area */
.story-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.story-content {
    font-size: 20px;
    line-height: 1.8;
    color: #333;
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Word Highlighting */
.story-content .word {
    display: inline;
    padding: 2px 1px;
    border-radius: 3px;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none; /* Prevent text selection when clicking */
}

.story-content .word.word.current {
    background: rgba(76, 175, 80, 0.4) !important; /* Same purple as background but more opaque */
    color: #333 !important;
    font-weight: bold !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    transition: background 0.1s ease !important;
}

.story-content .word.hover {
    background: rgba(76, 175, 80, 0.4) !important; /* Purple matching read-along */
    color: #333 !important;
    font-weight: bold !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    transition: background 0.1s ease !important;
}

.story-content .word.read {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

/* Word click highlight (same purple as read-along) */
.story-content .word.clicked {
    background: rgba(76, 175, 80, 0.4) !important;
    color: #333 !important;
    font-weight: bold !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    transition: background 0.1s ease !important;
    cursor: pointer;
}

/* Inline Sound Buttons in Story */
.story-content .inline-sound-button {
    display: inline-block;
    width: 120px;
    height: 95px;
    margin: 2px 3px;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
    padding: 8px 4px;
}

.story-content .inline-sound-button .emoji-icon {
    font-size: 2.2em;
    margin-bottom: 2px;
    line-height: 1;
    display: block;
}

.story-content .inline-sound-button .button-text {
    font-size: 12px; /* Increased from 10px for better readability */
    line-height: 1.2; /* Slightly increased for better spacing */
    padding: 0 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: block;
    max-width: 100%;
    text-align: center;
    min-height: 26px; /* Slightly increased to accommodate larger font */
}

/* Better text flow around buttons */
.story-content p {
    line-height: 1.8;
    margin-bottom: 1em;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Make buttons flow inline with text better */
.story-content .inline-sound-button {
    vertical-align: middle;
    margin: 2px 4px;
}

/* Story Title */
.story-title {
    font-size: 2.5em;
    text-align: center;
    margin: 30px 0;
    color: #4CAF50;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Post-Story Actions */
.post-story-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 40px 0;
    flex-wrap: wrap;
}

.post-story-actions button {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.post-story-actions button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.post-story-actions button:active {
    transform: translateY(-1px);
}

/* Story Metadata (hidden, for SEO) */
.story-metadata {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .reading-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .reading-controls button,
    .reading-controls select {
        width: 100%;
        min-width: unset;
    }
    
    .story-content {
        font-size: 18px;
        line-height: 1.6;
        padding: 20px;
    }
    
    .story-content .inline-sound-button {
        width: calc(50% - 10px);
        height: 120px;
        margin: 5px;
    }
    
    .story-content .inline-sound-button .emoji-icon {
        font-size: 2.5em;
    }
    
    .story-content .inline-sound-button .button-text {
        font-size: 14px; /* Increased from 12px for better readability on tablet */
    }
    
    .story-title {
        font-size: 2em;
    }
    
    .post-story-actions {
        flex-direction: column;
    }
    
    .post-story-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .story-content {
        font-size: 16px;
        padding: 15px;
    }
    
    .story-content .inline-sound-button {
        width: 100%;
        height: 110px;
    }
    
    .story-title {
        font-size: 1.75em;
    }
}

/* Ensure sound buttons maintain their styling */
.story-content .sound-button {
    position: relative;
    overflow: hidden;
}

.story-content .sound-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
    pointer-events: none;
}

.story-content .sound-button:hover:before {
    left: 100%;
}

/* Story End Marker */
.story-end {
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    color: #4CAF50;
    margin: 40px 0;
    padding: 20px;
    border-top: 2px solid #4CAF50;
    border-bottom: 2px solid #4CAF50;
}

/* Confetti Effect (matching home page) */
.confetti {
    position: fixed;
    font-size: 4em;
    pointer-events: none;
    z-index: 1000;
}

.confetti.super-size {
    font-size: 8em;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Resume Popup */
#storyResumePopup {
    animation: popupFadeIn 0.3s ease;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

#storyResumePopup button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Remove blue bar from button active/focus/hover state */
.story-content .inline-sound-button:focus,
.story-content .inline-sound-button:active,
.story-content .inline-sound-button:focus-visible,
.story-content .inline-sound-button:hover {
    outline: none !important;
    border: none !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2) !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.story-content .inline-sound-button:hover {
    transform: translateY(-5px) scale(1.05) !important;
}

.story-content .inline-sound-button.playing {
    transform: scale(1.05);
    transition: transform 0.2s ease;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%) !important;
}

.story-content .inline-sound-button.playing:hover {
    transform: translateY(-5px) scale(1.1) !important;
    box-shadow: 0 8px 25px rgba(255,107,107,0.3) !important;
}

/* Pending Interaction - Glowing Button Effect (Purple matching read-along) */
.story-content .inline-sound-button.pending-interaction {
    animation: pulse-glow 1.5s ease-in-out infinite !important;
    border: 3px solid rgba(76, 175, 80, 1) !important; /* Purple matching read-along - using rgba for exact match */
    background: rgba(76, 175, 80, 0.15) !important; /* Light purple background matching read-along theme */
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6) !important; /* Purple glow */
    transform: scale(1.05) !important;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6); /* Purple glow */
        transform: scale(1.05);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.8); /* Purple glow - stronger */
        transform: scale(1.08);
    }
}

/* Resume Modal */
.resume-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.resume-modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10001;  /* Above overlay */
    position: relative;
}

.resume-modal-content h2 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.resume-modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.1em;
    line-height: 1.5;
}

/* Modal word click-to-speak */
.resume-modal-content .modal-word {
    display: inline;
    padding: 2px 1px;
    border-radius: 3px;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.resume-modal-content .modal-word:hover,
.resume-modal-content .modal-word.hover {
    background: rgba(76, 175, 80, 0.2);
}

.resume-modal-content .modal-word.clicked {
    background: rgba(76, 175, 80, 0.4) !important; /* Purple matching read-along */
    color: #333 !important;
    font-weight: bold !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
}

.resume-modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.resume-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.resume-btn-continue {
    background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
    color: white;
}

.resume-btn-continue .red-arrow {
    color: #ff4444; /* Red color for arrow */
    font-size: 0.9em;
    display: inline-block;
    margin-right: 4px;
}

.resume-btn-continue:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.resume-btn-cancel {
    background: #e0e0e0;
    color: #333;
}

.resume-btn-cancel:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Record Celebration (matching home page) */
.record-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 90%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #4CAF50;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
    padding: 25px;
    pointer-events: none;
}

.record-celebration.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.celebration-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.celebration-trophy {
    font-size: 4em;
    animation: trophyBounce 0.6s ease-out;
}

.celebration-title {
    font-family: 'Arial Black', 'Helvetica', sans-serif;
    font-size: 2.2em;
    font-weight: 900;
    color: #e74c3c;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    line-height: 1;
    letter-spacing: 1px;
}

.celebration-trophy-right {
    font-size: 4em;
    animation: trophyBounce 0.6s ease-out 0.2s;
}

.celebration-record-info {
    text-align: center;
    margin-bottom: 15px;
}

.celebration-count {
    font-family: 'Arial', sans-serif;
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.celebration-emoji {
    font-size: 2.5em;
    margin: 0 8px;
    animation: emojiCelebrate 1s ease-in-out;
}

.celebration-message {
    text-align: center;
    font-family: 'Arial', sans-serif;
    font-size: 0.95em;
    color: #555;
    line-height: 1.4;
    margin-bottom: 8px;
}

.celebration-website {
    font-weight: bold;
    color: #4CAF50;
}

.celebration-click-hint {
    text-align: center;
    font-size: 0.8em;
    color: #e74c3c;
    font-style: italic;
    font-weight: bold;
}

@keyframes trophyBounce {
    0% { transform: scale(0.5) rotate(-15deg); }
    50% { transform: scale(1.2) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes emojiCelebrate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-5deg); }
    75% { transform: scale(1.2) rotate(5deg); }
}

@media (max-width: 768px) {
    .record-celebration {
        width: 95%;
        padding: 20px;
    }
    
    .celebration-title {
        font-size: 1.8em;
    }
    
    .celebration-trophy, .celebration-trophy-right {
        font-size: 3em;
    }
    
    .celebration-count {
        font-size: 1.5em;
    }
    
    .celebration-emoji {
        font-size: 2em;
    }
}
