/* Карта лояльности: шторка и страница карты, виджет кабинета, информер,
   блок заказа, удаление аккаунта. Вёрстка — по хендоффу этапа 1
   (mockups/etap1-board.html, specs/components.md), значения — из tokens.css.
   Подложка штрихкода белая всегда, независимо от темы А/Б: сканеры кассы
   иначе не читают (ТЗ 7.2). */

/* ── страница /user/card ───────────────────────────────────────────────── */

.loyalty-page {
  max-width: 390px;
  margin: 0 auto;
  padding: var(--inset-screen) 0 calc(var(--inset-desk) * 2);
}

.loyalty-page__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.loyalty-page__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -.01em;
}

.loyalty-page--guest .loyalty-page__title {
  margin-bottom: 12px;
}

/* ── шторка ────────────────────────────────────────────────────────────── */

.loyalty-sheet-modal__body {
  padding: 0 var(--inset-sheet) calc(var(--inset-sheet) + env(safe-area-inset-bottom)) !important;
}

.loyalty-sheet-modal__heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* C13: во вложенной шторке шапка та же — стрелка назад (зона 40) слева,
   заголовок сдвинут на 4 px, левый отступ 6 вместо 16. Свой заголовок
   вложенной панели в шторке не нужен — он для страницы /user/card. */
.loyalty-sheet-modal__back,
.loyalty-sheet-modal__title-nested,
.loyalty-sheet-modal .loyalty-nested__head {
  display: none;
}

.loyalty-sheet-modal.is-nested .loyalty-sheet-modal__header {
  gap: 4px;
  padding-left: 6px;
}

.loyalty-sheet-modal.is-nested .loyalty-sheet-modal__back {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  color: var(--ink);
}

.loyalty-sheet-modal.is-nested .loyalty-sheet-modal__title-nested {
  display: inline;
}

.loyalty-sheet-modal.is-nested .loyalty-sheet-modal__title-main,
.loyalty-sheet-modal.is-nested .loyalty-refreshing {
  display: none;
}

.loyalty-sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* C03: «Обновляем, код уже работает» — под заголовком. */
.loyalty-refreshing {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 400;
}

.is-refreshing .loyalty-refreshing {
  display: flex;
}

.loyalty-refreshing__icon {
  display: flex;
  animation: loyalty-spin 1s linear infinite;
}

/* ── карта ─────────────────────────────────────────────────────────────── */

.loyalty-card,
.loyalty-card__main,
.loyalty-card__issuing {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loyalty-card__main[hidden],
.loyalty-nested[hidden] {
  display: none;
}

.loyalty-card__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #fff;
}

.loyalty-card__barcode {
  width: 318px;
  max-width: 100%;
  background: #fff;
}

.loyalty-card__barcode svg {
  display: block;
  width: 100%;
  height: 150px;
}

.loyalty-card__number {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-total);
  font-weight: 600;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

/* ТЗ 7.5: уровень, если сервер вернёт, — нейтральный чип. */
.loyalty-card__tier,
.loyalty-card__chip {
  margin: 0;
  padding: 2px 6px;
  border-radius: var(--r-badge);
  background: var(--fill);
  color: var(--muted);
  font-size: var(--fs-caption);
  font-weight: 600;
}

.loyalty-card__caption {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 17px;
  text-align: center;
}

.loyalty-card__caption[hidden],
.loyalty-card__hint[hidden] {
  display: none;
}

/* C04, C05: плашка над картой. */
.loyalty-plate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-field);
  background: var(--fill);
  color: var(--muted);
  font-size: var(--fs-small);
}

.loyalty-plate b {
  color: var(--ink);
  font-weight: 600;
}

.loyalty-plate--warn {
  align-items: flex-start;
  background: var(--warn-soft);
  color: var(--ink);
  line-height: 17px;
}

.loyalty-plate__icon {
  display: flex;
  margin-top: 1px;
  color: var(--warn);
}

.loyalty-plate[hidden] {
  display: none;
}

/* C14 */
.loyalty-card__new-code {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: var(--soft);
}

.loyalty-card__new-code-title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
}

.loyalty-card__new-code-text {
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 17px;
}

/* C06: подсказка открыть картинку карты в Фото. */
.loyalty-card__photos {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-field);
  background: var(--fill);
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 17px;
  text-align: left;
}

.loyalty-card__photos svg {
  color: var(--ink);
}

/* C11 */
.loyalty-card__hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: var(--r-card);
  background: var(--ink);
  color: #fff;
}

.loyalty-card__hint-icon {
  display: flex;
  color: var(--accent);
}

.loyalty-card__hint-text {
  flex: 1;
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-card__hint-close {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .75);
}

/* C01, A06: скелетон */
.loyalty-card__skeleton {
  border-radius: 8px;
  background: var(--fill);
  animation: loyalty-shimmer 1.2s ease-in-out infinite;
}

.loyalty-card__skeleton--code {
  width: 318px;
  max-width: 100%;
  height: 150px;
  border-radius: var(--r-control);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.loyalty-card__skeleton--number {
  width: 220px;
  height: 28px;
  margin: 6px 0;
}

.loyalty-card__skeleton--caption {
  width: 210px;
  height: 14px;
  align-self: center;
  border-radius: 7px;
}

.loyalty-card__skeleton--line {
  display: block;
  height: 14px;
  border-radius: 7px;
}

.loyalty-card__skeleton-title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
}

.loyalty-card__skeleton-text {
  color: var(--muted);
  font-size: var(--fs-small);
}

@keyframes loyalty-shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

@keyframes loyalty-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loyalty-card__skeleton,
  .loyalty-refreshing__icon { animation: none; }
}

/* A06 → C08: 30 секунд без карты. */
.loyalty-card .loyalty-card__issuing-late,
.loyalty-card.is-late .loyalty-card__issuing {
  display: none;
}

