/* ============================================================
   Калькулятор 3D-печати — «инженерная панель»
   Самодостаточный стиль. Переопределяйте токены ниже под тему сайта.
   ============================================================ */

.calc {
  /* палитра */
  --ink: #0a0d0f;
  --panel: #121a1e;
  --panel-2: #172127;
  --raise: #1d282e;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #e9eff2;
  --muted: #8a9ba4;
  --dim: #5d6d75;
  --accent: #ffb02e;
  --accent-2: #4fd1dd;
  --ok: #64e3a0;
  --err: #ff6b5e;

  --f-display: 'Bricolage Grotesque', 'Archivo', sans-serif;
  --f-body: 'Archivo', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;

  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);

  color: var(--text);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.calc *,
.calc *::before,
.calc *::after { box-sizing: border-box; }

/* атрибут hidden должен побеждать display у компонентов */
.calc [hidden] { display: none !important; }

.calc button { font: inherit; color: inherit; cursor: pointer; }

/* --- шапка --------------------------------------------------- */
.calc__head { max-width: 1100px; margin-bottom: 34px; }
.calc__eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: 12px;
}
.calc__eyebrow::after {
  content: ''; height: 1px; flex: 1; max-width: 160px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.calc__title {
  font-family: var(--f-display);
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 12px 0 10px;
}
.calc__title em { font-style: normal; color: var(--accent); }
.calc__lead { color: var(--muted); max-width: 62ch; margin: 0; }

/* --- сетка ---------------------------------------------------- */
.calc__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.9fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 1080px) { .calc__grid { grid-template-columns: 1fr; } }

/* --- сцена (превью) ------------------------------------------ */
.stage {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 460px;
  aspect-ratio: 4 / 3;
}
.stage::before {
  /* чертёжная сетка */
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(120% 100% at 50% 30%, #000 55%, transparent 100%);
  pointer-events: none;
}
.stage::after {
  /* угловые засечки */
  content: '';
  position: absolute; inset: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  pointer-events: none;
}

/* зона загрузки */
.drop {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center;
  gap: 14px; text-align: center; padding: 32px;
  transition: background 0.25s;
}
.drop.is-over { background: rgba(255, 176, 46, 0.06); }
.drop.is-over .drop__ring { transform: scale(1.06); border-color: var(--accent); }
/* подсветка всей сцены, когда файл тащат в уже открытое окно модели */
.stage.is-over { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 176, 46, 0.14), var(--shadow); }
.drop__ring {
  width: 96px; height: 96px; border-radius: 50%;
  border: 1.5px dashed var(--line-2);
  display: grid; place-content: center;
  transition: transform 0.25s, border-color 0.25s;
  color: var(--accent);
}
.drop__ring svg { width: 38px; height: 38px; }
.drop__title { font-family: var(--f-display); font-size: 21px; font-weight: 600; }
.drop__hint { color: var(--muted); font-size: 13px; }
.drop__hint b { color: var(--text); font-weight: 600; }
.drop__formats {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px;
}
/* приглашение посмотреть демо-модель */
.drop__demo {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: var(--f-body); font-size: 13px; line-height: 1.4;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
  padding: 4px 2px; margin-top: 6px;
}
.drop__demo:hover { color: var(--text); }
.tag {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em;
  padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: rgba(255, 255, 255, 0.02);
}
.tag--on { color: var(--accent); border-color: rgba(255, 176, 46, 0.4); }

