/*
 * The freight calculator — the instrument itself.
 *
 * Split out of landing.css when the calculator moved from the homepage hero to a page
 * of its own. Everything here is scoped to the console; the field, segmented control,
 * pill and slip components it is built from live in components.css, which every page
 * already loads.
 *
 * Loaded only on a registered calculator page — see lb_calculator_assets() in
 * inc/calculator.php. The homepage no longer loads any of it.
 */

/* -------------------------------------------------------------------------
 * Calculator — the instrument
 *
 * Two panes inside one clipped shell. The 1px translucent white rule outlines the
 * whole object against the band, because Deep Green on Forest is a real tonal step
 * but a quiet one, and without the outline the answer pane reads as a hole punched
 * in the paper rather than as part of the same instrument.
 * ---------------------------------------------------------------------- */

.lb-calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  align-items: stretch;
  border: var(--border-width) solid var(--rule-on-dark);
  border-radius: var(--radius-xl);
  background: var(--paper);
  overflow: hidden;
}

/* Focal entrance — the quote slip is laid on the desk, once. Backwards fill keeps
   the card invisible only during its own delay window, and the keyframe (not a base
   opacity) holds the start state, so a failed or disabled animation still shows the
   calculator in full. */
@keyframes lb-laid {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.lb-calc {
  animation: lb-laid 560ms cubic-bezier(.16, 1, .3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .lb-calc {
    animation: none;
  }
}

/* Header, fields, ledger. The ledger takes the remaining row so the deck's tinted
   working area always meets the bottom of the answer pane beside it. */
.lb-calc__deck {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  background: var(--paper);
}

/* The console header: what this control is, and the one choice that changes what
   every number under it means. */
.lb-calc__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: var(--border-width) solid var(--border-default);
}

.lb-calc__title {
  margin: 0;
  font-size: var(--text-h3);
  line-height: var(--lh-h3);
  font-weight: var(--weight-semibold);
  color: var(--deep-green);
}

/* Two equal cells sized to the wider label, rather than the body's full-width
   split — in the header the control should measure itself, not the deck. */
.lb-calc__mode {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}

.lb-calc__body {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
  align-content: start;
}

/* Two fields per row. Control heights stay at 44px — the saving is in row count. */
.lb-calc__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}

/* Weight is one number; the carton is three. The row is split to match. */
.lb-calc__pair--measure {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.85fr);
}

/* Below this the two halves get too narrow to read a country name in. */
@media (max-width: 420px) {
  .lb-calc__pair,
  .lb-calc__pair--measure {
    grid-template-columns: 1fr;
  }
}

.lb-calc__notice {
  margin-top: calc(-1 * var(--space-2));
}

/* The worked area: both weight candidates, the formula that produced the second,
   and the badge naming which of them the bill is actually written against. */
.lb-calc__ledger {
  padding: var(--space-5) var(--space-6) var(--space-6);
  background: var(--green-tint-3);
  border-top: var(--border-width) solid var(--border-default);
}

.lb-calc__rows {
  display: grid;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-small);
}

.lb-calc__rows .lb-slip__row > span:first-child {
  font-family: var(--font-bangla), var(--font-body);
}

.lb-calc__rows .lb-slip__row--total {
  margin-top: var(--space-1);
  padding-top: 10px;
}

.lb-calc__note {
  margin: var(--space-3) 0 0;
}

.lb-calc--invalid .lb-calc__note {
  color: var(--status-delayed-ink);
}

/* -------------------------------------------------------------------------
 * The answer pane — the stub, torn off along the perforation
 * ---------------------------------------------------------------------- */

.lb-calc__answer {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-6);
  background: var(--surface-dark);
  color: var(--text-on-dark);
}

/*
 * The perforation, and the reason the whole thing reads as paper rather than as a
 * panel. The holes are punched right through: they are painted in the band's own
 * Forest so what shows through the deck is the page behind it. That ties the dot
 * colour to .lb-hero being a --darker band; if the hero ever moves to another
 * surface this value moves with it.
 */
.lb-calc__answer::before {
  content: "";
  position: absolute;
  inset-block: -8px;
  inset-inline-start: -3px;
  width: 6px;
  background-image: radial-gradient(circle at center, var(--surface-darker) 2.1px, transparent 2.5px);
  background-size: 6px 19px;
  background-repeat: repeat-y;
  pointer-events: none;
}

.lb-calc__answer-head {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

/* Named in the same breath as the price, and the pane's quietest line — it is a
   caveat, not a warning, so it steps down through white rather than changing hue. */
.lb-calc__excluded {
  margin: var(--space-1) 0 0;
  font-size: var(--text-body-sm);
  line-height: var(--lh-body-sm);
  color: var(--text-on-dark-2);
}

.lb-calc__answer-label {
  display: block;
  font-size: var(--text-small);
  color: var(--text-on-dark-3);
}

/* The answer's own register. The page's display type caps at 42px and this sits one
   step under it: the headline is the company's voice, the price is its proof. */
.lb-calc__price {
  display: block;
  font-size: var(--text-display);
  line-height: var(--lh-display);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--white);
}

.lb-calc--invalid .lb-calc__price {
  opacity: .45;
}

/* Principle 2 rendered as adjacency: what the price excludes is one line under the
   price, not a footnote further down the page. */
.lb-chrome .lb-calc__link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-size: var(--text-small);
  color: var(--text-on-dark-2);
  text-decoration: underline;
}

