/* site/css/tools.css -- the Marlmont Capital calculators (tools/toolspec.py, site/js/tools.js). The original site's .calc styles in base.css
   carry the frame: the fields on the left, the reading in a dark panel on the right. This file adds only what they lack: the results list,
   the stacked bar, grouped fields, a field marked invalid, the question tools' options and their results. Square corners, hairlines, no
   shadows, colors from the site's variables. */

/* ---------- the reading ---------- */
.calc[data-tool] .calc__out { gap: 12px; }
.calc[data-tool] .calc__v { overflow-wrap: anywhere; }
.calc[data-tool] .calc__eq { min-height: 1.45em; line-height: 1.45; }

/* the figures, one to a row: the label on the left, the figure on the right */
.tres { display: grid; margin: 4px 0 0; }
.tres__r { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 18px; padding: 11px 0; border-top: 1px solid var(--line-dark); }
.tres__r:last-child { border-bottom: 1px solid var(--line-dark); }
.tres dt { display: flex; align-items: baseline; gap: 10px; min-width: 0; color: rgba(255, 255, 255, .74); font-size: 14.5px; line-height: 1.45; }
.tres dd { margin: 0; color: #fff; font-size: 15.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tres__r--strong dt { color: #fff; font-weight: 600; }
.tres__r--strong dd { font-size: 17px; }
.tres__r.is-flag dd { color: var(--accent-dark); }
.tres__r.is-flag dd::after { content: " \2193"; }   /* a down arrow beside a figure below the usual test */
.tres + .calc__t { margin-top: 6px; padding-top: 10px; border-top: 0; }   /* one hairline under the figures, not two */

/* the stacked bar and its key: senior white, stretch pale, mezzanine the light accent, preferred equity the blue accent, equity faint */
.tk1 { --k: #fff; }
.tk2 { --k: rgba(255, 255, 255, .55); }
.tk3 { --k: var(--accent-dark); }
.tk4 { --k: var(--accent); }
.tk0 { --k: rgba(255, 255, 255, .16); }
.tbar { display: flex; height: 14px; margin: 6px 0 2px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.tbar__s { display: block; flex: none; width: 0; height: 100%; background: var(--k); transition: width .45s var(--ease); }
.tbar__s + .tbar__s { border-left: 1px solid var(--panel); }
.tkey { flex: none; width: 10px; height: 10px; background: var(--k); transform: translateY(-1px); }
.tkey.tk0 { outline: 1px solid rgba(255, 255, 255, .4); outline-offset: -1px; }
@media (prefers-reduced-motion: reduce) { .tbar__s { transition: none; } }

/* ---------- the fields ---------- */
/* a field outside its range, or empty: the original form's error color on its border */
.calc__inp.is-bad, .calc__inp.is-bad:hover, .calc__inp.is-bad:focus-within { border-color: #B42318; }
.calc__inp input[aria-invalid="true"] { color: #B42318; }
/* number fields without the browser's spinner, as on the original site's inputs */
.calc[data-tool] .calc__inp input::-webkit-outer-spin-button, .calc[data-tool] .calc__inp input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.calc[data-tool] .calc__inp input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* a group of two fields side by side (each layer of the capital stack: its share and its rate) */
.tgrp { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 18px 0 0; border: 0; border-top: 1px solid var(--line); }
.tgrp legend { float: left; display: grid; gap: 4px; width: 100%; padding: 0; color: var(--navy); font-size: 16px; font-weight: 600; }
.tgrp legend small { color: var(--muted); font-size: 14px; font-weight: 400; }
.tgrp__f { clear: both; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.tgrp .calc__f label { color: var(--muted); font-size: 14px; font-weight: 500; }

/* ---------- the question tools (solutions finder, structure matcher) ---------- */
.calc--quiz { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.calc--quiz .calc__in { gap: 10px; }
.calc--quiz .calc__in > .note { margin-top: 12px; }
.calc--quiz .pquiz__opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.calc--quiz .pquiz__o:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* an odd last option takes the full row, so rows end level */
.calc--quiz .pquiz__count { margin-bottom: 2px; }
.calc--quiz .calc__t { margin-top: 4px; }

/* the result: one to three structures, numbered, each with why it may fit and a link to its page */
.trec { display: grid; margin: 4px 0 0; padding: 0; list-style: none; }
.trec[hidden] { display: none; }
.trec__i { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 16px 0; border-top: 1px solid var(--line-dark); }
.trec__i:last-child { border-bottom: 1px solid var(--line-dark); }
.trec__n { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(255, 255, 255, .34); border-radius: 50%; color: #fff; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.trec__b { display: grid; gap: 6px; justify-items: start; }
.trec__t { color: #fff; font: 500 clamp(18px, 1.3vw, 20px)/1.3 var(--serif); letter-spacing: -.01em; }
.trec__b p { color: rgba(255, 255, 255, .8); font-size: 15px; line-height: 1.55; }
.trec__b .link { margin-top: 2px; color: #fff; font-size: 15px; }

/* ---------- smaller screens ---------- */
@media (max-width: 1279.98px) { .calc--quiz .pquiz__opts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1023.98px) { main .calc.calc--quiz { grid-template-columns: minmax(0, 1fr); } main .calc.calc--quiz .calc__out { margin: 0 -1px -1px; } }
@media (max-width: 759.98px) {
  .calc[data-tool] .calc__out .btn { white-space: normal; text-align: left; }   /* the button's words wrap rather than run past a phone's edge */
  .tres dt { font-size: 14px; }
  .tres dd { font-size: 15px; }
  .tgrp__f { gap: 10px 12px; }
}

/* The capital stack (18 November 2026): four tranches stacked one under another made the inputs far taller than the results, leaving
   an empty dark panel. On wide screens the tranches sit two by two, so the inputs and the results end close together. */
@media (min-width: 1024px) {
  .calc[data-tool="stack"] .calc__in { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .calc[data-tool="stack"] .calc__in > .calc__f, .calc[data-tool="stack"] .calc__in > .note { grid-column: 1 / -1; }
  .calc[data-tool="stack"] .tgrp legend small { min-height: 2.6em; }
}

/* Calculators with four or more inputs (18 November 2026): one long column of inputs left the results panel beside it with a large
   empty area. On wide screens the inputs sit two by two, with each input aligned to the foot of its row. */
@media (min-width: 1024px) {
  .calc[data-tool]:not(.calc--quiz) .calc__in:has(> .calc__f:nth-of-type(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .calc[data-tool]:not(.calc--quiz) .calc__in:has(> .calc__f:nth-of-type(4)) > .calc__f { align-content: space-between; }
  .calc[data-tool]:not(.calc--quiz) .calc__in:has(> .calc__f:nth-of-type(4)) > :not(.calc__f) { grid-column: 1 / -1; }
}

/* The question tools (the solutions finder, the structure matcher), 18 November 2026: the questions sit two by two on wide screens,
   so the answers panel beside them is not left half empty; an odd last question runs the full width with its options in pairs. */
@media (min-width: 1024px) {
  .calc--quiz .calc__in { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; align-items: stretch; }
  .calc--quiz .calc__in > :not(.pquiz__q) { grid-column: 1 / -1; }
  .calc--quiz .calc__in > .pquiz__q .pquiz__opts { grid-template-columns: minmax(0, 1fr); }
  .calc--quiz .calc__in > .pquiz__q:nth-last-child(2):nth-child(odd) { grid-column: 1 / -1; }
  .calc--quiz .calc__in > .pquiz__q:nth-last-child(2):nth-child(odd) .pquiz__opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
