/**
 * study.css — Study Mode Styles
 * Campaign-style chapter map + study player
 */

/* ── Variables (reuse exam.css tokens where possible) ──────────────────────── */
.ep-study-wrapper {
    font-family: var(--ep-font, 'Inter', system-ui, sans-serif);
    color: var(--ep-slate-800, #1e293b);
    max-width: 80rem;
    margin: 0 auto;
    padding: 2rem 1rem;
    -webkit-font-smoothing: antialiased;
    background: var(--ep-slate-50, #f8fafc);
    min-height: 100vh;
    box-sizing: border-box;
}

.ep-study-wrapper * {
    box-sizing: border-box;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.ep-hidden {
    display: none !important;
}

/* ── Loading spinner ───────────────────────────────────────────────────────── */
#ep-study-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--ep-slate-400, #94a3b8);
    font-size: 1rem;
    gap: 0.75rem;
}

#ep-study-loading::before {
    content: '';
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid var(--ep-slate-200, #e2e8f0);
    border-top-color: var(--ep-purple, #745fa8);
    border-radius: 50%;
    animation: epStudySpin 0.7s linear infinite;
}

@keyframes epStudySpin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Page title ────────────────────────────────────────────────────────────── */
.ep-study-page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ep-slate-900, #0f172a);
    margin: 0 0 0.5rem;
}

.ep-study-page-subtitle {
    font-size: 1rem;
    color: var(--ep-slate-500, #64748b);
    margin: 0 0 2.5rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.ep-study-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.ep-study-btn--primary {
    background: var(--ep-purple, #745fa8);
    color: #fff;
    box-shadow: 0 4px 12px rgba(116, 95, 168, 0.25);
}

.ep-study-btn--primary:hover {
    background: #6451a0;
    box-shadow: 0 6px 18px rgba(116, 95, 168, 0.35);
    transform: translateY(-1px);
}

.ep-study-btn--outline {
    background: #fff;
    color: var(--ep-slate-600, #475569);
    border: 1.5px solid var(--ep-slate-200, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ep-study-btn--outline:hover {
    border-color: var(--ep-slate-300, #cbd5e1);
    background: var(--ep-slate-50, #f8fafc);
}

.ep-study-btn--ghost {
    background: transparent;
    color: var(--ep-slate-400, #94a3b8);
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
}

.ep-study-btn--ghost:hover {
    color: var(--ep-red-500, #ef4444);
}

/* ── Subject grouping ──────────────────────────────────────────────────────── */
.ep-study-subject {
    margin-bottom: 2.5rem;
}

.ep-study-subject__title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ep-slate-400, #94a3b8);
    margin: 0 0 1.25rem;
}

/* ── Chapter card grid ─────────────────────────────────────────────────────── */
.ep-study-chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

@media (max-width: 540px) {
    .ep-study-chapter-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Chapter card ──────────────────────────────────────────────────────────── */
.ep-study-chapter-card {
    background: #fff;
    border: 1.5px solid var(--ep-slate-200, #e2e8f0);
    border-radius: 1.25rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.ep-study-chapter-card:hover {
    box-shadow: 0 6px 20px rgba(116, 95, 168, 0.12);
    border-color: rgba(116, 95, 168, 0.3);
    transform: translateY(-2px);
}

.ep-study-chapter-card.is-complete {
    border-color: var(--ep-green, #9cca3b);
    background: rgba(156, 202, 59, 0.03);
}

.ep-study-chapter-card.is-started {
    border-color: rgba(116, 95, 168, 0.35);
}

/* ── Progress ring ─────────────────────────────────────────────────────────── */
.ep-study-ring-wrap {
    position: relative;
    width: 3.5rem;
    height: 3.5rem;
    flex-shrink: 0;
    align-self: flex-start;
}

.ep-study-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ep-study-ring__bg {
    fill: none;
    stroke: var(--ep-slate-100, #f1f5f9);
    stroke-width: 3;
}

.ep-study-ring__fill {
    fill: none;
    stroke: var(--ep-purple, #745fa8);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.is-complete .ep-study-ring__fill {
    stroke: var(--ep-green, #9cca3b);
}

.ep-study-ring__icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    line-height: 1;
}

/* ── Card body ─────────────────────────────────────────────────────────────── */
.ep-study-chapter-card__body {
    flex: 1;
}

.ep-study-chapter-card__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ep-slate-900, #0f172a);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.ep-study-chapter-card__meta {
    font-size: 0.8125rem;
    color: var(--ep-slate-500, #64748b);
    margin: 0 0 0.625rem;
}

.ep-study-chapter-card__bar {
    height: 5px;
    background: var(--ep-slate-100, #f1f5f9);
    border-radius: 9999px;
    overflow: hidden;
}

.ep-study-chapter-card__bar-fill {
    height: 100%;
    background: var(--ep-purple, #745fa8);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

.is-complete .ep-study-chapter-card__bar-fill {
    background: var(--ep-green, #9cca3b);
}

/* ── Study player header ───────────────────────────────────────────────────── */
.ep-study-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.ep-study-back-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ep-slate-500, #64748b);
    cursor: pointer;
    padding: 0.375rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.ep-study-back-btn:hover {
    color: var(--ep-purple, #745fa8);
}

.ep-study-progress-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.ep-study-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--ep-slate-100, #f1f5f9);
    border-radius: 9999px;
    overflow: hidden;
}

.ep-study-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ep-purple, #745fa8), #9b8fd4);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

.ep-study-progress-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ep-slate-500, #64748b);
    white-space: nowrap;
}

.ep-study-chapter-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ep-purple, #745fa8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 14rem;
}

/* ── Question box ──────────────────────────────────────────────────────────── */
.ep-study-question-box {
    background: #fff;
    border: 1.5px solid var(--ep-slate-200, #e2e8f0);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: epStudyFadeIn 0.3s ease;
}

@keyframes epStudyFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ep-study-question-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.ep-study-q-num {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ep-slate-400, #94a3b8);
}

.ep-study-difficulty {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
}

.ep-study-difficulty--easy {
    background: #dcfce7;
    color: #166534;
}

.ep-study-difficulty--medium {
    background: #fef3c7;
    color: #92400e;
}

.ep-study-difficulty--hard {
    background: #fee2e2;
    color: #991b1b;
}

.ep-study-question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ep-slate-900, #0f172a);
    line-height: 1.45;
    margin-bottom: 1.75rem;
}

/* ── Options ───────────────────────────────────────────────────────────────── */
.ep-study-options-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.ep-study-option__btn {
    width: 100%;
    text-align: left;
    padding: 1rem 1.25rem;
    border: 2px solid var(--ep-slate-100, #f1f5f9);
    border-radius: 1rem;
    background: #fff;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 1rem;
}

.ep-study-option__btn:hover:not(.is-locked) {
    border-color: rgba(116, 95, 168, 0.35);
    background: rgba(116, 95, 168, 0.03);
    box-shadow: 0 2px 8px rgba(116, 95, 168, 0.1);
}

.ep-study-option__label {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: var(--ep-slate-100, #f1f5f9);
    color: var(--ep-slate-500, #64748b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.18s;
}

.ep-study-option__text {
    font-size: 1rem;
    color: var(--ep-slate-700, #334155);
    font-weight: 500;
}

/* Selected */
.ep-study-option__btn.is-selected {
    border-color: var(--ep-purple, #745fa8);
    background: rgba(116, 95, 168, 0.05);
}

.ep-study-option__btn.is-selected .ep-study-option__label {
    background: var(--ep-purple, #745fa8);
    color: #fff;
}

/* Locked */
.ep-study-option__btn.is-locked {
    pointer-events: none;
    opacity: 0.85;
}

/* Correct answer highlight (when student was wrong) */
.ep-study-option__btn.is-correct-answer {
    border-color: var(--ep-green, #9cca3b) !important;
    background: rgba(156, 202, 59, 0.07) !important;
    animation: epStudyCorrectPulse 0.45s ease-out;
}

.ep-study-option__btn.is-correct-answer .ep-study-option__label {
    background: var(--ep-green, #9cca3b) !important;
    color: #fff !important;
}

.ep-study-option__btn.is-correct-answer .ep-study-option__text {
    color: #3d5a14 !important;
    font-weight: 600 !important;
}

@keyframes epStudyCorrectPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(156, 202, 59, 0.55);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(156, 202, 59, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(156, 202, 59, 0);
    }
}

/* ── Feedback panel ────────────────────────────────────────────────────────── */
.ep-study-feedback {
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    border: 1.5px solid transparent;
    animation: epStudyFadeIn 0.25s ease;
}

.ep-study-feedback--correct {
    background: rgba(156, 202, 59, 0.08);
    border-color: var(--ep-green, #9cca3b);
    color: #3d5a14;
}

.ep-study-feedback--incorrect {
    background: rgba(239, 68, 68, 0.06);
    border-color: #fca5a5;
    color: #991b1b;
}

.ep-study-feedback__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.0625rem;
    font-weight: 700;
    margin-bottom: 0.625rem;
}

.ep-study-feedback__explanation {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--ep-slate-700, #334155);
    margin-bottom: 1.25rem;
}

.ep-study-next-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
    font-size: 1rem;
}

/* ── Complete screen ───────────────────────────────────────────────────────── */
#ep-study-complete {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.ep-study-complete-card {
    background: #fff;
    border: 1.5px solid var(--ep-slate-100, #f1f5f9);
    border-radius: 2rem;
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 30rem;
    width: 100%;
    box-shadow: 0 8px 32px rgba(116, 95, 168, 0.12);
    animation: epStudyFadeIn 0.4s ease;
}

.ep-study-complete-trophy {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: epStudyBounce 0.6s ease;
}

@keyframes epStudyBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-12px);
    }

    70% {
        transform: translateY(-5px);
    }
}

.ep-study-complete-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ep-slate-900, #0f172a);
    margin: 0 0 0.25rem;
}

.ep-study-complete-chapter {
    font-size: 1rem;
    color: var(--ep-purple, #745fa8);
    font-weight: 600;
    margin: 0 0 2rem;
}

.ep-study-complete-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--ep-slate-50, #f8fafc);
    border-radius: 1rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.ep-study-complete-score__num {
    font-size: 3rem;
    font-weight: 800;
    color: var(--ep-purple, #745fa8);
    line-height: 1;
}

.ep-study-complete-score__label {
    font-size: 0.8125rem;
    color: var(--ep-slate-500, #64748b);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ep-study-complete-detail {
    font-size: 0.9375rem;
    color: var(--ep-slate-600, #475569);
    margin: 0 0 2rem;
}

.ep-study-complete-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.ep-study-empty,
.ep-study-error {
    text-align: center;
    color: var(--ep-slate-500, #64748b);
    padding: 3rem 1rem;
    font-size: 1rem;
}