/* ============================================================
   Сторінка оформлення замовлення — у дизайн-системі «Гучний»
   (DESIGN.md). Затверджено розкладку «Афіша»: довга форма
   ліворуч, липкий чорний чек з оплатою праворуч.
   ============================================================ */

.co { padding-bottom: 9rem; }

@media (min-width: 64rem) {
  .co { padding-bottom: 6rem; }
}

/* ---------- Шапка сторінки ---------- */
.co-head { padding-block: 1.5rem 2rem; }

.co-title {
  margin-top: 1.25rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 9vw, 7rem);
  font-weight: 600;
  line-height: 0.9;
  text-transform: uppercase;
}

.co-title__big,
.co-title__rest { display: block; }
.co-title__rest { color: var(--ink-3); }
.co-lead { margin-top: 1.25rem; }

/* ---------- Сітка ---------- */
.co-grid { display: grid; gap: 1rem; align-items: start; }
.co-form { display: grid; gap: 1rem; min-width: 0; }

/* ---------- Кроки форми ---------- */
.co-step {
  min-width: 0;
  padding: 1.5rem;
  border-radius: var(--r-card);
  background: var(--surface);
}

.co-step__title {
  float: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.25rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
}

.co-step__title + * { clear: both; }

.co-step__n {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.375rem;
}

.co-step__hint { margin-top: 0.75rem; color: var(--ink-3); }

@media (min-width: 64rem) {
  .co-step { padding: 2rem; }
}

/* ---------- Поля: css/fields.css ---------- */

/* Радіо-пігулки: де зручніше отримувати повідомлення */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.125rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 500;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.chip input:checked + span { background: var(--ink); color: var(--bg); }
.chip input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Способи оплати */
.methods { display: grid; gap: 0.5rem; }
.method { position: relative; display: block; cursor: pointer; }
.method input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.method__box {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  min-height: 76px;
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-inner);
  background: #fff;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.method__icon { width: 28px; height: 28px; color: var(--ink); }
.method__text { display: grid; color: var(--ink); line-height: 1.35; }
.method__text b { font-size: 1.125rem; }
.method__text small { color: var(--ink-3); font-size: 1rem; }
.method:hover .method__box { border-color: var(--ink-3); }

.method input:checked + .method__box {
  background: #0f0f0f;
  border-color: #0f0f0f;
  --ink: #f2f2ef;
  --ink-3: #bdbcb7;
}

.method input:checked + .method__box .method__icon { color: var(--accent); }
.method input:focus-visible + .method__box { outline: 2px solid #0f0f0f; outline-offset: 3px; }

@media (min-width: 40rem) {
  .methods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Згода */
.consent { position: relative; display: flex; gap: 0.875rem; color: var(--ink-2); cursor: pointer; }
.consent input { position: absolute; left: 0; top: 0; width: 28px; height: 28px; opacity: 0; cursor: pointer; }

.consent__box {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fff;
}

.consent__box svg { width: 20px; height: 20px; color: var(--bg); opacity: 0; }
.consent input:checked + .consent__box { background: var(--ink); }
.consent input:checked + .consent__box svg { opacity: 1; }
.consent input:focus-visible + .consent__box { outline: 2px solid var(--ink); outline-offset: 3px; }
.field.is-invalid .consent__box { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.co-mock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: var(--ink-3);
  font-size: 1rem;
}

.co-mock svg { flex-shrink: 0; width: 20px; height: 20px; }

.co-pay.is-loading { cursor: progress; opacity: 0.75; }
.co-pay[disabled] { pointer-events: none; }

/* ---------- Замовлення ---------- */
.co-order { display: grid; gap: 1rem; min-width: 0; }

.co-order__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.co-order__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
}

.co-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

.co-edit svg { width: 20px; height: 20px; }
.co-edit:hover { background: var(--ink); color: var(--bg); }

.co-lines { display: grid; }

.co-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.co-line dd { color: var(--ink); font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.co-line--free dd { color: var(--ink-3); font-weight: 400; }

.co-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
}

.co-total span { font-weight: 600; }

.co-total output {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.co-order__note { color: var(--ink-3); font-size: 1rem; }

/* ---------- Поп-ап редагування ---------- */
.co-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: min(92svh, 60rem);
  padding: 0;
  border: 0;
  border-radius: 32px;
  background: var(--surface);
  color: var(--ink-2);
  overflow: auto;
  overscroll-behavior: contain;
}

.co-dialog::backdrop { background: rgba(15, 15, 15, 0.62); }

.co-dialog[open] { animation: dialog-in 0.35s var(--ease); }
.co-dialog[open]::backdrop { animation: fade-in 0.35s var(--ease); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in { from { opacity: 0; } }

.co-dialog__inner { display: grid; gap: 1.75rem; padding: 1.5rem 1.5rem 0; }

.co-dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }

.co-dialog__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 600;
  line-height: 0.95;
  text-transform: uppercase;
}

