/**
 * Сборная доставка — Калькулятор (змейка из станций) и трекинг
 * Стеклянные плитки, дорога-змейка, модальные окна с опциями
 */

/* ============================================
   Калькулятор — секция
   ============================================ */
#calculator {
  padding-top: 20px;
}

/* ============================================
   Змейка станций (зигзаг: левый/правый край)
   ============================================ */
.calc-outer {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 0 8px;
}

/* Правая панель: прогресс + поля для заявки (ширина = ширина второй карточки) */
.calc-head {
  position: absolute;
  top: 0;
  right: 0;
  width: 460px;
  z-index: 3;
}

/* Заголовок секции — слева сверху (первоначальное место) */
.calc-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 20px;
  z-index: 3;
}

.calc-title h2 {
  font-size: 42px;
  letter-spacing: -0.05em;
  margin: 10px 0 6px;
}

.calc-title .section-lead {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 640px;
  margin: 0;
}

.calc-head .progress-wrap {
  margin-top: 0;
  min-width: 0;
}

/* Поля заявки (в правой панели) */
.calc-fields {
  display: grid;
  gap: 14px;
  margin-top: 120px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.grow {
  min-width: 0;
}

.field-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.field-input {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--field-bg);
  color: var(--ink);
  outline: none;
  transition: 0.2s;
}

