/* Lessons Page Styles */

/* ============================================================================
   Lessons List Page
   ============================================================================ */

.lessons-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.lessons-header {
    text-align: center;
    margin-bottom: 3rem;
}

.lessons-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.lessons-header .lead {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
}

/* Lessons Grid */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
}

/* Lesson Card */
.lesson-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--color-border);
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.lesson-card-image {
    height: 180px;
    background: var(--color-gradient);
    position: relative;
    overflow: hidden;
}

.lesson-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lesson-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 3rem;
}

.lesson-card-image img + .lesson-card-placeholder {
    display: none;
}

.lesson-card-content {
    padding: 1.5rem;
}

.lesson-number {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.75rem;
}

.lesson-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.lesson-summary {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.lesson-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-light);
}

.lesson-models {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.lesson-models i {
    margin-right: 0.25rem;
}

.lesson-read-more {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-primary);
}

.lesson-read-more i {
    margin-left: 0.25rem;
    transition: transform 0.2s ease;
}

.lesson-card:hover .lesson-read-more i {
    transform: translateX(4px);
}

/* No Lessons State */
.no-lessons {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-secondary);
}

.no-lessons i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ============================================================================
   Lesson Detail Page
   ============================================================================ */

.lesson-detail-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Wider layout when embedded models are present */
.lesson-detail-page.has-embeds {
    max-width: 1200px;
}

.lesson-breadcrumb {
    margin-bottom: 2rem;
}

.lesson-breadcrumb a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

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

/* Article Header */
.lesson-article-header {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border-light);
}

.lesson-article-header .lesson-number {
    margin-bottom: 1rem;
}

.lesson-article-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.lesson-article-header .lesson-summary {
    font-size: 1.15rem;
    color: var(--color-text-secondary);
    margin-bottom: 0;
}

/* Cover Image */
.lesson-cover-image {
    margin-bottom: 2rem;
    border-radius: 12px;
    overflow: hidden;
}

.lesson-cover-image img {
    width: 100%;
    height: auto;
}

/* Lesson Content (Rendered Markdown) */
.lesson-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--color-text-primary);
}

.lesson-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary);
}

.lesson-content h3 {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.lesson-content p {
    margin-bottom: 1.25rem;
}

.lesson-content ul,
.lesson-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

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

.lesson-content strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

.lesson-content a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--color-primary-light);
    transition: border-color 0.2s ease;
}

.lesson-content a:hover {
    border-color: var(--color-primary);
}

.lesson-content code {
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--code-text);
}

.lesson-content pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

.lesson-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

.lesson-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* Models Sidebar */
.lesson-models-sidebar {
    background: var(--color-gradient);
    color: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    margin: 2rem 0;
}

.lesson-models-sidebar h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lesson-models-sidebar p {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.model-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.model-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
}

.model-link-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}

/* Lesson Navigation */
.lesson-navigation {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: center;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    .lessons-header h1 {
        font-size: 2rem;
    }

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

    .lesson-article-header h1 {
        font-size: 1.75rem;
    }

    .lesson-content {
        font-size: 1rem;
    }

    .lesson-content h2 {
        font-size: 1.5rem;
    }
}

/* ============================================================================
   Embeddable Model Viewer
   ============================================================================ */

