/**
 * Shared accessibility + interaction hardening.
 * Build 1.1.292-accessibility-ux-300.
 * Loaded after every public shortcode family, including the isolated table.
 */

/* Screen-reader-only utility shared by all shortcode renderers. */
.bmb-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Strong, consistent keyboard focus without changing pointer appearance. */
.bmb-calculator-shell :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-ingredient-table-container :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-presets :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-bowl-compare :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-ingredient-swap :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-article-ingredient-card :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-article-category-summary :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-article-metric :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-trust-authority :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible,
.bmb-disclaimer :where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid #a83f00 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 2px #fff !important;
}

/* Practical WCAG 2.2-oriented target sizes for compact interactive controls. */
.bmb-calculator-shell :where(.bmb-goal-chip, .bmb-meal-tool-chip, .bmb-tabs-nav, .bmb-category-tab, .bmb-carousel-nav, .bmb-tacos-quantity-option, .bmb-bowl-toggle, .bmb-mobile-drawer-close, .bmb-swap-apply, .bmb-saved-orders-save, .bmb-saved-orders-clear, .bmb-receipt-print-button, .bmb-receipt-export-button),
.bmb-ingredient-table-container :where(button, input, select),
.bmb-bowl-compare select,
.bmb-source-history-details > summary {
    min-height: 44px;
}

.bmb-calculator-shell :where(.bmb-tabs-nav, .bmb-carousel-nav, .bmb-mobile-drawer-close),
.bmb-ingredient-table-container .bmb-ingredient-table-compare-toggle {
    min-width: 44px;
    min-height: 44px;
}

/* Keep controls separated enough for touch without forcing a visual redesign. */
.bmb-calculator-shell .bmb-meal-tools-launcher-rail,
.bmb-calculator-shell .bmb-goal-options,
.bmb-calculator-shell .bmb-tacos-quantity-options,
.bmb-ingredient-table-export-actions,
.bmb-ingredient-table-compare-actions {
    gap: max(8px, 0.5rem);
}

/* Contrast corrections for common muted/orange text on pale backgrounds. */
.bmb-calculator-shell :where(.bmb-flow-chip, .bmb-ing-desc, .bmb-desktop-source-note, .bmb-drawer-meta-pill, .bmb-receipt-source, .bmb-receipt-disclaimer),
.bmb-presets :where(.bmb-preset-description, .bmb-preset-meta, small),
.bmb-bowl-compare :where(p, .bmb-compare-summary span, .bmb-bowl-compare-source-note),
.bmb-ingredient-swap :where(p, em, .bmb-ingredient-swap-note),
.bmb-article-ingredient-card :where(p, .bmb-article-widget-note),
.bmb-article-category-summary :where(p, .bmb-article-widget-note),
.bmb-ingredient-table-container :where(.bmb-ingredient-table-subtitle, .bmb-ingredient-table-preset-detail, .bmb-ingredient-table-meta-source, .bmb-ingredient-table-export-label) {
    color: #5f5144 !important;
}

.bmb-calculator-shell :where(.bmb-goal-match-pill, .bmb-section-ux-chip, .bmb-fixed-meal-status, .bmb-fixed-goal-status),
.bmb-ingredient-table-container .bmb-ingredient-table-lto-badge {
    color: #8a3700 !important;
}

/* Explicitly distinguish selected states without relying on color alone. */
.bmb-calculator-shell [aria-pressed="true"] .bmb-ing-selected-marker::after {
    content: "✓";
}

/* Region focus should be visible without looking like an editable field. */
.bmb-calculator-shell .bmb-ingredient-scroll:focus-visible,
.bmb-ingredient-table-scroll:focus-visible,
.bmb-article-table-wrap:focus-visible,
.bmb-ingredient-swap-table-wrap:focus-visible,
.bmb-compare-table-wrap:focus-visible {
    outline: 3px solid #a83f00;
    outline-offset: 2px;
}

/* Avoid animation-heavy state changes when the user asks for reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .bmb-calculator-shell *,
    .bmb-calculator-shell *::before,
    .bmb-calculator-shell *::after,
    .bmb-ingredient-table-container *,
    .bmb-ingredient-table-container *::before,
    .bmb-ingredient-table-container *::after,
    .bmb-presets *,
    .bmb-bowl-compare *,
    .bmb-ingredient-swap * {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Reflow/zoom safety for dense action clusters. */
@media (max-width: 480px) {
    .bmb-calculator-shell :where(.bmb-meal-tools-launcher-rail, .bmb-saved-orders-controls, .bmb-receipt-preview-actions),
    .bmb-ingredient-table-export-actions,
    .bmb-ingredient-table-compare-actions {
        flex-wrap: wrap;
    }

    .bmb-calculator-shell :where(button, select, input),
    .bmb-ingredient-table-container :where(button, select, input) {
        max-width: 100%;
    }
}