.co-dialog__close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.co-dialog__close svg { width: 22px; height: 22px; }
.co-dialog__close:hover { background: var(--ink); color: var(--bg); }

.d-ladder { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.d-ladder li {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.25rem 0.875rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
}

.d-ladder b { color: var(--ink); font-weight: 600; }
.d-ladder li.is-active { border-color: var(--ink); background: var(--ink); color: #cfcfca; }
.d-ladder li.is-active b { color: #f2f2ef; }

.co-dialog__foot {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 1rem;
  margin-inline: -1.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.co-dialog__total { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; color: var(--ink); font-weight: 600; }

.co-dialog__total output {
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.co-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.75rem; }

@media (max-width: 39.99rem) {
  /* На телефоні — аркуш знизу */
  .co-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 94svh;
    margin: auto 0 0;
    border-radius: 28px 28px 0 0;
  }

  .co-dialog__inner { padding: 1.25rem 1rem 0; }
  .co-dialog__foot { margin-inline: -1rem; padding: 1rem; }
  .co-dialog__actions .btn { flex: 1; }
}

@media (min-width: 40rem) {
  .co-dialog__inner { padding: 2rem 2rem 0; }
  .co-dialog__foot { margin-inline: -2rem; padding: 1.25rem 2rem 2rem; }
}

/* ---------- Оплачено ---------- */
.co-done { display: grid; gap: 1.5rem; justify-items: start; padding-block: 3rem var(--sec); }
.co-done:focus { outline: none; }

.co-done__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 7.5rem);
  font-weight: 600;
  line-height: 0.92;
  text-transform: uppercase;
}

.co-done__title::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin-bottom: 1.25rem;
  background: var(--accent);
  -webkit-mask: var(--star) center / contain no-repeat;
  mask: var(--star) center / contain no-repeat;
}

.co-done__number {
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.75rem;
  border-radius: var(--r-card);
  background: var(--dark);
  color: #cfcfca;
}

.co-done__number b {
  color: #f2f2ef;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
}

.co-done__lead b { color: var(--ink); }

.co-next { display: grid; width: 100%; max-width: 48rem; border-top: 1.5px solid var(--ink); counter-reset: next; }

.co-next li {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding: 1.25rem 0;
  border-bottom: 1.5px solid var(--ink);
  counter-increment: next;
}

.co-next li::before {
  content: counter(next);
  grid-row: span 2;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 600;
  line-height: 0.9;
}

.co-next h3 { color: var(--ink); font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; line-height: 1.1; text-transform: uppercase; }

/* ---------- Мобільна смужка з сумою ---------- */
.co-bar {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  border-radius: 999px;
  background: var(--dark);
  color: #cfcfca;
}

.co-bar__sum { display: grid; line-height: 1.1; }
.co-bar__sum span { font-size: 1rem; }
.co-bar__sum b { color: #f2f2ef; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }

@media (min-width: 64rem) {
  .co-bar { display: none; }
}

/* ---------- Футер ---------- */
.ftr--slim { padding-block: 2rem; }
.co-ftr { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.co-ftr a { text-decoration: none; }
.co-ftr p a:hover,
.co-ftr__legal a:hover { text-decoration: underline; text-underline-offset: 3px; }
.co-ftr__legal { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.co-ftr__legal a { display: inline-flex; align-items: center; min-height: 44px; }
.co-ftr__company { flex-basis: 100%; color: var(--ink-3); font-size: 1rem; }

/* Посилання на умови біля кнопки оплати */
.co-legal { color: var(--ink-3); font-size: 1rem; }
.co-legal a { color: var(--ink); text-underline-offset: 3px; }
.consent a { color: var(--ink); text-underline-offset: 3px; }


@media print {
  .co-bar { display: none; }
}

/* ============================================================
   Розкладка «Афіша»: довга форма ліворуч, чорний чек праворуч
   ============================================================ */
.co-order {
  order: 2;
  padding: 1.5rem;
  border-radius: var(--r-card);
  background: var(--dark);
  --bg: #0f0f0f;
  --line: rgba(236, 236, 234, 0.16);
  --ink: #f2f2ef;
  --ink-2: #cfcfca;
  --ink-3: #a6a5a0;
  color: var(--ink-2);
}

.co-order :focus-visible { outline-color: var(--accent); }
.co-total output { color: var(--ink); }

/* Номер кроку — великий киноварний, як у кроках на головній */
.co-step__n {
  width: auto;
  height: auto;
  background: none;
  color: var(--accent);
  font-size: 3.5rem;
  line-height: 0.85;
}

@media (min-width: 64rem) {
  .co-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.5rem; }
  .co-order { grid-column: 2; grid-row: 1; position: sticky; top: 92px; padding: 2rem; }
  .co-form { grid-column: 1; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .co-dialog[open],
  .co-dialog[open]::backdrop { animation: none; }
}

/* На телефоні в шапці лише стрілка «назад»; текст лишається для читалок */
@media (max-width: 39.99rem) {
  .co-back { width: 44px; padding: 0; }

  .co-back__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