.model-embed {
    margin: 2.5rem 0;
    border: 2px solid var(--draw-border, #d4c8b8);
    border-radius: 12px;
    overflow: hidden;
    background: var(--draw-bg-secondary, #faf8f5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.model-embed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--draw-bg-tertiary, #f5f2eb);
    border-bottom: 2px solid var(--draw-border, #d4c8b8);
    min-height: 48px;
}

.model-embed-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--draw-text-primary, #1f2937);
    font-family: system-ui, -apple-system, sans-serif;
    letter-spacing: -0.01em;
}

.embed-fullview-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--draw-text-secondary, #6b7280);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-left: auto;
}

.embed-fullview-link:hover {
    color: var(--draw-text-primary, #1f2937);
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}

.embed-fullview-link i {
    font-size: 1rem;
}

.model-embed-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--draw-bg-primary, #f8f6f1);
    padding: 0.75rem;
}

/* Embed/Compact Mode Layout for Results Charts */
.results-charts.results-compact {
    display: flex;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--draw-border, #d4c8b8);
    border-radius: 8px;
    overflow: hidden;
}

.results-charts.results-compact .chart-wrapper {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.results-charts.results-compact .chart-wrapper:first-child {
    flex: 60 1 60%;
    border-right: 2px solid var(--draw-border, #d4c8b8);
}

.results-charts.results-compact .chart-wrapper:last-child {
    flex: 40 1 40%;
    position: relative;
}

.results-charts.results-compact .chart-graph,
.results-charts.results-compact .chart-img {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--draw-bg-secondary, #faf8f5);
    overflow: hidden;
    min-height: 0;
}

.results-charts.results-compact .chart-graph svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
}

/* Heart animation canvas in compact mode */
.results-charts.results-compact .chart-img canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Loading State */
.model-embed.loading .results-charts {
    position: relative;
}

.model-embed.loading .results-charts::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Error State */
.model-embed.error .results-charts::after {
    content: "Failed to load model";
    color: #dc3545;
}

/* Responsive */
@media (max-width: 768px) {
    .results-charts.results-compact {
        flex-direction: column;
    }

    .results-charts.results-compact .chart-wrapper:first-child {
        flex: 1;
        border-right: none;
        border-bottom: 1px solid var(--draw-border);
    }

    .results-charts.results-compact .chart-wrapper:last-child {
        flex: 1;
    }

    .results-controls-wrapper.results-compact {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-control-group.playback-inline {
        margin-left: 0;
    }
}

/* ============================================================================
   Inline Images and Galleries
   ============================================================================ */

/* Single image with caption */
.lesson-figure {
    margin: 32px auto;
    text-align: center;
    max-width: 100%;
}

.lesson-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lesson-figure figcaption {
    margin-top: 12px;
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Gallery shared caption */
.gallery-caption {
    text-align: center;
    margin-top: 12px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Image gallery - scrollable mode */
.lesson-gallery.gallery-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 16px 0;
    margin: 24px 0;
    -webkit-overflow-scrolling: touch;
}

.lesson-gallery.gallery-scroll img {
    scroll-snap-align: center;
    flex-shrink: 0;
    max-height: 280px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Hide scrollbar but keep functionality */
.lesson-gallery.gallery-scroll::-webkit-scrollbar {
    height: 8px;
}

.lesson-gallery.gallery-scroll::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
    border-radius: 4px;
}

.lesson-gallery.gallery-scroll::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.lesson-gallery.gallery-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Image gallery - rotate/carousel mode */
.gallery-float-container {
    float: right;
    margin: 0 0 20px 24px;
    max-width: 320px;
    clear: right;
}

.lesson-gallery.gallery-rotate {
    position: relative;
    text-align: center;
}

.lesson-gallery.gallery-rotate .gallery-images {
    position: relative;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lesson-gallery.gallery-rotate img {
    display: none;
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lesson-gallery.gallery-rotate img.active {
    display: block;
}

/* Caption styling - appears between image and arrows */
.gallery-float-container .gallery-caption {
    margin: 8px 0;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
}

/* Gallery navigation buttons - positioned below caption */
.gallery-nav-container {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.gallery-nav {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.gallery-nav:active {
    transform: scale(0.95);
}

/* Clear floats after sections containing galleries */
.lesson-content h2 {
    clear: both;
}

/* Responsive - stack on mobile */
@media (max-width: 600px) {
    .gallery-float-container {
        float: none;
        margin: 24px auto;
        max-width: 100%;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .lesson-figure img,
[data-theme="dark"] .lesson-gallery img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .gallery-nav {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .gallery-nav:hover {
    background: rgba(255, 255, 255, 0.35);
}
