/*
 * Extra calculator parts for the bigger tools (groups, good/better/best
 * cards, result lists, the Copy results button). Builds on the .calc styles
 * in /content.css and its --c-* tokens, so light and dark both work.
 * Linked from each tools/*.widget.html. Could fold into content.css later.
 */
.calc [hidden] { display: none !important; }
/* Text inputs carry a wide default size; let them shrink to their column. */
.calc .calc__field { grid-template-columns: minmax(0, 1fr); min-width: 0; align-content: start; }
.calc .calc__input { min-width: 0; }
.calc .calc__input input, .calc .calc__input select { width: 100%; }
.calc .calc__unit { white-space: nowrap; min-width: 0; }
.calc__group { border: 0; margin: 0; padding: 0; min-width: 0; }
.calc__group + .calc__group { margin-top: 26px; padding-top: 20px; border-top: 1px dashed var(--c-dash); }
/* A plain legend sits ON the fieldset's top border, so the first one (no border)
   and the later ones (dashed rule) were spaced differently. Floated, the legend
   becomes ordinary content: every one starts the same distance below the rule. */
.calc__legend { float: left; width: 100%; padding: 0; margin: 0 0 12px; font-family: var(--hand); font-size: 23px; line-height: 1.2; color: var(--c-eyebrow); }
.calc__legend + * { clear: both; }
.calc__intro { margin: -4px 0 14px; font-size: 15px; line-height: 1.5; color: var(--c-soft); }
.calc__hint { font-size: 14px; line-height: 1.4; color: var(--c-muted); }
.calc__err { font-size: 14.5px; font-weight: 600; color: #a2402e; }
.calc__input input[aria-invalid="true"] { border-color: #a2402e; }
@media (prefers-color-scheme: dark) {
  .calc__err { color: #f0a48f; }
  .calc__input input[aria-invalid="true"] { border-color: #f0a48f; }
}

/* Good, better, best: three cards that stack on a phone. */
.calc__tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.calc__tier { border: 1px solid var(--c-card-line); border-radius: 14px; padding: 14px; display: grid; gap: 12px; align-content: start; background: var(--c-bg); min-width: 0; }
.calc__tiername { font-weight: 700; font-size: 17px; color: var(--c-ink); }

/* Results */
.calc__results { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--c-dash); }
.calc__results > * + * { margin-top: 14px; }
.calc__resgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.calc__res { border: 1px solid var(--c-card-line); border-radius: 14px; padding: 14px 16px; background: var(--c-bg); min-width: 0; }
.calc__res--main { border-width: 2px; border-color: var(--c-card-hover); }
.calc__reshead { font-family: var(--hand); font-size: 22px; line-height: 1.2; color: var(--c-eyebrow); }
.calc__res .calc__big { display: block; margin: 2px 0 8px; font-size: clamp(26px, 4.4vw, 32px); overflow-wrap: anywhere; }
.calc__dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; font-size: 15.5px; line-height: 1.45; }
.calc__dl dt, .calc__dl dd { padding: 6px 0; border-top: 1px dashed var(--c-line); }
.calc__dl dt { color: var(--c-soft); padding-right: 10px; }
.calc__dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--c-ink); }
.calc__dl dt:first-of-type, .calc__dl dd:first-of-type { border-top: 0; }
.calc__dl .calc__total { font-weight: 750; }
.calc__status { font-size: 15px; font-weight: 600; color: #a2402e; }
@media (prefers-color-scheme: dark) { .calc__status { color: #f0a48f; } }
.calc__flag { font-size: 15px; line-height: 1.5; color: var(--c-soft); border-left: 3px solid var(--c-card-hover); padding: 2px 0 2px 12px; }

/* Copy results */
.calc__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 18px; }
.calc__btn {
  min-height: 48px;
  padding: 0 20px;
  font: 600 16px var(--sans);
  color: var(--c-ink);
  background: var(--c-field);
  border: 1.6px solid var(--c-card-hover);
  border-radius: 12px;
  cursor: pointer;
}
.calc__btn:hover { border-color: var(--c-ink); }
.calc__btn:focus-visible { outline: 2px solid var(--c-link); outline-offset: 2px; }
.calc__copied { font-size: 15px; color: var(--c-soft); flex: 1 1 220px; }
.calc__fallback {
  display: block;
  width: 100%;
  min-height: 180px;
  margin-top: 10px;
  padding: 10px 12px;
  font: 16px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--c-ink);
  background: var(--c-field);
  border: 1.6px solid var(--c-card-line);
  border-radius: 12px;
}

/* Crew pay: four people side by side on a desktop, two or one on a phone. */
.calc__people { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); margin-top: 14px; }

/* "The math": each step of the answer in words, printed under the results. */
.calc__mathbox { border: 1px dashed var(--c-dash); border-radius: 14px; padding: 12px 16px 14px; min-width: 0; }
.calc__math { display: block; margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; color: var(--c-soft); font-variant-numeric: tabular-nums; }

/* The main result, pinned to the bottom of the screen while the inputs are
   on screen and the results are not (ui.js stickyResult). Fixed, so the
   page never moves when it shows. A full-width bar on a phone, a small card
   at the bottom right on a wider screen. */
.calc__sticky {
  position: fixed;
  z-index: 30;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--c-ink);
  color: var(--c-bg);
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  visibility: hidden;
  opacity: 0;
}
.calc__sticky.is-on { visibility: visible; opacity: 1; }
.calc__sticky:focus-visible { outline: 2px solid var(--c-link); outline-offset: 2px; }
.calc__sticky-label { font-size: 14px; font-weight: 600; opacity: 0.8; }
.calc__sticky-value { font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.calc__sticky-go { margin-left: auto; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
@media (min-width: 641px) {
  .calc__sticky { left: auto; right: 24px; bottom: 24px; max-width: 380px; }
}
@media (prefers-reduced-motion: no-preference) {
  .calc__sticky { transition: opacity 0.18s ease, visibility 0.18s ease; }
}
@media print { .calc__sticky { display: none !important; } }
/* A focused box near the bottom scrolls clear of the bar. */
html:has(.calc__sticky.is-on) { scroll-padding-bottom: 88px; }

/* On a phone every unit label in a calculator takes the same width, so the
   input boxes end at the same edge. A long unit wraps under itself. */
@media (max-width: 640px) {
  .calc .calc__unit { flex: 0 0 4.6em; white-space: normal; line-height: 1.2; }
}