.loyalty-card.is-late .loyalty-card__issuing-late {
  display: flex;
}

/* C07–C10, D05 в шторке: иконка в круге, заголовок, текст, кнопка. */
.loyalty-card__status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 0;
  text-align: center;
}

.loyalty-card__status-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  background: var(--soft);
  color: var(--brand);
}

.loyalty-card__status-icon--danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.loyalty-card__status-icon--muted {
  background: var(--fill);
  color: var(--muted);
}

.loyalty-card__status-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -.01em;
}

.loyalty-card__status-text {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-card__status .loyalty-card__button {
  align-self: stretch;
  margin-top: 8px;
}

/* Главная кнопка шторки: 52, радиус 14, бренд. */
.loyalty-card__button {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-photo);
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-field);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.loyalty-card__button:hover,
.loyalty-card__button:focus {
  color: #fff;
}

.loyalty-card__button--secondary,
.loyalty-card__button--secondary:hover,
.loyalty-card__button--secondary:focus {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: #fff;
  color: var(--ink);
  font-size: var(--fs-body);
}

/* Двойное нажатие: кнопка заблокирована, спиннер внутри, ширина та же. */
.is-loading > .loyalty-card__button-label {
  visibility: hidden;
}

.is-loading::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: loyalty-spin .8s linear infinite;
  content: '';
}

/* Меню под картой: история, «Это не моя карта». */
.loyalty-menu {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #fff;
}

.loyalty-menu__item {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}

.loyalty-menu__item:last-child {
  border-bottom: 0;
}

.loyalty-menu__item:hover {
  color: var(--ink);
}

.loyalty-menu__item svg {
  color: var(--muted);
}

.loyalty-menu__label {
  flex: 1;
}

/* C13: вложенная шторка. */
.loyalty-nested {
  display: flex;
  flex-direction: column;
}

.loyalty-nested__head {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px -10px;
}

.loyalty-nested__back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.loyalty-nested__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -.01em;
}

.loyalty-nested__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loyalty-nested__text {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-nested__plate {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--r-field);
  background: var(--fill);
}

.loyalty-nested__plate-label {
  color: var(--muted);
  font-size: var(--fs-small);
}

.loyalty-nested__plate-value {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── A03: гость ────────────────────────────────────────────────────────── */

.loyalty-guest {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.loyalty-guest__intro {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.loyalty-guest__title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-total);
  font-weight: 600;
}

.loyalty-guest__text {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-guest__benefits {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loyalty-guest__benefit {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-guest__benefit-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-control);
  background: var(--soft);
  color: var(--brand);
}

/* ── виджет личного кабинета (D01–D05) ─────────────────────────────────── */

.loyalty-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.loyalty-widget:hover {
  color: var(--ink);
}

.loyalty-widget--compact {
  padding: 12px 14px;
}

.loyalty-widget--offer {
  flex-direction: column;
  align-items: stretch;
  padding: 14px;
  border: 0;
  background: var(--soft);
}

.loyalty-widget--plain {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.loyalty-widget__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.loyalty-widget__icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-field);
  background: var(--soft);
  color: var(--brand);
}

.loyalty-widget__icon--white {
  background: #fff;
}

.loyalty-widget__icon--danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.loyalty-widget__icon--skeleton {
  background: var(--fill);
  animation: loyalty-shimmer 1.2s ease-in-out infinite;
}

.loyalty-widget__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loyalty-widget__title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
}

.loyalty-widget__number {
  color: var(--muted);
  font-size: var(--fs-small);
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.loyalty-widget__text {
  color: var(--muted);
  font-size: var(--fs-small);
}

.loyalty-widget__text--wrap {
  line-height: 17px;
}

.loyalty-widget__button {
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--r-control);
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
}

.loyalty-card__button--small {
  height: 48px;
}

/* B01: «Ваша карта готова» в профиле. */
.loyalty-ready {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
  padding: 16px;
  border-radius: var(--r-card);
  background: var(--brand);
  color: #fff;
}

.loyalty-ready__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loyalty-ready__badge {
  color: var(--accent);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.loyalty-ready__title {
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -.01em;
}

.loyalty-ready__text {
  color: rgba(255, 255, 255, .82);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-ready__button,
.loyalty-ready__button:hover,
.loyalty-ready__button:focus {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-field);
  background: #fff;
  color: var(--brand);
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
}

/* ── B03: информер строкой под шапкой ──────────────────────────────────── */

.loyalty-informer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 var(--inset-screen) 12px;
  padding: 10px 6px 10px 12px;
  border-radius: var(--r-card);
  background: var(--soft);
}

.loyalty-informer__icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-control);
  background: #fff;
  color: var(--brand);
}

.loyalty-informer__text {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 450;
  line-height: var(--lh-body);
}

.loyalty-informer__button,
.loyalty-informer__button:hover,
.loyalty-informer__button:focus {
  position: relative;
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-control);
  background: var(--brand);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
  text-decoration: none;
}

.loyalty-informer__close {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--icon-close);
}

/* B03: точка на Card, пока карту не открыли. */
.loyalty-tab-dot {
  position: absolute;
  top: -1px;
  right: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px #f7f7f7;
}

/* ── B02: блок на странице успеха заказа ───────────────────────────────── */

.loyalty-order {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  background: var(--soft);
  text-align: left;
}

.loyalty-order__icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-control);
  background: #fff;
  color: var(--brand);
}

.loyalty-order__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loyalty-order__title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: 600;
}

.loyalty-order__text {
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 17px;
}

.loyalty-order__link {
  margin-top: 4px;
  color: var(--brand);
  font-size: var(--fs-body);
  font-weight: 600;
}

