/* tanso.wiki - Carbon Science Encyclopedia */
/* Palette: #2C2C2C Carbon Text, #5A5A5A Light Ink, #FCFCFC Open White, #F7F7F7 Soft Gray,
   #FFFFFF Pure White, #1976D2 Reference Blue, #E8F0FE Blue Tint, #E0E0E0 Divider Gray */
/* Fonts: Lora (headings), Source Sans Pro (body), IBM Plex Mono (formulas/code) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: #FCFCFC;
    color: #2C2C2C;
    font-family: 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.8;
}

/* ===== STICKY HEADER ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #FCFCFC;
    border-bottom: 1px solid #E0E0E0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s ease;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: #2C2C2C;
    letter-spacing: -0.01em;
}

.site-title-dot {
    color: #1976D2;
}

.header-nav {
    display: flex;
    gap: 1.5rem;
}

.header-link {
    font-size: 0.88rem;
    color: #5A5A5A;
    text-decoration: none;
    transition: color 0.2s ease;
}

.header-link:hover {
    color: #1976D2;
}

/* ===== HERO / PORTAL ZONE ===== */
.hero {
    max-width: 680px;
    margin: 0 auto;
    padding: 4rem 2rem 2.5rem;
    text-align: center;
}

.hero-inner {
    max-width: 100%;
}

.hero-heading {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 2rem;
    color: #2C2C2C;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.hero-sub {
    font-size: 1.05rem;
    color: #5A5A5A;
    margin-bottom: 1.75rem;
    line-height: 1.6;
}

