/* ============================================
   SIMULATION STORY PAGE
   ============================================ */

@layer components {
    .simulation-story-page {
        position: relative;
        padding-block: var(--space-xl);
        overflow: hidden;

        [data-md] {
            p { margin: 0 0 0.35em; }
            p:last-child { margin-bottom: 0; }
            ul { margin: 0.35em 0; padding-left: 1.4em; }
            li { margin-bottom: 0.2em; line-height: 1.65; }
            code {
                font-size: 0.85em;
                padding: 0.1em 0.35em;
                border-radius: 4px;
                background: light-dark(oklch(0.95 0 0), oklch(0.25 0 0));
            }
        }

        .view-tabs {
            display: flex;
            border-radius: 100px;
            overflow: hidden;
            padding: var(--space-3xs);

            .view-tab {
                padding: var(--space-xs) var(--space-lg);
                border: none;
                background: transparent;
                cursor: pointer;
                font-size: var(--fs-small);
                border-radius: 100px;
                transition: all 0.2s ease-out;
            }
        }

        /* === MAIN CONTENT === */
        .story-content {
            flex: 1;
            min-inline-size: 300px;
            display: flex;
            flex-direction: column;
            gap: var(--space-lg);
        }

        .card {
            padding: var(--space-lg);
            border-radius: 12px;
        }

        .story-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;

            .difficulty {
                font-size: var(--fs-small);
            }

            .status-badge {
                padding: var(--space-3xs) var(--space-sm);
                border-radius: 100px;
                font-size: var(--fs-xsmall);
            }
        }

        .story-title {
            font-size: var(--fs-xl);
        }

        .story-intro {
            font-family: var(--font-body);
            line-height: 1.75;
            letter-spacing: 0.01em;
            padding: var(--space-lg);
            border-radius: 10px;
        }

        .mission-section,
        .chapters-section {
            h3 {
                display: flex;
                align-items: center;
                gap: var(--space-sm);
                margin-block-end: var(--space-lg);

                .section-icon {
                    display: inline-flex;
                    justify-content: center;
                    align-items: center;
                    inline-size: 32px;
                    block-size: 32px;
                    border-radius: 8px;
                    font-size: var(--fs-small);
                }
            }

            .chapter-count {
                font-weight: var(--fw-regular);
                font-size: var(--fs-small);
            }
        }

        .skill-tags,
        .chapter-tags {
            display: flex;
            flex-wrap: wrap;
            gap: var(--space-xs);
            margin-block-start: var(--space-md);

            .tag {
                padding: var(--space-3xs) var(--space-sm);
                border-radius: 100px;
                font-size: var(--fs-xsmall);
            }
        }

        .chapter-card {
            display: flex;
            gap: var(--wire-gap);
            align-items: flex-start;
            padding: var(--space-lg);
            border-radius: 12px;
            margin-block-end: var(--space-md);
            transition: all 0.2s ease-out;

            .chapter-number {
                flex-shrink: 0;
                display: flex;
                justify-content: center;
                align-items: center;
                inline-size: 40px;
                block-size: 40px;
                border-radius: 50%;
                font-size: var(--fs-small);
                transition: all 0.2s ease-out;
            }

            .chapter-content {
                flex: 1;

                > strong:first-child {
                    display: block;
                    margin-block-end: var(--space-3xs);
                }

                .chapter-type {
                    display: block;
                    font-size: var(--fs-xsmall);
                    margin-block-end: var(--space-xs);
                }

                p {
                    font-family: var(--font-body);
                    font-size: 0.9rem;
                    line-height: 1.75;
                    letter-spacing: 0.01em;
                }
            }

            .chapter-arrow {
                flex-shrink: 0;
                transition: all 0.2s ease-out;
            }
        }

        /* === ENTRANCE ANIMATIONS === */
        .page-header {
            animation: entrance-slide-right 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
        }

        .chat-sidebar {
            animation: entrance-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
        }

        .story-content > .card {
            animation: entrance-slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
            animation-delay: calc(0.1s + 0.08s * sibling-index());
        }

        .chapter-card {
            animation: entrance-slide-up 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
            animation-delay: calc(0.2s + 0.08s * sibling-index());
        }

        .page-bg-orb {
            animation: entrance-fade-in 1.2s ease-out both;
            animation-delay: calc(0.2s + 0.3s * sibling-index());
        }
    }
}

