/* =====================================================================
   Free calculators (short circuit, cable sizing, voltage drop, kVA,
   transformer current, power factor, per-unit), print and embed.
   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[hidden] { display: none; }
.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; }

/* Wide tables (e.g. standard transformer ratings) scroll sideways on phones */
.calc-table-wrap { max-width: 100%; margin: 12px 0 24px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.calc-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.calc-table th, .calc-table td { padding: 8px 12px; border-bottom: 1px solid var(--c-line); text-align: right; white-space: nowrap; }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table thead th { color: var(--c-ink); font-weight: 700; border-bottom: 2px solid var(--c-line); }
.calc-table tbody tr:nth-child(even) { background: var(--c-soft); }
.calc-table tbody th { color: var(--c-ink); font-weight: 700; }
.calc-table caption { caption-side: bottom; padding-top: 8px; color: var(--c-muted); font-size: 13.5px; text-align: left; }

/* Link to the formula cheat sheet at the end of "How it works" */
.calc-cheat { display: flex; align-items: center; gap: 10px; margin: 24px 0 0; padding: 14px 16px; border: 1px solid #c7d2fe; border-radius: 12px; background: var(--c-brand-soft); }
.calc-cheat i { color: #dc2626; font-size: 20px; }
.calc-doc .calc-cheat a { font-weight: 700; text-decoration: none; }
.calc-doc .calc-cheat a:hover { text-decoration: underline; }

/* "Add this calculator to your website" */
.calc-embed-box { max-width: 820px; margin: 0 0 40px; border: 1px solid var(--c-line); border-radius: 14px; background: #fff; }
.calc-embed-box summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    color: var(--c-ink);
    font-size: 16px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
}
.calc-embed-box summary::-webkit-details-marker { display: none; }
.calc-embed-box summary i { margin-right: 8px; color: var(--c-brand); }
.calc-embed-box summary::after { content: "+"; color: var(--c-brand); font-size: 22px; font-weight: 500; line-height: 1; }
.calc-embed-box[open] summary::after { content: "\2212"; }
.calc-embed-box__body { padding: 0 20px 20px; }
.calc-embed-box__body p { margin: 0 0 10px; font-size: 15px; }
.calc-embed-box textarea {
    display: block;
    width: 100%;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: var(--c-soft);
    color: var(--c-ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}
.calc-embed-box__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 10px; }
.calc-embed-box__actions a:not(.learn-btn) { font-weight: 600; }
.calc-embed-box__note { color: var(--c-muted) !important; font-size: 13.5px !important; }

/* Print and "Save as PDF": the calculation only, with a header and a link back */
.calc-print { display: none; }
@media print {
    @page { margin: 14mm 12mm; }
    body { background: #fff !important; }
    .site-nav, .site-footer, .subscribe-area, .learn-cta, .related-guides, .calc-faq, .calc-doc, .calc-embed-box,
    .calc__actions, .skip-link, .learn-crumbs, .learn-hero__lead, .learn-hero__stats, .calc__hint, .calc__note,
    .funnel-sticky-cta, .funnel-plan-modal, .cookie-notice-bar, .go-top, .preloader, .calc-embed__foot { display: none !important; }
    .learn-hero { padding: 0 0 6px !important; border: 0 !important; background: none !important; }
    .learn-hero h1 { margin: 0 !important; font-size: 20pt !important; }
    .learn-body { padding: 0 !important; }
    .container { max-width: none !important; padding: 0 !important; }
    .calc { display: flex !important; flex-direction: column; margin: 0 !important; }
    .calc-print { display: flex; }
    .calc-print--head { order: -1; }
    .calc-print--head { justify-content: space-between; gap: 12px; margin: 0 0 10px; padding: 0 0 6px; border-bottom: 2px solid var(--c-brand); color: #334155; font-size: 9.5pt; }
    .calc-print--head strong { color: var(--c-brand); }
    .calc-print--foot { display: block; margin-top: 10px; color: #475569; font-size: 8.5pt; line-height: 1.45; }
    .calc-print--foot p { margin: 0 0 3px; color: #475569 !important; font-size: 8.5pt !important; }
    .calc-print--foot span { color: var(--c-brand); word-break: break-all; }
    .calc__inputs, .calc__results { border: 1px solid #cbd5e1 !important; border-radius: 8px !important; box-shadow: none !important; break-inside: avoid; }
    .calc__inputs { margin-bottom: 8px; padding: 10px 12px !important; }
    .calc__results { position: static !important; }
    .calc fieldset { margin-bottom: 8px; }
    .calc legend { margin-bottom: 6px; font-size: 8.5pt; }
    .calc__grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px 12px; }
    .calc__field { gap: 2px; }
    .calc__field label, .calc__seg-label { font-size: 8.5pt; }
    .calc__control input, .calc__control select, .calc__field > select { height: auto; padding: 3px 6px; border-color: #cbd5e1; font-size: 10.5pt; background-image: none; }
    .calc__control .calc__unit { padding: 0 6px; font-size: 8.5pt; }
    .calc__seg input:not(:checked) + span { display: none; }
    .calc__seg input:checked + span { padding: 3px 8px; border: 1px solid #94a3b8; background: none; color: var(--c-ink); font-size: 10.5pt; }
    .calc__head { padding: 10px 12px 8px !important; background: none !important; border-bottom: 1px solid #cbd5e1; }
    .calc__head-label, .calc__sub { color: #475569 !important; }
    .calc__sub strong { color: var(--c-ink); }
    .calc__big { color: var(--c-ink) !important; font-size: 20pt !important; }
    .calc__invalid { color: #b91c1c !important; }
    .calc__list { padding: 2px 12px !important; }
    .calc__row { padding: 5px 0; }
    .calc__row dt, .calc__row dd { font-size: 10pt; }
    .calc__status { margin: 6px 12px 0 !important; padding: 4px 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
