/* =================================================================
   HVB COA CALCULATOR — calculator.css
   Heritage design language. All rules scoped under .hvb-calc so
   nothing leaks. Token block matches page-coas.css and the COA
   dashboard plugin's heritage overlay; values are local fallbacks
   so the calculator looks native on any page.
   ================================================================= */

.hvb-calc {
    --forest:        #1a3a2e;
    --forest-mid:    #2a5d3a;
    --forest-light:  #3a6d4a;
    --forest-deep:   #0f2a1f;

    --gold:          #d4af37;
    --gold-soft:     #e8c873;
    --gold-dark:     #b8960c;

    --cream:         #fff9e6;
    --cream-dark:    #fff3cd;
    --bone:          #f5ecd7;

    --text-dark:     #1a1a1a;
    --text-muted:    #555555;
    --text-light:    #737373;

    --shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md:     0 8px 24px rgba(0, 0, 0, 0.12);

    --t:             0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast:        0.18s ease;

    --font-display:  'Cinzel', Georgia, serif;
    --font-body:     'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;

    color: var(--text-dark);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;

    background: linear-gradient(180deg, var(--cream) 0%, #fff 100%);
    border: 1px solid rgba(26, 58, 46, 0.08);
    border-radius: 20px;
    padding: 0;
    margin: 0 auto;
    max-width: 1100px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.hvb-calc * { box-sizing: border-box; }

.hvb-calc-inner {
    padding: 44px 40px 36px;
}

/* ---------------- Header ---------------------------------------- */
.hvb-calc-head { margin-bottom: 28px; }

.hvb-calc-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--forest-mid);
    padding: 7px 16px 7px 12px;
    border: 1px solid rgba(42, 93, 58, 0.3);
    background: rgba(42, 93, 58, 0.08);
    border-radius: 100px;
    margin-bottom: 18px;
}
.hvb-calc-eyebrow .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--forest-mid);
    box-shadow: 0 0 0 3px rgba(42, 93, 58, 0.18);
}

.hvb-calc-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 700;
    color: var(--forest-deep);
    margin: 0 0 12px;
    line-height: 1.15;
    letter-spacing: 0.01em;
}
.hvb-calc-title em {
    font-style: normal;
    color: var(--forest-mid);
}

.hvb-calc-lede {
    font-size: 0.96rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0;
    max-width: 760px;
}

/* ---------------- Explainer (collapsible) ----------------------- */
.hvb-calc-explainer {
    background: var(--cream);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 28px;
}
.hvb-calc-explainer summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--forest-deep);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.hvb-calc-explainer summary::-webkit-details-marker { display: none; }
.hvb-calc-explainer summary::after {
    content: "+";
    font-size: 1.3rem;
    line-height: 1;
    color: var(--gold-dark);
    transition: transform var(--t-fast);
}
.hvb-calc-explainer[open] summary::after { content: "−"; }
.hvb-calc-explainer-body {
    padding: 4px 18px 18px;
    border-top: 1px solid rgba(212, 175, 55, 0.25);
}
.hvb-calc-explainer-body p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 12px 0 0;
}
.hvb-calc-explainer-body p strong { color: var(--forest-deep); }
.hvb-calc-explainer-note {
    font-style: italic;
    color: var(--text-light) !important;
    margin-top: 14px !important;
}

/* ---------------- Batch dropdown -------------------------------- */
.hvb-calc-batch-row {
    background: linear-gradient(135deg, rgba(42, 93, 58, 0.04), rgba(212, 175, 55, 0.05));
    border: 1px solid rgba(26, 58, 46, 0.1);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 24px;
}

