/* =====================================================
   Chinese Learning Page Styles
   Uses global CSS variables from styles.css
   ===================================================== */

/* ---- Hero Section ---- */
.cl-hero {
    padding: 120px 0 60px;
    text-align: center;
}

.cl-hero-content {
    max-width: 700px;
    margin: 0 auto;
}

.cl-hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    padding: 6px 20px;
    border-radius: 100px;
    margin-bottom: 20px;
}

.cl-hero-title {
    font-size: 52px;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 20px;
}

.cl-hero-desc {
    font-size: 18px;
    color: var(--text-light);
    line-height: 1.7;
    margin-bottom: 40px;
}

/* Stats Bar */
.cl-stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 20px 32px;
    max-width: 560px;
    margin: 0 auto;
}

.cl-stat-item {
    flex: 1;
    text-align: center;
}

.cl-stat-num {
    display: block;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cl-stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

.cl-stat-divider {
    width: 1px;
    height: 40px;
    background: #e2e8f0;
    margin: 0 8px;
}

/* ---- Controls Section ---- */
.cl-controls-section {
    padding: 12px 0 16px;
}

.cl-mode-toggle {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding: 0 16px 4px;
    margin-bottom: 12px;
}

.cl-mode-toggle::-webkit-scrollbar {
    display: none;
}

.cl-mode-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    background: white;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.cl-mode-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cl-mode-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.cl-mode-icon {
    font-size: 14px;
}

/* Filter Bar */
.cl-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding: 0 16px;
}

.cl-filter-bar::-webkit-scrollbar {
    display: none;
}

.cl-hsk-tabs {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.cl-hsk-tab {
    padding: 6px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    background: white;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cl-hsk-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cl-hsk-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.cl-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cl-search-input {
    padding: 9px 40px 9px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    font-size: 14px;
    color: var(--text-dark);
    background: white;
    width: 160px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cl-search-input:focus {
    border-color: var(--primary-color);
}

.cl-search-icon {
    position: absolute;
    right: 14px;
    font-size: 14px;
    pointer-events: none;
}

/* ---- Common Area ---- */
.cl-area {
    padding: 48px 0 80px;
    min-height: 60vh;
}

.cl-section-header {
    text-align: center;
    margin-bottom: 40px;
}

.cl-section-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.cl-section-desc {
    font-size: 16px;
    color: var(--text-light);
}

/* =====================================================
   FLASHCARD MODE
   ===================================================== */
.cl-flashcard-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 40px;
    align-items: start;
    max-width: 900px;
    margin: 0 auto;
}

/* 3D Flip Card */
.cl-flashcard-wrapper {
    perspective: 1200px;
}

.cl-flashcard {
    width: 100%;
    height: 380px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border-radius: 20px;
}

.cl-flashcard.is-flipped {
    transform: rotateY(180deg);
}

.cl-card-front,
.cl-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    box-shadow: var(--shadow-xl);
}

.cl-card-front {
    background: white;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.cl-card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: rotateY(180deg);
    color: white;
}

.cl-hsk-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    letter-spacing: 0.5px;
}

.cl-char-display {
    font-size: 120px;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

.cl-tap-hint {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 16px;
}

/* Card Back */
.cl-pinyin {
    font-size: 32px;
    font-weight: 700;
    color: rgba(255,255,255,0.95);
    margin-bottom: 12px;
}

.cl-meaning {
    font-size: 22px;
    font-weight: 600;
    color: white;
    text-align: center;
    margin-bottom: 10px;
}

.cl-example {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    text-align: center;
    font-style: italic;
    margin-bottom: 16px;
}

.cl-stroke-container {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Sidebar */
.cl-flashcard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 200px;
}

.cl-card-counter {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
}

.cl-card-counter span:first-child {
    color: var(--primary-color);
    font-size: 28px;
}

.cl-progress-bar-wrap {
    background: #e2e8f0;
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
}

.cl-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 100px;
    transition: width 0.4s ease;
}

.cl-fc-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cl-fc-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
}

.cl-know-btns {
    display: flex;
    gap: 10px;
}

.cl-know-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cl-know-yes {
    background: #d1fae5;
    color: #065f46;
}

.cl-know-yes:hover {
    background: #a7f3d0;
    transform: translateY(-2px);
}

.cl-know-no {
    background: #fee2e2;
    color: #991b1b;
}

.cl-know-no:hover {
    background: #fecaca;
    transform: translateY(-2px);
}

.cl-shuffle-btn {
    background: none;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 10px;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.cl-shuffle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* =====================================================
   RADICALS MODE
   ===================================================== */
.cl-radical-group {
    margin-bottom: 40px;
}

.cl-radical-group-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
    padding-left: 12px;
    border-left: 4px solid var(--primary-color);
}

.cl-radical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}

.cl-radical-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px 16px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.cl-radical-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: rgba(102, 126, 234, 0.3);
}

