/* ==========================================================================
   BALLRUN — underground digital posters by Krista Ann.
   Light theme, Inter font, orange CTA, clean product cards.
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #fafbfc;
  --surface:   #ffffff;
  --surface-2: #f3f4f6;
  --ink:       #1a1a1a;
  --ink-2:     #4b5563;
  --ink-3:     #6b7280;
  --ink-4:     #9ca3af;
  --border:    #e5e7eb;
  --border-2:  #d1d5db;

  --accent:        #ef5a00;        /* Rozetka-orange CTA */
  --accent-hover:  #d24d00;
  --accent-soft:   #fff1e6;
  --ok:            #00a046;
  --ok-soft:       #e9f7ee;
  --danger:        #d9000f;
  --danger-soft:   #fdecee;
  --review:        #ffaa00;        /* star colour */

  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow:    0 1px 3px rgba(16,24,40,.10), 0 1px 2px rgba(16,24,40,.06);
  --shadow-lg: 0 10px 28px rgba(16,24,40,.10), 0 4px 8px rgba(16,24,40,.05);

  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --pad-x: clamp(16px, 3vw, 40px);
  --ff: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* per-category cover gradients */
  --cat-business-1:    #dc2626;  --cat-business-2:    #7f1d1d;
  --cat-science-1:     #2563eb;  --cat-science-2:     #1e3a8a;
  --cat-engineering-1: #7c3aed;  --cat-engineering-2: #4c1d95;
  --cat-finance-1:     #059669;  --cat-finance-2:     #064e3b;
  --cat-tech-1:        #4f46e5;  --cat-tech-2:        #312e81;
}

*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Initial padding-top — JS replaces this with the real topbar height
     once the DOM is ready (and re-syncs on resize / banner toggle). */
  padding-top: 70px;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.topbar-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding:
    calc(14px + var(--safe-t))
    calc(var(--pad-x) + var(--safe-r))
    14px
    calc(var(--pad-x) + var(--safe-l));
}

/* "Your account is linked" banner — green stripe under the topbar.
   Hidden by default; JS adds .is-show when the handshake is valid. */