.hvb-calc-select-wrap {
    position: relative;
    margin-top: 8px;
}
.hvb-calc-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #fff;
    border: 1.5px solid rgba(26, 58, 46, 0.15);
    border-radius: 10px;
    padding: 12px 44px 12px 16px;
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-dark);
    line-height: 1.4;
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.hvb-calc-select:hover { border-color: rgba(42, 93, 58, 0.4); }
.hvb-calc-select:focus,
.hvb-calc-select:focus-visible {
    outline: none;
    border-color: var(--forest-mid);
    box-shadow: 0 0 0 4px rgba(42, 93, 58, 0.12);
}
.hvb-calc-select-caret {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--forest-mid);
    pointer-events: none;
    display: inline-flex;
}

.hvb-calc-batch-hint {
    margin: 10px 2px 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}
.hvb-calc-batch-hint.is-active {
    color: var(--forest-mid);
    font-weight: 600;
}
.hvb-calc-batch-hint.is-modified {
    color: var(--gold-dark);
    font-weight: 600;
}

/* ---------------- Form grid ------------------------------------- */
.hvb-calc-form { margin-bottom: 28px; }

.hvb-calc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.hvb-calc-field {
    background: #fff;
    border: 1px solid rgba(26, 58, 46, 0.1);
    border-radius: 12px;
    padding: 14px 14px 12px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.hvb-calc-field:focus-within {
    border-color: var(--forest-mid);
    box-shadow: 0 0 0 4px rgba(42, 93, 58, 0.1);
}

.hvb-calc-field-intake {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.02));
    border-color: rgba(212, 175, 55, 0.35);
}

.hvb-calc-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--forest-deep);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 8px;
}
.hvb-calc-symbol {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--gold-dark);
    text-transform: none;
    letter-spacing: 0;
}
.hvb-calc-unit {
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: none;
    letter-spacing: 0.04em;
    margin-left: auto;
}

.hvb-calc-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 2px solid rgba(26, 58, 46, 0.12);
    border-radius: 0;
    padding: 6px 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--forest-deep);
    line-height: 1.2;
    transition: border-color var(--t-fast);
}
.hvb-calc-input::-webkit-outer-spin-button,
.hvb-calc-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.hvb-calc-input:focus,
.hvb-calc-input:focus-visible {
    outline: none;
    border-bottom-color: var(--gold-dark);
}
.hvb-calc-input::placeholder { color: rgba(26, 58, 46, 0.25); }

.hvb-calc-loq-note {
    margin: 16px 2px 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}
.hvb-calc-loq-note strong {
    color: var(--forest-deep);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: 0.85em;
}

/* ---------------- Results --------------------------------------- */
.hvb-calc-results {
    background: linear-gradient(160deg, var(--forest) 0%, var(--forest-deep) 100%);
    border-radius: 16px;
    padding: 32px 28px 24px;
    color: #fff;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.hvb-calc-results::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 80% at 90% 0%, rgba(212, 175, 55, 0.12), transparent 60%);
    pointer-events: none;
}

.hvb-calc-results-head {
    position: relative;
    margin-bottom: 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: baseline;
    justify-content: space-between;
}
.hvb-calc-results-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold-soft);
    margin: 0;
    letter-spacing: 0.02em;
}
.hvb-calc-results-source {
    margin: 0;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
}
.hvb-calc-results-source strong { color: var(--gold); font-weight: 700; }

.hvb-calc-results-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

/* Result cards. No verdict styling: same neutral background regardless
   of where the exposure lands against any threshold. align-content: start
   packs the implicit grid rows to the top so cards stretched to match a
   taller sibling (e.g. lead with its context note) don't space their
   bars to the bottom. */
.hvb-calc-result {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.18);
    border-radius: 12px;
    padding: 18px 18px 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-content: start;
}
.hvb-calc-result-main { min-width: 0; }
.hvb-calc-result-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
    letter-spacing: 0.02em;
}
.hvb-calc-result-name .symbol {
    color: var(--gold);
    font-size: 0.85em;
    margin-left: 6px;
}
.hvb-calc-result-exposure {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.78);
    margin: 0;
}
.hvb-calc-result-exposure strong {
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
}