.cl-radical-char {
    font-size: 52px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    margin-bottom: 8px;
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

.cl-radical-pinyin {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.cl-radical-meaning {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.cl-radical-examples {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cl-radical-example-char {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-dark);
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

/* Radical Modal */
.cl-radical-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cl-radical-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    position: relative;
    text-align: center;
}

.cl-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
}

.cl-modal-char {
    font-size: 100px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 12px;
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

.cl-modal-pinyin {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.cl-modal-meaning {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.cl-modal-stroke-wrap {
    width: 160px;
    height: 160px;
    margin: 0 auto 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.cl-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* =====================================================
   WRITING MODE
   ===================================================== */
.cl-writing-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 40px;
    max-width: 900px;
    margin: 0 auto;
}

.cl-writing-char-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.cl-writing-char-selector label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.cl-writing-char-selector select {
    padding: 8px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 16px;
    color: var(--text-dark);
    font-family: 'Noto Sans SC', 'SimSun', serif;
    background: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.cl-writing-char-selector select:focus {
    border-color: var(--primary-color);
}

.cl-writing-canvas-wrap {
    text-align: center;
    margin-bottom: 24px;
}

.cl-writing-canvas {
    width: 280px;
    height: 280px;
    border: 3px solid #e2e8f0;
    border-radius: 16px;
    margin: 0 auto 16px;
    background: white;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
}

/* Grid lines for writing practice */
.cl-writing-canvas::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(#e2e8f0 1px, transparent 1px),
        linear-gradient(90deg, #e2e8f0 1px, transparent 1px),
        linear-gradient(rgba(226,232,240,0.5) 1px, transparent 1px),
        linear-gradient(90deg, rgba(226,232,240,0.5) 1px, transparent 1px);
    background-size: 140px 140px, 140px 140px, 46.67px 46.67px, 46.67px 46.67px;
    pointer-events: none;
    z-index: 1;
}

.cl-writing-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.cl-writing-char-label {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

.cl-writing-pinyin {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.cl-writing-meaning {
    font-size: 14px;
    color: var(--text-light);
}


.cl-writing-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cl-writing-feedback {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    min-height: 28px;
    border-radius: var(--border-radius);
    padding: 8px 0;
    transition: all 0.3s;
}

.cl-writing-feedback.success {
    color: #065f46;
    background: #d1fae5;
    padding: 8px 20px;
}

.cl-writing-feedback.error {
    color: #991b1b;
    background: #fee2e2;
    padding: 8px 20px;
}

/* Writing char list sidebar */
.cl-writing-char-list {
    position: sticky;
    top: 200px;
}

.cl-writing-char-list h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
}

#writing-char-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.cl-writing-grid-char {
    aspect-ratio: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    font-family: 'Noto Sans SC', 'SimSun', serif;
    color: var(--text-dark);
}

.cl-writing-grid-char:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

.cl-writing-grid-char.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: transparent;
    color: white;
}

/* =====================================================
   QUIZ MODE
   ===================================================== */
.cl-quiz-layout {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.cl-quiz-score-bar {
    display: flex;
    gap: 32px;
    background: white;
    border-radius: var(--border-radius);
    padding: 16px 40px;
    box-shadow: var(--shadow-md);
    width: 100%;
    justify-content: center;
}

.cl-quiz-score-item {
    text-align: center;
}

.cl-quiz-score-num {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
}

.cl-quiz-score-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.cl-quiz-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px 36px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    text-align: center;
    position: relative;
}

.cl-quiz-hsk-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
}

.cl-quiz-char {
    font-size: 100px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 8px;
    font-family: 'Noto Sans SC', 'SimSun', serif;
}

.cl-quiz-pinyin {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
}

.cl-quiz-instruction {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 12px;
}

.cl-quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.cl-quiz-option {
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    background: white;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
}

.cl-quiz-option:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.cl-quiz-option.correct {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.cl-quiz-option.wrong {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.cl-quiz-option:disabled {
    cursor: default;
}

.cl-quiz-result {
    font-size: 18px;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: var(--border-radius);
    width: 100%;
    text-align: center;
}

.cl-quiz-result.correct {
    background: #d1fae5;
    color: #065f46;
}

.cl-quiz-result.wrong {
    background: #fee2e2;
    color: #991b1b;
}

.cl-quiz-next-btn {
    padding: 14px 40px;
    font-size: 16px;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .cl-hero-title {
        font-size: 36px;
    }

    .cl-hero-desc {
        font-size: 15px;
    }

    .cl-stats-bar {
        padding: 16px 20px;
        gap: 0;
    }

    .cl-stat-num {
        font-size: 22px;
    }

    .cl-flashcard-layout {
        grid-template-columns: 1fr;
    }

    .cl-flashcard {
        height: 300px;
    }

    .cl-char-display {
        font-size: 90px;
    }

    .cl-quiz-char {
        font-size: 80px;
    }

    .cl-flashcard-sidebar {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .cl-fc-actions {
        flex-direction: row;
    }

    .cl-writing-layout {
        grid-template-columns: 1fr;
    }

    .cl-writing-char-list {
        position: static;
    }

    .cl-modal-char {
        font-size: 70px;
    }

    .cl-quiz-options {
        grid-template-columns: 1fr;
    }

    .cl-radical-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .cl-controls-section {
        top: 60px;
    }
}

@media (max-width: 480px) {
    .cl-mode-toggle {
        gap: 6px;
    }

    .cl-mode-btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .cl-hsk-tabs {
        gap: 4px;
    }

    .cl-hsk-tab {
        padding: 6px 12px;
        font-size: 12px;
    }

    .cl-search-input {
        width: 180px;
    }
}
