/* ===========================================
   课程详情页样式
   =========================================== */

.lesson-hero {
    position: relative;
    padding: 60px 0 80px;
    background: var(--bg-alt);
    overflow: hidden;
}

.lesson-hero::before {
    content: "";
    position: absolute;
    top: -150px;
    right: -150px;
    width: 400px;
    height: 400px;
    background: radial-gradient(
        circle,
        rgba(124, 58, 237, 0.18) 0%,
        transparent 70%
    );
    border-radius: 50%;
}

.lesson-hero-basics::before {
    background: radial-gradient(
        circle,
        rgba(124, 58, 237, 0.18) 0%,
        transparent 70%
    );
}

.lesson-hero-vibe::before {
    background: radial-gradient(
        circle,
        rgba(236, 72, 153, 0.18) 0%,
        transparent 70%
    );
}

.lesson-hero-python::before {
    background: radial-gradient(
        circle,
        rgba(16, 185, 129, 0.18) 0%,
        transparent 70%
    );
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-light);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-sep {
    color: var(--text-light);
    opacity: 0.5;
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

.lesson-hero-content {
    display: flex;
    align-items: center;
    gap: 32px;
    position: relative;
    z-index: 1;
}

.lesson-hero-icon {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    background: var(--bg-card);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    box-shadow: var(--shadow-lg);
}

.lesson-hero-info {
    flex: 1;
}

.lesson-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lesson-title {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    line-height: 1.2;
}

.lesson-summary {
    font-size: 17px;
    color: var(--text-light);
    margin-bottom: 20px;
    max-width: 720px;
}

.lesson-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.lesson-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

.lesson-meta-item strong {
    color: var(--text);
    font-weight: 700;
}

/* 课程内容 */
.lesson-body {
    padding: 60px 0 100px;
}

.lesson-content {
    max-width: 800px;
    margin: 0 auto;
}

.lesson-section {
    margin-bottom: 48px;
    animation: fadeIn 0.5s ease-out;
}

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

.section-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title-icon {
    font-size: 32px;
}

/* 故事区块 */
.story-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.story-content {
    font-size: 16px;
    line-height: 1.85;
    color: var(--text);
}

.story-content p {
    margin-bottom: 16px;
}

.story-content p:last-child {
    margin-bottom: 0;
}

.story-content strong {
    color: var(--primary);
    font-weight: 700;
}

/* 时间线 */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--gradient);
    opacity: 0.3;
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -28px;
    top: 8px;
    width: 14px;
    height: 14px;
    background: var(--gradient);
    border-radius: 50%;
    border: 3px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-year {
    font-weight: 800;
    color: var(--primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.timeline-event {
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

/* 卡片网格（用于展示概念卡片） */
.concept-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.concept-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.concept-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--primary-light);
}

.concept-card-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.concept-card-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--text);
}

.concept-card-desc {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 8px;
    line-height: 1.5;
}

.concept-card-example {
    font-size: 13px;
    background: var(--bg-alt);
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--primary);
    font-style: italic;
}

/* 对比框 */
.compare-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.compare-side {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 2px solid var(--border);
}

.compare-side.bad {
    border-color: #fca5a5;
    background: #fef2f2;
}

.compare-side.good {
    border-color: #86efac;
    background: #f0fdf4;
}

.compare-side.neutral {
    border-color: var(--border);
}

.compare-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-side.bad .compare-title {
    color: #dc2626;
}
.compare-side.good .compare-title {
    color: #16a34a;
}
.compare-side.neutral .compare-title {
    color: var(--primary);
}

.compare-list {
    list-style: none;
}

.compare-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.compare-list li:last-child {
    border-bottom: none;
}

/* 测验 */
.quiz-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 2px solid var(--primary-light);
    box-shadow: var(--shadow);
}

.quiz-question {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-alt);
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.quiz-option:hover:not(.disabled) {
    border-color: var(--primary-light);
    background: var(--bg-card);
}

.quiz-option-letter {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
    border: 1px solid var(--border);
}

.quiz-option.correct {
    background: #d1fae5;
    border-color: var(--success);
}

