/* =========================================================================
   Design tokens
   ========================================================================= */
:root {
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface-alt: #F8F9FC;
  --border: #E4E8F1;

  --text-primary: #161A23;
  --text-secondary: #6B7280;
  --text-tertiary: #9AA1B2;

  --shadow-sm: 0 2px 8px rgba(19, 23, 38, 0.06);
  --shadow-lg: 0 24px 48px -24px rgba(19, 23, 38, 0.28), 0 4px 12px rgba(19, 23, 38, 0.06);

  /* Акцент конкретной карты — переопределяется inline-стилем на .wallet-card,
     значения берутся из данных карты (см. комментарий в конце каждой card-страницы) */
  --card-accent: #E07A3F;
  --card-accent-2: #3E8E5A;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: "Unbounded", "Arial Rounded MT Bold", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --content-max-width: 420px;
  --page-padding: 20px;

  --dur-fast: 0.18s;
  --dur-base: 0.5s;
}

/* =========================================================================
   Reset
   ========================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, p, ol, ul {
  margin: 0;
}

button, a.share-btn, a.catalog-cta {
  font-family: inherit;
  cursor: pointer;
}

button {
  border: none;
  background: none;
  color: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================================
   App shell / layout
   ========================================================================= */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content {
  width: 100%;
  max-width: var(--content-max-width);
  padding: 0 var(--page-padding) 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* =========================================================================
   Page-load animation
   ========================================================================= */
.app-header,
.store-identity,
.wallet-card,
.card-number,
.instructions,
.share,
.info-block,
.app-footer,
.catalog-view {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal var(--dur-base) ease forwards;
}

.app-header { animation-delay: 0s; }
.store-identity { animation-delay: 0.05s; }
.wallet-card { animation-delay: 0.12s; }
.card-number { animation-delay: 0.2s; }
.instructions { animation-delay: 0.26s; }
.share { animation-delay: 0.32s; }
.info-block { animation-delay: 0.38s; }
.app-footer { animation-delay: 0.44s; }
.catalog-view { animation-delay: 0.05s; }

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================================
   Header
   ========================================================================= */
.app-header {
  width: 100%;
  max-width: var(--content-max-width);
  padding: 22px var(--page-padding) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__mark {
  color: var(--text-primary);
  display: flex;
}

.app-header__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.app-header__nav {
  min-height: 1px; /* резерв под будущий поиск / переключатель темы */
}

/* =========================================================================
   Store identity (лого + заголовок)
   ========================================================================= */
.store-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding-top: 8px;
}

.store-identity__badge {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--border);
}

.store-identity__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.store-identity__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.3;
  color: var(--text-primary);
  max-width: 280px;
}

/* =========================================================================
   Card switcher (Пятёрочка | Магнит) — обычные ссылки на реальные страницы
   ========================================================================= */
.card-switcher {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.card-switcher::-webkit-scrollbar {
  display: none;
}

.card-switcher__tab {
  flex: 1 1 auto;
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.card-switcher__tab.is-active {
  background: var(--text-primary);
  color: #fff;
}

.card-viewport {
  touch-action: pan-y;
}

/* =========================================================================
   Wallet card — карта-«пропуск» с цветной кромкой и перфорацией
   ========================================================================= */
.wallet-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.wallet-card__edge {
  height: 8px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, var(--card-accent), var(--card-accent-2));
}

.wallet-card__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 24px 16px;
}

.wallet-card__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.wallet-card__type {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wallet-card__perforation {
  position: relative;
  height: 1px;
  border-top: 2px dashed var(--border);
}

.wallet-card__perforation::before,
.wallet-card__perforation::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  background: var(--bg);
  border-radius: 50%;
  transform: translateY(-50%);
}

.wallet-card__perforation::before { left: -11px; }
.wallet-card__perforation::after { right: -11px; }

.wallet-card__barcode-area {
  padding: 26px 24px 12px;
  display: flex;
  justify-content: center;
}

.wallet-card__barcode-img {
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: var(--radius-sm);
}

.wallet-card__barcode-placeholder {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 7;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
  padding: 16px;
}

.wallet-card__hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 0 24px 22px;
}

/* =========================================================================
   Card number
   ========================================================================= */
.card-number {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-number__label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-number__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-number__value {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
  flex-shrink: 0;
}

.icon-button:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* =========================================================================
   Section titles
   ========================================================================= */
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 14px;
}

/* =========================================================================
   Instructions
   ========================================================================= */
.instructions__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: step;
}

.instructions__list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  counter-increment: step;
}

.instructions__list li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================================
   Share
   ========================================================================= */
.share__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.share-btn:hover {
  border-color: var(--card-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.share-btn--primary {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
}

/* =========================================================================
   Info block
   ========================================================================= */
.info-block {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.info-block p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* =========================================================================
   Catalog CTA + view
   ========================================================================= */
.catalog-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.catalog-cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.catalog-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.catalog-view__header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.catalog-view__back {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.catalog-view__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.catalog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.catalog-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.catalog-card__badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.catalog-card__badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.catalog-card__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.catalog-card--placeholder {
  border-style: dashed;
  color: var(--text-tertiary);
}

/* =========================================================================
   Footer
   ========================================================================= */
.app-footer {
  width: 100%;
  max-width: var(--content-max-width);
  padding: 8px var(--page-padding) 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-footer__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

.app-footer__meta,
.app-footer__copy {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
  z-index: 100;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================================
   Focus visibility
   ========================================================================= */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--card-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =========================================================================
   Small screens
   ========================================================================= */
@media (max-width: 360px) {
  .wallet-card__barcode-img { max-width: 100%; }
  .share__actions { gap: 8px; }
  .share-btn { padding: 9px 13px; font-size: 12.5px; }
}