.hvb-calc-result-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}
.hvb-calc-result-bar {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: baseline;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.78);
}
.hvb-calc-result-bar-label {
    grid-column: 1;
    grid-row: 1;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.65);
}
.hvb-calc-result-bar-value {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    color: rgba(255, 255, 255, 0.78);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    white-space: nowrap;
}
.hvb-calc-result-bar-track {
    grid-column: 1;
    grid-row: 2;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
}
.hvb-calc-result-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: var(--gold);
    opacity: 0.78;
    border-radius: 100px;
    transition: width var(--t);
}
.hvb-calc-result-bar-fill.na {
    background: rgba(255, 255, 255, 0.12);
    width: 100%;
}
.hvb-calc-result-bar-pct {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
}
.hvb-calc-result-bar-pct.na { color: rgba(255, 255, 255, 0.45); font-weight: 500; }
.hvb-calc-result-note {
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 4px 0 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
    font-style: italic;
}

/* Per-card context note (e.g., why lead reads higher % than other metals) */
.hvb-calc-result-context {
    grid-column: 1 / -1;
    margin: 12px 0 0;
    padding: 12px 14px;
    background: rgba(212, 175, 55, 0.08);
    border-left: 2px solid var(--gold-soft);
    border-radius: 0 8px 8px 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.78);
}
.hvb-calc-result-context strong {
    color: var(--gold-soft);
    font-weight: 700;
}

/* Two-column "How to read these thresholds" context grid. Stacked
   on narrow screens. Both boxes share styling — neither is more
   important; both equally educational. */
.hvb-calc-context-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.hvb-calc-context-box {
    padding: 16px 18px;
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 10px;
}
.hvb-calc-context-title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--gold-soft);
    letter-spacing: 0.02em;
}
.hvb-calc-context-box p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.82);
}
@media (max-width: 760px) {
    .hvb-calc-context-grid { grid-template-columns: 1fr; }
}

/* "In familiar terms" — per-metal equivalents block. Translates each
   metal's exposure into an equivalent serving of common foods and
   botanical supplements so a customer can anchor the µg number to
   something they already know. */
.hvb-calc-equivs {
    margin: 22px 0 0;
    padding: 18px 18px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.18);
    border-radius: 12px;
}
.hvb-calc-equivs-head { margin-bottom: 14px; }
.hvb-calc-equivs-title {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--gold-soft);
}
.hvb-calc-equivs-sub {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.7);
}
.hvb-calc-equivs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hvb-calc-equiv-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 14px;
    align-items: baseline;
    padding: 10px 0;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
}
.hvb-calc-equiv-row:first-child { border-top: 0; padding-top: 4px; }
.hvb-calc-equiv-meta { display: flex; flex-direction: column; gap: 2px; }
.hvb-calc-equiv-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.hvb-calc-equiv-name em {
    font-style: normal;
    color: var(--gold);
    font-size: 0.85em;
    margin-left: 4px;
}
.hvb-calc-equiv-exp {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    font-variant-numeric: tabular-nums;
}
.hvb-calc-equiv-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.55;
}
.hvb-calc-equiv-equals {
    color: var(--gold-soft);
    font-weight: 700;
    margin-right: 4px;
}
.hvb-calc-equiv-item { white-space: nowrap; }
.hvb-calc-equiv-amount {
    color: var(--gold-soft);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.hvb-calc-equiv-sep {
    color: rgba(212, 175, 55, 0.4);
    margin: 0 8px;
}
.hvb-calc-equiv-empty .hvb-calc-equiv-text {
    color: rgba(255, 255, 255, 0.55);
    font-style: italic;
    font-size: 0.82rem;
}
@media (max-width: 640px) {
    .hvb-calc-equiv-row { grid-template-columns: 1fr; gap: 6px; }
    .hvb-calc-equiv-meta { flex-direction: row; gap: 10px; align-items: baseline; }
    .hvb-calc-equiv-text { white-space: normal; }
    .hvb-calc-equiv-item { display: inline-block; white-space: normal; }
}

/* Section divider rows in the static reference table */
.hvb-calc-foods-table .hvb-calc-foods-section td {
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold-soft);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 10px;
    text-align: left !important;
}

