/* Корзина Premium — «консьерж-карточка»: раскрывается кругом прямо из иконки
   корзины в шапке и висит под ней; шапка остаётся видимой. На телефоне —
   панель во всю ширину, опускается из-под шапки. Точку раскрытия
   (--cart-right, --cart-origin) ставит ui/cart-drawer.js. */

.cart-overlay {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: var(--z-drawer);
  background: rgba(2, 6, 4, 0.55);
  opacity: 0;
  transition: opacity var(--t);
}
.cart-overlay.is-open { opacity: 1; }

.cart {
  position: fixed;
  top: calc(var(--header-h) - 4px);
  right: var(--cart-right, 16px);
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  width: min(430px, 100vw - 24px);
  max-height: calc(100svh - var(--header-h) - 20px);
  background:
    radial-gradient(420px 260px at 85% 0%, rgba(31, 94, 70, 0.35), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  clip-path: circle(0 at var(--cart-origin, calc(100% - 22px)) -24px);
  transition: clip-path 560ms var(--ease-out);
  outline: none;
}
.cart.is-open { clip-path: circle(160% at var(--cart-origin, calc(100% - 22px)) -24px); }
/* пока корзина открыта, иконка в шапке «горит» — видно, откуда она раскрылась */
.site-header .icon-btn.is-cart-open { border-color: var(--foil); color: var(--foil-light); box-shadow: 0 0 0 4px rgba(201, 161, 90, 0.12); }
.cart.is-dragging { transition: none; }

.cart__handle { display: none; }
.cart__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 24px 10px; }
.cart__head h2 { font-size: 1.7rem; }
.cart__count { font-size: var(--fs-xs); color: var(--muted); letter-spacing: 0.04em; }
.cart__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 24px 16px; overscroll-behavior: contain; }

/* ── Мини-орбита выбранных подписок ── */
.cart-orbit { position: relative; height: 168px; margin: 4px 0 6px; display: grid; place-items: center; }
.cart-orbit:empty { display: none; }
.cart-orbit__ring {
  position: absolute;
  width: 300px; height: 124px;
  border-radius: 50%;
  border: 1px dashed var(--line-strong);
  opacity: 0.6;
}
.cart-orbit__core {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 30% 25%, rgba(233, 207, 150, 0.25), transparent 60%), var(--bg-3);
  color: var(--foil-light);
  box-shadow: 0 0 30px rgba(201, 161, 90, 0.3);
}
.cart-orbit__core { --mark-bg: var(--bg-3); }
.cart-orbit__core svg { width: 26px; height: 26px; }
/* планеты бегут по эллипсу (offset-path) и остаются ровными */
.cart-orbit__spin { position: absolute; width: 300px; height: 124px; }
.cart-orbit__planet {
  position: absolute;
  left: 0; top: 0;
  offset-path: ellipse(150px 62px at 150px 62px);
  offset-rotate: 0deg;
  offset-distance: var(--d);
  animation: cart-orbit 22s linear infinite;
}
@keyframes cart-orbit { from { offset-distance: var(--d); } to { offset-distance: calc(var(--d) + 100%); } }

/* ── Орб позиции ── */
.cart-orb {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 250, 235, 0.3), transparent 36%),
    radial-gradient(circle, color-mix(in srgb, var(--accent) 68%, #0b1410), color-mix(in srgb, var(--accent) 18%, #050a07) 74%);
  box-shadow: inset -6px -8px 16px rgba(0, 0, 0, 0.45), 0 0 22px -6px color-mix(in srgb, var(--accent) 75%, transparent);
}
.cart-orb img { width: 44%; height: 44%; filter: brightness(0) invert(1); }
.cart-orb svg { width: 22px; height: 22px; color: var(--cream); }
.cart-orb--sm { width: 36px; height: 36px; }
.cart-orb--bundle { background: var(--bg-3); border: 1px solid var(--line); }
.cart-orb__mini {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(244, 234, 217, 0.18);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 65%, #0b1410), #0b1410 85%);
}
.cart-orb__mini img { width: 13px; height: 13px; }
.cart-orb__mini:nth-child(1) { left: 2px; top: 16px; }
.cart-orb__mini:nth-child(2) { left: 14px; top: 2px; }
.cart-orb__mini:nth-child(3) { right: 2px; top: 22px; }
.cart-orb--sm.cart-orb--bundle .cart-orb__mini { width: 18px; height: 18px; }
.cart-orb--sm.cart-orb--bundle .cart-orb__mini img { width: 9px; height: 9px; }
.cart-orb--sm.cart-orb--bundle .cart-orb__mini:nth-child(1) { left: 0; top: 11px; }
.cart-orb--sm.cart-orb--bundle .cart-orb__mini:nth-child(2) { left: 9px; top: 0; }
.cart-orb--sm.cart-orb--bundle .cart-orb__mini:nth-child(3) { right: 0; top: 15px; }

/* ── Позиция ── */
.cart__list { display: grid; gap: 10px; }
.cart-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "orb main side" "orb controls controls";
  gap: 10px 14px;
  padding: 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-soft);
  background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 55%), var(--glass);
  animation: slide-up var(--t) var(--ease-out);
  transition: border-color var(--t);
}
.cart-item:hover { border-color: var(--line); }
.cart-item > .cart-orb { grid-area: orb; align-self: start; }
.cart-item__main { grid-area: main; display: grid; gap: 7px; min-width: 0; }
.cart-item__name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
a.cart-item__name:hover { color: var(--foil-light); }
.cart-item__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cart-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--cream-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-tag svg { width: 12px; height: 12px; flex: none; color: var(--foil-light); }
.cart-item__side { grid-area: side; display: grid; justify-items: end; align-content: start; gap: 2px; }
.cart-item__price { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--foil-light); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cart-item__unit { font-size: 11px; color: var(--faint); white-space: nowrap; }
.cart-item__controls { grid-area: controls; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.stepper {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: rgba(7, 13, 10, 0.5);
}
.stepper button {
  display: grid;
  place-items: center;
  width: 32px; height: 30px;
  border: 0;
  background: none;
  color: var(--cream-dim);
  border-radius: var(--r-pill);
  transition: color var(--t), background var(--t);
}
.stepper button:hover:not(:disabled) { color: var(--foil-light); background: rgba(201, 161, 90, 0.1); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper svg { width: 14px; height: 14px; }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

.cart-item__remove {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--faint);
  font-size: var(--fs-xs);
  transition: color var(--t), background var(--t);
}
.cart-item__remove svg { width: 13px; height: 13px; }
.cart-item__remove:hover { color: var(--bad); background: rgba(224, 122, 111, 0.08); }

/* ── Сводка ── */
.cart__summary { padding: 16px 24px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); display: grid; gap: 12px; background: rgba(7, 13, 10, 0.55); }
.cart__summary:empty { display: none; }
.cart-sum { display: grid; gap: 10px; }
.cart-sum__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); color: var(--cream-dim); }
.cart-sum__row span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.cart-sum__row svg { width: 16px; height: 16px; color: var(--foil-light); }
.cart-sum__row--total { font-size: var(--fs-md); color: var(--cream); }
.cart-sum__row--total strong { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--foil-light); font-variant-numeric: tabular-nums; }
.cart-sum__balance { font-weight: 700; color: var(--cream); font-variant-numeric: tabular-nums; }

