/* ═══════════════════════════════════════════════════════════
   Калькулятор (главная) — «бланк заказа + табличка сметы».
   Слева белый бланк с пронумерованными строками, справа
   сумеречная табличка: строки сметы, итог тёплым LED и каналы
   связи. Токены — из home.css (body.home).
   ═══════════════════════════════════════════════════════════ */

.cx {
  position: relative;
  padding: clamp(48px, 6vw, 88px) 0;
  scroll-margin-top: 64px;
}

.cx__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  align-items: start;
  border: 2px solid var(--h-ink);
  background: var(--h-white);
}

/* ── Бланк ─────────────────────────────────────────────────── */

.cx__sheet {
  margin: 0;
  min-width: 0;
}

.cx__row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px 28px;
  margin: 0;
  padding: 26px 28px;
  border: 0;
  border-top: 1px solid var(--h-line);
  min-inline-size: 0;
}

.cx__row:first-child {
  border-top: 0;
}

.cx__row[hidden] {
  display: none;
}

/* legend в fieldset не участвует в grid — выносим его из потока */
fieldset.cx__row {
  position: relative;
  display: block;
  padding-left: calc(28px + 168px + 28px);
}

fieldset.cx__row > .cx__label {
  position: absolute;
  top: 26px;
  left: 28px;
  width: 168px;
}

.cx__label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 0;
  font-family: var(--h-display);
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--h-ink);
}

.cx__num {
  font-size: 15px;
  font-weight: 700;
  color: var(--h-ochre-deep);
  font-variant-numeric: tabular-nums;
}

/* Плитки выбора */

.cx__choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.cx__choices:has(.cx__choice--light) {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.cx__choices--compact {
  grid-template-columns: repeat(2, minmax(0, 220px));
}

.cx__choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1.5px solid var(--h-line);
  border-radius: 6px;
  background: var(--h-white);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.cx__choice:hover {
  border-color: var(--h-ink);
}

.cx__choice input,
.cx__pill input,
.cx__check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cx__choice-name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
}

.cx__choice-meta {
  font-size: 13px;
  color: var(--h-ochre-deep);
}

.cx__choice:has(input:checked) {
  border-color: var(--h-dusk);
  background: var(--h-dusk);
  color: var(--h-dusk-text);
}

.cx__choice:has(input:checked) .cx__choice-meta {
  color: var(--h-led);
}

.cx__choice:has(input:focus-visible),
.cx__pill:has(input:focus-visible),
.cx__check:has(input:focus-visible) {
  outline: 3px solid var(--h-ochre);
  outline-offset: 2px;
}

/* Подсветка: мини-табличка с буквой, горящей нужным способом */

.cx__choice--light {
  padding-top: 12px;
}

.cx__glyph {
  display: grid;
  place-items: center;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: var(--h-dusk-2);
  font-family: var(--h-display);
  font-style: normal;
  font-weight: 900;
  font-size: 48px;
  line-height: 1;
  color: var(--h-opal);
}

.cx__choice:has(input:checked) .cx__glyph {
  background: #14203a;
}

[data-light="flat"] .cx__glyph {
  color: #C9CDD6;
}

[data-light="side"] .cx__glyph {
  color: var(--h-opal);
  text-shadow: 0 0 2px var(--h-led), 0 0 10px rgba(255, 226, 166, 0.7);
  -webkit-text-stroke: 1.5px var(--h-led);
}

[data-light="face"] .cx__glyph {
  color: var(--h-led);
  text-shadow: 0 0 8px rgba(255, 226, 166, 0.9), 0 0 22px rgba(255, 200, 110, 0.6);
}

[data-light="contour"] .cx__glyph {
  color: #0e1628;
  text-shadow: 0 0 6px rgba(255, 226, 166, 0.95), 0 0 18px rgba(255, 200, 110, 0.75), 0 0 34px rgba(255, 190, 90, 0.45);
}

/* Поля */

.cx__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px 28px;
}

.cx__field--wide {
  grid-column: 1 / -1;
}

.cx__field-label {
  display: block;
  margin: 0 0 10px;
  font-weight: 600;
  font-size: 14px;
}

.cx__field-hint {
  font-weight: 400;
  font-size: 13px;
  color: var(--h-ink-soft);
}