.lb-chrome .lb-calc__link:hover {
  color: var(--white);
}

/* The Deep Green ring disappears into this pane, so focus switches to white here —
   the same per-surface move the ghost button and the accent button already make. */
.lb-chrome .lb-calc__link:focus-visible,
.lb-chrome .lb-calc__share:focus-visible {
  box-shadow: 0 0 0 var(--focus-width) var(--white);
}

.lb-calc__answer-foot {
  display: grid;
  gap: var(--space-4);
}

/* The second register of the receipt: what the price buys in days. Ruled off from
   the money above it, and part of the same top group, so the pane's air collects in
   one place — between the answer and the action — instead of pooling in its middle. */
.lb-calc__transit {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--rule-on-dark);
}

.lb-calc__transit-value {
  font-size: var(--text-h3);
  font-weight: var(--weight-semibold);
  color: var(--white);
}

.lb-chrome .lb-calc__share {
  justify-self: center;
  min-height: 24px; /* Same floor as a standalone link, per WCAG 2.5.8. */
  padding: 0 var(--space-1);
  font-size: var(--text-small);
  font-weight: var(--weight-regular);
  color: var(--text-on-dark-2);
}

.lb-chrome .lb-calc__share:hover {
  color: var(--white);
  text-decoration: underline;
}

/* -------------------------------------------------------------------------
 * Answer motion — the rise family
 *
 * The volumetric line is the answer people came for; it fades in when it changes,
 * and the total and the basis badge re-rise with it as one event.
 * ---------------------------------------------------------------------- */

@keyframes lb-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.lb-calc__reveal.is-revealed,
.lb-calc__price.is-revealed,
.lb-pill--basis.is-revealed {
  animation: lb-rise var(--dur-slow) var(--ease-standard) both;
}

@media (prefers-reduced-motion: reduce) {
  .lb-calc__reveal.is-revealed,
  .lb-calc__price.is-revealed,
  .lb-pill--basis.is-revealed {
    animation: none;
  }
}

/* -------------------------------------------------------------------------
 * Instrument, narrowed
 * ---------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .lb-calc {
    grid-template-columns: minmax(0, 1fr) minmax(272px, 320px);
  }

  .lb-calc__body,
  .lb-calc__head {
    padding-inline: var(--space-5);
  }

  .lb-calc__ledger {
    padding-inline: var(--space-5);
  }

  .lb-calc__answer {
    padding: var(--space-5);
  }
}

/* One column. The perforation turns with the layout: the stub now tears off the
   bottom of the deck rather than its side. */
@media (max-width: 899px) {
  .lb-calc {
    grid-template-columns: minmax(0, 1fr);
  }

  .lb-calc__answer::before {
    inset-block: auto;
    inset-inline: -8px;
    inset-block-start: -3px;
    width: auto;
    height: 6px;
    background-size: 19px 6px;
    background-repeat: repeat-x;
  }

  .lb-calc__answer {
    gap: var(--space-6);
  }
}

/* The header's two halves stop sharing a line before either of them has to wrap
   inside itself. */
@media (max-width: 559px) {
  .lb-calc__head {
    justify-content: flex-start;
  }

  .lb-calc__mode {
    width: 100%;
  }
}
/* -------------------------------------------------------------------------
 * The page around the instrument
 *
 * The console keeps the Forest band it was designed on — the perforation depends on
 * it — so the page opens dark and the explanation runs on Paper beneath.
 * ---------------------------------------------------------------------- */

.lb-calcpage__top {
  padding-block: var(--space-12) var(--space-16);
}

.lb-calcpage__head {
  display: grid;
  gap: var(--space-4);
  max-width: 680px;
  margin: 0 0 var(--space-10);
}

.lb-calcpage__overline {
  margin: 0;
  color: var(--text-on-dark-3);
}

.lb-calcpage__title {
  color: var(--white);
  text-wrap: balance;
}

/* One step up from body, the way a standfirst under a display always is here — 17px
   under a 40px display reads as fine print. */
.lb-calcpage__standfirst {
  margin: 0;
  max-width: 62ch;
  font-size: var(--text-lede-lg);
  line-height: var(--lh-bangla);
  color: var(--text-on-dark-2);
}

@media (max-width: 767px) {
  .lb-calcpage__top {
    padding-block: var(--space-10) var(--space-12);
  }

  .lb-calcpage__head {
    margin-bottom: var(--space-8);
  }
}

/* -------------------------------------------------------------------------
 * Explanation furniture
 * ---------------------------------------------------------------------- */

/* A formula is read left to right and compared against the one above it, so it gets
   the numeric face, tabular figures and a quiet surface of its own. A tonal step and a
   1px rule, not a box shadow — the Flat-At-Rest Rule holds here too. */
.lb-formula {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-quiet);
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-numeric);
  font-size: var(--text-body-sm);
  line-height: var(--lh-body-sm);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  overflow-x: auto;
}

/* The answer a card is making. One step up from its body copy, Deep Green, and never
   amber — amber on this page belongs to the basis badge inside the console. */
.lb-calc-fact {
  margin: var(--space-3) 0 0;
  font-size: var(--text-body-sm);
  line-height: var(--lh-body-sm);
  font-weight: var(--weight-semibold);
  color: var(--deep-green);
}

.lb-calc-rules {
  max-width: 74ch;
}

.lb-calc-rules strong {
  font-weight: var(--weight-semibold);
  color: var(--deep-green);
}
