/* ===================================
   Module Page Styles
   Web Foundations: HTML & CSS Mastery
   Lesson page layout: sidebar + main
   =================================== */

/* === Course Color Palette Override ===
   Override global gray/black palette with
   blue-tinted dark theme to match Node.js course feel */
:root {
    --bg-primary: #0f1220;
    --bg-secondary: #171a2b;
    --bg-tertiary: #1a1f36;
    --bg-card: rgba(23, 26, 43, 0.8);
    --bg-card-hover: rgba(32, 36, 60, 0.95);

    --text-primary: #e8ecff;
    --text-secondary: #d4dbf9;
    --text-tertiary: #9ba3c2;

    --accent-primary: #7aa2ff;
    --accent-secondary: #d87bff;
    --accent-gradient: linear-gradient(135deg, #7aa2ff, #d87bff);

    --border-color: #2a2f4a;
    --border-hover: #3a4470;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #eef1f6;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;

    --text-primary: #1a1a2e;
    --text-secondary: #334155;
    --text-tertiary: #4a5568;

    --accent-primary: #2563eb;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #2563eb, #7c3aed);

    --border-color: #cbd5e1;
    --border-hover: #94a3b8;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* === Reading Progress Bar === */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #e34c26, #264de4);
    z-index: 10000;
    transition: width 0.1s linear;
}

/* === Module Header Bar === */
.module-header-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-xl) 0 var(--spacing-lg);
    margin-top: 70px; /* navbar height */
}

[data-theme="light"] .module-header-bar {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.module-header-content {
    text-align: center;
}

.module-badge-number {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #fff;
    background: linear-gradient(135deg, #e34c26, #264de4);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    margin-bottom: var(--spacing-xs);
}

.module-header-bar h1 {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.module-header-subtitle {
    font-size: 1.1rem;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.03em;
}

/* === Module Layout (Sidebar + Main) === */
.module-layout {
    display: flex;
    min-height: calc(100vh - 200px);
}

/* === Sidebar === */
.module-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    padding-top: 70px; /* below navbar */
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
    transition: transform 0.3s ease;
}

.module-sidebar::-webkit-scrollbar {
    width: 4px;
}
.module-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.module-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 80px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.sidebar-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-header {
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-course-badge {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #e34c26;
    background: rgba(227, 76, 38, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    margin-bottom: 0.3rem;
}

.sidebar-course-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: var(--spacing-sm) 0;
}

.back-to-course {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem var(--spacing-md);
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-xs);
}
.back-to-course:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-section {
    padding: var(--spacing-xs) 0;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem var(--spacing-md);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.sidebar-section-icon {
    font-size: 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem var(--spacing-md) 0.45rem calc(var(--spacing-md) + 4px);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-left-color: var(--border-hover);
}

.sidebar-link.active {
    color: #e34c26;
    background: rgba(227, 76, 38, 0.06);
    border-left-color: #e34c26;
    font-weight: 500;
}

.link-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.sidebar-link.active .link-number {
    background: #e34c26;
    color: #fff;
}

/* Module links in sidebar */
.module-link {
    padding-left: var(--spacing-md);
    font-size: 0.78rem;
}

.module-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.module-link.active-module {
    color: #e34c26;
    font-weight: 500;
}

.module-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.module-dot--m0 { background: #e34c26; }
.module-dot--m1 { background: var(--text-tertiary); }
.module-dot--m2 { background: var(--text-tertiary); }
.module-dot--m3 { background: var(--text-tertiary); }

/* === Main Content === */
.module-main {
    flex: 1;
    margin-left: 280px;
    padding: var(--spacing-2xl) var(--spacing-3xl) var(--spacing-3xl);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.module-main > .lesson-card {
    width: 100%;
    max-width: 900px;
}

/* === Lesson Cards === */
.lesson-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl) var(--spacing-2xl);
    margin-bottom: var(--spacing-xl);
    transition: all var(--transition-smooth);
    width: 100%;
    max-width: 900px;
}

.lesson-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.lesson-card h2 {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.3;
}

.lesson-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--spacing-xl) 0 var(--spacing-md);
}

.lesson-card p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: var(--spacing-md);
}

.lesson-card ul, .lesson-card ol {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
    padding-left: 1.5rem;
    margin-bottom: var(--spacing-md);
}

