/* ===== Typing Practice Page - New Layout ===== */

.practice-wrapper {
    min-height: calc(100vh - 120px);
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* Header */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.practice-header h2 {
    font-size: 28px;
    margin: 0;
    color: #333;
}

.challenge-info {
    margin: 5px 0 0 0;
    color: #666;
    font-size: 14px;
}

.btn-back {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Main Split Container */
.practice-split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* LEFT SIDE: Text Display */
.text-display-side {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.text-display-header h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-display-box {
    flex: 1;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    margin-bottom: 15px;
    max-height: 500px;
}

.challenge-text {
    font-family: 'Fira Code', monospace;
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    transition: all 0.3s ease;
}

/* Character highlighting */
.char-correct {
    color: #4CAF50;
    font-weight: 600;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 0;
}

.char-wrong {
    color: #f44336;
    font-weight: 600;
    background: rgba(244, 67, 54, 0.2);
    padding: 2px 0;
    text-decoration: underline wavy #f44336;
}

.char-remaining {
    color: #999;
    opacity: 0.6;
}

/* Highlight typed part */
.challenge-text.highlight {
    color: #4CAF50;
}

.text-progress {
    text-align: center;
    font-size: 14px;
    color: #666;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
    font-weight: 600;
}

/* RIGHT SIDE: Input & Controls */
.input-control-side {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Stats Bar - Compact */
.stats-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
}

/* Sound Toggle Button */
.sound-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #FFD700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.sound-toggle-btn:hover {
    background: #FFC700;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.sound-toggle-btn.muted {
    background: #ccc;
    color: #666;
}

.sound-icon {
    font-size: 18px;
}

.sound-text {
    font-size: 12px;
}

/* Keyboard Guide */
.keyboard-guide-section {
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-align: center;
}

.guide-label {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.keyboard-preview {
    width: 100%;
    height: auto;
    border-radius: 6px;
    max-height: 120px;
}

/* Input Field */
.input-field-wrapper {
    flex: 1;
    display: flex;
}

.typing-input {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    resize: none;
    background: #f8f9fa;
    color: #333;
    transition: all 0.3s ease;
}

.typing-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e9ecef;
    color: #333;
}

.btn-secondary:hover {
    background: #dee2e6;
    transform: translateY(-2px);
}

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

.modal.hidden {
    display: none;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #333;
}

/* Result Grid */
.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.result-label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.result-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
}

/* Performance Message */
.comparison-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.comparison-section p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

.performance-message {
    font-weight: 600;
    margin-top: 10px !important;
}

/* Modal Footer */
.modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.modal-footer .btn {
    padding: 12px 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .practice-split-container {
        grid-template-columns: 1fr;
    }

    .text-display-box {
        max-height: 300px;
    }
}

@media (max-width: 600px) {
    .practice-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .practice-header h2 {
        font-size: 20px;
    }

    .stats-compact {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-value {
        font-size: 16px;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .modal-footer {
        grid-template-columns: 1fr;
    }
}

/* Animation for text scrolling */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-line-completed {
    animation: slideUp 0.3s ease-out;
    color: #4CAF50;
}

/* Tamil typing */
.tamil-text {
    font-family: 'Noto Sans Tamil', 'Latha', 'Nirmala UI', sans-serif;
    font-size: 1.35rem;
    line-height: 1.9;
}

.practice-tamil .practice-header h1 {
    font-size: 1.5rem;
}

/* Tamil layout: text top (2 lines), type bottom, stats + keyboard right */
.practice-tamil-layout {
    display: grid;
    grid-template-columns: minmax(0, 60%) minmax(0, 40%);
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1rem;
}

.tamil-main-column {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: min(70vh, 640px);
}

.tamil-sidebar {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    position: sticky;
    top: 0.75rem;
    align-self: start;
}

.viewport-hint {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

/* Exactly 2 lines visible; rest scrolls up via JS transform */
.challenge-viewport-lines {
    --tamil-line-height: 2.565rem;
    height: calc(var(--tamil-line-height) * 2);
    overflow: hidden;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    position: relative;
}

.challenge-text-scroll {
    transition: transform 0.25s ease;
    will-change: transform;
    padding: 0.65rem 1rem;
}

.challenge-viewport-lines .challenge-text {
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.challenge-viewport-lines .char-correct {
    color: #94a3b8;
    opacity: 0.55;
}

.challenge-viewport-lines .char-wrong {
    color: #dc2626;
    background: #fee2e2;
    border-radius: 2px;
}

.challenge-viewport-lines .char-remaining {
    color: #1e293b;
}

.challenge-viewport-lines .char-current {
    background: #fef08a;
    border-radius: 3px;
    box-shadow: 0 0 0 2px #eab308;
}

.tamil-typing-bottom {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.practice-tamil .tamil-typing-bottom .typing-input {
    min-height: 88px;
    max-height: 22vh;
    resize: vertical;
    font-size: 1.2rem;
    width: 100%;
}

/* Override purple 2-col grid from .stats-compact for Tamil sidebar */
.tamil-sidebar .stats-compact.stats-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.tamil-sidebar .stats-compact .stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    border: none;
    color: #fff;
}

.tamil-sidebar .stats-compact .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.92;
    color: #fff;
}

.tamil-sidebar .stats-compact .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Fira Code', monospace;
    line-height: 1.2;
}

.sound-toggle-compact {
    width: 100%;
    padding: 0.55rem;
    font-size: 0.85rem;
}

/* Keyboard in left column (60% width) */
.practice-tamil .tamil-main-column .keyboard-guide-section {
    flex-shrink: 0;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.practice-tamil .tamil-main-column .btn-view-keyboard {
    width: 100%;
    max-width: 320px;
    margin-bottom: 0.5rem;
}

.practice-tamil .tamil-main-column .tamil-keyboard-panel {
    width: 100%;
    overflow-x: auto;
    margin-top: 0.5rem;
}

.practice-tamil .tamil-main-column .tamil99-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.practice-tamil .tamil-main-column .tamil99-key {
    min-width: 44px;
    flex: 0 0 auto;
}

@media (max-width: 900px) {
    .practice-tamil-layout {
        grid-template-columns: 1fr;
    }

    .tamil-sidebar {
        position: relative;
        top: 0;
        order: -1;
    }

    .tamil-sidebar .stats-compact.stats-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .tamil-sidebar .stats-compact .stat-item {
        padding: 0.6rem;
    }

    .tamil-sidebar .stats-compact .stat-value {
        font-size: 1.2rem;
    }

    .tamil-main-column {
        min-height: auto;
    }
}

.tamil-mode-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.input-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #475569;
}

/* Tamil99 keyboard toggle panel */
.btn-view-keyboard {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view-keyboard:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.tamil-keyboard-panel {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.tamil-keyboard-panel.hidden {
    display: none;
}

.keyboard-panel-intro {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.keyboard-panel-note {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.keyboard-panel-note kbd,
.keyboard-examples-list kbd {
    background: #e2e8f0;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.keyboard-examples {
    background: #ede9fe;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
}

.keyboard-examples-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin: 0 0 0.5rem;
    color: #5b21b6;
}

.keyboard-examples-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.8;
}

.tamil99-row-shift .tamil99-key {
    min-width: 52px;
}

/* Tamil phonetic guide (legacy) */
.phonetic-guide {
    font-size: 0.9rem;
}

.phonetic-intro {
    color: #475569;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.phonetic-preview {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
}

.phonetic-preview-label {
    color: #166534;
    font-weight: 600;
}

.phonetic-preview-value {
    font-family: 'Fira Code', monospace;
    color: #15803d;
    font-weight: 700;
}

.phonetic-table-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #334155;
}

.phonetic-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.phonetic-example-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    background: white;
    border: 2px solid #c4b5fd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.phonetic-example-btn:hover {
    background: #ede9fe;
    border-color: #6366f1;
}

.phonetic-en {
    font-family: monospace;
    color: #6366f1;
    font-weight: 600;
}

.phonetic-arrow {
    color: #94a3b8;
}

.phonetic-ta {
    font-family: 'Noto Sans Tamil', sans-serif;
    font-size: 1rem;
}

.phonetic-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.keyboard-guide-section {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.guide-label {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: #334155;
}

.guide-sublabel {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 10px;
}

.tamil99-keyboard {
    overflow-x: auto;
}

.tamil99-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
    justify-content: center;
}

.tamil99-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
    padding: 8px 6px;
    background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s ease;
    box-shadow: 0 2px 0 #94a3b8;
}

.tamil99-key:hover {
    background: #ede9fe;
    border-color: #6366f1;
    transform: translateY(-1px);
}

.tamil99-key:active {
    transform: translateY(1px);
    box-shadow: none;
}

.tamil-input-active {
    border-color: #6366f1 !important;
    background: #faf5ff !important;
}

.tamil99-en {
    color: #64748b;
    font-weight: 600;
    font-family: monospace;
}

.tamil99-ta {
    font-family: 'Noto Sans Tamil', sans-serif;
    font-size: 1.1rem;
    color: #1e293b;
}

.tamil99-hint {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 8px;
    text-align: center;
}

/* SEO content on practice page */
.practice-seo-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-top: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    max-width: 100%;
}

.practice-seo-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.practice-seo-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.practice-seo-content p,
.practice-seo-content li {
    color: #64748b;
    line-height: 1.7;
}

.seo-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 1.5rem 0;
}