.cx__slide {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.cx__readout {
  min-width: 3.6ch;
  font-family: var(--h-display);
  font-weight: 900;
  font-size: clamp(48px, 5vw, 68px);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.cx__range {
  --fill: 21%;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.cx__range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--h-dusk) var(--fill), var(--h-line) var(--fill));
}

.cx__range::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--h-dusk) var(--fill), var(--h-line) var(--fill));
}

.cx__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border: 3px solid var(--h-white);
  border-radius: 50%;
  background: var(--h-ochre);
  box-shadow: 0 0 0 1.5px var(--h-ink);
}

.cx__range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid var(--h-white);
  border-radius: 50%;
  background: var(--h-ochre);
  box-shadow: 0 0 0 1.5px var(--h-ink);
}

.cx__range:focus-visible {
  outline: 3px solid var(--h-ochre);
  outline-offset: 4px;
}

.cx__presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.cx__presets .cx__field-hint {
  margin-left: 8px;
}

.cx__preset {
  min-width: 48px;
  min-height: 36px;
  padding: 0 10px;
  border: 1.5px solid var(--h-line);
  border-radius: 6px;
  background: var(--h-white);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--h-ink);
  cursor: pointer;
}

.cx__preset:hover {
  border-color: var(--h-ink);
}

.cx__preset[aria-pressed="true"] {
  border-color: var(--h-dusk);
  background: var(--h-dusk);
  color: var(--h-white);
}

.cx__stepper {
  display: inline-grid;
  grid-template-columns: 44px 64px 44px;
  height: 48px;
  border: 1.5px solid var(--h-ink);
  border-radius: 6px;
  overflow: hidden;
}

.cx__stepper button {
  border: 0;
  background: var(--h-white);
  font-size: 22px;
  line-height: 1;
  color: var(--h-ink);
  cursor: pointer;
}

.cx__stepper button:hover {
  background: var(--h-ochre-pale);
}

.cx__stepper input,
.cx__input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 18px;
  text-align: center;
  color: var(--h-ink);
  -moz-appearance: textfield;
}

.cx__stepper input {
  border-inline: 1.5px solid var(--h-line);
}

.cx__input {
  height: 48px;
  max-width: 140px;
  border: 1.5px solid var(--h-ink);
  border-radius: 6px;
  text-align: left;
  padding: 0 14px;
}

.cx__stepper input::-webkit-inner-spin-button,
.cx__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* Таблетки и галочки */

.cx__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cx__pill {
  position: relative;
  cursor: pointer;
}

.cx__pill span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1.5px solid var(--h-line);
  border-radius: 999px;
  font-size: 15px;
}

.cx__pill:hover span {
  border-color: var(--h-ink);
}

.cx__pill input:checked + span {
  border-color: var(--h-dusk);
  background: var(--h-dusk);
  color: var(--h-white);
}

.cx__sub {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--h-line);
}

.cx__sub[hidden] {
  display: none;
}

.cx__check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 16px;
  font-size: 15px;
  cursor: pointer;
}

.cx__check::before {
  content: '';
  flex: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--h-ink);
  border-radius: 4px;
  background: var(--h-white) center / 14px no-repeat;
}

.cx__check:has(input:checked)::before {
  border-color: var(--h-dusk);
  background-color: var(--h-dusk);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFE2A6' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* ── Табличка сметы ────────────────────────────────────────── */

.cx__bill {
  align-self: stretch;
  background: var(--h-dusk);
  color: var(--h-dusk-text);
}

.cx__bill-inner {
  position: sticky;
  top: 84px;
  padding: 28px;
}

.cx__bill-title {
  margin: 0 0 14px;
  font-family: var(--h-display);
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
}

.cx__lines {
  margin: 0;
}

.cx__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--h-dusk-line);
}

.cx__line dt {
  font-weight: 600;
  font-size: 15px;
}

.cx__line dt small {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.4;
  color: var(--h-dusk-soft);
}

.cx__line dd {
  margin: 0;
  flex: none;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.cx__total {
  margin: 4px 0 24px;
  padding-top: 16px;
  border-top: 2px solid var(--h-dusk-text);
}

.cx__total-label {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--h-dusk-soft);
}