.lesson-card li {
    margin-bottom: 0.3rem;
}

.lesson-card code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--bg-tertiary);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: #e34c26;
}

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

.lesson-card kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.1em 0.5em;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* === Diagram Boxes === */
.diagram-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    overflow-x: auto;
}

.diagram-title {
    font-size: 1rem !important;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--spacing-md) 0 !important;
    text-align: center;
}

/* === Journey Flow (Intro) === */
.journey-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: var(--spacing-sm) 0;
}

.journey-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 80px;
    max-width: 100px;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
    flex: 1 1 0;
}

.journey-step:hover {
    transform: translateY(-2px);
    border-color: #e34c26;
}

.journey-icon {
    font-size: 1.6rem;
}

.journey-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.3;
}

.journey-arrow {
    font-size: 1.1rem;
    color: var(--text-tertiary);
    font-weight: 700;
    flex-shrink: 0;
}

/* === Learning Objectives === */
.learning-objectives {
    background: rgba(227, 76, 38, 0.05);
    border: 1px solid rgba(227, 76, 38, 0.15);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: var(--spacing-md);
}

.learning-objectives h3 {
    font-size: 1rem;
    margin: 0 0 var(--spacing-sm) 0;
    color: #e34c26;
}

.learning-objectives ul {
    list-style: none;
    padding: 0;
}

.learning-objectives li {
    position: relative;
    padding-left: 1.5rem;
}

.learning-objectives li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #e34c26;
    font-weight: 700;
}

/* === URL Anatomy Visual === */
.url-anatomy-visual {
    text-align: center;
}

.url-full {
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.url-full code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.92rem;
    color: var(--text-primary);
    white-space: nowrap;
    background: none;
    padding: 0;
}

.url-parts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.url-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 2px solid;
}

.url-part-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.url-part code {
    font-size: 0.88rem;
    background: none;
    padding: 0;
}