/* --- THEME --- */
@layer theme {
    .simulation-story-page {

        /* Markdown-rendered AI content */
        .story-content strong, .chapter-content strong {
            color: var(--accent-primary, oklch(0.65 0.15 250));
            font-weight: 600;
        }

        /* === VIEW TABS === */
        .view-tabs {
            background: light-dark(oklch(0% 0 0 / 0.03), oklch(100% 0 0 / 0.04));
            border: 1px solid light-dark(oklch(0% 0 0 / 0.06), oklch(100% 0 0 / 0.08));
            backdrop-filter: blur(12px);
        }

        /* === STORY META === */
        .story-meta {
            .difficulty {
                padding: var(--space-xs) var(--space-md);
                background: light-dark(oklch(0% 0 0 / 0.03), oklch(100% 0 0 / 0.04));
                border-radius: 100px;
                border: 1px solid light-dark(oklch(0% 0 0 / 0.06), oklch(100% 0 0 / 0.08));
                backdrop-filter: blur(8px);
                color: var(--text-secondary);
            }

            .status-badge {
                background: oklch(from var(--color-warning) l c h / 0.12);
                border: 1px solid oklch(from var(--color-warning) l c h / 0.25);
                color: var(--color-warning);
            }
        }

        /* === STORY INTRO === */
        .story-intro {
            color: light-dark(oklch(40% 0.01 250), oklch(78% 0.01 250));
            background: light-dark(oklch(0% 0 0 / 0.02), oklch(100% 0 0 / 0.03));
            border-inline-start: 3px solid var(--accent-primary);
        }

        /* === CHAPTER CARDS === */
        .chapter-card {
            background: light-dark(oklch(0% 0 0 / 0.02), oklch(100% 0 0 / 0.03));
            border: 1px solid oklch(from var(--glass-tint) l c h / 0.06);
            backdrop-filter: blur(8px);
            cursor: pointer;

            &:hover {
                border-color: light-dark(oklch(from var(--accent-primary) l c h / 0.2), oklch(from var(--accent-primary) l c h / 0.25));
                transform: translateX(4px);
                box-shadow: 0 4px 20px light-dark(oklch(from var(--accent-primary) l c h / 0.05), oklch(from var(--accent-primary) l c h / 0.08));

                .chapter-number {
                    background: var(--accent-primary);
                    color: var(--button-text-color);
                    border-color: transparent;
                }

                .chapter-arrow {
                    color: var(--accent-primary);
                }
            }

            .chapter-number {
                border: 1px solid light-dark(oklch(0% 0 0 / 0.08), oklch(100% 0 0 / 0.1));
            }

            .chapter-content {
                .chapter-type {
                    color: var(--text-secondary);
                }

                p {
                    color: light-dark(oklch(40% 0.01 250), oklch(78% 0.01 250));
                }
            }

            .chapter-arrow {
                color: var(--text-secondary);
            }
        }

        /* === SECTION ICONS === */
        .section-icon {
            background: linear-gradient(135deg,
                light-dark(oklch(from var(--accent-primary) l c h / 0.15), oklch(from var(--accent-primary) l c h / 0.25)),
                light-dark(oklch(from var(--accent-primary) l c h / 0.05), oklch(from var(--accent-primary) l c h / 0.1)));
            border: 1px solid light-dark(oklch(from var(--accent-primary) l c h / 0.2), oklch(from var(--accent-primary) l c h / 0.3));
            color: var(--accent-primary);
            box-shadow: 0 2px 12px light-dark(oklch(from var(--accent-primary) l c h / 0.08), oklch(from var(--accent-primary) l c h / 0.15));
        }

        .chapters-section .chapter-count {
            color: var(--text-secondary);
        }

        /* === CHIPS === */
        .chip {
            backdrop-filter: blur(8px);
            transition: all 0.2s ease-out;

            &:hover {
                transform: translateY(-1px);
                box-shadow: 0 4px 12px oklch(0% 0 0 / 0.15);
            }
        }
    }
}
