/* ============================================
   CHARLES BABBAGE - Father of Computing
   The Irascible Genius
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@300;400&family=Playfair+Display:ital,wght@0,400;0,700;1,400&display=swap');

/* === Babbage-specific palette — Brass & Steam === */
:root {
    --bb-ink: #1a1510;
    --bb-parchment: #f5efe4;
    --bb-brass: #c9a040;
    --bb-copper: #b87333;
    --bb-steel: #7b8794;
    --bb-steam: #e8dcc8;
    --bb-teal: #3a7d7d;
    --bb-crimson: #a0373f;
    --bb-sepia: #8b7355;
    --bb-gear: #d4a853;
    --bb-dark-bg: #0d0b08;
}

[data-theme="light"] {
    --bb-ink: #2d2520;
    --bb-dark-bg: #fdf9f3;
}

/* === Main Container === */
.bb-page {
    padding-top: 80px;
    min-height: 100vh;
}

.bb-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* === Hero Section === */
.bb-hero {
    text-align: center;
    padding: var(--space-xl) 0;
    position: relative;
}

.bb-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--bb-brass), transparent);
}

.bb-pretitle {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--bb-brass);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-bottom: var(--space-sm);
}

.bb-hero-portrait {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bb-brass);
    box-shadow: 0 0 40px rgba(201, 160, 64, 0.2);
    margin: var(--space-md) 0;
}

.bb-hero-gears {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    margin: var(--space-md) auto;
    border: 3px solid var(--bb-brass);
    background: linear-gradient(135deg, #1a1510 0%, #2a2015 50%, #1a1510 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    box-shadow: 0 0 40px rgba(201, 160, 64, 0.2);
}

.bb-name {
    font-family: 'Playfair Display', 'EB Garamond', serif;
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: var(--space-sm) 0;
    background: linear-gradient(135deg, var(--bb-brass) 0%, var(--bb-copper) 50%, var(--bb-gear) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bb-subtitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--bb-brass);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.bb-years {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.bb-key-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.bb-fact {
    text-align: center;
}

.bb-fact-icon {
    font-size: 1.5rem;
    margin-bottom: var(--space-xs);
}

.bb-fact-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--bb-brass);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.bb-fact-value {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 2px;
}

/* === Recommendation Quote === */
.bb-recommendation {
    background: linear-gradient(135deg, rgba(201, 160, 64, 0.05) 0%, rgba(184, 115, 51, 0.05) 100%);
    border: 1px solid rgba(201, 160, 64, 0.15);
    border-radius: 12px;
    padding: var(--space-lg);
    margin: var(--space-lg) 0;
    position: relative;
}

.bb-recommendation::before {
    content: '📖';
    position: absolute;
    top: -12px;
    left: 20px;
    font-size: 1.5rem;
    background: var(--bg-primary);
    padding: 0 8px;
}

.bb-recommendation-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--bb-brass);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: var(--space-sm);
}

.bb-recommendation p {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    line-height: 1.9;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.bb-recommendation strong {
    color: var(--bb-brass);
}

/* === Section Styles === */
.bb-section {
    margin: var(--space-xl) 0;
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border-default);
}

.bb-section-label {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--bb-brass);
    background: rgba(201, 160, 64, 0.08);
    padding: 4px 12px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: var(--space-md);
}

.bb-section-title {
    font-family: 'Playfair Display', 'EB Garamond', serif;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 600;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.bb-section-lead {
    font-family: 'EB Garamond', serif;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

/* === Timeline === */
.bb-timeline {
    position: relative;
    padding-left: 20px;
}

.bb-timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--bb-brass), var(--bb-copper), var(--bb-steel));
}

.bb-timeline-item {
    position: relative;
    padding: var(--space-sm) 0 var(--space-sm) var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.bb-timeline-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 18px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bb-steel);
    border: 2px solid var(--bg-primary);
}

.bb-timeline-item.highlight::before {
    background: var(--bb-brass);
    box-shadow: 0 0 8px rgba(201, 160, 64, 0.5);
    width: 10px;
    height: 10px;
    left: -25px;
}

.bb-timeline-year {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--bb-brass);
    font-weight: 600;
    margin-right: var(--space-sm);
}

.bb-timeline-age {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--bb-copper);
    margin-right: var(--space-sm);
}

.bb-timeline-text {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.bb-timeline-text strong {
    color: var(--bb-brass);
}

/* === Biography === */
.bb-bio {
    font-family: 'EB Garamond', serif;
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-secondary);
}

.bb-bio p {
    margin-bottom: var(--space-md);
}

.bb-bio strong {
    color: var(--text-primary);
}

.bb-bio a {
    color: var(--bb-brass);
    text-decoration: none;
    border-bottom: 1px dotted var(--bb-brass);
    transition: border-color 0.3s;
}

.bb-bio a:hover {
    border-bottom-style: solid;
}

/* === Quote === */
.bb-quote {
    border-left: 3px solid var(--bb-brass);
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-lg) 0;
    font-family: 'EB Garamond', serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.8;
    color: var(--text-secondary);
    background: rgba(201, 160, 64, 0.03);
    border-radius: 0 8px 8px 0;
}

.bb-quote cite {
    display: block;
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--bb-sepia);
    font-style: normal;
}

/* === Works / Writings Grid === */
.bb-works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.bb-work-card {
    background: rgba(201, 160, 64, 0.03);
    border: 1px solid rgba(201, 160, 64, 0.12);
    border-radius: 12px;
    padding: var(--space-md);
    transition: transform 0.3s, box-shadow 0.3s;
}

