/* Story-specific styles */
:root {
    /* Elegant Warm Red-Green Theme */
    --primary: #d63384; /* Elegant rose/magenta */
    --primary-dark: #b02a5f; /* Deeper rose */
    --primary-light: #e85d9f; /* Lighter rose */
    --accent: #20c997; /* Teal green accent */
    --accent-dark: #1aa179; /* Deeper teal */
    --accent-light: #3dd5a8; /* Lighter teal */
    --bg-dark: #0d0a0b; /* Deep dark with subtle warm tone */
    --bg-card: #181315; /* Card background with warm undertone */
    --bg-elevated: #221b1e; /* Elevated elements */
    --text-primary: #f8f0f2; /* Soft warm light text */
    --text-secondary: #d9b8c1; /* Warm secondary text */
    --text-muted: #9d7a85; /* Warm muted text */
    --border: #2a1f23; /* Warm border */
    --border-light: #352a2e; /* Lighter warm border */
    --shadow: 0 4px 6px -1px rgba(214, 51, 132, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(214, 51, 132, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --gradient: linear-gradient(135deg, #d63384 0%, #20c997 100%); /* Rose to teal gradient */
}

.story-container {
    display: flex;
    min-height: 100vh;
    background: var(--bg-dark);
}

.story-nav {
    width: 300px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.story-progress {
    margin-bottom: 2rem;
}

.progress-bar {
    background: var(--bg-elevated);
    height: 4px;
    border-radius: 2px;
    margin-bottom: 2rem;
    position: relative;
}

.progress-fill {
    background: var(--primary);
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 20%;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.progress-step:hover {
    background: var(--bg-elevated);
}

.progress-step.active {
    background: rgba(214, 51, 132, 0.1);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.progress-step.active .step-number {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.step-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-step.active .step-label {
    color: var(--text-primary);
}

.story-content {
    flex: 1;
    margin-left: 300px;
    padding: 2rem;
    background: var(--bg-dark);
    color: var(--text-primary);
}

.story-section {
    display: none;
    max-width: 800px;
    margin: 0 auto;
}

.story-section.active {
    display: block;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.section-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

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

.section-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.section-content h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

.section-content p {
    font-size: 1.125rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    color: var(--gray);
}

/* Business Metrics */
.business-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.metric-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Code Blocks */
.code-block {
    background: #1a1b26;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #16161e;
    color: #a9b1d6;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
}

.copy-btn {
    background: none;
    border: none;
    color: #a9b1d6;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.copy-btn:hover {
    background: #2a2b3a;
}

pre {
    margin: 0;
    padding: 1.5rem;
    color: #c0caf5;
    font-family: 'Monaco', 'Consolas', monospace;
    line-height: 1.5;
    overflow-x: auto;
    font-size: 0.875rem;
}

/* Architecture Diagrams */
.architecture-diagram {
    margin: 2rem 0;
}

.diagram {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.diagram-title {
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.diagram-flow {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.diagram-node {
    background: var(--bg-elevated);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    border: 2px solid var(--border);
    min-width: 120px;
    color: var(--text-primary);
}

.diagram-node.problem {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.diagram-node.success {
    border-color: var(--accent);
    background: rgba(6, 182, 212, 0.1);
}

.diagram-arrow {
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-weight: bold;
}

/* Problem List */
.problem-list {
    margin: 2rem 0;
}

.problem-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.problem-icon {
    font-size: 1.25rem;
}

.problem-content {
    flex: 1;
}

/* Solution Features */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.feature-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Business Impact */
.business-impact {
    margin: 2rem 0;
}

.impact-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.impact-metric {
    text-align: center;
    padding: 1.5rem;
}

.impact-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.impact-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Code Tabs */
.code-tabs {
    margin: 2rem 0;
}

.tab-buttons {
    display: flex;
    background: var(--bg-elevated);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab-button {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.tab-button:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-button.active {
    background: #1a1b26;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Download Section */
.download-section {
    background: rgba(6, 182, 212, 0.1);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--accent);
    margin: 2rem 0;
    text-align: center;
}

.download-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Results Showcase */
.results-showcase {
    display: grid;
    gap: 1.5rem;
    margin: 2rem 0;
}

.result-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.result-icon {
    font-size: 3rem;
}

.result-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.result-content p {
    margin: 0;
    color: var(--text-secondary);
}

/* Production Secrets */
.production-secrets {
    margin: 3rem 0;
}

.secrets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.secret-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

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

.secret-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.secret-header h4 {
    margin: 0;
    color: var(--text-primary);
}

.secret-indicator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.secret-content {
    display: none;
    color: var(--text-secondary);
    line-height: 1.6;
}

.secret-card.revealed .secret-content {
    display: block;
}

.secret-card.revealed .secret-indicator {
    display: none;
}

/* CTA Section */
.cta-section {
    background: var(--bg-card);
    border: 1px solid var(--primary);
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    color: var(--text-primary);
    margin: 3rem 0;
}

.cta-section h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.cta-section p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.cta-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Navigation Actions */
.navigation-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    .story-container {
        flex-direction: column;
    }
    
    .story-nav {
        position: static;
        width: 100%;
        height: auto;
    }
    
    .story-content {
        margin-left: 0;
    }
    
    .progress-steps {
        flex-direction: row;
        overflow-x: auto;
    }
    
    .progress-step {
        flex-direction: column;
        text-align: center;
        min-width: 80px;
    }
    
    .step-label {
        font-size: 0.75rem;
    }
    
    .diagram-flow {
        flex-direction: column;
    }
    
    .diagram-arrow {
        transform: rotate(90deg);
    }
    
    .navigation-actions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .cta-actions {
        flex-direction: column;
    }
}

/* Stories Navigation Sidebar */
.stories-sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.stories-sidebar.open {
    left: 0;
}

/* When sidebar is present, adjust story content */
body:has(.stories-sidebar) .story-content {
    padding-left: 1rem;
}

/* On desktop, show sidebar by default (only on saga landing pages) */
@media (min-width: 769px) {
    .stories-sidebar {
        left: 0;
    }
    
    /* Story pages should NOT have sidebar, only progress bar */
    /* The sidebar is only shown on saga landing pages via JavaScript */
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--bg-card);
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sidebar-content {
    padding: 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.sidebar-link:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    transform: translateX(4px);
}

.sidebar-link.active {
    background: rgba(214, 51, 132, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: calc(1rem - 3px);
}

.sidebar-link.saga-link {
    font-weight: 600;
    color: var(--primary);
}

.sidebar-link.back-link {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.link-icon {
    font-size: 1.125rem;
    display: flex;
    align-items: center;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.sidebar-stories {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.story-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.sidebar-link.active .story-number {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.story-name {
    flex: 1;
}

/* Breadcrumbs */
.breadcrumbs {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s;
}

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

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: var(--text-muted);
}

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

/* Story Navigation Footer (Previous/Next) */
.story-nav-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 2rem;
    margin-top: 4rem;
}

.story-nav-footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s;
    flex: 1;
    max-width: 400px;
}

.nav-link:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.nav-link.prev-link {
    text-align: left;
}

.nav-link.next-link {
    text-align: right;
    flex-direction: row-reverse;
}

.nav-link-content {
    flex: 1;
}

.nav-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.nav-title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-arrow {
    font-size: 1.5rem;
    color: var(--primary);
    flex-shrink: 0;
}

.nav-link-spacer {
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .stories-sidebar {
        width: 280px;
        left: -280px;
    }
    
    .breadcrumbs {
        padding: 0.75rem 1rem;
        font-size: 0.8125rem;
    }
    
    .story-nav-footer {
        padding: 1.5rem 1rem;
    }
    
    .story-nav-footer-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-link {
        max-width: 100%;
    }
    
    .nav-link.next-link {
        flex-direction: row;
        text-align: left;
    }
    
    /* Add padding to story content when sidebar is open on mobile */
    body:has(.stories-sidebar.open) .story-content {
        margin-left: 0;
    }
}

/* Desktop: Hide toggle button */
@media (min-width: 769px) {
    .sidebar-toggle {
        display: none;
    }
}
