/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */

/* Main container */
.read-along-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-size: 18px;
    line-height: 1.6;
    position: relative;
    font-family: 'Arial', sans-serif;
}

.read-along-header {
    text-align: center;
    margin-bottom: 20px;
}

.read-along-title {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #2c3e50;
}

.read-along-meta {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.read-along-meta span {
    margin: 0 15px;
    background-color: #f8f9fa;
    padding: 5px 10px;
    border-radius: 15px;
}

/* Story content */
.read-along-story {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    position: relative;
}

.read-along-paragraph {
    margin-bottom: 20px;
    line-height: 1.8;
}

/* Word styling */
.read-along-word {
    display: inline-block;
    padding: 3px 5px;
    margin: 3px 1px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.read-along-word:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

.read-along-word.current {
    background-color: #ffeb3b; /* Yellow for current word */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: scale(1.1);
    z-index: 1;
}

.read-along-word.potential-match {
    background-color: #fff9c4; /* Light yellow for potential match */
}

.read-along-word.correct {
    background-color: #c8e6c9; /* Green for correct pronunciation */
    font-weight: 500;
}

.read-along-word.incorrect {
    background-color: #ffcdd2; /* Red for incorrect pronunciation */
    animation: shake 0.5s; /* Shake effect when incorrect */
}

.read-along-word.attempted {
    border-bottom: 2px dotted #f44336; /* Indicator for attempted words */
    position: relative;
}

/* Adding attempt counter indicators like Google Read Along */
.read-along-word.attempted:after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background-color: #ff9800;
    border-radius: 50%;
}

.read-along-word.attempted.attempt-2:after {
    box-shadow: -8px 0 0 #ff9800;
}

.read-along-word.attempted.attempt-3:after {
    box-shadow: -8px 0 0 #ff9800, 8px 0 0 #ff9800;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.read-along-word.help-given {
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.8); /* Blue glow for words the system helped with */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 5px rgba(33, 150, 243, 0.8);
    }
    50% {
        box-shadow: 0 0 15px rgba(33, 150, 243, 0.8);
    }
    100% {
        box-shadow: 0 0 5px rgba(33, 150, 243, 0.8);
    }
}

/* Controls */
.read-along-controls {
    margin-bottom: 25px;
    text-align: center;
}

.read-along-btn {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 50px;
    cursor: pointer;
    margin: 0 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.read-along-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.read-along-btn.stop {
    background-color: #f44336;
}

.read-along-btn.stop:hover {
    background-color: #d32f2f;
}

.read-along-btn.read-along-replay {
    background-color: #2196f3;
}

.read-along-btn.read-along-replay:hover {
    background-color: #1976d2;
}

.read-along-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Progress bar */
.read-along-progress-container {
    width: 100%;
    height: 20px;
    background-color: #f1f1f1;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.read-along-progress-bar {
    height: 100%;
    background: linear-gradient(to right, #4caf50, #8bc34a);
    text-align: center;
    line-height: 20px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    transition: width 0.5s ease;
}

/* Score display */
.read-along-score {
    text-align: center;
    font-size: 16px;
    margin-bottom: 20px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
}

.read-along-score span {
    font-weight: bold;
    color: #2c3e50;
}

/* Messages */
.read-along-message {
    background-color: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.read-along-error {
    background-color: #ffebee;
    border-left: 4px solid #f44336;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.read-along-info {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.read-along-completion {
    background-color: #f3e5f5;
    border-left: 4px solid #9c27b0;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    animation: fadeInUp 0.6s ease-out;
    font-size: 18px;
}

/* Browser not supported message */
.read-along-not-supported {
    background-color: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Instructions */
.read-along-instructions {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.read-along-instructions h3 {
    color: #2c3e50;
    font-size: 20px;
    margin-bottom: 15px;
}

.read-along-instructions ol {
    padding-left: 20px;
}

.read-along-instructions li {
    margin-bottom: 8px;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Language-specific styling */
.read-along-container[data-language="hindi"] .read-along-word {
    font-family: 'Noto Sans', 'Arial Unicode MS', sans-serif;
    font-size: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
    .read-along-container {
        padding: 15px;
        font-size: 16px;
    }
    
    .read-along-title {
        font-size: 22px;
    }
    
    .read-along-story {
        padding: 15px;
        max-height: 300px;
    }
    
    .read-along-btn {
        padding: 10px 20px;
        font-size: 14px;
        margin: 0 5px 10px 5px;
    }
    
    .read-along-score {
        flex-direction: column;
        padding: 10px;
    }
    
    .read-along-score > div {
        margin: 5px 0;
    }
}

/* Touch-friendly adjustments for mobile */
@media (hover: none) {
    .read-along-word {
        padding: 5px 7px;
        margin: 5px 2px;
    }
}
