/* ========================================
   CHEMISTRY TOPICS - EDUCATIONAL CONTENT
   In-depth guides with worked examples
======================================== */

/* Section Container */
.chemistry-topics-section {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 var(--gap-md);
}

.chem-topics-container {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* Header */
.chem-topics-header {
    padding: 2rem var(--gap-lg);
    background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
    color: white;
    text-align: center;
}

.chem-topics-header h2 {
    font-size: 1.375rem;
    font-weight: 800;
    margin: 0 0 0.75rem 0;
}

.chem-topics-header p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: #ccfbf1;
    margin: 0;
    max-width: 700px;
    margin-inline: auto;
}

/* Topic Tabs */
.chem-topic-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: #f0fdfa;
    border-bottom: 2px solid #99f6e4;
}

.chem-topic-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.85rem 0.5rem;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    touch-action: manipulation;
}

.chem-topic-tab i {
    font-size: 1rem;
}

.chem-topic-tab:hover {
    color: #0f766e;
    background: #ccfbf1;
}

.chem-topic-tab.active {
    color: #0d9488;
    border-bottom-color: #14b8a6;
    background: white;
}

/* Topic Content */
.chem-topic-content {
    display: none;
    padding: 1.5rem var(--gap-md);
}

.chem-topic-content.active {
    display: block;
}

/* Topic Hero */
.chem-topic-hero {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid #f0fdfa;
}

.chem-topic-hero h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.chem-topic-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.5;
    margin: 0;
}

/* Concept Block */
.chem-concept-block {
    margin-bottom: 2rem;
}

.chem-concept-block h4 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
}

.chem-concept-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: #14b8a6;
    color: white;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 800;
}

.chem-concept-block>p {
    font-size: 0.875rem;
    line-height: 1.7;
    color: #475569;
    margin: 0 0 1rem 0;
}

/* Law / Info Cards */
.chem-card {
    background: #f0fdfa;
    border: 2px solid #99f6e4;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.chem-badge {
    display: inline-block;
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
}

.chem-card p {
    font-size: 0.85rem;
    line-height: 1.7;
    color: #475569;
    margin: 0 0 0.75rem 0;
}

.chem-card p:last-child {
    margin-bottom: 0;
}

/* Key Insight */
.chem-insight {
    display: flex;
    gap: 0.75rem;
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 2px solid #5eead4;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0.75rem 0;
}

.chem-insight i {
    color: #0d9488;
    font-size: 1rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.chem-insight span {
    font-size: 0.8rem;
    line-height: 1.6;
    color: #134e4a;
}

/* Formula Box */
.chem-formula-box {
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 2px solid #5eead4;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin: 1rem 0;
    text-align: center;
}

.chem-formula-main {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f766e;
    font-family: 'Courier New', monospace;
    margin-bottom: 0.75rem;
}

.chem-formula-break {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.chem-formula-break span {
    font-size: 0.75rem;
    color: #115e59;
    font-family: 'Courier New', monospace;
}

/* Diagram Container */
.chem-diagram {
    margin: 1.25rem 0;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chem-svg-wrap {
    background: white;
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.chem-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.chem-diagram-caption {
    background: #f0fdfa;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    line-height: 1.6;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
}

/* Steps Summary */
.chem-steps {
    background: #f0fdf4;
    border: 2px solid #bbf7d0;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin: 1rem 0;
}

.chem-steps-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #166534;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.chem-step-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    align-items: flex-start;
}

.chem-step-item:last-child {
    margin-bottom: 0;
}

.chem-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    background: #16a34a;
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
}

.chem-step-item span:last-child {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.5;
}

/* Worked Examples */
.chem-example {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-xl);
    margin-bottom: 1.75rem;
    overflow: hidden;
}

.chem-ex-header {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    padding: 1rem 1.25rem;
}

.chem-ex-badge {
    display: inline-block;
    background: #fbbf24;
    color: #1e293b;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.chem-ex-header h5 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.chem-ex-problem {
    padding: 1.25rem;
    background: #fef2f2;
    border-bottom: 2px solid #fecaca;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #7f1d1d;
}

.chem-ex-solution {
    padding: 1.25rem;
}

.chem-sol-step {
    margin-bottom: 1.25rem;
}

.chem-sol-step:last-child {
    margin-bottom: 0;
}

.chem-sol-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #0d9488;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #e2e8f0;
}

.chem-sol-content {
    padding-left: 0.5rem;
}

