/* Tiraz Labs: "calculator" (packages.html#calculator). Owner: E (simplified: collapsed behind one toggle). Tokens only.
   Phones: one column; item rows = text, then price + stepper (48px buttons); a sticky compact total bar at the end of the
   choices (it replaces the site's mobile bar while in view: data-hide-actionbar). ≥ 1080: choices | sticky summary card. */

/* collapsed by default: a short head + one toggle button, so the band is compact (sec-y-sm, not the full section rhythm) */
.calc.sec { padding-block: var(--sec-y-sm); }
.calc-intro { display: grid; gap: 20px; justify-items: start; }
.calc .calc-head { margin-block-end: 0; }
.calc-toggle { min-height: 52px; gap: 12px; }
.calc-toggle-ic { position: relative; width: 12px; height: 12px; }
.calc-toggle-ic::before, .calc-toggle-ic::after { content: ""; position: absolute; inset-block-start: 5px; inset-inline-start: 0; width: 12px; height: 1.6px; background: currentColor; }
.calc-toggle-ic::after { transform: rotate(90deg); }
.calc-toggle[aria-expanded="true"] .calc-toggle-ic::after { transform: none; }
.calc-panel { margin-block-start: 36px; }
.calc-panel[hidden] { display: none; }
.calc-save-chip { border: 1px solid var(--prestige-line); background: transparent; color: var(--prestige); font-weight: 600; }
@media (min-width: 900px) {
  .calc-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 32px; }
}

/* layout */
.calc-layout { display: grid; gap: 32px; min-width: 0; }
.calc-main { display: grid; gap: 28px; min-width: 0; }
.calc-side { min-width: 0; }

/* figures */
.calc-now, .calc-was, .calc-line-v, .calc-tot-v, .calc-step-v { font-variant-numeric: lining-nums tabular-nums; unicode-bidi: isolate; white-space: nowrap; }
.calc-now { font-family: var(--f-num); font-weight: 700; color: var(--text); }
.calc-was { color: var(--text-faint); font-size: var(--t-caption); }
.calc-per { color: var(--text-faint); font-size: var(--t-caption); }

/* start-from chips (the presets, names only + «from scratch») */
.calc-presets { display: grid; gap: 10px; }
.calc-p-k { margin: 0; font-size: var(--t-small); color: var(--text-soft); }
.calc-p-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* groups */
.calc-group { display: grid; gap: 12px; min-width: 0; }
.calc-g-title { margin: 0; }
.calc-g-note { margin: -6px 0 0; }
.calc-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.calc-item { display: grid; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); min-width: 0; transition: border-color var(--dur-1); }
.calc-item[data-on] { border-color: var(--accent-line); }
.calc-item-txt { display: grid; gap: 4px; min-width: 0; }
.calc-item-name { margin: 0; font-weight: 600; color: var(--text); line-height: 1.5; }
.calc-item-desc { margin: 0; font-size: var(--t-small); line-height: 1.6; color: var(--text-soft); }
.calc-item-note { margin: 0; font-size: var(--t-caption); color: var(--text-faint); }
.calc-item-act { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.calc-unit { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; margin: 0; min-width: 0; }
.calc-item-act .calc-unit .calc-now { flex-basis: 100%; }
.calc-unit .calc-now { font-size: 19px; }

/* stepper */
.calc-step { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface-2); }
.calc-step-btn { display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; }
.calc-step-btn:hover { background: var(--accent-soft); }
.calc-step-btn[aria-disabled="true"] { color: var(--text-faint); cursor: default; background: transparent; }
.calc-step-btn svg { width: 18px; height: 18px; }
.calc-step-v { min-width: 2.2ch; text-align: center; font-family: var(--f-num); font-weight: 700; font-size: 19px; color: var(--text); }