.search-wrapper {
    position: relative;
    max-width: 520px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-bar {
    width: 100%;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 1rem;
    color: #2C2C2C;
    outline: none;
    background: #FFFFFF;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar:focus {
    border-color: #1976D2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.search-bar::placeholder {
    color: #5A5A5A;
    opacity: 0.7;
}

/* Category Pills */
.category-pills {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.pill {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.85rem;
    color: #1976D2;
    background: #E8F0FE;
    padding: 0.35rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.pill:hover {
    background: #1976D2;
    color: #FFFFFF;
}

.pill.active {
    background: #1976D2;
    color: #FFFFFF;
}

/* ===== ARTICLE LAYOUT ===== */
.article-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.article-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 2.5rem;
}

/* Floating Mini-TOC Sidebar */
.toc-sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
    background: #F7F7F7;
    padding: 1.25rem;
    border-radius: 6px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: opacity 0.3s ease;
}

.toc-heading {
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: #2C2C2C;
    display: block;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toc-list {
    list-style: none;
}

.toc-item {
    font-size: 0.85rem;
    color: #5A5A5A;
    padding: 0.3rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.toc-item a {
    color: inherit;
    text-decoration: none;
}

.toc-item:hover {
    color: #1976D2;
}

.toc-item.active {
    color: #1976D2;
    font-weight: 600;
}

.toc-marker {
    width: 5px;
    height: 5px;
    background: transparent;
    display: inline-block;
    flex-shrink: 0;
    border-radius: 0;
    transition: background 0.2s ease;
}

.toc-item.active .toc-marker {
    background: #1976D2;
}

/* Article Content */
.article-content {
    max-width: 680px;
}

/* Quality Bar */
.quality-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid #E0E0E0;
}

.quality-label {
    font-size: 0.8rem;
    color: #1976D2;
    font-weight: 600;
}

.quality-date {
    font-size: 0.8rem;
    color: #5A5A5A;
}

/* Article Headings */
.article-heading {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: #2C2C2C;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid #E0E0E0;
    scroll-margin-top: 80px;
}

.article-heading:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Article Text */
.article-text {
    font-size: 1.05rem;
    color: #2C2C2C;
    margin-bottom: 1.1rem;
    line-height: 1.8;
}

.article-text strong {
    font-weight: 600;
    color: #2C2C2C;
}

.article-text em {
    font-style: italic;
    color: #5A5A5A;
}

/* Chemical Formulas */
.formula {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.92em;
    color: #2C2C2C;
    background: #F7F7F7;
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

.element {
    font-variant: small-caps;
}

/* Figure Blocks */
.figure-block {
    border: 1px solid #E0E0E0;
    padding: 1.25rem;
    margin: 1.75rem 0;
    background: #FFFFFF;
    border-radius: 4px;
}

.diagram-svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.figure-caption {
    font-size: 0.82rem;
    color: #5A5A5A;
    display: block;
    text-align: center;
    margin-top: 0.75rem;
    font-style: italic;
}

/* Citations */
.citation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72em;
    color: #1976D2;
    cursor: pointer;
    text-decoration: none;
    vertical-align: super;
    line-height: 0;
    padding: 0 0.15em;
    transition: color 0.15s ease;
    position: relative;
}

.citation:hover {
    color: #FFFFFF;
    background: #1976D2;
    border-radius: 2px;
}

/* Citation Tooltip */
.citation-tooltip {
    position: fixed;
    z-index: 200;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    max-width: 380px;
    font-size: 0.82rem;
    color: #2C2C2C;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.citation-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Glossary Tooltips (inline) */
.glossary-term {
    color: #2C2C2C;
    border-bottom: 1px dashed #1976D2;
    cursor: help;
    position: relative;
}

.glossary-tooltip {
    position: fixed;
    z-index: 200;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-left: 3px solid #1976D2;
    border-radius: 4px;
    padding: 0.6rem 0.9rem;
    max-width: 320px;
    font-size: 0.82rem;
    color: #5A5A5A;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.glossary-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Reference List */
.ref-list {
    list-style: none;
    padding-left: 0;
}

.ref-item {
    font-size: 0.88rem;
    color: #5A5A5A;
    padding: 0.4rem 0;
    line-height: 1.6;
    border-bottom: 1px solid #F7F7F7;
    transition: background 0.2s ease;
}

.ref-item:last-child {
    border-bottom: none;
}

.ref-item.highlighted {
    background: #E8F0FE;
    padding-left: 0.5rem;
    border-radius: 3px;
}

.ref-num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #1976D2;
    font-weight: 400;
    margin-right: 0.4rem;
}

.ref-item em {
    font-style: italic;
}

/* ===== RELATED ARTICLES / EXPLORATION ===== */
.related {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.related-inner {
    border-top: 1px solid #E0E0E0;
    padding-top: 2rem;
}

.related-heading {
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: 1.25rem;
    color: #2C2C2C;
    margin-bottom: 1rem;
}

.related-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #E0E0E0 transparent;
}

.related-scroll::-webkit-scrollbar {
    height: 4px;
}

.related-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.related-scroll::-webkit-scrollbar-thumb {
    background: #E0E0E0;
    border-radius: 2px;
}

.related-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 200px;
    padding: 1rem 1.25rem;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    text-decoration: none;
    flex-shrink: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.related-card:hover {
    border-color: #1976D2;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.1);
}

.related-card-title {
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1976D2;
}

.related-card-desc {
    font-size: 0.8rem;
    color: #5A5A5A;
    line-height: 1.4;
}

/* ===== GLOSSARY SECTION ===== */
.glossary-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
}

.glossary-inner {
    border-top: 1px solid #E0E0E0;
    padding-top: 2rem;
}

.section-heading {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: #2C2C2C;
    margin-bottom: 1.25rem;
}

.glossary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.glossary-entry {
    background: #F7F7F7;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    border-left: 3px solid #E0E0E0;
    transition: border-color 0.2s ease;
}

.glossary-entry:hover {
    border-left-color: #1976D2;
}

.glossary-entry-term {
    display: block;
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: #2C2C2C;
    margin-bottom: 0.2rem;
}

.glossary-entry-def {
    display: block;
    font-size: 0.82rem;
    color: #5A5A5A;
    line-height: 1.5;
}

/* ===== FOOTER ===== */
.footer {
    max-width: 960px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    border-top: 1px solid #E0E0E0;
}

.footer-inner {
    text-align: center;
}

.footer-heading {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #2C2C2C;
    margin-bottom: 1.25rem;
}

.footer-index {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 0.75rem;
    margin-bottom: 2rem;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.index-letter {
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: #2C2C2C;
    width: 100%;
    text-align: left;
    margin-top: 0.5rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid #E0E0E0;
}

.index-link {
    font-size: 0.85rem;
    color: #1976D2;
    text-decoration: none;
    transition: color 0.15s ease;
}

.index-link:hover {
    color: #2C2C2C;
    text-decoration: underline;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.flink {
    font-size: 0.85rem;
    color: #1976D2;
    text-decoration: none;
    transition: color 0.15s ease;
}

.flink:hover {
    color: #2C2C2C;
}

.footer-copy {
    font-size: 0.75rem;
    color: #5A5A5A;
    margin-top: 0.5rem;
}

/* ===== ANIMATIONS ===== */
.fade-in {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered fade for child elements */
.fade-in.visible .pill:nth-child(1) { transition-delay: 0.05s; }
.fade-in.visible .pill:nth-child(2) { transition-delay: 0.1s; }
.fade-in.visible .pill:nth-child(3) { transition-delay: 0.15s; }
.fade-in.visible .pill:nth-child(4) { transition-delay: 0.2s; }
.fade-in.visible .pill:nth-child(5) { transition-delay: 0.25s; }
.fade-in.visible .pill:nth-child(6) { transition-delay: 0.3s; }

/* Search filtering: hidden articles */
.article-heading.hidden-by-search,
.article-heading.hidden-by-search + .article-text,
.article-heading.hidden-by-search + .article-text + .article-text,
.article-heading.hidden-by-search + .article-text + .article-text + .article-text,
.article-heading.hidden-by-search + .article-text + .figure-block,
.article-heading.hidden-by-search + .figure-block {
    display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .article-layout {
        grid-template-columns: 1fr;
    }

    .toc-sidebar {
        position: static;
        margin-bottom: 1.5rem;
    }

    .hero {
        padding: 3rem 1.5rem 2rem;
    }

    .hero-heading {
        font-size: 1.6rem;
    }

    .article-section,
    .related,
    .glossary-section,
    .footer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .header-nav {
        gap: 1rem;
    }

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

    .footer-index {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header-inner {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .header-nav {
        gap: 0.75rem;
    }

    .hero-heading {
        font-size: 1.35rem;
    }

    .article-heading {
        font-size: 1.25rem;
    }

    .related-card {
        min-width: 170px;
    }

    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
}
