/* Витрина DELIRIA. Основа берёт цвета темы Telegram (--tg-theme-*), бренд - акценты.
   Вне Telegram те же переменные получают значения по умолчанию для светлой и тёмной темы. */

:root {
  --graphite: #3b3d3f;
  --pistachio: #e3ebcf;
  --pistachio-deep: #8ea65f;

  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1f1f1d);
  --hint: var(--tg-theme-hint-color, #85857f);
  --surface: var(--tg-theme-secondary-bg-color, #f4f4f0);
  --link: var(--text);
  --danger: var(--tg-theme-destructive-text-color, #c2410c);
  --line: color-mix(in srgb, var(--text) 13%, transparent);
  --accent: var(--graphite);
  --accent-text: #ffffff;
  --chip: var(--pistachio);
  --chip-text: #1f1f1d;

  --radius: 14px;
  --gutter: 16px;
  color-scheme: light;
}

:root[data-scheme="dark"] {
  --bg: var(--tg-theme-bg-color, #161617);
  --text: var(--tg-theme-text-color, #f2f2ee);
  --hint: var(--tg-theme-hint-color, #8f8f8a);
  --surface: var(--tg-theme-secondary-bg-color, #222224);
  --danger: var(--tg-theme-destructive-text-color, #fb923c);
  --accent: var(--pistachio);
  --accent-text: #1f1f1d;
  --chip: color-mix(in srgb, var(--pistachio) 22%, transparent);
  --chip-text: var(--pistachio);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; overflow-x: hidden; }
body.has-web-main { padding-bottom: 88px; }

img { display: block; max-width: 100%; }
a { color: var(--link); }
button { font: inherit; color: inherit; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px var(--gutter) 32px;
}
.center { text-align: center; padding-top: 30vh; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.warn { color: var(--danger); }
.page-title { font-size: 26px; line-height: 1.15; margin: 8px 0 16px; letter-spacing: -0.01em; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--hint);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 14px;
  cursor: pointer;
}

/* --- шапка и каталог --- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 12px;
}
.wordmark {
  font-weight: 800;
  letter-spacing: 0.32em;
  font-size: 15px;
  text-decoration: none;
}
.topbar-cart {
  font-size: 14px;
  text-decoration: none;
  background: var(--chip);
  color: var(--chip-text);
  padding: 6px 12px;
  border-radius: 999px;
}

.intro { margin: 18px 0 22px; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pistachio-deep);
}
.intro h1 {
  margin: 6px 0 8px;
  font-size: clamp(34px, 11vw, 52px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.intro p { margin: 0; max-width: 32ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 12px;
}
.tile { text-decoration: none; color: inherit; }
.tile-img {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-title { margin-top: 8px; font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.tile-meta { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--hint); }
.tile-price { font-size: 15px; margin-top: 2px; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
}
.badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}

.footer { margin-top: 36px; font-size: 14px; }
.footer a { color: var(--hint); }

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

.product { padding-top: 0; }
.gallery {
  position: relative;
  margin: 0 calc(var(--gutter) * -1);
}
.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-track img {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  scroll-snap-align: start;
  background: var(--surface);
}
.gallery-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.gallery-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transition: width 0.2s;
}
.gallery-dots span.on { width: 18px; border-radius: 3px; background: #fff; }

.product-head { margin: 18px 0 8px; }
.product-head h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.01em; }
.product-head p { margin: 4px 0 0; }
.price { font-size: 20px; font-weight: 600; color: var(--text); }

.picker { margin: 20px 0; }
.picker-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-weight: 600;
}
.picker-label .muted { font-weight: 400; }

.swatches { display: flex; gap: 12px; }
.swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px var(--line), 0 0 0 2px var(--bg), 0 0 0 3px transparent;
  cursor: pointer;
}
.swatch[aria-checked="true"] { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

.sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.size {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.size[aria-checked="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.size:disabled {
  color: var(--hint);
  text-decoration: line-through;
  opacity: 0.55;
  cursor: default;
}

.about { margin-top: 26px; }
.details { margin: 14px 0 0; border-top: 1px solid var(--line); }
.details div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.details dt { color: var(--hint); font-size: 14px; }
.details dd { margin: 0; font-size: 15px; }

/* --- таблица размеров --- */

.table-wrap { overflow-x: auto; margin: 16px 0 8px; }
.size-table { width: 100%; border-collapse: collapse; text-align: center; font-variant-numeric: tabular-nums; }
.size-table th, .size-table td { padding: 12px 6px; border-bottom: 1px solid var(--line); }
.size-table thead th { font-size: 15px; }
.size-table tbody th { text-align: left; font-weight: 500; color: var(--hint); }
.note {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--chip-text);
}
.note p { margin: 0 0 8px; }
.note p:last-child { margin: 0; }

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

.lines { border-top: 1px solid var(--line); }
.line {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.line-off { opacity: 0.6; }
.line-img img { width: 72px; height: 90px; object-fit: cover; border-radius: 10px; }
.line-title { font-weight: 700; font-size: 15px; }
.line-side { text-align: right; display: flex; flex-direction: column; justify-content: space-between; }
.line-sum { font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; }
.stepper button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.4; }
.stepper span { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.total {
  display: flex;
  justify-content: space-between;
  padding: 16px 0 6px;
  font-size: 18px;
}

/* --- оформление --- */

.summary {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 20px;
  font-size: 14px;
}
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.lead-note { margin: -8px 0 20px; }
.summary-line.total { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 15px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field, .group { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.field-row .field { width: 100%; }
.field-label { font-weight: 600; font-size: 14px; }
.field input, .field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--hint); }
.field textarea { resize: vertical; }
.field-error { color: var(--danger); font-size: 13px; }
.field-error:empty { display: none; }

.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.option[aria-checked="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }

.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.group > a { font-size: 13px; color: var(--hint); }
.consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

/* --- заказ принят --- */

.done { padding-top: 22vh; }
.done-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--chip-text);
  display: grid;
  place-items: center;
  font-size: 30px;
}
.done p { max-width: 32ch; margin: 0 auto 20px; }

/* --- кнопка внизу и уведомление (только вне Telegram) --- */

#web-main {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
#web-main button {
  display: block;
  width: 100%;
  max-width: 528px;
  margin: 0 auto;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}
#web-main button:disabled { opacity: 0.45; cursor: default; }
#web-main button.loading { opacity: 0.7; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 10;
  max-width: calc(100% - 32px);
  text-align: center;
}
:root[data-platform="telegram"] #toast { bottom: 24px; }
#toast[hidden] { display: none; }