/* Standalone starter controls and article/widget table scroll regions. */
.bmb-presets-container .bmb-starter-reveal-more,
.bmb-bowl-compare select,
.bmb-bowl-compare button,
.bmb-ingredient-swap button {
    min-height: 44px;
}

.bmb-article-table-wrap,
.bmb-ingredient-swap-table-wrap,
.bmb-compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Selected state must remain legible when high-contrast themes remove backgrounds. */
.bmb-calculator-shell :where(.bmb-meal-type-card, .bmb-goal-chip, .bmb-category-tab, .bmb-ingredient-btn)[aria-pressed="true"],
.bmb-calculator-shell .bmb-category-tab[aria-selected="true"],
.bmb-presets-container .bmb-preset-card[aria-pressed="true"],
.bmb-ingredient-table-container [aria-pressed="true"] {
    border-width: 2px;
}

/* Dynamic and secondary actions created after initial render must retain usable hit areas. */
.bmb-calculator-shell :where(
    .bmb-ingredient-btn,
    .bmb-preset-card,
    .bmb-starter-reveal-more,
    .bmb-desktop-clear-all,
    .bmb-drawer-edit-name,
    .bmb-bowl-name-editor-actions button,
    .bmb-saved-order-actions button,
    .bmb-setup-summary-edit,
    .bmb-swap-impact-actions button
),
.bmb-ingredient-table-container :where(
    .bmb-ingredient-table-columns-toggle,
    .bmb-ingredient-table-columns-action,
    .bmb-ingredient-table-export-action,
    .bmb-ingredient-table-compare-clear,
    .bmb-ingredient-table-sort-button
) {
    min-height: 44px;
}

.bmb-calculator-shell .bmb-saved-order-actions,
.bmb-calculator-shell .bmb-bowl-name-editor-actions,
.bmb-ingredient-table-container .bmb-ingredient-table-columns-actions {
    gap: 8px;
}

/* Heading-level compatibility: semantic h2–h6 output keeps the established visual design. */
.bmb-step-head h2 {
    margin: 0;
    color: #21160d;
    font-size: clamp(1.25rem, 2vw, 1.58rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.18;
}

.bmb-bowl-compare-head :is(h2, h4, h5, h6) {
    margin: 0;
    color: #ed7400;
    font-size: 1.85rem;
    line-height: 1.05;
}

.bmb-compare-section-head :is(h3, h5, h6) {
    margin: 0;
    color: #1f140c;
    font-size: 1.28rem;
    line-height: 1.2;
}

.bmb-source-history-copy :is(h2, h3, h5, h6) {
    margin: 0;
    color: #2d1e12;
    font-size: 0.86rem;
    font-weight: 950;
    line-height: 1.2;
}

.bmb-ingredient-swap-head :is(h2, h4, h5, h6) {
    margin: 0;
    color: #ed7400;
    font-size: 1.45rem;
    line-height: 1.1;
}

.bmb-article-card-head :is(h2, h4, h5, h6),
.bmb-article-category-head :is(h2, h4, h5, h6) {
    margin: 0;
    color: #2a190f;
    font-size: 1.1rem;
    font-weight: 950;
    line-height: 1.18;
}

.bmb-fixed-goal-mode .bmb-fixed-goal-step .bmb-step-head h2,
.bmb-fixed-meal-mode .bmb-fixed-meal-step .bmb-step-head h2 {
    overflow-wrap: break-word;
}

@media (min-width: 900px) {
    .bmb-approved-dashboard .bmb-step-head h2 {
        font-size: clamp(1.32rem, 1.7vw, 1.72rem);
        letter-spacing: -0.035em;
    }

    .bmb-approved-dashboard[data-bmb-desktop-visual-hierarchy-ui="1.1.166"] .bmb-step-head h2 {
        letter-spacing: -0.035em;
    }
}

@media (max-width: 699.98px) {
    .bmb-bowl-compare-head :is(h2, h4, h5, h6) {
        font-size: 1.52rem;
    }
}

@media (max-width: 767.98px) {
    .bmb-approved-dashboard[data-bmb-mobile-ui-chrome-cleanup="1.1.190"] .bmb-step-head h2 {
        font-size: 1rem;
        letter-spacing: -0.03em;
    }
}

@media print {
    .bmb-bowl-compare-head :is(h2, h4, h5, h6),
    .bmb-source-history-copy :is(h2, h3, h5, h6) {
        margin: 0 0 0.28rem !important;
        color: #111 !important;
        font-size: 14pt !important;
    }
}