.bb-work-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(201, 160, 64, 0.1);
}

.bb-work-year {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--bb-copper);
    letter-spacing: 0.1em;
}

.bb-work-title {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 600;
    margin: var(--space-xs) 0;
    color: var(--bb-brass);
}

.bb-work-desc {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* === Machine Grid === */
.bb-machine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.bb-machine-card {
    background: linear-gradient(135deg, rgba(201, 160, 64, 0.05) 0%, rgba(184, 115, 51, 0.03) 100%);
    border: 1px solid rgba(201, 160, 64, 0.15);
    border-radius: 12px;
    padding: var(--space-lg);
    text-align: center;
}

.bb-machine-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.bb-machine-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bb-brass);
    margin-bottom: var(--space-xs);
}

.bb-machine-subtitle {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--bb-copper);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: var(--space-sm);
}

.bb-machine-desc {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* === Specs Table === */
.bb-specs-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-lg) 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.bb-specs-table th {
    text-align: left;
    padding: 10px 14px;
    background: rgba(201, 160, 64, 0.08);
    color: var(--bb-brass);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.7rem;
    border-bottom: 2px solid rgba(201, 160, 64, 0.2);
}

.bb-specs-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.bb-specs-table tr:hover td {
    background: rgba(201, 160, 64, 0.03);
}

/* === Insights / Philosophy === */
.bb-insights {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.bb-insight {
    background: rgba(201, 160, 64, 0.03);
    border: 1px solid rgba(201, 160, 64, 0.1);
    border-radius: 10px;
    padding: var(--space-md);
}

.bb-insight-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--bb-brass);
    margin-bottom: var(--space-xs);
    font-weight: 600;
}

.bb-insight-text {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* === Chapter Grid (Autobiography) === */
.bb-chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-sm);
    margin: var(--space-lg) 0;
}

.bb-chapter {
    background: rgba(201, 160, 64, 0.02);
    border: 1px solid rgba(201, 160, 64, 0.08);
    border-radius: 8px;
    padding: var(--space-sm) var(--space-md);
}

.bb-chapter-num {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--bb-copper);
}

.bb-chapter-title {
    font-family: 'EB Garamond', serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-top: 2px;
}

.bb-chapter-desc {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === Difference Engine Visualization === */
.bb-diff-demo {
    background: rgba(201, 160, 64, 0.03);
    border: 1px solid rgba(201, 160, 64, 0.1);
    border-radius: 12px;
    padding: var(--space-lg);
    margin: var(--space-lg) 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    overflow-x: auto;
}

.bb-diff-demo table {
    width: 100%;
    border-collapse: collapse;
}

.bb-diff-demo th,
.bb-diff-demo td {
    padding: 8px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(201, 160, 64, 0.08);
}

.bb-diff-demo th {
    color: var(--bb-brass);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.bb-diff-demo td {
    color: var(--text-secondary);
}

.bb-diff-demo .constant {
    color: var(--bb-brass);
    font-weight: 600;
}

/* === Meta Question Box === */
.bb-meta-question {
    background: linear-gradient(135deg, rgba(201, 160, 64, 0.08) 0%, rgba(58, 125, 125, 0.05) 100%);
    border: 2px solid rgba(201, 160, 64, 0.2);
    border-radius: 16px;
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    text-align: center;
}

.bb-meta-question h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: var(--bb-brass);
    margin-bottom: var(--space-md);
}

.bb-meta-question p {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* === References === */
.bb-references {
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    border-top: 1px solid var(--border-default);
}

.bb-references-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--bb-sepia);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: var(--space-md);
}

.bb-references-list {
    list-style: none;
    padding: 0;
}

.bb-references-list li {
    margin-bottom: var(--space-xs);
}

.bb-references-list a {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--bb-brass);
    text-decoration: none;
    border-bottom: 1px dotted var(--bb-brass);
}

.bb-references-list a:hover {
    border-bottom-style: solid;
}

/* === Footer === */
.bb-footer {
    text-align: center;
    padding: var(--space-xl) 0;
    margin-top: var(--space-xl);
    border-top: 1px solid var(--border-default);
}

.bb-footer-memorial {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-muted);
}

.bb-footer-meta {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: var(--space-md);
    letter-spacing: 0.1em;
}

/* === Collapsible Sections === */
.bb-collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: var(--space-md);
    background: rgba(201, 160, 64, 0.03);
    border: 1px solid rgba(201, 160, 64, 0.1);
    border-radius: 8px;
    margin-bottom: var(--space-sm);
    transition: background 0.3s;
}

.bb-collapsible-header:hover {
    background: rgba(201, 160, 64, 0.06);
}

.bb-collapsible-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    color: var(--bb-brass);
    font-weight: 600;
    margin: 0;
}

.bb-collapsible-toggle {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--bb-copper);
    transition: transform 0.3s;
}

.bb-collapsible-body {
    display: none;
    padding: var(--space-md);
    animation: slideDown 0.3s ease;
}

.bb-collapsible-body.open {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    .bb-container {
        padding: 0 var(--space-md);
    }

    .bb-key-facts {
        grid-template-columns: repeat(2, 1fr);
    }

    .bb-works-grid,
    .bb-machine-grid {
        grid-template-columns: 1fr;
    }

    .bb-chapter-grid {
        grid-template-columns: 1fr;
    }
}