/* choice + toggle options */
.calc-opts { display: grid; gap: 10px; }
.calc-opt { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 14px; min-height: 64px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); cursor: pointer; transition: border-color var(--dur-1); }
.calc-opt[data-on] { border-color: var(--accent-line); }
.calc-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.calc-opt:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.calc-opt-txt { display: grid; gap: 2px; min-width: 0; }
.calc-opt .calc-unit { grid-column: 2; }
.calc-opt-mark { width: 22px; height: 22px; border: 1.5px solid var(--line-strong); border-radius: 50%; }
.calc-opt[data-on] .calc-opt-mark { border-color: var(--accent); box-shadow: inset 0 0 0 5px var(--surface), inset 0 0 0 11px var(--accent); }
.calc-opt.is-switch { grid-template-columns: 1fr auto; }
.calc-opt.is-switch .calc-unit { grid-column: 1; }
.calc-opt.is-switch .calc-switch { grid-column: 2; grid-row: 1 / span 2; }
.calc-switch { position: relative; width: 46px; height: 28px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--line-strong); transition: background-color var(--dur-1); }
.calc-switch span { position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-soft); transition: inset-inline-start var(--dur-2) var(--ease-out), background-color var(--dur-1); }
.calc-opt[data-on] .calc-switch { background: var(--accent-fill); border-color: var(--accent-fill); }
.calc-opt[data-on] .calc-switch span { inset-inline-start: 21px; background: var(--accent-ink); }

/* sticky compact total (< 1080) */
.calc-bar { position: sticky; inset-block-end: calc(var(--safe-b, 0px) + 8px); z-index: 3; }
.calc-bar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 8px 8px 8px 16px;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--r-card); box-shadow: var(--shadow-2); }
html[dir="rtl"] .calc-bar-in { padding: 8px 16px 8px 8px; }
.calc-bar-t { display: grid; gap: 0; min-width: 0; }
.calc-bar-k { font-size: var(--t-caption); color: var(--text-soft); }
.calc-bar-v { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.calc-bar-v .calc-now { font-size: 20px; color: var(--prestige); }
.calc-bar-btn { flex: none; min-height: 48px; }

/* summary */
.calc-sum { padding: 22px; }
.calc-sum-title { margin: 0 0 14px; }
.calc-sum-title:focus { outline: none; }
.calc-sum-title:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
.calc-empty { margin: 0; color: var(--text-soft); font-size: var(--t-small); }
.calc-lines { display: grid; gap: 8px; margin: 0 0 16px; padding: 0 0 16px; list-style: none; border-block-end: 1px solid var(--line); font-size: var(--t-small); }
.calc-lines li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.calc-line-n { color: var(--text-soft); min-width: 0; }
.calc-line-x { color: var(--text-faint); white-space: nowrap; }
.calc-line-v { color: var(--text); }
.calc-tot { display: grid; gap: 6px; margin: 0; }
.calc-tot-k { margin: 0; font-size: var(--t-caption); color: var(--text-faint); }
.calc-tot-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.calc-tot-row dt { color: var(--text-soft); font-size: var(--t-small); }
.calc-tot-row dd { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; gap: 2px 10px; margin: 0; }
.calc-tot-v { font-family: var(--f-num); font-weight: 700; font-size: 20px; color: var(--text); }
.calc-tot-row.is-main .calc-tot-v { font-size: clamp(30px, 1rem + 2vw, 40px); line-height: 1.15; color: var(--prestige-lg); }
.calc-save { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; font-size: var(--t-small); color: var(--text-soft); }
.calc-fine { margin: 12px 0 0; font-size: var(--t-caption); color: var(--text-faint); line-height: 1.6; }
.calc-sum-act { display: grid; gap: 10px; margin-block-start: 20px; }
.calc-unavail-cta { margin-block-start: 20px; }

@media (min-width: 640px) {
  .calc-item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 20px; }
  .calc-item-act { justify-content: flex-end; }
  .calc-item-act .calc-unit { justify-content: flex-end; text-align: end; }
  .calc-opt { grid-template-columns: auto minmax(0, 1fr) auto; }
  .calc-opt .calc-opt-mark { grid-column: 1; grid-row: 1; }
  .calc-opt .calc-opt-txt { grid-column: 2; grid-row: 1; }
  .calc-opt .calc-unit { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  .calc-opt.is-switch { grid-template-columns: minmax(0, 1fr) auto auto; }
  .calc-opt.is-switch .calc-opt-txt { grid-column: 1; }
  .calc-opt.is-switch .calc-unit { grid-column: 2; }
  .calc-opt.is-switch .calc-switch { grid-column: 3; grid-row: 1; }
}

@media (min-width: 1080px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); align-items: start; gap: 40px; }
  .calc-side { position: sticky; inset-block-start: calc(var(--hdr-h) + 16px); }
  .calc-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .calc-item, .calc-opt, .calc-switch, .calc-switch span { transition: none; }
}