/* превью */
.viewport { position: absolute; inset: 0; }
.viewport canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.viewport__bar {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.viewport__file {
  font-family: var(--f-mono); font-size: 12px; color: var(--text);
  background: rgba(10, 13, 15, 0.72); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.viewport__btn {
  pointer-events: auto;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.06em;
  background: rgba(10, 13, 15, 0.72); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px;
  color: var(--muted); transition: 0.2s;
}
.viewport__btn:hover { color: var(--text); border-color: var(--line-2); }
.viewport__btn[aria-pressed='true'] { background: var(--accent); color: #14100a; border-color: var(--accent); font-weight: 600; }
.viewport__spacer { flex: 1; }

/* панель нарезки в превью */
.stage-tools {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 3;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(10, 13, 15, 0.8); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px;
}
.tgl {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
  color: var(--muted); border-radius: 999px; padding: 6px 13px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; transition: 0.18s; white-space: nowrap;
}
.tgl:hover { color: var(--text); border-color: var(--line-2); }
.tgl[aria-pressed='true'] {
  background: var(--accent); color: #14100a; border-color: var(--accent); font-weight: 600;
}
.stage-tools__sep { width: 1px; height: 18px; background: var(--line-2); }
input[type='range'].rng--sm { flex: 1 1 120px; min-width: 90px; max-width: 240px; height: 3px; }
input[type='range'].rng--sm:disabled { opacity: 0.35; }
.stage-tools__read {
  font-family: var(--f-mono); font-size: 11px; color: var(--text);
  white-space: nowrap; min-width: 108px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* разворот окна просмотра */
.stage.is-theater {
  position: fixed; inset: 0; z-index: 80; margin: 0;
  height: 100vh; min-height: 0; aspect-ratio: auto; border-radius: 0;
}
body.theater-open { overflow: hidden; }

/* спецификация */
.spec {
  position: absolute; left: 14px; bottom: 66px;
  background: rgba(10, 13, 15, 0.8); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 12px; margin: 0; min-width: 230px;
  max-width: min(380px, calc(100% - 28px));
}
.spec__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.spec__head > span { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.spec__toggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 2px 9px; font-family: var(--f-mono);
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; transition: 0.18s;
}
.spec__toggle:hover { color: var(--text); border-color: var(--line-2); }
.spec__toggle[aria-pressed='true'] { background: var(--accent); color: #14100a; border-color: var(--accent); font-weight: 600; }
.spec__full > div { display: flex; justify-content: space-between; gap: 18px; padding: 2.5px 0; }
.spec__full dt { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--dim); }
.spec__full dd { margin: 0; font-family: var(--f-mono); font-size: 12.5px;
  color: var(--text); font-variant-numeric: tabular-nums; }
.spec__compact { font-family: var(--f-mono); font-size: 12px; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spec.is-compact .spec__full { display: none; }
.spec:not(.is-compact) .spec__compact { display: none; }

/* индикатор загрузки */
.busy {
  position: absolute; inset: 0; display: grid; place-content: center;
  background: rgba(10, 13, 15, 0.82); backdrop-filter: blur(3px);
  gap: 14px; justify-items: center; z-index: 5;
}
.busy__ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.busy__text { font-family: var(--f-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.1em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- правая панель ------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pricecard {
  position: relative;
  padding: 22px 22px 20px;
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(255, 176, 46, 0.14), transparent 55%),
    var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.pricecard__label {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--dim);
}
.pricecard__value {
  font-family: var(--f-display); font-weight: 600;
  font-size: clamp(38px, 6vw, 58px); line-height: 1;
  letter-spacing: -0.02em; margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 8px;
}
.pricecard__value .cur { font-size: 0.42em; color: var(--accent); font-weight: 500; }
.pricecard__meta { color: var(--muted); font-size: 13px; }
.pricecard__meta b { color: var(--text); font-weight: 600; }
.pricecard__note {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 11.5px; color: var(--dim); font-family: var(--f-mono); letter-spacing: 0.01em;
}

/* управление */
.controls { padding: 8px 22px 22px; }
.fieldset { padding: 16px 0; border-bottom: 1px solid var(--line); }
.fieldset:last-of-type { border-bottom: 0; }
.fieldset__title {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 12px;
}

/* чипы материалов */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  --chip: var(--accent);
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 11px; text-align: left;
  transition: 0.18s;
}
.chip:hover { border-color: var(--line-2); background: var(--raise); }
.chip.is-active { border-color: var(--chip); background: color-mix(in srgb, var(--chip) 12%, var(--panel-2)); }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip); flex: none;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--chip) 60%, transparent); transition: 0.2s; }
.chip.is-active .chip__dot { box-shadow: 0 0 0 4px color-mix(in srgb, var(--chip) 22%, transparent); }
.chip__name { font-size: 13.5px; font-weight: 600; }
.chip__price { margin-left: auto; font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); }

/* слайдеры */
.slider { margin-bottom: 15px; }
.slider:last-child { margin-bottom: 0; }
.slider__top { display: flex; justify-content: space-between; margin-bottom: 7px; }
.slider__name { font-size: 13px; color: var(--muted); }
.slider__val { font-family: var(--f-mono); font-size: 12.5px; color: var(--text);
  font-variant-numeric: tabular-nums; }
input[type='range'].rng {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 999px;
  outline: none;
  background: linear-gradient(90deg, var(--accent) var(--p, 0%), var(--line-2) var(--p, 0%));
}
input[type='range'].rng::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--ink); cursor: grab;
  box-shadow: 0 0 0 1px var(--accent);
}
input[type='range'].rng::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--ink); cursor: grab;
}

