/* M7: order page (/dev/order/) */

.xf-order {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: start;
}

.xf-order__main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Block (numbered section) ──────────────────────────────── */
.xf-order__block {
  padding: 24px 26px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.xf-order__block-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent-2);
  margin-bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.xf-order__block-eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--accent-2);
}
.xf-order__block-title {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

/* ─── Contacts grid ─────────────────────────────────────────── */
.xf-order__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.xf-field--wide { grid-column: 1 / -1; }
.xf-field__req {
  color: var(--accent-2);
  font-family: var(--font-mono);
  margin-left: 2px;
}
.xf-field__input--area {
  resize: vertical;
  min-height: 88px;
  line-height: 1.45;
  font-family: var(--font-sans);
}

/* ─── Radio-cards for delivery / payment ────────────────────── */
.xf-order__choices {
  display: grid;
  gap: 10px;
}
/* Есть описания (доставка) → 1 колонка, чтобы не было асимметрии в
   парных ячейках когда одно описание короче другого. Нет описаний
   (оплата) → 2 колонки, компакт. */
.xf-order__choices:has(.xf-choice__desc) {
  grid-template-columns: 1fr;
}
.xf-order__choices:not(:has(.xf-choice__desc)) {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 720px) {
  .xf-order__choices:not(:has(.xf-choice__desc)) { grid-template-columns: 1fr; }
}

.xf-choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}
@media (hover: hover) {
  .xf-choice:hover { background: var(--surface-3); }
}
.xf-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.xf-choice__dot {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line-soft);
  background: var(--surface);
  flex-shrink: 0;
  transition: border-color .2s ease, box-shadow .2s ease;
  position: relative;
}
.xf-choice__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.xf-choice__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
/* Описание: max-height вместо line-clamp — это даёт плавную анимацию
   раскрытия по клику. Мягкий градиент-фейд внизу сигнализирует, что
   есть ещё текст, который появится при выборе. */
.xf-choice__desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  max-height: 36px;
  overflow: hidden;
  /* mask-image даёт true-alpha фейд независимо от фона карточки
     (которая в hover/selected меняет цвет). Лучше, чем псевдо-градиент. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
  /* Предыдущий cubic-bezier(.2,.8,.3,1) был сильно front-loaded: 80%
     прогресса в первые 20% времени. При expand max-height проскакивал
     отметку «реальная высота контента» за ~15ms — раскрытие выглядело
     мгновенным, при collapse visible-часть попадала в «медленный хвост»
     и ощущалась плавной. Material-style cubic-bezier(.4,0,.2,1) почти
     линейный — visible-длительность примерно одинакова в обе стороны. */
  transition: max-height .38s cubic-bezier(.4, 0, .2, 1),
              color .25s ease,
              mask-image .25s ease,
              -webkit-mask-image .25s ease;
}
.xf-choice:has(input:checked) .xf-choice__desc {
  /* 320px вместо 400 — ближе к реальной высоте типичных описаний (~120px).
     Чем ближе max-height к контенту, тем больше visible-части умещается
     в окне анимации. */
  max-height: 320px;
  color: var(--text-2);
  mask-image: linear-gradient(to bottom, #000, #000);
  -webkit-mask-image: linear-gradient(to bottom, #000, #000);
}

/* Interactive state driven by actual radio, not PHP-side class.
   Needs `:has()` — supported in all modern browsers. */
.xf-choice:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent-line);
}
.xf-choice:has(input:checked) .xf-choice__dot {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 4px var(--accent-2);
}
.xf-choice:has(input:checked) .xf-choice__name { color: var(--text); }
.xf-choice input:focus-visible + .xf-choice__dot {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ─── Summary aside ─────────────────────────────────────────── */
.xf-order__summary {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.xf-order__summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 2px 0 4px;
  max-height: 320px;
  overflow-y: auto;
}
.xf-order__summary-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  align-items: center;
}
.xf-order__summary-item + .xf-order__summary-item {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}
.xf-order__summary-img {
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-3);
}
.xf-order__summary-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.xf-order__summary-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.xf-order__summary-name {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.xf-order__summary-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.xf-order__summary-qty { color: var(--text-3); }
.xf-order__summary-sum { color: var(--text); font-weight: 500; }
.xf-order__summary-cur { color: var(--text-3); font-size: 0.85em; margin-left: 2px; }

.xf-order__submit {
  width: 100%;
  margin-top: 6px;
}

/* ─── Success screen ────────────────────────────────────────── */
.xf-order-success {
  max-width: 620px;
  margin: 0 auto;
  padding: 36px 28px 40px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  text-align: center;
}
.xf-order-success__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  background: var(--accent-dim);
  color: var(--accent-2);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
}
.xf-order-success__title {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.6px;
  line-height: 1.2;
}
.xf-order-success__sub {
  margin: 0 auto 24px;
  max-width: 44ch;
  color: var(--text-2);
  line-height: 1.5;
}

.xf-order-success__card {
  text-align: left;
  padding: 18px 20px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}
.xf-order-success__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--text-2);
}
.xf-order-success__val {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
  text-align: right;
  max-width: 62%;
  overflow-wrap: anywhere;
}
.xf-order-success__divider {
  height: 1px;
  background: var(--line-soft);
  margin: 4px 0;
}
.xf-order-success__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 2px;
}
.xf-order-success__total > span:first-child {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-2);
}
.xf-order-success__total-val {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.4px;
}
.xf-order-success__total-cur { font-size: 0.6em; color: var(--text-3); margin-left: 4px; }

.xf-order-success__actions {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Main grid → single column, summary drops below form */
  .xf-order { grid-template-columns: 1fr; }
  .xf-order__summary {
    position: static;
    max-height: none;
  }
  /* Contacts → 1-col, pay-choices (no-desc) → 1-col, tighter padding */
  .xf-order__grid { grid-template-columns: 1fr; }
  .xf-order__block { padding: 18px 16px; }
  .xf-order__choices:not(:has(.xf-choice__desc)) {
    grid-template-columns: 1fr;
  }
  /* Radio cards: bigger tap target on phone */
  .xf-choice { padding: 16px; }
}