.cx__total-value {
  margin: 6px 0 0;
  font-family: var(--h-display);
  font-weight: 900;
  font-size: clamp(54px, 5.4vw, 76px);
  line-height: 0.95;
  color: var(--h-led);
  text-shadow: 0 0 22px rgba(255, 200, 110, 0.35);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Пришли из первого экрана: итог «загорается», чтобы было видно, куда смотреть */
.cx__total-value.is-lit {
  animation: cx-lit 1400ms ease-out 450ms both;
}

@keyframes cx-lit {
  0% { text-shadow: 0 0 22px rgba(255, 200, 110, 0.35); }
  25% { text-shadow: 0 0 6px #fff, 0 0 30px rgba(255, 210, 130, 0.95), 0 0 70px rgba(255, 190, 90, 0.6); color: #FFF4DA; }
  100% { text-shadow: 0 0 22px rgba(255, 200, 110, 0.35); }
}

.cx__total-value .calc__total-from-prefix {
  font-size: 0.5em;
}

.cx__total-value b {
  font-weight: 900;
}

.cx__fine {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--h-dusk-soft);
}

.cx__send-title {
  margin: 0 0 10px;
  font-weight: 600;
  font-size: 15px;
}

.cx__send {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cx__send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 8px;
  border: 1.5px solid var(--h-dusk-line);
  border-radius: 4px;
  font-weight: 600;
  font-size: 15px;
  color: var(--h-dusk-text);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 240ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cx__send-btn:hover {
  border-color: var(--h-dusk-text);
  background-color: rgba(233, 236, 243, 0.06);
}

.cx__send-btn:active {
  transform: translateY(1px) scale(0.985);
}

/* Главный канал — охра с бликом, как кнопки в цоколе первого экрана */
.cx__send-btn--main {
  grid-column: 1 / -1;
  min-height: 56px;
  border-color: var(--h-ochre);
  background-color: var(--h-ochre);
  background-image: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.5) 50%, transparent 62%);
  background-size: 260% 100%;
  background-position: 130% 0;
  background-repeat: no-repeat;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 -2px 0 rgba(138, 90, 16, 0.35) inset;
  font-size: 16px;
  color: var(--h-ink);
  transition:
    background-color 160ms ease,
    background-position 0s linear 200ms,
    box-shadow 240ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cx__send-btn--main:hover {
  border-color: #EBB955;
  background-color: #EBB955;
  background-position: -30% 0;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 -2px 0 rgba(138, 90, 16, 0.35) inset,
    0 0 0 4px rgba(221, 162, 58, 0.3),
    0 0 28px rgba(255, 200, 110, 0.4);
  transition:
    background-color 160ms ease,
    background-position 750ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 240ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cx__send-btn:focus-visible,
.cx__tool:focus-visible {
  outline: 3px solid var(--h-led);
  outline-offset: 2px;
}

.cx__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 16px;
}

.cx__tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--h-dusk-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cx__tool:hover {
  color: var(--h-dusk-text);
}

.cx__consent {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--h-dusk-soft);
}

.cx__consent a {
  color: inherit;
}

.cx__toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 60;
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--h-ink);
  color: var(--h-white);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.cx__toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Планшет и телефон ─────────────────────────────────────── */

@media (max-width: 1023px) {
  .cx__body {
    grid-template-columns: 1fr;
  }

  .cx__bill,
  .cx__bill-inner {
    position: static;
  }
}

@media (max-width: 719px) {
  .cx__body {
    margin-inline: calc(var(--ks-gutter, 16px) * -1);
    border-inline: 0;
  }

  .cx__row,
  fieldset.cx__row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 22px 16px;
  }

  /* float выносит legend из рамки fieldset */
  fieldset.cx__row > .cx__label {
    position: static;
    float: left;
    width: 100%;
    margin-bottom: 16px;
  }

  fieldset.cx__row > .cx__label + * {
    clear: both;
  }

  .cx__label {
    font-size: 24px;
  }

  .cx__choices {
    grid-template-columns: 1fr 1fr;
  }

  .cx__choices--product {
    grid-template-columns: 1fr;
  }

  .cx__slide {
    gap: 16px;
  }

  .cx__bill-inner {
    padding: 24px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cx__total-value.is-lit {
    animation: none;
  }

  .cx__send-btn,
  .cx__send-btn--main,
  .cx__send-btn--main:hover {
    transition: none;
  }
}
