/* ============================================================
   SANS LAB — витрина магазина
   Эстетика: refined minimal / "архивный" премиум-ресейл.
   Монохром (бумага + чернила), тонкие линии, технический моно-акцент.
   Светлая и тёмная темы (адаптация под Telegram).
   ============================================================ */

:root {
  --paper:      #F4F3EF;
  --surface:    #FBFAF7;
  --surface-2:  #FFFFFF;
  --ink:        #15140F;
  --ink-soft:   #3A3833;
  --muted:      #7A766D;
  --line:       rgba(21,20,15,.12);
  --line-soft:  rgba(21,20,15,.07);
  --ok:         #15140F;   /* статус-акценты монохромные */
  --shadow:     0 1px 2px rgba(21,20,15,.04), 0 12px 30px -18px rgba(21,20,15,.28);
  --radius:     16px;
  --radius-sm:  10px;
  --maxw:       1180px;

  --font-display: "Bricolage Grotesque", "Archivo", system-ui, sans-serif;
  --font-body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

.dark {
  --paper:      #100F0C;
  --surface:    #161510;
  --surface-2:  #1C1B15;
  --ink:        #F3F1EA;
  --ink-soft:   #D9D6CC;
  --muted:      #8C887D;
  --line:       rgba(243,241,234,.14);
  --line-soft:  rgba(243,241,234,.07);
  --ok:         #F3F1EA;
  --shadow:     0 1px 2px rgba(0,0,0,.4), 0 16px 40px -20px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* лёгкая зернистость для атмосферы */
  background-image:
    radial-gradient(rgba(21,20,15,.02) 1px, transparent 1px);
  background-size: 4px 4px;
}

.dark body {
  background-image:
    radial-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ----------------------- Шапка ----------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand .mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(18px, 2.4vw, 22px);
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1;
}
.brand .tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 520px) { .brand .tag { display: none; } }

.cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .02em;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.cart-btn:hover { background: var(--ink); color: var(--paper); }
.cart-btn:active { transform: scale(.97); }
.cart-btn .count {
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
}
.cart-btn:hover .count { background: var(--paper); color: var(--ink); }

/* ----------------------- Контейнер ----------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* ----------------------- Hero ----------------------- */
.hero { padding: clamp(34px, 7vw, 72px) 0 clamp(22px, 4vw, 40px); }
.hero .kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 16px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 7vw, 68px);
  line-height: .98;
  letter-spacing: -.02em;
  margin: 0;
  max-width: 14ch;
}
.hero p {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 17px);
  max-width: 46ch;
  line-height: 1.5;
}

/* ----------------------- Фильтры ----------------------- */
.filters {
  position: sticky;
  top: 73px;
  z-index: 20;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 14px 0;
  margin-bottom: 6px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: all .16s ease;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ----------------------- Сетка товаров ----------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: clamp(14px, 2vw, 26px);
  padding: 18px 0 40px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.thumb {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--surface-2);
  overflow: hidden;
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2,.7,.2,1);
}
.card:hover .thumb img { transform: scale(1.045); }

/* placeholder, если фото нет */
.thumb .ph {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--line);
  font-size: 26px;
  background:
    repeating-linear-gradient(45deg, var(--line-soft) 0 1px, transparent 1px 11px);
}

.badge {
  position: absolute;
  top: 10px; left: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 6px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line);
  color: var(--ink);
}
.badge.sold { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.card.is-sold .thumb img { filter: grayscale(1); opacity: .55; }

.body { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 16px; flex: 1; }
.name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.18;
  letter-spacing: -.01em;
  margin: 0;
}
.specs {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: -2px;
}
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}
.price { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.price.struck { text-decoration: line-through; color: var(--muted); font-weight: 600; }

.add {
  width: 100%;
  margin-top: 12px;
  height: 44px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .01em;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.add:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.add:active:not(:disabled) { transform: scale(.98); }
.add:disabled { border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.add.in-cart { background: var(--ink); color: var(--paper); }

/* ----------------------- Скелетоны ----------------------- */
.skeleton .thumb,
.skeleton .sk-line {
  background: linear-gradient(100deg, var(--line-soft) 30%, var(--line) 50%, var(--line-soft) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.skeleton .sk-line { height: 12px; border-radius: 6px; margin: 0; }
.skeleton .sk-line.lg { height: 18px; width: 70%; }
.skeleton .sk-line.sm { width: 45%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ----------------------- Состояния ----------------------- */
.state {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}
.state h3 { font-family: var(--font-display); color: var(--ink); margin: 0 0 8px; font-size: 20px; }
.state p { margin: 0 auto; max-width: 38ch; line-height: 1.5; }
.state button {
  margin-top: 18px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
}

/* ----------------------- Подвал ----------------------- */
.foot {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ----------------------- Корзина (drawer) ----------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(8,8,6,.45);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
  z-index: 40;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  z-index: 50;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
/* десктоп: панель справа */
.drawer {
  top: 0; right: 0; height: 100%;
  width: min(420px, 100%);
  border-left: 1px solid var(--line);
  transform: translateX(105%);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: 18px; letter-spacing: .04em; text-transform: uppercase; margin: 0;
}
.x {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  border-radius: 10px; font-size: 18px;
  transition: background .16s ease;
}
.x:hover { background: var(--surface-2); }

.cart-list { flex: 1; overflow: auto; padding: 8px 20px; }
.cart-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.cart-row img { width: 56px; height: 70px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.cart-row .cr-ph { width: 56px; height: 70px; border-radius: 8px; background: repeating-linear-gradient(45deg,var(--line-soft) 0 1px,transparent 1px 9px); }
.cart-row .ttl { font-family: var(--font-display); font-weight: 700; font-size: 14px; line-height: 1.2; }
.cart-row .sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.cart-row .cr-right { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cart-row .cr-price { font-family: var(--font-display); font-weight: 800; font-size: 14px; }
.rm { border: none; background: transparent; color: var(--muted); font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em; padding: 0; transition: color .16s ease; }
.rm:hover { color: var(--ink); text-decoration: underline; }

.empty { text-align: center; color: var(--muted); padding: 56px 16px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }

.drawer-foot { padding: 18px 20px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.total-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.total-row span { font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.total-row strong { font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -.01em; }
.checkout {
  width: 100%; height: 52px;
  border: none; border-radius: 12px;
  background: var(--ink); color: var(--paper);
  font-weight: 800; font-size: 15px; letter-spacing: .04em; text-transform: uppercase;
  transition: opacity .16s ease, transform .12s ease;
}
.checkout:hover { opacity: .9; }
.checkout:active { transform: scale(.99); }
.checkout:disabled { opacity: .4; cursor: not-allowed; }

/* мобильный: корзина как нижний лист */
@media (max-width: 640px) {
  .filters { top: 71px; }
  .drawer {
    top: auto; bottom: 0; right: 0;
    height: auto; max-height: 86vh;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
  }
  .drawer.open { transform: translateY(0); }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .add { height: 42px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}
