/* =====================================================================
   Mechanism explorer — every rule is scoped to .mx so nothing leaks
   into the rest of the site.
   ===================================================================== */
/* The explorer measures its own width, so the layout adapts
   whether or not the page has a sidebar */
.mx { container-type: inline-size; }

@container (min-width: 600px) {
    .mx-main {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 240px;   /* was: 360px minmax(0, 1fr) */
        gap: 16px;
        align-items: start;
    }

    .mx-drug-section {
        max-height: 426px;
        overflow-y: auto;
        padding-right: 4px;
    }

    /* Two-column mode: panels run across the full width below */
    .mx-panels {
        grid-column: 1 / -1;
    }
}

@container (min-width: 1000px) {
    .mx-main {
        grid-template-columns: minmax(0, 1fr) 240px 320px;   /* was: 360px minmax(0, 1fr) 320px */
    }

    /* Three-column mode: panels become the right-hand column */
    .mx-panels {
        grid-column: auto;
        grid-template-columns: 1fr;
        max-height: 420px;
        overflow-y: auto;
        padding-right: 4px;
    }
}

.mx {
    --mx-text: #0f172a;
    --mx-muted: #64748b;
    --mx-border: #e2e8f0;
    --mx-surface: #ffffff;
    --mx-soft: #f8fafc;
    --mx-accent: #0284c7;
    --mx-accent-soft: #e0f2fe;

    background: var(--mx-surface);
    border: 1px solid var(--mx-border);
    border-radius: 12px;
    padding: 18px;
    color: var(--mx-text);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mx h2, .mx h3, .mx h4, .mx p { margin: 0; }

/* ---------- Toolbar ---------- */
.mx-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.mx-heading {
    font-size: 1.1rem;
    font-weight: 600;
}

.mx-gram-toggle {
    display: inline-flex;
    border: 1px solid var(--mx-border);
    border-radius: 999px;
    overflow: hidden;
}

.mx-gram-toggle button {
    background: var(--mx-surface);
    color: var(--mx-muted);
    border: none;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.mx-gram-toggle button.on {
    background: var(--mx-accent);
    color: #ffffff;
}

/* ---------- Drawing ---------- */
.mx-stage {
    background: var(--mx-soft);
    border: 1px solid var(--mx-border);
    border-radius: 10px;
    padding: 10px;
}

.mx-svg {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 0 auto;
}

.mx-hotspot {
    cursor: pointer;
    transition: filter 0.2s ease;
    outline: none;
}

.mx-hotspot:hover,
.mx-hotspot:focus-visible {
    filter: brightness(1.1) drop-shadow(0 0 4px currentColor);
}

.mx-hotspot.active {
    filter: drop-shadow(0 0 7px currentColor);
}

.mx-hotspot.secondary {
    filter: drop-shadow(0 0 3px currentColor);
}

.mx-label {
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 3px;
    stroke-linejoin: round;
}

.mx-effect-marker { pointer-events: none; }

@keyframes mx-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.mx-pulse { animation: mx-pulse 1.4s ease-in-out infinite; }

.mx-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--mx-muted);
}

.mx-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mx-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* ---------- Information panels ---------- */
.mx-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.mx-panel {
    background: var(--mx-soft);
    border: 1px solid var(--mx-border);
    border-radius: 10px;
    padding: 14px 16px;
}

.mx-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mx-muted);
    margin-bottom: 8px;
}

.mx-struct-title,
.mx-moa-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.mx-moa-title { color: var(--mx-accent); }

.mx-text {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #334155;
}

.mx-target-tag {
    display: inline-block;
    margin-top: 10px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--mx-accent-soft);
    color: #075985;
}

.mx-also {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #334155;
}

/* Structure → drugs chips */
.mx-chips-title {
    margin-top: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--mx-muted);
}

.mx-chips-empty {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--mx-muted);
}

.mx-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.mx-chip {
    background: var(--mx-accent-soft);
    border: 1px solid #7dd3fc;
    color: #075985;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.8rem;
    cursor: pointer;
}

.mx-chip:hover { background: #bae6fd; }
.mx-chip.secondary { border-style: dashed; }
.mx-chip.inactive { opacity: 0.55; text-decoration: line-through; }
.mx-chip.current { background: var(--mx-accent); border-color: var(--mx-accent); color: #ffffff; }
.mx-chip-note { font-size: 0.72rem; opacity: 0.85; }

/* Gram activity badges */
.mx-gram-rows {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.mx-gram-row {
    font-size: 0.82rem;
    color: var(--mx-muted);
    opacity: 0.75;
}

.mx-gram-row.current { opacity: 1; color: #334155; }

.mx-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-weight: 600;
    margin-right: 6px;
}

.mx-badge.active   { background: #dcfce7; color: #15803d; }
.mx-badge.limited  { background: #fef3c7; color: #b45309; }
.mx-badge.inactive { background: #fee2e2; color: #b91c1c; }

/* Monograph links */
.mx-mono-links {
    display: grid;
    gap: 4px;
    margin-top: 12px;
}

.mx-mono-link {
    color: #15803d;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.mx-mono-link:hover { text-decoration: underline; }

/* ---------- Antibiotic buttons ---------- */
.mx-drug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}

.mx-ab-btn {
    background: var(--mx-surface);
    border: 1px solid var(--mx-border);
    border-radius: 8px;
    padding: 7px 10px;          /* was 9px 12px */
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font: inherit;
    color: var(--mx-text);
}

.mx-ab-btn:hover { border-color: var(--mx-accent); }

.mx-ab-btn.active {
    border-color: var(--mx-accent);
    background: var(--mx-accent-soft);
    box-shadow: 0 0 0 1px var(--mx-accent);
}

.mx-ab-btn.dimmed { opacity: 0.55; }

.mx-ab-name { font-weight: 600; font-size: 0.88rem; }
.mx-ab-target { font-size: 0.72rem; color: var(--mx-muted); }
.mx-ab-flag { font-size: 0.72rem; font-weight: 600; color: #b91c1c; }

/* Keyboard focus */
.mx button:focus-visible,
.mx a:focus-visible {
    outline: 2px solid var(--mx-accent);
    outline-offset: 2px;
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
    .mx-pulse { animation: none; }
    .mx-hotspot { transition: none; }
}