/* tools/calculator.css — the trade calculators (/tools/<calculator>).

   One stylesheet for every calculator, as there is one template
   (templates/tools/calculator_base.html) and one controller
   (static/js/controllers/esm/calculator_controller.js). The AI bar and the
   closing CTA come from generator.css, loaded before this file; the worked
   examples and FAQ from seo/components.css.

   The calculator is the page, so it leads: boxes on the left, the answer on
   the right and sticky on wide screens, the answer straight under the boxes
   on a phone. Every colour is a token from the public shell; the design token
   ratchet allows this file no hex literals. */

.calc { max-width: 1180px; margin: 0 auto; padding: 22px 20px 72px; }

.calc__head { max-width: 72ch; margin-bottom: 16px; }
.calc__head h1 {
    font-size: clamp(24px, 3vw, 32px); line-height: 1.15; margin-bottom: 6px;
    letter-spacing: -0.5px;
}
.calc__lede { font-size: 15px; color: var(--text-2); }

.calc__split {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px; align-items: start; margin-top: 18px;
}

/* ---- The boxes ---- */
.calc__form {
    background: var(--white); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
}
.calc__field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.calc__field[hidden] { display: none; }
.calc__field > label, .calc__field .form-label {
    font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px;
}
/* A choice is the shared segmented control (macros/segmented.html): its options
   side by side, each an equal, thumb-sized target. */
.calc__field--choice > .mb-3 { margin-bottom: 0 !important; }
.calc__field--choice .segmented-control {
    display: flex; width: 100%; gap: 3px; padding: 3px;
    background: var(--white); border: 1px solid var(--border); border-radius: 10px;
}
.calc__field--choice .segmented-control .btn {
    flex: 1 1 0; min-height: 40px; padding: 6px 8px; font-size: 14px; font-weight: 600;
    line-height: 1.2; color: var(--text-2); background: transparent;
    border: none; border-radius: 8px !important;
}
.calc__field--choice .btn-check:checked + .btn { background: var(--black); color: var(--white); }
.calc__field--choice .btn-check:focus-visible + .btn { outline: 2px solid var(--orange); outline-offset: 1px; }
.calc__control { display: flex; align-items: center; gap: 8px; }
.calc__control .form-control { flex: 1; min-width: 0; }
.calc__unit { font-size: 13px; color: var(--text-2); white-space: nowrap; min-width: 4.5em; }
.calc__error { font-size: 12px; color: var(--alert-danger-text); min-height: 0; margin: 0; }
.calc__field.has-error .form-control { border-color: var(--alert-danger-border); }
.calc__go {
    grid-column: 1 / -1; justify-self: start; padding: 10px 18px; border-radius: 10px;
    border: none; background: var(--orange); color: var(--white); font-weight: 600;
    cursor: pointer;
}

/* ---- The answer ---- */
.calc__answer {
    background: var(--sandstone); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px; position: sticky; top: 84px; outline: none;
}
.calc__answer-title { font-size: 15px; margin: 0 0 10px; color: var(--text-2); }
.calc__notice { color: var(--alert-danger-text); font-size: 14px; }
.calc__warnings {
    margin: 0 0 12px; padding: 10px 12px 10px 28px; border-radius: 10px;
    background: var(--alert-danger-bg); border: 1px solid var(--alert-danger-border);
    color: var(--alert-danger-text); font-size: 14px;
}
.calc__figures { width: 100%; border-collapse: collapse; }
.calc__figure th, .calc__figure td {
    padding: 9px 0; border-bottom: 1px solid var(--border); vertical-align: baseline;
}
.calc__figure:last-child th, .calc__figure:last-child td { border-bottom: none; }
.calc__figure th { font-size: 14px; font-weight: 400; color: var(--text-2); text-align: left; padding-right: 12px; }
.calc__figure td { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.calc__figure--lead th { font-weight: 600; color: var(--black); }
.calc__figure--lead td { font-size: 22px; color: var(--black); }
.calc__handoff {
    display: inline-block; margin-top: 14px; padding: 10px 16px; border-radius: 10px;
    background: var(--black); color: var(--white); font-weight: 600; text-decoration: none;
}
.calc__handoff[hidden] { display: none; }
.calc__handoff-note { font-size: 12px; color: var(--text-2); margin: 6px 0 0; }

/* ---- Below the tool ---- */
.calc__assist { margin-top: 20px; }
.calc__examples, .calc__faq { max-width: 78ch; margin-top: 40px; }
.calc__example-warning { font-size: 13px; color: var(--alert-danger-text); }

/* ---- The peek bar (phones only) ----
   Pinned to the bottom while the answer card is below the screen. The right
   edge stops short of the Chip chat bubble, which sits in that corner. */
.calc__peek { display: none; }
@media (max-width: 860px) {
    .calc__split { grid-template-columns: 1fr; }
    .calc__answer { position: static; }
    .calc__peek {
        position: fixed; left: 12px; right: 84px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 20;
        display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px;
        border-radius: 14px; background: var(--black); color: var(--white);
        text-decoration: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    }
    .calc__peek[hidden] { display: none; }
    .calc__peek-label { flex: 1; min-width: 0; font-size: 13px; line-height: 1.2; opacity: 0.8; }
    .calc__peek strong { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
}

@media (max-width: 480px) {
    .calc { padding: 16px 16px 56px; }
    .calc__form { grid-template-columns: 1fr; }
}