/* селекты/счётчик */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
select.sel, input.num {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--f-mono);
  font-size: 13px; color: var(--text); outline: none;
}
select.sel:focus, input.num:focus { border-color: var(--accent); }
.stepper { display: flex; align-items: center; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.stepper input { border: 0; background: transparent; text-align: center; width: 100%; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* сегменты (срочность) */
.seg-group { display: grid; grid-auto-flow: column; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.seg { border: 0; background: transparent; border-radius: 6px; padding: 8px 6px;
  font-size: 12.5px; color: var(--muted); transition: 0.18s; }
.seg:hover { color: var(--text); }
.seg.is-active { background: var(--accent); color: #14100a; font-weight: 600; }

/* чекбоксы */
.checks { display: grid; gap: 7px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check em { margin-left: auto; font-family: var(--f-mono); font-size: 10.5px; font-style: normal; color: var(--dim); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* переключатель */
.switch { display: flex; align-items: center; justify-content: space-between; }
.switch input { -webkit-appearance: none; appearance: none; width: 42px; height: 24px;
  border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: 0.2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: 0.2s; }
.switch input:checked { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.switch input:checked::after { left: 21px; background: var(--accent); }

/* предупреждения */
.warnings { padding: 0 22px 4px; display: grid; gap: 7px; }
.warn { font-size: 12.5px; color: #ffd08a; background: rgba(255, 176, 46, 0.08);
  border: 1px solid rgba(255, 176, 46, 0.22); border-radius: var(--r-sm); padding: 9px 12px; }
.warn--err { color: #ffb3ac; background: rgba(255, 107, 94, 0.08); border-color: rgba(255, 107, 94, 0.28); }

/* разбивка */
.breakdown { padding: 0 22px 20px; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; text-align: right; }
.kv dd b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.kv dd small { display: block; font-family: var(--f-mono); font-size: 10.5px; color: var(--dim); }

.cost { margin-top: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.cost h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted);
  font-family: var(--f-mono); letter-spacing: 0.06em; display: flex; justify-content: space-between; }
.cost h4 span { color: var(--text); }
.cost ul { list-style: none; margin: 0; padding: 0; }
.cost li { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); padding: 2.5px 0; font-family: var(--f-mono); }
.cost__total { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.cost__total span:last-child { font-family: var(--f-mono); }
.cost--price { background: color-mix(in srgb, var(--accent) 7%, var(--panel-2)); border-color: rgba(255, 176, 46, 0.28); }
.cost--price h4 { color: var(--text); }
.cost li i { font-style: normal; color: var(--dim); font-size: 10.5px; }
.cost__row { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.cost__row span:last-child { font-family: var(--f-mono); color: var(--ok); }

.marginbar { margin-top: 14px; }
.marginbar__track { height: 7px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.marginbar__track span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--ok)); transition: width 0.4s ease; }
.marginbar__legend { display: flex; justify-content: space-between; margin-top: 6px;
  font-family: var(--f-mono); font-size: 10.5px; color: var(--dim); }

/* CTA */
.cta { padding: 18px 22px 22px; border-top: 1px solid var(--line); background: var(--panel-2); }
.cta__btn { width: 100%; border: 0; border-radius: var(--r-sm); padding: 14px;
  font-family: var(--f-display); font-size: 16px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--accent); color: #14100a; transition: 0.18s; }
.cta__btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.cta__btn:disabled { opacity: 0.45; cursor: not-allowed; }
.cta__done { margin-top: 10px; font-size: 13px; color: var(--ok); }

/* раскрывающийся блок */
details.more { border-bottom: 1px solid var(--line); }
details.more > summary { list-style: none; cursor: pointer; padding: 14px 22px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: '+'; font-size: 16px; color: var(--accent); }
details.more[open] > summary::after { content: '–'; }
details.more[open] > summary { color: var(--text); }

/* ввод контактов */
.contacts { padding: 0 22px 20px; display: grid; gap: 9px; }
.contacts input, .contacts textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 13px; color: var(--text);
  font-family: var(--f-body); font-size: 14px; outline: none; resize: vertical;
}
.contacts input:focus, .contacts textarea:focus { border-color: var(--accent); }

/* появление */
.calc .fade { opacity: 0; transform: translateY(14px); }
.calc-ready .calc__head, .calc-ready .stage, .calc-ready .panel {
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.calc-ready .stage { animation-delay: 0.06s; }
.calc-ready .panel { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .calc * { animation: none !important; transition: none !important; }
}

/* --- адаптив сцены -------------------------------------------- */
/* Сцену нельзя считать от min-height: иначе ширина = 460×4/3 = 613px,
   и превью вылезает за экран телефона. Задаём ширину от колонки.
   Блок идёт ПОСЛЕ базового .stage — иначе тот его перебивает. */
@media (max-width: 1080px) {
  .stage { width: 100%; min-height: 0; aspect-ratio: 4 / 3; }
}
@media (max-width: 640px) {
  .stage { aspect-ratio: 1 / 1; }
}
