/* ============================================================
   REACTION EQUATION COMPONENT
   Renders chemical reactions with SMILES molecule drawings + arrows.
   Usage:
     <div class="reaction-eq">
       <div class="reaction-side reactants">
         <canvas data-smiles="c1ccccc1" width="100" height="80"></canvas>
         <span class="reaction-plus">+</span>
         <span class="reaction-reagent">Cl₂</span>
       </div>
       <div class="reaction-arrow" data-conditions="AlCl₃">→</div>
       <div class="reaction-side products">
         <canvas data-smiles="Clc1ccccc1" width="110" height="80"></canvas>
         <span class="reaction-plus">+</span>
         <span class="reaction-reagent">HCl</span>
       </div>
     </div>
   ============================================================ */

.reaction-eq {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e8ecf0;
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.reaction-side {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Molecule rendered on canvas inside a reaction */
.reaction-eq canvas {
    display: block;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Plus sign between molecules */
.reaction-plus {
    font-size: 1.3rem;
    font-weight: 700;
    color: #64748b;
    padding: 0 0.15rem;
    user-select: none;
}

/* Simple text reagent (H₂, Cl₂, NaOH etc.) */
.reaction-reagent {
    font-size: 1rem;
    font-weight: 600;
    color: #1a2332;
    padding: 0.35rem 0.65rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    white-space: nowrap;
    font-family: 'Open Sans', system-ui, sans-serif;
}

/* Reaction arrow */
.reaction-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0 0.5rem;
    position: relative;
    user-select: none;
}

.reaction-arrow::before {
    content: '→';
    font-size: 1.6rem;
    font-weight: 400;
    color: #F5A623;
    line-height: 1;
}

/* Conditions label above arrow */
.reaction-arrow[data-conditions]::after {
    content: attr(data-conditions);
    font-size: 0.72rem;
    font-weight: 600;
    color: #8c9bab;
    white-space: nowrap;
    position: absolute;
    top: -1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(248,250,252,0.95);
    padding: 0 0.3rem;
    font-family: 'Open Sans', system-ui, sans-serif;
}

/* Reversible arrow */
.reaction-arrow.reversible::before {
    content: '⇌';
}

/* Product name label */
.reaction-product-name {
    font-size: 0.8rem;
    color: #5a6a7b;
    font-style: italic;
    text-align: center;
    margin-top: 0.2rem;
    font-family: 'Open Sans', system-ui, sans-serif;
}

/* Molecule wrapper with name below */
.reaction-mol {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.reaction-mol canvas {
    display: block;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.reaction-mol .mol-label {
    font-size: 0.75rem;
    color: #5a6a7b;
    font-weight: 500;
    text-align: center;
    font-family: 'Open Sans', system-ui, sans-serif;
}

/* Precipitate / gas indicators */
.reaction-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    vertical-align: super;
    font-size: 0.7rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .reaction-eq {
        padding: 0.75rem;
        gap: 0.35rem;
    }
    .reaction-eq canvas {
        max-width: 80px;
        max-height: 65px;
    }
    .reaction-reagent {
        font-size: 0.85rem;
        padding: 0.25rem 0.45rem;
    }
    .reaction-arrow::before {
        font-size: 1.3rem;
    }
    .reaction-arrow[data-conditions]::after {
        font-size: 0.65rem;
    }
}