.field-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.field-input::placeholder {
  color: var(--ink-faint);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

/* Сегментированный переключатель единиц */
.seg {
  display: inline-flex;
  background: var(--field-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  padding: 9px 15px;
  border-radius: 9px;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink-muted);
  transition: 0.2s;
}

.seg-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.snake {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 26px 48px;
  /* нижний отступ: запас под последней карточкой перед панелью */
  padding: 14px 0 40px;
}

/* --- Дорога (SVG) --- */
.road {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.road-bed {
  fill: none;
  stroke: var(--stroke-bed);
  stroke-width: 40;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.road-line {
  fill: none;
  stroke: var(--stroke-line);
  stroke-width: 3;
  stroke-dasharray: 3 19;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: roadFlow 1.2s linear infinite;
}

.road-glow {
  fill: none;
  stroke: url(#roadGlow);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.5;
  filter: blur(4px);
}

/* ============================================
   Стеклянная плитка-станция
   ============================================ */
.tile {
  position: relative;
  z-index: 2;
  width: min(460px, 100%);
  aspect-ratio: 0.9;
  border-radius: 26px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 45px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
  text-align: left;
  overflow: hidden;
  transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1), border-color 0.32s, box-shadow 0.32s;
}

/* Акцентный цвет каждой станции */
.tile[data-stage="1"] { --tile-c: #3b82f6; --tile-glow: rgba(59, 130, 246, 0.5); }
.tile[data-stage="2"] { --tile-c: #22d3ee; --tile-glow: rgba(34, 211, 238, 0.5); }
.tile[data-stage="3"] { --tile-c: #22c55e; --tile-glow: rgba(34, 197, 94, 0.5); }
.tile[data-stage="4"] { --tile-c: #f59e0b; --tile-glow: rgba(245, 158, 11, 0.5); }
.tile[data-stage="5"] { --tile-c: #fb923c; --tile-glow: rgba(251, 146, 60, 0.5); }
.tile[data-stage="6"] { --tile-c: #ef4444; --tile-glow: rgba(239, 68, 68, 0.5); }
.tile[data-stage="7"] { --tile-c: #a855f7; --tile-glow: rgba(168, 85, 247, 0.5); }

/* Зигзаг: нечётные — у левого края, чётные — у правого и на 50% ниже */
.tile[data-stage="1"], .tile[data-stage="3"], .tile[data-stage="5"], .tile[data-stage="7"] {
  grid-column: 1;
  justify-self: start;
}

.tile[data-stage="2"], .tile[data-stage="4"], .tile[data-stage="6"] {
  grid-column: 2;
  justify-self: end;
  transform: translateY(50%);
}

/* Свечение при наведении */
.tile:hover {
  border-color: var(--tile-c);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px var(--tile-c),
    0 26px 55px rgba(0, 0, 0, 0.5),
    0 14px 44px var(--tile-glow);
}

.tile[data-stage="1"]:hover, .tile[data-stage="3"]:hover, .tile[data-stage="5"]:hover, .tile[data-stage="7"]:hover {
  transform: translateY(-8px);
}

.tile[data-stage="2"]:hover, .tile[data-stage="4"]:hover, .tile[data-stage="6"]:hover {
  transform: translateY(calc(50% - 8px));
}

.tile.selected {
  border-color: var(--tile-c);
  box-shadow: 0 0 0 1px var(--tile-c), 0 18px 45px rgba(0, 0, 0, 0.4);
}

/* Подсветка-градиент внутри */
.tile-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  background: radial-gradient(130% 95% at 50% 110%, var(--tile-glow), transparent 62%);
}

.tile:hover .tile-glow,
.tile.selected .tile-glow {
  opacity: 1;
}

/* Изображение в первой карточке — полное, без обрезки (contain), контент поверх */
.tile-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 20px;
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
  opacity: 0.9;
}

/* Блик-блик по диагонали при наведении */
.tile::after {
  content: '';
  position: absolute;
  top: -10%;
  bottom: -10%;
  width: 46%;
  left: -70%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.14), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.tile:hover::after {
  left: 130%;
}

/* Номер станции */
.tile-num {
  position: absolute;
  top: 18px;
  left: 20px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--tile-c);
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px;
}

/* Заголовок и подпись */
.tile-title {
  margin-top: auto;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  max-width: 90%;
}

.tile-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* Бейдж количества услуг */
.tile-badge {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 11px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  transition: 0.25s;
}

.tile-badge b {
  font-size: 15px;
  color: var(--ink);
}

.tile-badge em {
  font-style: normal;
}

.tile.selected .tile-badge {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.55);
  color: var(--green-text);
}

.tile.selected .tile-badge::before {
  content: '✓';
  color: var(--green);
  font-weight: 900;
}

/* ============================================
   Модальные окна с опциями
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.modal.open {
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  max-height: 86vh;
  overflow: auto;
  border-radius: 24px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  background: var(--overlay);
  border-color: var(--border-strong);
}

.modal.open .modal-panel {
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: translateY(26px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 15px;
  transition: 0.2s;
}

.modal-close:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: #fff;
}

.modal-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-right: 30px;
}

.modal-num {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 950;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #7c3aed);
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.4);
}

.modal-head h3 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-list {
  display: grid;
  gap: 9px;
}

/* Строка услуги с чекбоксом */
.svc {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.18s;
}

.svc:hover {
  border-color: var(--blue);
  background: var(--accent-bg);
}

.svc:has(input:checked) {
  border-color: var(--blue);
  background: var(--accent-bg);
}

.svc input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.svc-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--checkbox-border);
  background: var(--surface);
  position: relative;
  transition: 0.18s;
}

.svc input:checked + .svc-box {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.6);
}

.svc input:checked + .svc-box::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 14px;
}

.svc-copy b {
  display: block;
  font-size: 14px;
}

.svc-copy small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 3px;
}

.svc-price {
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  color: var(--ink-soft-2);
}

.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.modal-foot span {
  color: var(--muted);
  font-size: 13px;
}

.modal-foot b {
  color: var(--ink);
  font-size: 17px;
}

/* ============================================
   Нижняя плавающая панель (sticky, паркуется под шестой плиткой)
   ============================================ */
.calcbar {
  position: sticky;
  bottom: 14px;
  z-index: 15;
  border-radius: 22px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  width: min(1020px, calc(100% - 36px));
  margin: 44px auto 0;
}

.calcbar .sum {
  font-size: 26px;
  font-weight: 950;
  color: var(--ink);
}

.calcbar small {
  color: var(--ink-soft);
  display: block;
  font-size: 11px;
}

.bar-mid {
  color: var(--ink-soft-2);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.calcbar-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ============================================
   Трекинг
   ============================================ */
.track-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 22px;
}

.track-form {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.track-form input {
  flex: 1;
  border: 1px solid var(--glass-border);
  border-radius: 13px;
  padding: 13px 14px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  transition: 0.2s;
}

.track-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.track-form input::placeholder {
  color: var(--ink-faint);
}

.status-list {
  display: grid;
  gap: 0;
  margin-top: 16px;
}

.status {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 14px 0;
  position: relative;
}

.status:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 43px;
  bottom: 0;
  width: 2px;
  background: var(--hover-bg);
}

.status-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-bg);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 900;
  z-index: 1;
}