.seo-content-grid ul {
    padding-left: 1.25rem;
}

.seo-content-grid li {
    margin-bottom: 0.5rem;
}

.related-tests {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 768px) {
    .seo-content-grid {
        grid-template-columns: 1fr;
    }
}

.lang-mode-badge,
.tamil-mode-badge {
    margin: 0.5rem 0 0;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.88rem;
    background: #eef2ff;
    color: #4338ca;
}

.cjk-badge {
    background: #ecfdf5;
    color: #047857;
}

.cjk-text {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 1.25rem;
    line-height: 1.75;
}

.practice-cjk .challenge-text {
    font-size: 1.2rem;
    line-height: 1.8;
}

.practice-rtl .text-display-box,
.practice-rtl .typing-input {
    direction: rtl;
    text-align: right;
}

.script-thai,
.script-thai.typing-input {
    font-family: 'Noto Sans Thai', 'Leelawadee UI', sans-serif;
    font-size: 1.15rem;
    line-height: 1.75;
}

.script-hindi,
.script-hindi.typing-input {
    font-family: 'Noto Sans Devanagari', 'Mangal', sans-serif;
    font-size: 1.15rem;
    line-height: 1.75;
}

.script-cyrillic,
.script-cyrillic.typing-input {
    font-family: 'Noto Sans', system-ui, sans-serif;
    font-size: 1.1rem;
    line-height: 1.65;
}

.script-arabic,
.script-arabic.typing-input {
    font-family: 'Noto Naskh Arabic', 'Segoe UI', sans-serif;
    font-size: 1.2rem;
    line-height: 1.85;
}

.script-hebrew,
.script-hebrew.typing-input {
    font-family: 'Noto Sans Hebrew', 'Segoe UI', sans-serif;
    font-size: 1.15rem;
    line-height: 1.75;
}

.script-hiragana,
.script-hiragana.typing-input {
    font-family: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
    font-size: 1.2rem;
    line-height: 1.8;
}

/* Latin extended: click-to-insert (DE/FR/ES on US keyboard) */
.latin-palette-wrap {
    margin-top: 0.75rem;
}

.latin-palette-hint {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.4;
}

.latin-char-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.char-palette-btn {
    min-width: 2.25rem;
    padding: 0.35rem 0.5rem;
    font-size: 1.1rem;
    line-height: 1.2;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.char-palette-btn:hover {
    background: #eef2ff;
    border-color: #818cf8;
}

.char-palette-btn:active {
    transform: scale(0.97);
}
