/* Grammar Article Common Styles */
.article-header {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    padding-bottom: 16px;
}

.article-header h2 {
    margin: 0 0 12px;
    font-size: 1.6rem;
    line-height: 1.4;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    color: var(--muted, #888);
    font-size: 0.9rem;
}

.article-category {
    display: inline-block;
    padding: 3px 10px;
    background: var(--accent, #007aff);
    color: #fff;
    border-radius: 4px;
    font-size: 0.8rem;
}

.lang-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.lang-tab {
    padding: 6px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-tab.active {
    background: var(--accent);
    color: #fff;
}

.lang-tab:not(.active) {
    background: var(--chip);
    color: var(--muted);
}

.lang-tab:not(.active):hover {
    background: var(--border);
    text-decoration: none;
}

.article-content {
    line-height: 1.8;
}

.article-content h3 {
    margin-top: 32px;
    margin-bottom: 16px;
    font-size: 1.3rem;
    border-left: 4px solid var(--accent, #007aff);
    padding-left: 12px;
}

.article-content p {
    margin-bottom: 16px;
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 1rem;
}

.grammar-table th,
.grammar-table td {
    border: 1px solid var(--border, #ddd);
    padding: 12px;
    text-align: left;
}

.grammar-table th {
    background: #34495e;
    color: #fff;
}

.grammar-table tr:nth-child(even) {
    background: var(--chip, #f5f5f5);
}

.example-box {
    background: var(--card, #fff);
    border-left: 4px solid var(--accent, #007aff);
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}

.example-sentence {
    margin-bottom: 12px;
}

.example-sentence:last-child {
    margin-bottom: 0;
}

.jp-text {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.romaji {
    display: block;
    font-size: 0.9rem;
    color: var(--accent, #007aff);
    margin-bottom: 4px;
}

.en-text {
    display: block;
    font-size: 0.95rem;
    color: var(--muted, #666);
}

.tip-box {
    background: var(--chip, #e8f4fd);
    border-left: 4px solid var(--accent, #007aff);
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 0 8px 8px 0;
}

.tip-box>strong:first-child {
    display: block;
    margin-bottom: 8px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--accent, #007aff);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.related-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border, #e0e0e0);
}

.related-section h4 {
    margin-bottom: 16px;
}

.related-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.related-list a {
    color: var(--accent, #007aff);
    text-decoration: none;
}

.related-list a:hover {
    text-decoration: underline;
}

/* Grammar Formula Visualization */
.grammar-formula {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border-radius: 12px;
    font-family: sans-serif;
    justify-content: center;
    margin: 20px 0;

    /* Default (Dark Mode) */
    background: var(--chip);
    border: 1px solid var(--border);
}

.g-block {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Noun: Blue */
.g-noun {
    background: rgba(33, 150, 243, 0.15);
    color: #90caf9;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Verb: Orange */
.g-verb {
    background: rgba(255, 152, 0, 0.15);
    color: #ffcc80;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

/* Particle: White/Gray with Red Accent */
.g-particle {
    background: var(--card);
    color: #ef5350;
    border: 1px solid #ef5350;
}

.g-plus {
    color: var(--muted);
    font-weight: bold;
}

/* Light Mode Overrides */
:root[data-theme="light"] .grammar-formula {
    background: #f8f9fa;
    border-color: #e0e0e0;
}

:root[data-theme="light"] .g-noun {
    background: #e3f2fd;
    color: #0d47a1;
    border-color: #bbdefb;
}

:root[data-theme="light"] .g-verb {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffe0b2;
}

:root[data-theme="light"] .g-particle {
    background: #ffffff;
    color: #ef5350;
    border-color: #ffcdd2;
}

:root[data-theme="light"] .g-plus {
    color: #999;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .grammar-formula {
        gap: 4px;
        padding: 15px;
    }

    .g-block {
        font-size: 0.95rem;
        padding: 6px 10px;
    }
}

/* ===============================
   Interactive Example Cards
   (Bunpro/Kanshudo Hybrid Style)
   =============================== */

/* Khmer Text Optimization */
.khmer-text {
    line-height: 1.8;
    font-family: 'Noto Sans Khmer', 'Suwannaphum', serif;
}

/* Example Card Container */
.example-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.example-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Action Buttons (Audio, Flashcard) */
.action-buttons {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 1;
    transition: opacity 0.2s;
}

@media (min-width: 768px) {
    .action-buttons {
        opacity: 0;
    }

    .example-card:hover .action-buttons {
        opacity: 1;
    }
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--chip);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--accent);
    color: #fff;
}

.action-btn.playing {
    background: var(--accent);
    color: #fff;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Japanese Sentence with Highlighting */
.example-jp {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 8px;
    padding-right: 80px;
    /* Space for action buttons */
}

.example-jp .highlight-person {
    border-bottom: 2px solid #6366f1;
    padding-bottom: 2px;
}

.example-jp .highlight-particle {
    color: #ef4444;
    font-weight: 700;
}

.example-jp .highlight-verb {
    color: #f59e0b;
    font-weight: 700;
}

/* Blur Hint Effect (Bunpro-style) */
.blur-hint {
    filter: blur(5px);
    transition: filter 0.3s ease;
    cursor: pointer;
    user-select: none;
    display: inline-block;
}

.blur-hint:hover,
.blur-hint.revealed {
    filter: blur(0);
}

.blur-hint::after {
    content: " 👆";
    font-size: 0.8em;
    opacity: 0.5;
}

.blur-hint.revealed::after {
    display: none;
}

/* Reading (Furigana) */
.example-reading {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 12px;
}

/* Translation Grid */
.translation-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

@media (min-width: 600px) {
    .translation-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.translation-item {
    padding: 0;
}

.translation-label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.translation-text {
    font-size: 1rem;
    line-height: 1.6;
}

.translation-text.khmer-text {
    font-size: 1.1rem;
}

/* ===============================
   Quiz Section
   =============================== */

.quiz-section {
    margin-top: 40px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    text-align: center;
}

.article-content .quiz-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
    border-left: none;
    padding-left: 0;
    margin-top: 0;
}

.quiz-description {
    color: var(--muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.quiz-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.quiz-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.quiz-start-btn:active {
    transform: translateY(0);
}

/* Quiz Modal */
.quiz-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.quiz-modal-overlay.is-visible {
    display: flex;
}

.quiz-modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.quiz-question-number {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

.furigana-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--chip);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.furigana-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.furigana-toggle-icon {
    font-family: 'Noto Sans JP', sans-serif;
}

.quiz-question {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    line-height: 1.4;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-option {
    padding: 14px 18px;
    background: var(--chip);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-option:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.quiz-option.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.quiz-option.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.quiz-result {
    text-align: center;
    padding: 20px;
}

.quiz-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 8px;
}

.quiz-feedback {
    color: var(--muted);
    margin-bottom: 20px;
}

.quiz-close-btn {
    padding: 12px 24px;
    background: var(--chip);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-close-btn:hover {
    background: var(--border);
}

/* Quiz Review Section */
.quiz-review {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
}

.review-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.review-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--chip);
    border-radius: 10px;
    text-align: left;
}

.review-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 50%;
}

.review-content {
    flex: 1;
    min-width: 0;
}

.review-answer {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
}

.review-answer strong {
    color: var(--accent);
}

.review-furigana {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.review-furigana strong {
    color: var(--accent);
}

.review-translation {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* Quiz Actions (Retry + Close) */
.quiz-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.quiz-retry-btn {
    padding: 12px 24px;
    background: var(--accent);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-retry-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}