.quiz-option.correct .quiz-option-letter {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

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

.quiz-option.wrong .quiz-option-letter {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.quiz-option.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.quiz-feedback {
    padding: 16px;
    border-radius: var(--radius);
    font-size: 14px;
    display: none;
}

.quiz-feedback.show {
    display: block;
    animation: fadeIn 0.3s;
}

.quiz-feedback.correct {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.quiz-feedback.wrong {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.quiz-feedback-title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 15px;
}

/* 提示框 */
.tip-block {
    display: flex;
    gap: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    border-left: 5px solid var(--warning);
}

.tip-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.tip-content {
    flex: 1;
    color: #78350f;
}

.tip-title {
    font-weight: 800;
    margin-bottom: 6px;
    font-size: 15px;
}

.tip-text {
    font-size: 14px;
    line-height: 1.7;
}

.tip-text p {
    margin-bottom: 8px;
}
.tip-text strong {
    color: #92400e;
}

/* 示例块 */
.example-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--accent);
}

.example-content {
    background: #1f2937;
    color: #e5e7eb;
    border-radius: var(--radius);
    padding: 20px;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    line-height: 1.8;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.example-content em {
    color: #fbbf24;
    font-style: normal;
    font-weight: 700;
}

/* 列表块 */
.list-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
}

.list-items {
    list-style: none;
}

.list-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.7;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item strong {
    color: var(--primary);
}

/* 步骤块 */
.steps-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--border);
}

.steps-list {
    list-style: none;
    counter-reset: step;
}

.step-item {
    position: relative;
    padding: 14px 0 14px 56px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.7;
    counter-increment: step;
}

.step-item:last-child {
    border-bottom: none;
}

.step-item::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 12px;
    width: 36px;
    height: 36px;
    background: var(--gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    box-shadow: var(--shadow);
}

.step-item strong {
    color: var(--primary);
}

/* 代码块 */
.code-block {
    background: #1f2937;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #111827;
    border-bottom: 1px solid #374151;
}

.code-lang {
    color: #9ca3af;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-copy {
    color: #d1d5db;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-copy:hover {
    background: #374151;
}

.runner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.runner-run-btn {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    color: white;
    font-weight: 800;
}

.runner-run-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #0891b2 100%);
}

.runner-run-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.runner-editor {
    display: block;
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border: 0;
    outline: none;
    margin: 0;
    padding: 20px;
    background: #1f2937;
    color: #e5e7eb;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    line-height: 1.7;
    tab-size: 4;
}

.runner-editor:focus {
    box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.45);
}

.runner-stdin-wrap {
    padding: 14px 18px 18px;
    background: #111827;
    border-top: 1px solid #374151;
}

.runner-stdin-label {
    display: block;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.runner-stdin {
    width: 100%;
    min-height: 58px;
    resize: vertical;
    border: 1px solid #374151;
    border-radius: 10px;
    padding: 10px 12px;
    background: #1f2937;
    color: #e5e7eb;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    outline: none;
}

.runner-stdin:focus {
    border-color: #10b981;
}

.runner-output-panel {
    border-top: 1px solid #374151;
    background: #0f172a;
}

.runner-output-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 700;
    border-bottom: 1px solid #1f2937;
}

.runner-status {
    color: #86efac;
}

.runner-output {
    min-height: 74px;
    max-height: 280px;
    overflow: auto;
    margin: 0;
    padding: 16px 20px;
    color: #d1fae5;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    line-height: 1.6;
}

.runner-output-error {
    color: #fecaca;
}

.runner-interactive-wrap {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.runner-interactive-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: #0f172a;
    color: #e5e7eb;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 14px;
}

.runner-interactive-input:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.runner-interactive-input:disabled {
    opacity: 0.62;
}

.runner-stop-btn:not(:disabled) {
    background: #ef4444;
    color: white;
}

.runner-send-btn:not(:disabled) {
    background: #10b981;
    color: white;
}

.code-body {
    padding: 20px;
    font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #e5e7eb;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
}

.code-body .tag {
    color: #f472b6;
}
.code-body .attr {
    color: #fbbf24;
}
.code-body .str {
    color: #86efac;
}
.code-body .cmt {
    color: #6b7280;
    font-style: italic;
}
.code-body .kw {
    color: #c4b5fd;
}
.code-body .num {
    color: #fdba74;
}
.code-body .fn {
    color: #93c5fd;
}

/* 表格 */
.table-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table-block table {
    width: 100%;
    border-collapse: collapse;
}

