/* ==========================================================================
   SMP — ROADMAP (Lộ Trình Chuyên Đề Số Học)
   Primary Design Reference: SMP Home (shared.css) & Serpentine Skill Tree
   - Bảng màu: var(--main-bg), var(--card-bg), var(--text-dark), var(--text-muted)
   - Điểm nhấn: var(--accent-cyan), var(--accent-gold), var(--border-light)
   - Phong cách: Ấn phẩm toán học độc lập, tối giản, thanh lịch, giàu khoảng trắng
   ========================================================================== */

#sohoc-roadmap {
    min-height: 80vh;
}

.rm-root {
    max-width: 1040px;
    margin: 0 auto 60px;
    color: var(--text-dark);
    position: relative;
    animation: fadeUp 0.5s ease forwards;
}

.rm-view-detailed {
    animation: fadeUp 0.4s ease forwards;
}

/* --------------------------------------------------------------------------
   1. EDITORIAL HERO
   -------------------------------------------------------------------------- */
.rm-hero {
    margin-bottom: 40px;
    padding-bottom: 8px;
}

.rm-hero-kicker {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--accent-gold);
    margin-bottom: 10px;
}

.rm-hero-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 12px;
}

.rm-hero-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    line-height: 1.25;
    color: var(--text-dark);
    margin: 0;
    font-weight: 700;
}

.rm-hero-action {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--accent-cyan);
    text-decoration: none;
    letter-spacing: 1px;
    padding: 7px 14px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--card-bg);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rm-hero-action:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: translateX(2px);
}

.rm-hero-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 0;
    max-width: 720px;
}

/* --------------------------------------------------------------------------
   1.1. VIEW SWITCHER (Cần gạt chuyển đổi chế độ xem)
   -------------------------------------------------------------------------- */
.rm-view-switch-row {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.rm-view-switch-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.rm-view-switch {
    display: inline-flex;
    align-items: center;
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    padding: 3px;
    min-width: 250px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    user-select: none;
}

.rm-view-tab {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 999px;
    border: none;
    background: transparent;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, font-weight 0.2s ease;
    white-space: nowrap;
}

.rm-view-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.rm-view-tab:hover {
    color: var(--text-dark);
}

.rm-view-tab.is-active {
    color: var(--text-dark);
    font-weight: 700;
}

body.dark-mode .rm-view-tab.is-active {
    color: #ffffff;
}

.rm-view-switch-indicator {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc(50% - 3px);
    background: var(--main-bg);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s;
    z-index: 1;
    pointer-events: none;
}

.rm-view-switch[data-active="tree"] .rm-view-switch-indicator {
    transform: translateX(100%);
    border-color: rgba(0, 158, 179, 0.45);
}

body.dark-mode .rm-view-switch[data-active="tree"] .rm-view-switch-indicator {
    border-color: rgba(92, 225, 230, 0.5);
    background: rgba(92, 225, 230, 0.08);
}

/* --------------------------------------------------------------------------
   2. TABLE OF CONTENTS (Mục Lục Chuyên Đề — Trong View Chi Tiết)
   -------------------------------------------------------------------------- */
.rm-toc {
    margin-bottom: 56px;
}

.rm-toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 36px 48px;
    margin-top: 20px;
}

.rm-toc-col {
    display: flex;
    flex-direction: column;
}

.rm-toc-phase-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
}

.rm-toc-items {
    display: flex;
    flex-direction: column;
}

.rm-toc-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition);
    cursor: pointer;
    border-bottom: 1px solid transparent;
}

.rm-toc-row:hover .rm-toc-num,
.rm-toc-row:hover .rm-toc-title {
    color: var(--accent-cyan);
}

.rm-toc-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-cyan);
    width: 24px;
    flex-shrink: 0;
}

.rm-toc-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.98rem;
    color: var(--text-dark);
    transition: color 0.2s;
    white-space: nowrap;
}

.rm-toc-dots {
    flex: 1;
    border-bottom: 1px dotted var(--border-light);
    margin: 0 6px;
    min-width: 20px;
    position: relative;
    top: -4px;
}

.rm-toc-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.rm-toc-status.is-soon {
    opacity: 0.6;
}

/* --------------------------------------------------------------------------
   3. ROADMAP TIMELINE (Dòng Thời Gian Chuyên Đề — View Chi Tiết)
   -------------------------------------------------------------------------- */
.rm-timeline-divider {
    height: 1px;
    background: var(--border-light);
    margin: 48px 0 40px;
    border: none;
}

.rm-timeline {
    position: relative;
    padding-left: 56px;
}

/* Trục dọc hairline 1px */
.rm-spine {
    position: absolute;
    left: 17px;
    top: 8px;
    bottom: 24px;
    width: 1px;
    background: var(--border-light);
}

