/* =====================================================================
   Free calculators (short circuit, voltage drop, per-unit).
   Uses the tokens from site.css and the hero/sections from learn.css.
   ===================================================================== */

.calc {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin-bottom: 44px;
}
.calc__inputs,
.calc__results {
    border: 1px solid var(--c-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.calc__inputs { padding: 24px; }
.calc__results {
    position: sticky;
    top: 88px;
    overflow: hidden;
}

/* Fields */
.calc fieldset { margin: 0 0 22px; padding: 0; border: 0; }
.calc fieldset:last-child { margin-bottom: 0; }
.calc legend {
    float: none;
    width: auto;
    margin: 0 0 12px;
    padding: 0;
    color: var(--c-ink);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.calc__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.calc__grid > [hidden] { display: none; }
.calc__field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.calc__field--wide { grid-column: 1 / -1; }
.calc__field label { color: #334155; font-size: 14px; font-weight: 600; line-height: 1.35; }
.calc__field label small { color: var(--c-muted); font-weight: 500; }
.calc__control { position: relative; display: flex; align-items: stretch; }
.calc__control input,
.calc__control select,
.calc__field > select {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: var(--c-ink);
    font-family: inherit;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    -webkit-appearance: none;
    appearance: none;
}
.calc select {
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
}
.calc__control input:focus,
.calc select:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 4px rgba(47, 91, 234, .15); }
.calc__control .calc__unit {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    margin-left: -1px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 0 10px 10px 0;
    background: var(--c-soft);
    color: var(--c-muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.calc__control--unit input { border-radius: 10px 0 0 10px; }
.calc__hint { margin: 0; color: var(--c-muted); font-size: 13px; line-height: 1.45; }

/* Segmented radio buttons */
.calc__seg { display: flex; flex-wrap: wrap; gap: 6px; }
.calc__seg label {
    position: relative;
    margin: 0;
    font-weight: 600;
}
.calc__seg input { position: absolute; opacity: 0; pointer-events: none; }
.calc__seg span {
    display: inline-flex;
    align-items: center;
    padding: 9px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 14px;
    cursor: pointer;
}
.calc__seg input:checked + span { border-color: var(--c-ink); background: var(--c-ink); color: #fff; }
.calc__seg input:focus-visible + span { outline: 2px solid var(--c-brand); outline-offset: 2px; }

/* Results */
.calc__head {
    padding: 22px 24px 20px;
    background:
        radial-gradient(420px 200px at 0% 0%, rgba(99, 102, 241, .45), transparent 70%),
        linear-gradient(135deg, #0b1a4f 0%, #1e3a8a 60%, #2f5bea 100%);
    color: #fff;
}
.calc__head-label { margin: 0 0 4px; color: rgba(255, 255, 255, .8) !important; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.calc__big { margin: 0; color: #fff !important; font-size: clamp(32px, 2vw + 22px, 44px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.calc__sub { margin: 6px 0 0; color: rgba(255, 255, 255, .85) !important; font-size: 15px; }
.calc__list { margin: 0; padding: 8px 24px; }
.calc__row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--c-line); }
.calc__row:last-child { border-bottom: 0; }
.calc__row dt { color: var(--c-body); font-size: 14.5px; font-weight: 500; }
.calc__row dd { margin: 0; color: var(--c-ink); font-size: 15px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc__status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 24px 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 700;
}
.calc__status[hidden] { display: none; }
.calc__status.is-ok { background: #ecfdf5; color: #047857; }
.calc__status.is-bad { background: #fef2f2; color: #b91c1c; }
.calc__status.is-ok::before { content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.calc__status.is-bad::before { content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.calc__actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 24px 22px; }
.calc__actions button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--c-line);
    border-radius: 999px;
    background: #fff;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.calc__actions button:hover { border-color: var(--c-brand); color: var(--c-brand); }
.calc__note { margin: 0; padding: 0 24px 22px; color: var(--c-muted) !important; font-size: 13px !important; line-height: 1.5; }
.calc.is-invalid .calc__big { opacity: .5; }
.calc__invalid { display: none; margin: 8px 0 0; color: #fecaca !important; font-size: 13.5px; }
.calc.is-invalid .calc__invalid { display: block; }

/* Explanations below the calculator */
.calc-doc { max-width: 820px; }
.calc-doc h2 { margin: 0 0 12px; font-size: clamp(22px, .8vw + 17px, 28px); letter-spacing: -0.02em; }
.calc-doc h3 { margin: 26px 0 10px; font-size: 19px; }
.calc-doc p, .calc-doc li { color: #334155; font-size: 16.5px; line-height: 1.7; }
.calc-doc ul, .calc-doc ol { padding-left: 22px; }
.calc-doc a:not([class]) { color: var(--c-brand); text-decoration: underline; text-decoration-color: rgba(47, 91, 234, .35); text-underline-offset: 2px; }
.calc-formulas { margin: 14px 0 22px; padding: 0; list-style: none; counter-reset: f; }
.calc-formulas li {
    position: relative;
    margin: 0 0 10px;
    padding: 14px 16px 14px 52px;
    border: 1px solid var(--c-line);
    border-radius: 12px;
    background: var(--c-soft);
    counter-increment: f;
}
.calc-formulas li::before {
    content: counter(f);
    position: absolute;
    left: 14px;
    top: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--c-brand);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.calc-formulas strong { display: block; margin-bottom: 4px; color: var(--c-ink); font-size: 15px; }
.calc-eq {
    display: block;
    overflow-x: auto;
    color: var(--c-ink);
    font-family: "Cambria Math", "STIX Two Math", "Times New Roman", serif;
    font-size: 18px;
    white-space: nowrap;
}
.calc-example { margin: 12px 0 24px; border-collapse: collapse; width: 100%; max-width: 620px; font-size: 15px; }
.calc-example th, .calc-example td { padding: 9px 12px; border-bottom: 1px solid var(--c-line); text-align: left; }
.calc-example th { color: var(--c-muted); font-weight: 600; }
.calc-example td:last-child { font-weight: 700; color: var(--c-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* FAQ */
.calc-faq { max-width: 820px; margin-top: 36px; }
.calc-faq details { border-bottom: 1px solid var(--c-line); }
.calc-faq summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    color: var(--c-ink);
    font-size: 16.5px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}
.calc-faq summary::-webkit-details-marker { display: none; }
.calc-faq summary::after { content: "+"; color: var(--c-brand); font-size: 22px; font-weight: 500; line-height: 1; }
.calc-faq details[open] summary::after { content: "\2212"; }
.calc-faq details p { margin: 0 0 16px; }

/* Hub page */
.calc-hub { margin-bottom: 44px; }

@media (max-width: 991.98px) {
    .calc { grid-template-columns: 1fr; }
    .calc__results { position: static; }
}
@media (max-width: 575.98px) {
    .calc__inputs { padding: 18px; }
    .calc__grid { grid-template-columns: 1fr; }
    .calc__head, .calc__list, .calc__actions, .calc__note { padding-left: 18px; padding-right: 18px; }
    .calc__status { margin-left: 18px; margin-right: 18px; }
    .calc-eq { white-space: normal; font-size: 17px; }
}
.calc__seg-label { color: #334155; font-size: 14px; font-weight: 600; line-height: 1.35; }