/* Intake-above-labeled-max warning. Sits between the source line and
   the result cards so a user pushing intake well past 6 g/day sees
   the framing before they read the bars. */
.hvb-calc-intake-warning {
    position: relative;
    margin: 0 0 18px;
    padding: 12px 14px;
    background: rgba(255, 184, 0, 0.1);
    border: 1px solid rgba(255, 184, 0, 0.3);
    border-left: 3px solid #ffb800;
    border-radius: 0 8px 8px 0;
    font-size: 0.82rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}
.hvb-calc-intake-warning strong {
    color: #ffd66e;
    font-weight: 700;
}
.hvb-calc-intake-warning[hidden] { display: none; }

/* Food comparison details/summary block. Collapsed by default so the
   results panel doesn't get bottom-heavy; opens to a small reference
   table grounding the user's number against everyday dietary sources. */
.hvb-calc-foods {
    position: relative;
    margin: 16px 0 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.18);
    border-radius: 8px;
    overflow: hidden;
}
.hvb-calc-foods summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.hvb-calc-foods summary::-webkit-details-marker { display: none; }
.hvb-calc-foods summary::after {
    content: "+";
    font-size: 1.1rem;
    line-height: 1;
    color: var(--gold-soft);
    transition: transform var(--t-fast);
}
.hvb-calc-foods[open] summary::after { content: "−"; }
.hvb-calc-foods-body {
    padding: 8px 14px 14px;
    border-top: 1px solid rgba(212, 175, 55, 0.18);
}
.hvb-calc-foods-intro {
    margin: 10px 0 12px;
    font-size: 0.78rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
}
.hvb-calc-foods-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.18);
}
.hvb-calc-foods-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}
.hvb-calc-foods-table th,
.hvb-calc-foods-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    white-space: nowrap;
}
.hvb-calc-foods-table th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gold-soft);
    background: rgba(212, 175, 55, 0.06);
    border-bottom-color: rgba(212, 175, 55, 0.28);
}
.hvb-calc-foods-table th:not(:first-child):not(:nth-child(2)),
.hvb-calc-foods-table td:not(:first-child):not(:nth-child(2)) {
    text-align: right;
}
.hvb-calc-foods-table tbody tr:last-child td { border-bottom: none; }
.hvb-calc-foods-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.hvb-calc-foods-note {
    margin: 12px 0 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.55;
    font-style: italic;
}

/* ---------------- Footer / disclaimers -------------------------- */
.hvb-calc-foot {
    border-top: 1px solid rgba(26, 58, 46, 0.08);
    padding-top: 18px;
}
.hvb-calc-disclaimer {
    margin: 0 0 10px;
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--text-muted);
}
.hvb-calc-disclaimer:last-child { margin-bottom: 0; }
.hvb-calc-disclaimer strong { color: var(--forest-deep); }
.hvb-calc-disclaimer-fda {
    background: var(--cream);
    border-left: 3px solid var(--gold);
    padding: 12px 14px;
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------------- Responsive ------------------------------------ */
@media (max-width: 900px) {
    .hvb-calc-grid { grid-template-columns: repeat(2, 1fr); }
    .hvb-calc-field-intake { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .hvb-calc-inner { padding: 28px 20px 24px; }
    .hvb-calc-results { padding: 24px 18px 20px; }
    .hvb-calc-results-grid { grid-template-columns: 1fr; }
    .hvb-calc-result-bar { font-size: 0.72rem; }
    .hvb-calc-disclaimer-fda { font-size: 0.78rem; }
}

@media (max-width: 420px) {
    .hvb-calc-grid { grid-template-columns: 1fr; }
    .hvb-calc-field-intake { grid-column: auto; }
    .hvb-calc-input { font-size: 1.2rem; }
    .hvb-calc-title { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
    .hvb-calc * { transition: none !important; }
}
