/* ============================================
   Gramatica Exercise - Word Bubbles & Quiz
   ============================================ */

/* Reduce gap between navbar and exercise card */
.quiz-wrapper {
    margin-top: -0.75rem;
}

/* Question area */
.gram-question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

/* Phrase display - Speech bubble style (matching correct answer colors) */
.gram-phrase-box {
    background: linear-gradient(135deg, #28a745, #20c997);
    border: 2px solid #28a745;
    border-radius: 1rem 1rem 1rem 0.25rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: white;
    box-shadow: var(--shadow-sm);
    position: relative;
}

/* Speech bubble tail */
.gram-phrase-box::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 1.25rem;
    width: 0;
    height: 0;
    border-width: 12px 12px 0 0;
    border-style: solid;
    border-color: #20c997 transparent transparent transparent;
}

/* Speech bubble tail border */
.gram-phrase-box::before {
    content: '';
    position: absolute;
    bottom: -16px;
    left: calc(1.25rem - 2px);
    width: 0;
    height: 0;
    border-width: 14px 14px 0 0;
    border-style: solid;
    border-color: #28a745 transparent transparent transparent;
}

/* Word bubbles container */
.gram-bubbles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

/* Individual word bubble - WhatsApp style */
.gram-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 1.25rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    position: relative;
    min-width: 2.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gram-bubble::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--border-color);
    transition: border-top-color 0.2s ease;
}

.gram-bubble:hover:not(.disabled) {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--brand-primary);
    background: var(--bg-card);
}

.gram-bubble:hover:not(.disabled)::before {
    border-top-color: var(--brand-primary);
}

/* Correct answer */
.gram-bubble.correct {
    background: linear-gradient(135deg, #28a745, #20c997);
    border-color: #28a745;
    color: white;
    animation: bubbleCorrect 0.4s ease;
}

.gram-bubble.correct::before {
    border-top-color: #28a745;
}

/* Wrong answer */
.gram-bubble.wrong {
    background: linear-gradient(135deg, #dc3545, #e74c5f);
    border-color: #dc3545;
    color: white;
    animation: bubbleWrong 0.4s ease;
}

.gram-bubble.wrong::before {
    border-top-color: #dc3545;
}

/* Show correct answer when wrong was selected */
.gram-bubble.reveal-correct {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
    font-weight: 700;
}

.gram-bubble.reveal-correct::before {
    border-top-color: #28a745;
}

/* Disabled state */
.gram-bubble.disabled {
    cursor: default;
    opacity: 0.65;
}

.gram-bubble.correct.disabled,
.gram-bubble.wrong.disabled,
.gram-bubble.reveal-correct.disabled {
    opacity: 1;
}

/* Feedback area */
.gram-feedback {
    border-radius: var(--radius-lg);
    padding: 0.6rem 0.75rem;
    margin: 0.5rem 0;
    display: none;
    animation: fadeIn 0.3s ease;
}

.gram-feedback.show {
    display: block;
}

.gram-feedback.correct-feedback {
    background: rgba(40, 167, 69, 0.1);
    border: 2px solid rgba(40, 167, 69, 0.3);
}

.gram-feedback.wrong-feedback {
    background: rgba(220, 53, 69, 0.1);
    border: 2px solid rgba(220, 53, 69, 0.3);
}

.gram-feedback-icon {
    font-size: 1.25rem;
    margin-right: 0.5rem;
}

.gram-feedback-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.gram-feedback.correct-feedback .gram-feedback-title {
    color: #28a745;
}

.gram-feedback.wrong-feedback .gram-feedback-title {
    color: #dc3545;
}

.gram-feedback-explanation {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.25rem;
}

/* Next button */
.gram-next-btn {
    display: none;
    margin: 0.5rem auto 0;
    padding: 0.4rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 2rem;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.gram-next-btn.show {
    display: inline-block;
    animation: fadeIn 0.3s ease;
}

.gram-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Results screen */
.gram-results {
    display: none;
    text-align: center;
    padding: 2rem 0;
}

.gram-results.show {
    display: block;
    animation: fadeIn 0.4s ease;
}

.gram-results-score {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.gram-results-score.great {
    color: #28a745;
}

.gram-results-score.good {
    color: #ffc107;
}

.gram-results-score.poor {
    color: #dc3545;
}

.gram-results-label {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.gram-results-bar {
    height: 1.5rem;
    border-radius: 0.75rem;
    background: var(--bg-input);
    overflow: hidden;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.gram-results-bar-inner {
    height: 100%;
    width: 0%;
    border-radius: 0.75rem;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-success));
}

/* Results detail list */
.gram-results-list {
    text-align: left;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.gram-result-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.gram-result-item .result-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.gram-result-item .result-icon.correct {
    color: #28a745;
}

.gram-result-item .result-icon.wrong {
    color: #dc3545;
}

.gram-result-item .result-details {
    flex: 1;
}

.gram-result-item .result-question {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.gram-result-item .result-answer {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.gram-result-item .result-answer strong {
    color: #28a745;
}

.gram-result-item .result-answer .wrong-word {
    color: #dc3545;
    text-decoration: line-through;
}

/* Exercise area */
.gram-exercise-area {
    display: block;
}

.gram-exercise-area .card-body {
    padding: 0.75rem;
}

.gram-exercise-area.hidden {
    display: none;
}

/* Animations */
@keyframes bubbleCorrect {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes bubbleWrong {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-8px); }
    30% { transform: translateX(8px); }
    45% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
}

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