/* Палитра из макета витрины: шоколад, крем, малиновый акцент. */
:root {
  --ground:      #FBF7F2;
  --surface:     #FFFFFF;
  --surface-alt: #F4EDE4;
  --ink:         #2B1E1A;
  --ink-soft:    #6B5A52;
  --ink-faint:   #9C8B82;
  --line:        #E6DACE;
  --berry:       #C4315A;
  --berry-soft:  #F7E4EA;
  --pistachio:   #7A8B5C;
  --shadow:      rgba(43, 30, 26, .10);
  --shadow-lift: rgba(43, 30, 26, .18);
}

/* Telegram переключает тему на лету — ставит класс на <html>. */
@media (prefers-color-scheme: dark) {
  :root:not(.tg-light) {
    --ground:      #1A1210;
    --surface:     #241A17;
    --surface-alt: #2E211D;
    --ink:         #F5E9E0;
    --ink-soft:    #C0AA9E;
    --ink-faint:   #8A7469;
    --line:        #3B2A24;
    --berry:       #F2718F;
    --berry-soft:  #3A1D26;
    --pistachio:   #A3B47F;
    --shadow:      rgba(0, 0, 0, .38);
    --shadow-lift: rgba(0, 0, 0, .55);
  }
}

:root.tg-dark {
  --ground:      #1A1210;
  --surface:     #241A17;
  --surface-alt: #2E211D;
  --ink:         #F5E9E0;
  --ink-soft:    #C0AA9E;
  --ink-faint:   #8A7469;
  --line:        #3B2A24;
  --berry:       #F2718F;
  --berry-soft:  #3A1D26;
  --pistachio:   #A3B47F;
  --shadow:      rgba(0, 0, 0, .38);
  --shadow-lift: rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

/* Атрибут hidden обязан прятать элемент.
   Браузерное правило [hidden]{display:none} — из user-agent stylesheet,
   и ЛЮБОЕ авторское правило с display его перебивает независимо от
   специфичности. Из-за этого `.sheet{display:grid}` держал диалог
   «Откуда вы?» открытым, сколько бы JS ни ставил hidden = true.
   !important здесь по делу: hidden не должен зависеть от порядка правил. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px;
}

.wrap { max-width: 520px; margin: 0 auto; }

/* --- шапка --- */

.top {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}
.brand span { color: var(--berry); }

.region {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.region:hover { border-color: var(--berry); color: var(--berry); }

/* --- категории --- */

.cats {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }

.cat {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s, border-color .18s;
}
.cat:hover { border-color: var(--berry); color: var(--berry); }
.cat[aria-selected="true"] {
  background: var(--berry);
  border-color: var(--berry);
  color: #fff;
}
.cat:focus-visible, .add:focus-visible, .checkout:focus-visible,
.region:focus-visible, .stepper button:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 2px;
}

/* --- карточки --- */

.grid { display: grid; gap: 14px; padding: 0 20px; }

.card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 1px 2px var(--shadow);
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: 0 6px 20px var(--shadow-lift); transform: translateY(-2px); }

/* Фотографий товаров пока нет — вкус передаём градиентом. */
.swatch {
  border-radius: 11px;
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #D8C3A5, #A1846A);
}
.swatch::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.42), transparent 58%);
}
/* Фото ложится поверх градиента: пока грузится — видно цвет вкуса.
   Элемент в документе с самого начала (иначе lazy-loading не стартует),
   но прозрачен, пока картинка не пришла. */
.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  opacity: 0;
  transition: opacity .25s ease-out;
}
.photo.photo-on { opacity: 1; }

.s-mousse-1 { background: linear-gradient(150deg, #E85A7E, #A3234A); }
.s-mousse-2 { background: linear-gradient(150deg, #7A4A32, #3D2118); }
.s-classic-1{ background: linear-gradient(150deg, #E5A94F, #B06E24); }
.s-classic-2{ background: linear-gradient(150deg, #F0DCB4, #C39A63); }
.s-macaron  { background: linear-gradient(150deg, #F2A8C0, #9FBE7E 62%, #E9C46A); }
.s-cake     { background: linear-gradient(150deg, #FBEFD8, #D9B98C); }
.s-cookie   { background: linear-gradient(150deg, #C08A56, #6E4327); }
.s-new      { background: linear-gradient(150deg, #C9A57E, #5C4033); }

.body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.name {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.24;
  margin: 0;
  text-wrap: balance;
}

.desc { font-size: 13px; color: var(--ink-soft); margin: 0; }

.foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.add {
  border: 0;
  background: var(--ink);
  color: var(--ground);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s;
}
.add:hover { background: var(--berry); }
.add[disabled] { opacity: .5; cursor: default; }

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--berry-soft);
  border-radius: 999px;
  padding: 3px;
}
.stepper button {
  width: 26px; height: 26px;
  border: 0; border-radius: 50%;
  background: var(--surface);
  color: var(--berry);
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
}
.qty {
  min-width: 22px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--berry);
  font-variant-numeric: tabular-nums;
}

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 40px 20px;
  font-size: 14px;
}

/* --- корзина --- */

.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(115%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.bar.on { transform: none; }
.bar-inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.sum { display: flex; flex-direction: column; line-height: 1.25; }
.sum b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sum span { font-size: 12px; color: var(--ink-faint); }

.checkout {
  margin-left: auto;
  border: 0;
  background: var(--berry);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 26px;
  border-radius: 12px;
  cursor: pointer;
}
.checkout[disabled] { opacity: .6; cursor: default; }

/* --- выбор региона --- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 10, .55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.sheet-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.sheet-box h2 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 21px;
  margin: 0 0 6px;
}
.sheet-box p { margin: 0 0 18px; font-size: 13.5px; color: var(--ink-soft); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions button {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 13px;
  border-radius: 12px;
  cursor: pointer;
}
.sheet-actions button:hover { border-color: var(--berry); color: var(--berry); }

.top-actions { display: flex; gap: 8px; align-items: center; }

.orders-box { max-width: 400px; text-align: left; }
.orders-box h2 { text-align: center; }

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 6px;
}

.order {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface-alt);
}
.order-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.order-no { font-weight: 600; font-size: 14.5px; }
.order-date { font-size: 11.5px; color: var(--ink-faint); }
.order-line {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.order-total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.order-status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pistachio);
}

.info-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 6px;
}

.info-row { display: flex; flex-direction: column; gap: 2px; }
.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
}
.info-value { font-size: 14px; white-space: pre-line; }
.info-value a { color: var(--berry); text-decoration: none; }
.info-value a:hover { text-decoration: underline; }

.info-links { display: flex; flex-wrap: wrap; gap: 8px; }
.info-links a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}
.info-links a:hover { border-color: var(--berry); color: var(--berry); }

.done-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--pistachio);
  color: #fff;
  font-size: 24px;
  line-height: 46px;
}

.sheet-close {
  margin-top: 14px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}
.sheet-close:hover { color: var(--ink); }

/* --- уведомление --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--ground);
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 30;
  max-width: 90vw;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