.chem-sol-content p {
    font-size: 0.825rem;
    line-height: 1.6;
    color: #475569;
    margin: 0 0 0.5rem 0;
}

.chem-math {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #1e293b;
    padding: 0.3rem 0;
    line-height: 1.5;
}

.chem-result {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-weight: 700;
    color: #166534;
    display: inline-block;
    margin: 0.25rem 0;
}

.chem-ex-answer {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border-top: 2px solid #99f6e4;
    font-size: 0.825rem;
    line-height: 1.6;
    color: #134e4a;
}

/* Equations Table */
.chem-eq-table {
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: 1rem 0;
}

.chem-eq-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.chem-eq-row:last-child {
    border-bottom: none;
}

.chem-eq-row:nth-child(even) {
    background: #f0fdfa;
}

.chem-eq-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
}

.chem-eq-note {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
}

/* Two Column Info */
.chem-two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.chem-info-col {
    background: #f0fdfa;
    border: 2px solid #99f6e4;
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.chem-info-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0d9488;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.chem-info-col p {
    font-size: 0.8rem;
    line-height: 1.6;
    color: #475569;
    margin: 0 0 0.5rem 0;
}

.chem-info-col .chem-math {
    font-size: 0.8rem;
}

/* Comparison Table */
.chem-compare {
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: 1rem 0;
    font-size: 0.75rem;
}

.chem-compare-head {
    display: grid;
    grid-template-columns: 1.2fr repeat(2, 1fr);
    background: #0f766e;
}

.chem-compare-head .chem-compare-cell {
    color: white !important;
    font-weight: 700 !important;
    font-size: 0.65rem !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chem-compare-row {
    display: grid;
    grid-template-columns: 1.2fr repeat(2, 1fr);
    border-bottom: 1px solid #f1f5f9;
}

.chem-compare-row:last-child {
    border-bottom: none;
}

.chem-compare-row:nth-child(even) {
    background: #f0fdfa;
}

.chem-compare-cell {
    padding: 0.6rem 0.5rem;
    color: #475569;
    font-size: 0.7rem;
    line-height: 1.4;
}

.chem-label-cell {
    font-weight: 700;
    color: #1e293b;
}

/* Reaction Box */
.chem-reaction-box {
    background: #fffbeb;
    border: 2px solid #fcd34d;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    text-align: center;
}

.chem-reaction-eq {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: #92400e;
    line-height: 1.6;
}

/* pH Scale Visualization */
.chem-ph-scale {
    margin: 1rem 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 2px solid #e2e8f0;
}

.chem-ph-bar {
    height: 30px;
    background: linear-gradient(to right, #dc2626, #ea580c, #f59e0b, #eab308, #84cc16, #22c55e, #14b8a6, #0ea5e9, #3b82f6, #6366f1, #8b5cf6);
    position: relative;
}

.chem-ph-labels {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
}

.chem-ph-labels span {
    font-size: 0.6rem;
    font-weight: 700;
    color: #64748b;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (min-width: 576px) {
    .chem-topic-tabs {
        grid-template-columns: repeat(6, 1fr);
    }

    .chem-topic-tab {
        font-size: 0.6rem;
        padding: 0.75rem 0.25rem;
    }

    .chem-two-col {
        grid-template-columns: 1fr 1fr;
    }

    .chem-topic-content {
        padding: 2rem 1.5rem;
    }

    .chem-topic-hero h3 {
        font-size: 1.375rem;
    }
}

@media (min-width: 768px) {
    .chemistry-topics-section {
        max-width: 800px;
    }

    .chem-topics-header h2 {
        font-size: 1.5rem;
    }

    .chem-topic-tab {
        font-size: 0.65rem;
        padding: 1rem 0.5rem;
    }

    .chem-topic-tab i {
        font-size: 1.1rem;
    }

    .chem-formula-main {
        font-size: 1.375rem;
    }

    .chem-compare-head {
        grid-template-columns: 1.2fr repeat(3, 1fr);
    }

    .chem-compare-row {
        grid-template-columns: 1.2fr repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .chemistry-topics-section {
        max-width: 900px;
    }

    .chem-topic-content {
        padding: 2rem;
    }
}

@media print {
    .chem-topic-tabs {
        display: none;
    }

    .chem-topic-content {
        display: block !important;
        break-inside: avoid;
    }

    .chem-example {
        break-inside: avoid;
    }
}