.rm-spine-fill {
    position: absolute;
    left: 17px;
    top: 8px;
    width: 1px;
    background: var(--accent-cyan);
    height: 0;
    transition: height 0.15s ease-out;
}

/* Tiêu đề giai đoạn trên timeline */
.rm-phase {
    position: relative;
    margin: 24px 0 36px -56px;
}

.rm-phase .section-label {
    margin-bottom: 0;
}

/* Từng chặng học (Station) */
.rm-station {
    position: relative;
    margin-bottom: 60px;
    scroll-margin-top: 100px;
}

.rm-node {
    position: absolute;
    left: -56px;
    top: -2px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--main-bg);
    border: 1px solid var(--border-light);
    box-shadow: 0 0 0 4px var(--main-bg);
    transition: var(--transition);
    z-index: 2;
}

.rm-station.is-passed .rm-node {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.rm-station-body {
    position: relative;
}

.rm-station-head {
    margin-bottom: 24px;
}

.rm-station-meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.rm-station-kicker {
    color: var(--accent-cyan);
    font-weight: 700;
}

.rm-station-sep {
    color: var(--border-light);
}

.rm-station-title-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.rm-station-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    line-height: 1.35;
    color: var(--text-dark);
    margin: 0;
    font-weight: 600;
}

.rm-station-formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    color: var(--accent-cyan);
    opacity: 0.85;
}

.rm-station-desc {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.65;
    margin: 8px 0 0;
    max-width: 720px;
}

/* --------------------------------------------------------------------------
   4. LESSON CARDS (Ô Bài Học Chuẩn SMP Card — View Chi Tiết)
   -------------------------------------------------------------------------- */
.rm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.rm-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.rm-card::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent-cyan);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.rm-card.is-ready:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
    border-color: rgba(0, 158, 179, 0.35);
}

body.dark-mode .rm-card.is-ready:hover {
    border-color: rgba(92, 225, 230, 0.35);
}

.rm-card.is-ready:hover::before {
    transform: scaleX(1);
}

.rm-card.is-soon {
    opacity: 0.72;
    border-style: dashed;
}

.rm-card-top {
    margin-bottom: 12px;
}

.rm-card-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

.rm-card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.12rem;
    line-height: 1.45;
    margin: 0 0 10px;
    color: var(--text-dark);
    font-weight: 600;
}

.rm-card-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.65;
    margin: 0 0 18px;
    flex: 1;
}

.rm-card-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.rm-soon-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   5. SERPENTINE ROADMAP TREE VIEW (Mindmap lượn sóng)
   -------------------------------------------------------------------------- */
.rm-view-tree {
    margin-bottom: 56px;
    animation: fadeUp 0.45s ease forwards;
}

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

.rm-tree-scroll-wrapper {
    position: relative;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--card-bg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.rm-mobile-hint {
    display: none;
    padding: 10px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--accent-cyan);
    background: rgba(0, 158, 179, 0.06);
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

.rm-serpentine-canvas {
    position: relative;
    min-width: 920px;
    padding: 44px 36px 72px;
    background: radial-gradient(var(--border-light) 1px, transparent 1px);
    background-size: 24px 24px;
    min-height: 800px;
}

/* Lớp SVG vẽ đường nối */
.rm-serpentine-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Trục chính S-curve rộng rãi */
.rm-trunk-path {
    stroke: var(--accent-cyan);
    stroke-width: 2.8;
    fill: none;
    stroke-linecap: round;
    transition: stroke 0.2s;
}

body.dark-mode .rm-trunk-path {
    stroke: #5ce1e6;
}

/* Nhánh nét đứt rẽ sang bài học */
.rm-branch-path {
    stroke: var(--accent-cyan);
    stroke-width: 1.8;
    fill: none;
    stroke-dasharray: 4, 4;
    stroke-linecap: round;
    opacity: 0.7;
    transition: stroke 0.2s, opacity 0.2s, stroke-width 0.2s, filter 0.2s;
}

body.dark-mode .rm-branch-path {
    stroke: #5ce1e6;
    opacity: 0.8;
}

.rm-branch-path.is-hovered {
    stroke-width: 2.6;
    opacity: 1;
    stroke: var(--accent-cyan);
    filter: drop-shadow(0 0 3px rgba(0, 158, 179, 0.6));
}

body.dark-mode .rm-branch-path.is-hovered {
    filter: drop-shadow(0 0 4px rgba(92, 225, 230, 0.7));
}

/* Header bar bên trong canvas: Root ở giữa, Legend ở góc phải */
.rm-tree-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 48px;
    position: relative;
    z-index: 2;
}

.rm-tree-root-box {
    display: flex;
    justify-content: center;
    flex: 1;
    margin-left: 170px;
}

.rm-tree-root-node {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dark);
    padding: 10px 24px;
    background: var(--main-bg);
    border: 2px solid var(--accent-cyan);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 158, 179, 0.15);
}