.table-block th,
.table-block td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table-block th {
    background: var(--bg-alt);
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-block tr:last-child td {
    border-bottom: none;
}

.table-block tr:hover td {
    background: var(--bg-alt);
}

/* 完成行动 */
.lesson-actions {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.complete-section {
    flex: 1;
    min-width: 240px;
}

.complete-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-alt);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.complete-checkbox:hover {
    border-color: var(--primary-light);
}

.complete-checkbox.checked {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: var(--success);
}

.complete-checkbox input {
    width: 24px;
    height: 24px;
    accent-color: var(--success);
    cursor: pointer;
}

.complete-text {
    font-weight: 600;
    font-size: 15px;
}

.complete-checkbox.checked .complete-text {
    color: #065f46;
}

.lesson-nav {
    display: flex;
    gap: 12px;
}

/* 庆祝动画 */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall 3s ease-in forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .lesson-hero {
        padding: 30px 0 40px;
    }

    .lesson-hero-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .lesson-hero-icon {
        width: 64px;
        height: 64px;
        font-size: 36px;
    }

    .lesson-title {
        font-size: clamp(22px, 5vw, 28px);
    }

    .lesson-summary {
        font-size: 14px;
    }

    .lesson-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    .lesson-meta-item {
        font-size: 13px;
    }

    .lesson-body {
        padding: 30px 0 50px;
    }

    .lesson-section {
        margin-bottom: 28px;
    }

    .section-title {
        font-size: 17px;
    }

    .compare-block {
        grid-template-columns: 1fr;
    }

    .concept-cards {
        grid-template-columns: 1fr;
    }

    .story-block,
    .quiz-block,
    .list-block,
    .steps-block,
    .tip-block,
    .example-block {
        padding: 16px;
        border-radius: var(--radius);
    }

    .story-content {
        font-size: 15px;
        line-height: 1.7;
    }

    .code-body {
        font-size: 12px;
        padding: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .code-block {
        border-radius: var(--radius);
    }

    .code-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px 14px;
    }

    .code-lang {
        font-size: 12px;
    }

    .runner-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .runner-actions .code-copy {
        min-height: 36px;
        padding: 8px 14px;
        font-size: 13px;
    }

    .runner-run-btn {
        font-size: 14px;
        padding: 8px 18px;
    }

    .runner-stop-btn:not(:disabled) {
        font-size: 13px;
        padding: 8px 14px;
    }

    .runner-send-btn:not(:disabled) {
        font-size: 13px;
        padding: 8px 14px;
    }

    .runner-editor {
        min-height: 150px;
        font-size: 12px;
        padding: 14px;
    }

    .runner-stdin {
        min-height: 60px;
        font-size: 13px;
        padding: 12px;
    }

    .runner-stdin-label {
        font-size: 12px;
    }

    .runner-output {
        font-size: 13px;
        padding: 14px;
        min-height: 80px;
        max-height: 200px;
    }

    .runner-interactive-wrap {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }

    .runner-interactive-input {
        min-height: 44px;
        font-size: 15px;
    }

    .runner-send-btn {
        min-height: 44px;
    }

    .quiz-option {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 48px;
    }

    .quiz-question {
        font-size: 16px;
    }

    .compare-side {
        padding: 18px;
    }

    .concept-card {
        padding: 18px;
    }

    .concept-card-icon {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }

    .timeline {
        padding-left: 28px;
    }

    .timeline-item {
        padding: 12px 16px;
    }

    .timeline-year {
        font-size: 14px;
    }

    .timeline-event {
        font-size: 14px;
    }

    .list-item {
        font-size: 15px;
        padding: 10px 0;
    }

    .step-item {
        font-size: 15px;
        padding: 10px 0 10px 36px;
        min-height: 44px;
    }

    .lesson-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .complete-checkbox {
        padding: 14px;
        justify-content: center;
    }

    .lesson-nav {
        flex-direction: column;
        gap: 10px;
    }

    .lesson-nav .btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .example-content {
        font-size: 14px;
        padding: 0;
    }

    .quiz-feedback {
        padding: 14px;
        font-size: 14px;
    }

    .table-block {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-block th,
    .table-block td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .lesson-hero {
        padding: 24px 0 30px;
    }

    .lesson-hero-icon {
        width: 52px;
        height: 52px;
        font-size: 28px;
    }

    .lesson-eyebrow {
        font-size: 11px;
        padding: 3px 10px;
    }

    .lesson-body {
        padding: 24px 0 40px;
    }

    .lesson-section {
        margin-bottom: 22px;
    }

    .runner-editor {
        min-height: 120px;
        font-size: 11px;
        padding: 12px;
    }

    .runner-actions .code-copy {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 32px;
    }

    .code-body {
        font-size: 11px;
        padding: 12px;
    }

    .concept-card-name {
        font-size: 16px;
    }

    .compare-title {
        font-size: 15px;
    }
}