.cart-gauge { height: 6px; border-radius: 6px; background: rgba(224, 122, 111, 0.18); overflow: hidden; }
.cart-gauge span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--bad), var(--warn)); transition: width 0.8s var(--ease-out); }
.cart-gauge.is-ok { background: var(--line-soft); }
.cart-gauge.is-ok span { background: var(--foil-sheen); }

.cart-sum__note { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--muted); }
.cart-sum__note svg { width: 14px; height: 14px; flex: none; color: var(--foil-light); }
.cart-sum__note.is-ok { color: var(--good); }
.cart-sum__note.is-ok svg { color: var(--good); }
.cart-sum__note.is-short { color: var(--warn); }
.cart-sum__club { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px dashed var(--line); font-size: var(--fs-xs); color: var(--cream-dim); }
.cart-sum__club svg { width: 15px; height: 15px; flex: none; color: var(--foil-light); }
.cart-sum__actions { display: grid; gap: 8px; }
.cart__fine { font-size: 11.5px; color: var(--faint); text-align: center; }

/* ── Пустая корзина ── */
.cart__empty { display: grid; justify-items: center; gap: 12px; padding: 18px 4px 8px; text-align: center; }
.cart__empty h3 { font-size: 1.45rem; }
.cart__empty > p { color: var(--muted); font-size: var(--fs-sm); max-width: 30ch; }
.cart-void { width: 190px; height: 190px; margin-bottom: 2px; }
.cart-void canvas { display: block; width: 100%; height: 100%; }
.cart-picks { width: 100%; display: grid; gap: 8px; margin-top: 14px; text-align: left; }
.cart-picks__title { font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.cart-pick {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line-soft);
  background: var(--glass);
  transition: border-color var(--t), transform var(--t-fast);
}
.cart-pick:hover { border-color: var(--line-strong); transform: translateX(3px); }
.cart-pick__name { font-weight: 700; font-size: var(--fs-sm); }
.cart-pick__price { font-size: var(--fs-xs); color: var(--foil-light); white-space: nowrap; }

/* ── Уведомление с действием («Вернуть») ── */
.toast__text { flex: 1; }
.toast__action {
  flex: none;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: rgba(201, 161, 90, 0.1);
  color: var(--foil-light);
  font-weight: 700;
  font-size: var(--fs-xs);
}

/* ── Телефон: лист снизу ── */
@media (max-width: 640px) {
  /* телефон: панель во всю ширину опускается из-под шапки */
  .cart {
    top: var(--header-h);
    left: 0; right: 0;
    width: 100%;
    max-height: calc(100svh - var(--header-h) - 70px);
    border: 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0 0 26px 26px;
    clip-path: inset(0 0 100% 0);
    transition: clip-path 440ms var(--ease-out);
  }
  .cart.is-open { clip-path: inset(0 0 0 0 round 0 0 26px 26px); }
  /* на телефоне место отдаём позициям: без мини-орбиты и мелкого текста */
  .cart-orbit, .cart__fine, .cart-sum__club { display: none; }
  .cart__summary { gap: 8px; padding-top: 12px; }
  .cart-sum { gap: 7px; }
  .cart-sum__row--total strong { font-size: 1.45rem; }
  .cart-sum__actions .btn--ghost { --btn-h: 40px; }
  .cart__summary .btn--lg { --btn-h: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-orbit__planet { animation: none; }
}
.cart__summary .form-status:empty { display: none; }