body.dark-mode .rm-tree-root-node {
    border-color: #5ce1e6;
    box-shadow: 0 4px 14px rgba(92, 225, 230, 0.2);
}

.rm-tree-legend-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    background: var(--main-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.rm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rm-legend-chip {
    width: 18px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.rm-legend-chip.is-hub {
    background: rgba(197, 155, 39, 0.15);
    border: 1.5px solid var(--accent-gold);
}

.rm-legend-chip.is-ready {
    background: rgba(0, 158, 179, 0.15);
    border: 1.5px solid var(--accent-cyan);
}

.rm-legend-chip.is-soon {
    background: transparent;
    border: 1.5px dashed var(--text-muted);
}

/* Các hàng Chặng (Rows) với 3 slot cân đối */
.rm-st-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 68px 0;
    position: relative;
    z-index: 2;
    gap: 24px;
}

.rm-st-slot-left {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.rm-st-slot-hub {
    flex: 0 0 280px;
    display: flex;
    justify-content: center;
}

.rm-st-slot-right {
    flex: 1;
    display: flex;
    justify-content: flex-start;
}

/* Hub lệch nhẹ quanh tâm để tạo đường cong uốn lượn rộng */
.rm-st-row[data-side="right"] .rm-st-slot-hub {
    justify-content: flex-end;
    padding-right: 18px;
}

.rm-st-row[data-side="left"] .rm-st-slot-hub {
    justify-content: flex-start;
    padding-left: 18px;
}

/* Station Hub (Nút chủ đề trung tâm) */
.rm-st-hub {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 22px;
    background: var(--main-bg);
    border: 2px solid var(--accent-gold);
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.rm-st-hub-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    white-space: nowrap;
    text-transform: none !important;
}

/* Nhóm các thẻ bài học (Cards) */
.rm-st-cards-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    width: 100%;
}

/* Khi có từ 5-6 bài (ví dụ Chặng 9): chia 2 cột */
.rm-st-cards-group.is-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 480px;
}

/* Từng thẻ bài học (Chỉ Tiêu Đề, Không Mã, Không Mũi Tên, In Hoa Chữ Đầu) */
.rm-st-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition);
    background: var(--main-bg);
    min-width: 200px;
    max-width: 340px;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}

.rm-st-card.card-link {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-family: inherit;
}

/* Triệt tiêu mũi tên -> của shared.css */
.rm-st-card.card-link::after {
    display: none !important;
    content: '' !important;
}

.rm-st-card-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-dark);
    text-align: center;
    margin: 0;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.rm-st-card.is-ready {
    border: 1.5px solid var(--accent-cyan);
    background: rgba(0, 158, 179, 0.05);
    cursor: pointer;
}

body.dark-mode .rm-st-card.is-ready {
    background: rgba(92, 225, 230, 0.08);
    border-color: #5ce1e6;
}

.rm-st-card.is-ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 158, 179, 0.2);
    border-color: var(--accent-cyan);
    background: var(--card-bg);
}

.rm-st-card.is-ready:hover .rm-st-card-title {
    color: var(--accent-cyan);
}

.rm-st-card.is-soon {
    border: 1.5px dashed var(--border-light);
    opacity: 0.72;
    cursor: default;
}

/* Phase Milestone Marker */
.rm-st-phase-milestone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin: 44px auto;
    padding: 8px 24px;
    background: var(--main-bg);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    width: fit-content;
    position: relative;
    z-index: 2;
}

.rm-st-phase-kicker {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-gold);
    font-weight: 700;
}

.rm-st-phase-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* --------------------------------------------------------------------------
   6. COLOPHON
   -------------------------------------------------------------------------- */
.rm-colophon {
    text-align: center;
    padding: 56px 20px 32px;
    margin-top: 48px;
    border-top: 1px solid var(--border-light);
}

.rm-colophon-divider {
    width: 48px;
    height: 1px;
    background: var(--accent-gold);
    margin: 0 auto 24px;
    opacity: 0.6;
}

.rm-quote {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text-dark);
    line-height: 1.7;
    max-width: 620px;
    margin: 0 auto 12px;
}

.rm-cite {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-style: normal;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   7. RESPONSIVE DESIGN
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    .rm-mobile-hint {
        display: block;
    }
}

@media (max-width: 768px) {
    .rm-hero-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .rm-hero-title {
        font-size: 1.8rem;
    }
    .rm-timeline {
        padding-left: 42px;
    }
    .rm-spine, .rm-spine-fill {
        left: 14px;
    }
    .rm-node {
        left: -42px;
        width: 29px;
        height: 29px;
        font-size: 0.7rem;
    }
    .rm-phase {
        margin-left: -42px;
    }
    .rm-toc-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .rm-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .rm-view-switch {
        width: 100%;
        min-width: 0;
    }
}