.linked-banner {
  display: none;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: linear-gradient(90deg, #e9f7ee 0%, #d6f0df 50%, #e9f7ee 100%);
  border-top: 1px solid rgba(0, 160, 70, 0.22);
  color: #058144;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.3;
}
.linked-banner.is-show { display: flex; }
.linked-banner svg { color: #00a046; flex-shrink: 0; }

.logo {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink);
}
.logo-icon { flex-shrink: 0; }
.logo-text {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.logo-text em { font-style: normal; color: var(--accent); }

.search {
  position: relative;
  display: flex; align-items: center;
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px 0 36px;
  color: var(--ink-3);
  transition: border-color .2s, background .2s;
  max-width: 540px;
  justify-self: stretch;
}
.search:focus-within {
  background: var(--surface);
  border-color: var(--accent);
}
.search svg {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3);
}
.search input {
  border: none; background: none;
  width: 100%; height: 100%;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.search input::placeholder { color: var(--ink-4); }

.head-right { display: inline-flex; align-items: center; gap: 10px; }

.lang {
  display: inline-flex; align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.lang-btn {
  background: none; border: none;
  padding: 5px 8px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  border-radius: 6px;
  transition: background .2s, color .2s;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.cart-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  transition: border-color .2s, background .2s, transform .15s;
}
.cart-btn:hover { border-color: var(--ink-4); background: var(--surface-2); }
.cart-btn:active { transform: translateY(1px); }
.cart-count {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 10.5px;
  display: inline-grid; place-items: center;
  border: 2px solid var(--surface);
  animation: cart-pop .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes cart-pop { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* ==========================================================================
   PROMO STRIP
   ========================================================================== */
.promo {
  padding: 24px calc(var(--pad-x) + var(--safe-r)) 0 calc(var(--pad-x) + var(--safe-l));
}
.promo-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 28px 32px;
  background:
    linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 60%, #ef5a00 130%);
  border-radius: 16px;
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.promo-inner::before {
  content: ""; position: absolute; right: -10%; top: -50%;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(239, 90, 0, 0.45), transparent 70%);
  pointer-events: none;
}
.promo-text { position: relative; z-index: 1; max-width: 600px; }
.promo-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd3b3;
  margin-bottom: 8px;
}
.promo-title {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.promo-sub {
  font-size: 14px;
  color: #e5e7eb;
  font-weight: 400;
  margin: 0;
  line-height: 1.5;
  max-width: 520px;
}
.promo-badges {
  position: relative; z-index: 1;
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: flex-end;
}
.promo-badge {
  display: inline-flex; flex-direction: column;
  padding: 10px 14px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  min-width: 96px;
}
.promo-badge strong {
  font-weight: 800; font-size: 14px; color: #fff;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   ARTIST / ABOUT BALLRUN
   ========================================================================== */
.artist {
  padding: 28px calc(var(--pad-x) + var(--safe-r)) 28px calc(var(--pad-x) + var(--safe-l));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.artist-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 36px;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 860px) {
  .artist-inner { grid-template-columns: 1fr; gap: 24px; }
}
.artist-photo-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #0a0a0a;
  aspect-ratio: 16 / 9;
}
.artist-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.artist-signature {
  position: absolute;
  left: 14px; bottom: 14px;
  padding: 6px 12px;
  background: rgba(10, 10, 10, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.artist-text { max-width: 620px; }
.artist-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.artist-title {
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 14px;
}
.artist-p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 12px;
}
.artist-p-strong {
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   CATEGORY FILTER
   ========================================================================== */
.cats {
  display: flex; gap: 8px;
  flex-wrap: wrap;
  padding: 22px calc(var(--pad-x) + var(--safe-r)) 16px calc(var(--pad-x) + var(--safe-l));
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cat {
  background: #ffffff;
  border: 1.5px solid var(--border-2);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s, transform .15s;
  box-shadow: var(--shadow-sm);
}
.cat:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(239, 90, 0, 0.15);
}
.cat:active { transform: translateY(1px); }
.cat.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 90, 0, 0.35);
}
.cat.is-active:hover { color: #fff; }

/* ==========================================================================
   PRODUCT GRID
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding:
    6px
    calc(var(--pad-x) + var(--safe-r))
    32px
    calc(var(--pad-x) + var(--safe-l));
  flex: 1 0 auto;
}

/* ==========================================================================
   PRODUCT CARD
   ========================================================================== */
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .25s, transform .2s;
  opacity: 0; transform: translateY(8px);
  animation: rise .55s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
.card:hover {
  border-color: var(--ink-4);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.cover {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  color: #fff;
  overflow: hidden;
  background: #1a1a1a;
}
/* the real photo */
.cover-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.card:hover .cover-img { transform: scale(1.05); }
/* dark gradient scrim — keeps the overlaid text readable on any photo */
.cover::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 35%, transparent 55%, rgba(0,0,0,0.85) 100%);
  z-index: 1;
  pointer-events: none;
}
.cover > *:not(.cover-img) { position: relative; z-index: 2; }

/* tiny per-category accent strip at the very top of the cover */
.cover[data-category="business"]    { --accent-bar: var(--cat-business-1); }
.cover[data-category="science"]     { --accent-bar: var(--cat-science-1); }
.cover[data-category="engineering"] { --accent-bar: var(--cat-engineering-1); }
.cover[data-category="finance"]     { --accent-bar: var(--cat-finance-1); }
.cover[data-category="tech"]        { --accent-bar: var(--cat-tech-1); }
.cover::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--accent-bar);
  z-index: 2;
}

.cover-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cover-format {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 4px 9px;
  background: rgba(0, 0, 0, 0.60);
  border-radius: 999px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.20);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.cover-discount {
  display: inline-block;
  font-size: 11px; font-weight: 800;
  padding: 4px 9px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(239, 90, 0, 0.50);
}
.cover-bottom {
  display: flex; flex-direction: column; gap: 4px;
}
.cover-source {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
}
.cover-bigname {
  font-size: clamp(15px, 1.5vw, 19px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: #fff;
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.85),
    0 1px 2px rgba(0, 0, 0, 0.95);
  /* never let the bigname clip the buttons above */
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.body {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
  flex: 1 1 auto;
  /* keep room for the button at the bottom; everything above flows on top */
  min-height: 0;
}
.body-meta {
  display: flex; align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.body-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-4); }

.body-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.body-rating {
  display: flex; align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}
.stars { display: inline-flex; gap: 1px; color: var(--review); }
.stars svg { width: 13px; height: 13px; fill: currentColor; }
.stars .star-off { color: var(--border-2); }

.price-row {
  display: flex; align-items: baseline; gap: 8px;
  margin-top: 4px;
}
.price-now {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.price-old {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-4);
  text-decoration: line-through;
}

.add-btn {
  /* Push to the bottom of the card so the BUY/ADDED button sits at the
     same vertical position across the whole grid row. */
  margin-top: auto;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.add-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(239, 90, 0, 0.35); }
.add-btn:active { transform: translateY(1px); }
.add-btn.is-added {
  background: var(--ok);
  color: #fff;
}
.add-btn.is-added::before {
  content: "✓ ";
  margin-right: 2px;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.foot {
  padding: 28px calc(var(--pad-x) + var(--safe-r)) calc(32px + var(--safe-b)) calc(var(--pad-x) + var(--safe-l));
  font-size: 12px;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.foot-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.foot-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin-bottom: 2px;
}
.foot-brand span {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 12.5px;
  font-weight: 600;
}
.foot-links a {
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.foot-links a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.foot-meta {
  font-size: 11.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   TERMS NOTE (inside cart drawer)
   ========================================================================== */
.terms-note {
  margin: 8px 0 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
}
.terms-note a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

/* ==========================================================================
   CART DRAWER
   ========================================================================== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(16, 16, 16, 0.45);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
  z-index: 200;
}
.scrim.is-open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.2,.7,.2,1);
  z-index: 201;
  box-shadow: -10px 0 30px rgba(0,0,0,0.10);
}
.drawer.is-open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + var(--safe-t)) 22px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.drawer-close {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  transition: background .2s;
}
.drawer-close:hover { background: var(--border); color: var(--ink); }

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 22px;
  display: flex; flex-direction: column;
  gap: 10px;
}

.drawer-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.5;
}
.drawer-empty .empty-icon {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  margin: 0 auto 12px;
  color: var(--ink-4);
}

.line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.line-cover {
  width: 64px; height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #1a1a1a;
  flex-shrink: 0;
}
.line-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.line-info { min-width: 0; }
.line-name {
  font-size: 13px; font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.line-controls {
  display: flex; align-items: center; gap: 6px;
}
.qty {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.qty-btn {
  width: 26px; height: 26px;
  background: none; border: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  display: inline-grid; place-items: center;
  transition: background .2s;
}
.qty-btn:hover { background: var(--surface-2); }
.qty-val {
  min-width: 26px; text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--ink);
}
.line-remove {
  background: none; border: none;
  color: var(--ink-4);
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border-radius: 6px;
  margin-left: 4px;
  transition: color .2s, background .2s;
}
.line-remove:hover { color: var(--danger); background: var(--danger-soft); }
.line-right {
  display: flex; flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.line-price {
  font-size: 14px; font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ----- drawer footer (totals + email + pay) -------------------------- */
.drawer-foot {
  padding: 16px 22px calc(20px + var(--safe-b));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.totals-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.totals-label {
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.totals-value {
  font-size: 22px; font-weight: 800; color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.min-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #8a0009;
}

.email-block { margin-bottom: 14px; }
.email-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.email-req {
  color: var(--danger);
  font-weight: 700;
}
.email-block input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.email-block input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 90, 0, 0.15);
}
.email-block input.is-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.email-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.4;
}

.sync-block { margin-bottom: 14px; }
.sync-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff1e6 0%, #fff7ee 100%);
  border: 1px solid rgba(239, 90, 0, 0.25);
  border-radius: 10px;
}
.sync-dot {
  width: 22px; height: 22px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 0 0 3px rgba(239, 90, 0, 0.15);
}
.sync-dot .bx { font-size: 14px; }
.sync-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sync-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.sync-uid {
  font-size: 11px; color: var(--ink-3); font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.sync-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.4;
}

.pay-btn {
  position: relative;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background .2s, box-shadow .2s, transform .15s;
}
.pay-btn:hover:not([disabled]) {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(239, 90, 0, 0.4);
}
.pay-btn:active:not([disabled]) { transform: translateY(1px); }
.pay-btn[disabled] {
  background: var(--border-2);
  color: var(--ink-4);
  cursor: not-allowed;
}
.pay-btn.is-busy { color: transparent !important; }
.pay-btn.is-busy::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 50%; top: 50%; margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255,255,255,.30);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   TOAST
   ========================================================================== */
.toast {
  position: fixed; left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error {
  background: var(--danger);
}
.toast.is-ok {
  background: var(--ok);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1080px) {
  .topbar { grid-template-columns: auto auto; gap: 14px; }
  .search { grid-column: 1 / -1; order: 3; max-width: 100%; }
  .head-right { justify-self: end; }
  .promo-inner { grid-template-columns: 1fr; }
  .promo-badges { justify-content: flex-start; }
}

@media (max-width: 640px) {
  :root { --pad-x: 14px; }
  .topbar { padding-top: calc(10px + var(--safe-t)); padding-bottom: 10px; gap: 10px; }
  .logo-text { font-size: 16px; }
  .logo-icon { width: 24px; height: 24px; }
  .search { height: 36px; padding-left: 32px; }
  .search svg { left: 10px; }
  .search input { font-size: 13px; }
  .lang-btn { font-size: 10.5px; padding: 4px 7px; }
  .cart-btn { width: 36px; height: 36px; }
  .cart-btn svg { width: 19px; height: 19px; }

  .promo { padding-top: 14px; }
  .promo-inner { padding: 18px 18px; gap: 14px; }
  .promo-title { font-size: 22px; }
  .promo-sub { font-size: 13px; }
  .promo-badge { padding: 8px 10px; min-width: 0; font-size: 10px; }
  .promo-badge strong { font-size: 13px; }

  .cats { padding-top: 14px; padding-bottom: 10px; gap: 5px; }
  .cat { padding: 6px 12px; font-size: 12px; }

  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding-bottom: 24px; }
  .cover { padding: 10px 10px 10px; }
  .cover-format { font-size: 9px; padding: 2px 6px; letter-spacing: 0.1em; }
  .cover-discount { font-size: 10px; padding: 2px 6px; }
  .cover-source { font-size: 9.5px; letter-spacing: 0.14em; }
  .cover-bigname { font-size: 16px; }
  .body { padding: 10px 12px 12px; gap: 4px; }
  .body-name { font-size: 13px; min-height: 34px; }
  .body-meta { font-size: 10.5px; }
  .body-rating { font-size: 11px; }
  .stars svg { width: 11px; height: 11px; }
  .price-now { font-size: 17px; }
  .price-old { font-size: 11px; }
  .add-btn { padding: 9px 10px; font-size: 12px; margin-top: 6px; }

  .drawer { width: 100vw; }
  .drawer-head { padding-left: 16px; padding-right: 16px; }
  .drawer-body { padding: 12px 16px; }
  .drawer-foot { padding: 14px 16px calc(18px + var(--safe-b)); }
  .line { grid-template-columns: 56px 1fr auto; padding: 8px; gap: 10px; }
  .line-cover { width: 56px; height: 50px; font-size: 9px; }
  .line-name { font-size: 12.5px; }
  .qty-btn { width: 24px; height: 24px; font-size: 13px; }
  .qty-val { font-size: 12px; }
  .pay-btn { padding: 12px 14px; font-size: 13px; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
  .promo-badges { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ==========================================================================
   Poster preview lightbox
   ========================================================================== */
.preview {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 24px;
  opacity: 0; visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.preview[aria-hidden="false"] { opacity: 1; visibility: visible; }
.preview-scrim {
  position: absolute; inset: 0;
  background: rgba(10, 10, 14, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: zoom-out;
}
.preview-card {
  position: relative;
  background: var(--surface, #ffffff);
  border-radius: 20px;
  width: 100%;
  max-width: 980px;
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.55);
  transform: scale(0.96);
  transition: transform .2s ease;
}
.preview[aria-hidden="false"] .preview-card { transform: scale(1); }
.preview-image-wrap {
  background: #0a0a0a;
  display: grid; place-items: center;
  padding: 14px;
  min-height: 320px;
}
.preview-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 76px);
  object-fit: contain;
  border-radius: 6px;
}
.preview-info {
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.preview-source {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft, #6b7280);
  font-weight: 700;
}
.preview-name {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink, #1a1a1a);
  line-height: 1.15;
}
.preview-tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft, #4b5563);
}
.preview-price-row {
  display: flex; align-items: baseline; gap: 12px;
  margin-top: 6px;
}
.preview-price {
  font-size: 30px;
  font-weight: 800;
  color: var(--ink, #1a1a1a);
}
.preview-price-old {
  font-size: 15px;
  color: var(--ink-dim, #9ca3af);
  text-decoration: line-through;
}
.preview-buy {
  margin-top: 12px;
  background: #ef5a00;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.preview-buy:hover { background: #d44d00; }
.preview-buy:active { transform: scale(0.98); }
.preview-buy.is-added { background: #1f2937; }
.preview-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 2;
  transition: background .15s, transform .15s;
}
.preview-close:hover { background: rgba(0,0,0,0.78); transform: scale(1.06); }

.card { cursor: zoom-in; }
.card .add-btn { cursor: pointer; }

@media (max-width: 760px) {
  .preview { padding: 12px; }
  .preview-card {
    grid-template-columns: 1fr;
    max-height: calc(100dvh - 24px);
  }
  .preview-image-wrap {
    max-height: 56dvh;
    min-height: 220px;
  }
  .preview-image-wrap img { max-height: 54dvh; }
  .preview-info { padding: 20px 20px 22px; gap: 10px; }
  .preview-name { font-size: 22px; }
  .preview-price { font-size: 26px; }
}

/* ==========================================================================
   Short viewports — landscape phones (height ≤ 520px)
   Goal: cart drawer + poster preview stay fully usable. Buy button visible.
   ========================================================================== */
@media (max-height: 520px) {
  /* ----- Preview modal — compact 2-column layout in landscape phones --- */
  .preview { padding: 8px; }
  .preview-card {
    max-height: calc(100dvh - 16px);
    grid-template-columns: minmax(0, 1.1fr) minmax(240px, 1fr);
    border-radius: 14px;
  }
  .preview-image-wrap {
    padding: 6px;
    min-height: 0;
  }
  .preview-image-wrap img {
    max-height: calc(100dvh - 32px);
    border-radius: 4px;
  }
  .preview-info {
    padding: 14px 18px;
    gap: 6px;
    min-height: 0;          /* allow flex item to shrink so scroll engages */
    overflow-y: auto;
  }
  .preview-source { font-size: 10px; letter-spacing: 0.14em; }
  .preview-name { font-size: 18px; line-height: 1.1; }
  .preview-tagline { font-size: 12.5px; line-height: 1.4; }
  .preview-price { font-size: 22px; }
  .preview-price-old { font-size: 13px; }
  .preview-price-row { margin-top: 2px; }
  .preview-buy {
    margin-top: 8px;
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 10px;
    /* keep button anchored even if info overflows */
    position: sticky;
    bottom: 0;
  }
  .preview-close { width: 30px; height: 30px; top: 8px; right: 8px; }
  .preview-close svg { width: 16px; height: 16px; }

  /* ----- Cart drawer — shrink chrome so list + email + pay all fit ----- */
  .drawer-head {
    padding: calc(10px + var(--safe-t)) 16px 10px;
  }
  .drawer-title { font-size: 15px; }
  .drawer-close { width: 28px; height: 28px; }
  .drawer-body { padding: 8px 14px; gap: 6px; }
  .drawer-empty { padding: 18px 12px; font-size: 13px; }
  .drawer-empty .empty-icon { width: 40px; height: 40px; margin-bottom: 8px; }
  .line {
    grid-template-columns: 44px 1fr auto;
    padding: 6px 8px;
    gap: 8px;
  }
  .line-cover { width: 44px; height: 38px; border-radius: 4px; }
  .line-name { font-size: 12px; margin-bottom: 2px; }
  .qty-btn { width: 22px; height: 22px; font-size: 12px; }
  .qty-val { min-width: 20px; font-size: 12px; }
  .line-price { font-size: 13px; }
  .drawer-foot {
    padding: 10px 14px calc(10px + var(--safe-b));
  }
  .totals-row { margin-bottom: 6px; }
  .totals-label { font-size: 12px; }
  .totals-value { font-size: 18px; }
  .min-note { margin-bottom: 6px; padding: 5px 9px; font-size: 11px; }
  .email-block { margin-bottom: 6px; }
  .email-label { font-size: 12px; margin-bottom: 4px; }
  .email-block input {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 8px;
    height: 36px;
  }
  .email-hint { font-size: 11px; margin-top: 4px; }
  .pay-btn {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 10px;
  }
}

/* Very short — tiny landscape phones (height ≤ 380px). Switch preview to
   image-left, info-right but make info side narrower and force scroll. */
@media (max-height: 380px) {
  .preview-card { grid-template-columns: minmax(0, 1fr) 220px; }
  .preview-info { padding: 10px 12px; }
  .preview-name { font-size: 16px; }
  .preview-tagline { font-size: 12px; }
  .preview-price { font-size: 20px; }
  .preview-buy { padding: 9px 12px; font-size: 13px; }
}