.url-part--protocol { border-color: #22c55e; }
.url-part--protocol .url-part-label { color: #22c55e; }
.url-part--protocol code { color: #22c55e; }

.url-part--domain { border-color: #3b82f6; }
.url-part--domain .url-part-label { color: #3b82f6; }
.url-part--domain code { color: #3b82f6; }

.url-part--port { border-color: #a855f7; }
.url-part--port .url-part-label { color: #a855f7; }
.url-part--port code { color: #a855f7; }

.url-part--path { border-color: #f59e0b; }
.url-part--path .url-part-label { color: #f59e0b; }
.url-part--path code { color: #f59e0b; }

.url-part--query { border-color: #ec4899; }
.url-part--query .url-part-label { color: #ec4899; }
.url-part--query code { color: #ec4899; }

.url-part--fragment { border-color: #06b6d4; }
.url-part--fragment .url-part-label { color: #06b6d4; }
.url-part--fragment code { color: #06b6d4; }

/* === Info Table === */
.info-table {
    margin: var(--spacing-md) 0;
    overflow-x: auto;
}

.info-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.info-table th {
    text-align: left;
    padding: 0.65rem 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
}

.info-table td {
    padding: 0.6rem 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.info-table tr:hover td {
    background: var(--bg-secondary);
}

/* === Callout Boxes === */
.callout {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    font-size: 1rem;
    line-height: 1.7;
    border: 1px solid;
}

.callout-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.callout--tip {
    background: rgba(34, 197, 94, 0.06);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--text-secondary);
}
.callout--tip strong { color: #22c55e; }

.callout--info {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--text-secondary);
}
.callout--info strong { color: #3b82f6; }

.callout--warning {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--text-secondary);
}
.callout--warning strong { color: #f59e0b; }

/* === Client-Server Diagram === */
.cs-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-md) 0;
}

.cs-actor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 140px;
    text-align: center;
}

.cs-icon { font-size: 2.2rem; }

.cs-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.cs-desc {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.cs-arrows {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 120px;
}

.cs-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
}

.cs-arrow--request {
    color: #3b82f6;
}
.cs-arrow--response {
    color: #22c55e;
}

.cs-arrow-line {
    font-size: 1.5rem;
    letter-spacing: 0.3em;
}

/* === Two Column Info Cards === */
.two-column-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.info-card {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid;
}

.info-card h4 {
    font-size: 1.05rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.info-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-card li {
    font-size: 0.95rem;
    padding: 0.3rem 0;
    color: var(--text-secondary);
    padding-left: 1rem;
    position: relative;
}

.info-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    font-weight: 700;
}

.info-card--blue {
    background: rgba(59, 130, 246, 0.04);
    border-color: rgba(59, 130, 246, 0.15);
}
.info-card--blue li::before { color: #3b82f6; }

.info-card--orange {
    background: rgba(227, 76, 38, 0.04);
    border-color: rgba(227, 76, 38, 0.15);
}
.info-card--orange li::before { color: #e34c26; }

/* === DNS Flow === */
.dns-flow {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: var(--spacing-sm) 0;
    align-items: center;
}

.dns-step {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.65rem var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 420px;
    transition: border-color 0.2s;
}

.dns-step:hover {
    border-color: #3b82f6;
}

.dns-step--result {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
}

.dns-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    background: #3b82f6;
    color: #fff;
    flex-shrink: 0;
}

.dns-step--result .dns-step-number {
    background: #22c55e;
}

.dns-step-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dns-step-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.dns-connector {
    width: 2px;
    height: 16px;
    background: var(--border-color);
    flex-shrink: 0;
}

/* === HTTP Message === */
.http-message {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    line-height: 1.8;
}

.http-line {
    display: flex;
    gap: var(--spacing-sm);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.http-line:nth-child(odd) {
    background: var(--bg-card);
}

.http-label {
    font-weight: 600;
    min-width: 110px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.http-line code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: inherit;
}

.http-line--method code { color: #3b82f6; }
.http-line--url code { color: #f59e0b; }
.http-line--status code { color: #22c55e; }
.http-line--body code { color: #a855f7; font-size: 0.75rem; }

.http-message--response .http-line--status code {
    color: #22c55e;
    font-weight: 600;
}

/* === HTTP Methods Grid === */
.methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin: var(--spacing-sm) 0 var(--spacing-md);
}

.method-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.9rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.method-card code {
    font-weight: 700;
    font-size: 1rem;
    background: none;
    padding: 0;
}

.method-card--get { border-color: #3b82f6; }
.method-card--get code { color: #3b82f6; }

.method-card--post { border-color: #22c55e; }
.method-card--post code { color: #22c55e; }

.method-card--put { border-color: #f59e0b; }
.method-card--put code { color: #f59e0b; }

.method-card--delete { border-color: #ef4444; }
.method-card--delete code { color: #ef4444; }

/* === Status Codes Grid === */
.status-grid {
    display: grid;
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.status-group {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid;
}

.status-group h4 {
    font-size: 1rem;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.status-item code {
    font-weight: 700;
    min-width: 36px;
}

.status-item--highlight {
    font-weight: 500;
    color: var(--text-primary);
}

.status-group--1xx { background: rgba(148,163,184,0.05); border-color: rgba(148,163,184,0.2); }
.status-group--1xx h4 { color: #94a3b8; }
.status-group--1xx code { color: #94a3b8; }

.status-group--2xx { background: rgba(34,197,94,0.05); border-color: rgba(34,197,94,0.2); }
.status-group--2xx h4 { color: #22c55e; }
.status-group--2xx code { color: #22c55e; }

.status-group--3xx { background: rgba(59,130,246,0.05); border-color: rgba(59,130,246,0.2); }
.status-group--3xx h4 { color: #3b82f6; }
.status-group--3xx code { color: #3b82f6; }

.status-group--4xx { background: rgba(239,68,68,0.05); border-color: rgba(239,68,68,0.2); }
.status-group--4xx h4 { color: #ef4444; }
.status-group--4xx code { color: #ef4444; }

.status-group--5xx { background: rgba(168,85,247,0.05); border-color: rgba(168,85,247,0.2); }
.status-group--5xx h4 { color: #a855f7; }
.status-group--5xx code { color: #a855f7; }

/* === DevTools Grid === */
.devtools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.devtools-card {
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}

.devtools-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.devtools-card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.devtools-card h4 {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.devtools-card p {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    line-height: 1.6;
    margin: 0;
}

/* === Try It Box === */
.try-it-box {
    background: linear-gradient(135deg, rgba(227,76,38,0.06), rgba(38,77,228,0.06));
    border: 1px solid rgba(227, 76, 38, 0.2);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: var(--spacing-md);
}

.try-it-box h4 {
    color: #e34c26;
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
}

.try-it-box ol {
    margin: 0;
    padding-left: 1.3rem;
}

.try-it-box li {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

/* === Summary Grid === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.summary-item {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}

.summary-item:hover {
    border-color: var(--border-hover);
}

.summary-emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.summary-item strong {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.summary-item p {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    line-height: 1.6;
    margin: 0;
}

/* === Next Module Box === */
.next-module-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    background: linear-gradient(135deg, rgba(227,76,38,0.08), rgba(38,77,228,0.08));
    border: 1px solid rgba(227, 76, 38, 0.2);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.3s;
}

.next-module-box:hover {
    transform: translateY(-2px);
    border-color: #e34c26;
}

.next-module-label {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e34c26;
    margin-bottom: 0.3rem;
}

.next-module-content h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--text-primary);
    margin: 0 0 0.4rem 0;
}

.next-module-content p {
    font-size: 1rem;
    color: var(--text-tertiary);
    margin: 0;
    line-height: 1.6;
}

.next-module-arrow {
    font-size: 2rem;
    color: #e34c26;
    flex-shrink: 0;
    margin-left: var(--spacing-md);
}

/* === Mobile Sidebar Toggle === */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e34c26, #264de4);
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 99;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.sidebar-mobile-toggle:hover {
    transform: scale(1.1);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-backdrop.visible {
    display: block;
    opacity: 1;
}

/* ===================================
   HTTP SIMULATION
   =================================== */

/* SVG theme variables */
:root {
    --svg-node-bg: #0e1326;
    --svg-node-stroke: #233045;
    --svg-node-hover: rgba(26, 29, 50, 0.9);
    --svg-node-stroke-hover: #3a4470;
    --svg-text: #e6eaff;
    --svg-text-muted: #dde3f7;
    --svg-legend-bg: rgba(23, 26, 43, 0.9);
    --http-req-color: #4da3ff;
    --http-res-color: #5be37d;
}

[data-theme="light"] {
    --svg-node-bg: #ffffff;
    --svg-node-stroke: #94a3b8;
    --svg-node-hover: #f1f5f9;
    --svg-node-stroke-hover: #2563eb;
    --svg-text: #1e293b;
    --svg-text-muted: #64748b;
    --svg-legend-bg: rgba(248, 250, 252, 0.98);
}

/* Figure container */
.http-figure {
    display: block;
    margin: 1rem 0 0;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card, #0e1326);
    position: relative;
}

[data-theme="light"] .http-figure {
    background: #ffffff !important;
    border-color: rgba(74, 124, 212, 0.15) !important;
}

#http-topology-caption {
    position: static;
    display: block;
    opacity: 1;
    margin-top: 0.75rem;
    font-size: 0.9em;
    font-style: italic;
    color: var(--text-tertiary) !important;
    width: 100%;
    left: 0;
    text-align: justify;
}

[data-theme="light"] #http-topology-caption {
    color: #4b5563 !important;
}

.http-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.http-svg .popover { pointer-events: all; }
.http-svg .sim-overlay { overflow: visible; }

.http-stage {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
}

.http-canvas { min-width: 0; }

/* Simulation controls */
.sim-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0.5rem 0 0.5rem;
    flex-wrap: wrap;
}

.sim-controls label {
    color: var(--text-tertiary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sim-controls select {
    appearance: none;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}

.sim-controls button {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.sim-controls button:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.sim-controls .spacer { flex: 1 1 auto; }

[data-theme="light"] .sim-controls button {
    background: linear-gradient(180deg, #ffffff, #f1f5f9);
    color: #374151;
    border-color: rgba(74, 124, 212, 0.25);
}

[data-theme="light"] .sim-controls button:hover {
    background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
    border-color: #4a7cd4;
    color: #4a7cd4;
}

[data-theme="light"] .sim-controls select {
    background: #ffffff;
    color: #374151;
    border-color: rgba(74, 124, 212, 0.25);
}

[data-theme="light"] .sim-controls label {
    color: #4b5563;
}

/* Simulation caption HUD */
.sim-caption {
    position: absolute;
    left: auto;
    top: 10px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 14.5px;
    font-weight: 600;
    pointer-events: none;
    z-index: 2;
    max-width: 360px;
}

[data-theme="light"] .sim-caption {
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(74, 124, 212, 0.2);
    color: #374151;
}

.http-figure .http-svg {
    margin-top: 42px;
}

/* SVG light theme node overrides */
[data-theme="light"] .http-svg .node {
    fill: #ffffff !important;
    stroke: rgba(74, 124, 212, 0.3) !important;
}

[data-theme="light"] .http-svg .node:hover {
    fill: #f8fafc !important;
    stroke: #4a7cd4 !important;
}

[data-theme="light"] .http-svg .label {
    fill: #1a1a2e !important;
}

[data-theme="light"] .http-svg .small {
    fill: #4b5563 !important;
}

[data-theme="light"] .http-svg text {
    fill: #1a1a2e;
}

[data-theme="light"] .http-svg .legend rect {
    fill: rgba(248, 250, 252, 0.95) !important;
    stroke: rgba(74, 124, 212, 0.2) !important;
}

/* Envelope (request/response packet) */
.http-svg .envelope { cursor: pointer; }
.http-svg .envelope .click-area { pointer-events: all; cursor: pointer; }
.http-svg .envelope .inner { pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.15s ease, filter 0.15s ease; }
.http-svg .envelope .body { pointer-events: none; }
.http-svg .envelope .flap { pointer-events: none; }

.http-svg .envelope .inner.appear {
    animation: env-pop 460ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.http-svg .envelope.docked .inner { transform: scale(1.75); }
.http-svg .envelope.docked.hover .inner { transform: scale(1.8); }

.http-svg .envelope.hover .inner {
    transform: scale(1.05);
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}

.http-svg .envelope.pinned .inner {
    animation: pulse-pin 1.5s ease-in-out infinite;
}

@keyframes pulse-pin {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.http-svg .envelope rect.body {
    fill: rgba(15, 18, 32, 0.95);
    stroke: currentColor;
    stroke-width: 1.5;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

[data-theme="light"] .http-svg .envelope rect.body {
    fill: rgba(255, 255, 255, 0.98);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.http-svg .envelope path.flap { fill: currentColor; opacity: 0.85; }
.http-svg .envelope .env-icon { opacity: 0.9; }
.http-svg .envelope.req { color: var(--http-req-color, #4da3ff); }
.http-svg .envelope.res { color: var(--http-res-color, #5be37d); }

@keyframes env-pop {
    0% { opacity: 0; transform: scale(0.5) rotate(-12deg); filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
    60% { opacity: 1; transform: scale(1.12) rotate(3deg); filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.4)); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35)); }
}

/* Construction spinner */
.http-svg .spinner { pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; animation: sim-spin 0.8s linear infinite; }
.http-svg .spinner .ring-bg { fill: none; stroke: rgba(230, 234, 255, 0.2); stroke-width: 1.6; }
.http-svg .spinner .ring-fg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 16 20; opacity: 0.9; }

@keyframes sim-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Flow visibility */
.http-svg .flow { transition: stroke-width 0.15s ease, opacity 0.15s ease; }
.http-svg .flow:hover { opacity: 0.95; }
.http-figure.flows-on-use .flow-label { display: none; }
.http-figure.flows-on-use .flow { opacity: 0 !important; pointer-events: none; }
.http-figure.flows-on-use .flow.active { opacity: 1 !important; pointer-events: auto; }
.http-figure.flows-on-use svg.http-svg:hover .flow.active { opacity: 1 !important; }
.http-figure.flows-on-use svg.http-svg:hover .flow:not(.active) { opacity: 0 !important; }
.http-figure.flows-on-use .legend .flow { opacity: 1 !important; pointer-events: auto; }

/* Node pulse animation */
@keyframes glowPulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(122, 162, 255, 0)); }
    50% { filter: drop-shadow(0 0 14px rgba(122, 162, 255, 0.7)); }
}

.http-svg .pulse rect {
    stroke: #3b82f6;
    stroke-width: 2.5;
    animation: glowPulse 0.8s ease-in-out infinite alternate;
}

/* HTML Popover */
.http-popover {
    position: fixed;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    background: rgba(15, 18, 32, 0.98);
    border: 2px solid #4a5578;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    cursor: move;
    z-index: 999999;
    pointer-events: all;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: #c7d0e8;
    font-size: 12px;
    line-height: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

[data-theme="light"] .http-popover {
    background: rgba(255, 255, 255, 0.98);
    border-color: #cbd5e1;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    color: #1e293b;
}

.http-popover .popover-accent {
    position: absolute; top: 0; left: 0; right: 0;
    height: 4px; border-radius: 12px 12px 0 0;
}

.http-popover .popover-accent.req { background: #4da3ff; }
.http-popover .popover-accent.res { background: #5be37d; }

.http-popover .popover-close {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.1); border: none;
    color: white; font-size: 20px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}

[data-theme="light"] .http-popover .popover-close {
    background: rgba(0, 0, 0, 0.05); color: #1e293b;
}

.http-popover .popover-close:hover {
    background: rgba(255, 59, 48, 0.8) !important;
    color: white !important;
}

.http-popover .popover-content {
    margin-top: 12px; pointer-events: none;
    max-width: 100%; overflow-x: auto;
}

.http-popover .popover-title {
    color: white; font-size: 14px; font-weight: 700;
    margin-bottom: 8px; padding-right: 30px;
}

[data-theme="light"] .http-popover .popover-title { color: #0f172a; }

.http-popover .popover-line {
    white-space: pre-wrap; word-break: break-word; margin-bottom: 2px;
}

.http-popover .popover-line.empty { height: 12px; }

/* Responsive simulation adjustments */
@media (max-width: 640px) {
    .http-figure { padding: 0.75rem; }
    .http-figure .http-svg { margin-top: 56px; }
    .http-svg .label { font-size: 14px !important; }
    .http-svg .small { font-size: 11px !important; }
}

/* ===================================
   RESPONSIVE BREAKPOINTS
   =================================== */

/* <= 1200px: Narrower sidebar */
@media (max-width: 1200px) {
    .module-sidebar { width: 250px; }
    .module-main {
        margin-left: 250px;
        padding: var(--spacing-xl) var(--spacing-2xl) var(--spacing-3xl);
    }
}

/* <= 900px: Sidebar goes offscreen (mobile drawer) */
@media (max-width: 900px) {
    .module-sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 200;
        box-shadow: var(--shadow-lg);
    }
    .module-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn { display: block; }

    .sidebar-mobile-toggle {
        display: flex;
    }

    .module-main {
        margin-left: 0;
        padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-3xl);
    }

    .module-main > .lesson-card {
        max-width: 100%;
    }
}

/* <= 768px: Tighter content */
@media (max-width: 768px) {
    .module-header-bar {
        padding: var(--spacing-md) 0 var(--spacing-sm);
        margin-top: 60px;
    }

    .lesson-card {
        padding: var(--spacing-md);
        border-radius: var(--radius-md);
    }

    .journey-flow {
        flex-direction: column;
        gap: 0.2rem;
    }
    .journey-arrow {
        transform: rotate(90deg);
    }
    .journey-step {
        flex-direction: row;
        min-width: auto;
        max-width: 220px;
        width: 100%;
    }

    .cs-diagram {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    .cs-arrows {
        flex-direction: row;
        gap: var(--spacing-md);
        min-width: auto;
    }
    .cs-arrow--request .cs-arrow-line { transform: rotate(90deg); }
    .cs-arrow--response .cs-arrow-line { transform: rotate(90deg); }

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

    .url-parts {
        flex-direction: column;
        align-items: center;
    }

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

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

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

    .http-label {
        min-width: 80px;
        font-size: 0.7rem;
    }

    .next-module-box {
        flex-direction: column;
        text-align: center;
    }
    .next-module-arrow {
        margin: var(--spacing-sm) 0 0 0;
        transform: rotate(90deg);
    }
}

/* <= 480px: Compact everything */
@media (max-width: 480px) {
    .module-main {
        padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-xl);
    }

    .lesson-card {
        padding: var(--spacing-sm);
    }

    .diagram-box {
        padding: var(--spacing-sm);
    }

    .info-table td,
    .info-table th {
        padding: 0.4rem;
        font-size: 0.78rem;
    }
}