.status.done .status-dot {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--green-text);
}

.status strong {
  font-size: 13px;
}

.status small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

/* ============================================
   Контактная форма
   ============================================ */
.contact {
  border-radius: 32px;
  padding: 36px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 30px;
  align-items: center;
  background:
    radial-gradient(120% 150% at 0% 0%, rgba(59, 130, 246, 0.16), transparent 55%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.contact h2 {
  color: var(--ink);
}

.contact p {
  color: var(--ink-soft);
}

.contact-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.contact-form {
  display: grid;
  gap: 12px;
}

.contact-form input {
  border: 1px solid var(--glass-border);
  border-radius: 13px;
  padding: 13px 14px;
  outline: 0;
  background: var(--field-bg);
  color: var(--ink);
  transition: 0.2s;
}

.contact-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.contact-form input::placeholder {
  color: var(--ink-faint);
}

.contact-form .btn {
  width: 100%;
}

/* Honeypot для защиты от ботов: скрыт от людей, виден ботам */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Капча: арифметический пример */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-q {
  flex: 1;
  padding: 11px 14px;
  border: 1px dashed var(--glass-border);
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft-2);
  background: var(--surface-2);
  user-select: none;
}

.captcha-row input {
  width: 110px;
  flex: none;
}

/* Согласие на обработку ПД */
.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
  cursor: pointer;
}

.agree-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
  accent-color: var(--blue);
}

.agree-row a {
  color: var(--accent-text);
  text-decoration: underline;
}

/* Модальные окна: политика и оферта */
.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

/* Cookie-уведомление */
.cookie-banner {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--overlay);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  color: var(--ink);
  transform: translateY(150%);
  transition: transform 0.4s ease;
}

.cookie-banner.show {
  transform: translateY(0);
}

/* ============================================
   Адаптивность
   ============================================ */
@media (max-width: 900px) {
  .snake {
    grid-template-columns: 1fr;
    max-width: 560px;
    gap: 28px 0;
    padding-bottom: 24px;
  }

  .calc-outer {
    display: flex;
    flex-direction: column;
    max-width: 560px;
  }

  .calc-title {
    order: -2;
    margin-bottom: 16px;
  }

  .calc-head {
    position: static;
    width: 100%;
    order: -1;
    margin-bottom: 24px;
  }

  .calc-title h2 {
    font-size: 38px;
  }

  .tile[data-stage="1"], .tile[data-stage="3"], .tile[data-stage="5"], .tile[data-stage="7"],
  .tile[data-stage="2"], .tile[data-stage="4"], .tile[data-stage="6"] {
    grid-column: 1;
    justify-self: center;
    transform: none;
  }

  .tile[data-stage="1"]:hover, .tile[data-stage="3"]:hover, .tile[data-stage="5"]:hover, .tile[data-stage="7"]:hover,
  .tile[data-stage="2"]:hover, .tile[data-stage="4"]:hover, .tile[data-stage="6"]:hover {
    transform: translateY(-8px);
  }

  .track-grid,
  .contact {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .progress-wrap {
    width: 100%;
  }

  .calcbar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .bar-mid {
    text-align: center;
  }

  .calcbar-actions {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  /* На мобильных прячем кнопки действий, но оставляем переключатель темы */
  .nav-actions {
    display: flex;
  }

  .nav-actions .btn {
    display: none;
  }

  .theme-toggle {
    display: grid;
  }

  .tile {
    padding: 20px;
    width: min(360px, 90vw);
  }
}
