/*
  A margin, drawn and typed: PriceSplit, AmountBox, CurrencyPick and CountryPick, on both hosts.
  ADR 0007 — no package, and every figure is also in text. A host lays the panel out; this draws
  its parts.

  Taxes and fees are shades of ink, the supplier's part is kraft — the parcel — and what is kept is
  solid ink. A loss is said in words and drawn hatched; a colour for it would be the red/green ramp
  the validator already refused. Tokens a host does not define fall back here, so neither host
  needs the other's stylesheet.
*/

/* ----------------------------------------------------------- the answer */

/* The figure first and large, the words beneath it: one sentence, read aloud whole. */
.answer { display: flex; flex-direction: column; gap: 0.15rem; margin: 0; }

.answer-figure {
    font-size: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.answer-line { font-size: var(--t-small); color: var(--ink-soft); line-height: 1.4; }
.answer-line strong { color: var(--ink); }

/* ------------------------------------------------------------ the split */

.price-split { margin: 1rem 0 0.4rem; }

.split-bar {
    position: relative;
    display: flex;
    gap: 2px;
    height: 1.4rem;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--chart-track, var(--tint));
}

.split-part {
    flex: 0 1 var(--w);
    min-width: 3px;
    background: color-mix(in srgb, var(--ink) 30%, transparent);
    transform-origin: left;
    transition: flex-basis calc(420ms * var(--m, 1)) var(--ease);
    animation: split-grow calc(480ms * var(--m, 1)) var(--ease) both;
    animation-delay: calc(var(--k, 0) * 55ms);
}

@keyframes split-grow { from { transform: scaleX(0); opacity: 0; } }

/* After the first answer the bar moves rather than grows again: money.js marks the fresh one. */
.price-split[data-still] .split-part { animation: none; }

@media (prefers-reduced-motion: reduce) {
    .split-part { animation: none; transition: none; }
}

.split-part.tax { background: color-mix(in srgb, var(--ink) 22%, transparent); }
.split-part.fee { background: color-mix(in srgb, var(--ink) 32%, transparent); }
.split-part.cost { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.split-part.buy { background: var(--kraft, #B89D6E); }
.split-part.kept { background: var(--ink); }
.split-part.room {
    background: color-mix(in srgb, var(--kraft, #B89D6E) 14%, transparent);
    border: 1.5px dashed var(--kraft-side, #9A8052);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* A loss: the costs past the price, hatched, with a firm edge where the price ends. */
.split-short {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--x);
    width: var(--w);
    border-left: 2px solid var(--ink);
    background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ink) 55%, transparent) 0 2px, transparent 2px 6px);
}

/* The receipt: every figure of the bar in words, each beside its colour. */
.split-receipt { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 1px; }

.split-row {
    display: grid;
    grid-template-columns: 0.75rem 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.22rem 0.4rem;
    border-radius: var(--r-sm);
    font-size: var(--t-small);
}

.split-row:hover { background: var(--tint); }
.split-label { color: var(--ink-soft); min-width: 0; }
.split-value { color: var(--ink); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.split-missing { color: var(--ink-faint); }

.split-key { width: 0.75rem; height: 0.75rem; border-radius: 3px; background: color-mix(in srgb, var(--ink) 30%, transparent); }
.split-key.price { background: none; }
.split-key.tax { background: color-mix(in srgb, var(--ink) 22%, transparent); }
.split-key.cost { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.split-key.buy { background: var(--kraft, #B89D6E); }
.split-key.kept { background: var(--ink); }
.split-key.room { background: none; border: 1.5px dashed var(--kraft-side, #9A8052); }
.split-key.loss { background: repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 4px); }

/* The first row is the price the rest come out of; the last is what is left. */
.split-row:first-child,
.split-row:last-child { border-top: 1px solid var(--line); }
.split-row:first-child { border-top: 0; }
.split-row.price .split-label,
.split-row:last-child .split-label { color: var(--ink); font-weight: 600; }
.split-row:last-child .split-value { font-weight: 700; }

.split-more { margin-top: 0.45rem; font-size: var(--t-small); }
.split-more summary { cursor: pointer; color: var(--ink-soft); }

/* --------------------------------------------------------- amount boxes */

/*
  A labelled box, its unit in front, and one line beneath saying whose figure it is. "Yours" is a
  weight and a word, never a colour on its own.
*/
.amount-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.75rem 1rem;
    margin: 0.8rem 0 0;
}

.amount-box { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.amount-field,
.amount-currency { display: flex; flex-direction: column; gap: 0.25rem; }
.amount-label { font-size: var(--t-small); color: var(--ink-soft); font-weight: 500; }

.amount-input {
    display: flex;
    align-items: center;
    min-height: var(--ctl-h, 2.25rem);
    background: var(--card);
    border: 1px solid var(--line-hi);
    border-radius: var(--r-sm);
    padding: 0 0.55rem;
}

.amount-input:focus-within { border-color: var(--ink); }

.amount-unit { color: var(--ink-faint); font-size: var(--t-small); margin-right: 0.35rem; }

.amount-input input {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: var(--t-small);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    outline: none;
}

.amount-currency select {
    font: inherit;
    font-size: var(--t-small);
    min-height: var(--ctl-h, 2.25rem);
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line-hi);
    border-radius: var(--r-sm);
    padding: 0 0.4rem;
}

.amount-country select { max-width: 100%; }

.amount-note { margin: 0; font-size: var(--t-meta); color: var(--ink-faint); line-height: 1.35; }
.amount-yours { color: var(--ink); font-weight: 650; }
.amount-problem { color: var(--ink); }
.amount-box.yours .amount-input { border-color: var(--ink-soft); }

/* Read out, never seen: the sentence a screen reader hears when the figure changes. */
.vh {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.amount-reset {
    font: inherit;
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
