/* Мини-приложение «Сырный край». Цвета и шрифты — с сайта syrkray.ru:
   тёплый каменный фон, почти чёрные кнопки, золотой акцент, Comfortaa + Montserrat. */
:root {
  --ground: #f7f5f0;
  --surface: #ede8de;
  --surface-2: #e2dbcd;
  --ink: #1f1d1a;
  --ink-2: #56504a;
  --accent: #171717;
  --on-accent: #f7f5f0;
  --gold: #c99a40;
  --gold-ink: #7a5718;
  --danger: #9a3333;
  --display: "Comfortaa", "Montserrat", system-ui, sans-serif;
  --text: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground: #171614;
  --surface: #23211e;
  --surface-2: #2f2c28;
  --ink: #f3efe7;
  --ink-2: #b2a99c;
  --accent: #f3efe7;
  --on-accent: #171614;
  --gold: #d6a84f;
  --gold-ink: #e7c27a;
  --danger: #e28b8b;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #171614;
    --surface: #23211e;
    --surface-2: #2f2c28;
    --ink: #f3efe7;
    --ink-2: #b2a99c;
    --accent: #f3efe7;
    --on-accent: #171614;
    --gold: #d6a84f;
    --gold-ink: #e7c27a;
    --danger: #e28b8b;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--text);
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
::selection { background: var(--gold); color: #171614; }
[hidden] { display: none !important; }

/* ---------- экраны ---------- */
#app { max-width: 640px; margin: 0 auto; }
.screen { padding: 20px var(--gutter) calc(112px + env(safe-area-inset-bottom)); }
.wordmark {
  font: 700 clamp(40px, 12.5vw, 64px)/1 var(--display);
  letter-spacing: -0.035em;
}
.title {
  font: 700 clamp(26px, 7.4vw, 34px)/1.08 var(--display);
  letter-spacing: -0.03em;
}
.lead { margin-top: 12px; font-size: 17px; color: var(--ink); max-width: 34em; }
.lead strong { color: var(--ink); font-weight: 600; }
.block { margin-top: 56px; }
.block-title { font: 700 22px/1.15 var(--display); letter-spacing: -0.02em; margin-bottom: 16px; }
.note { font-size: 16px; color: var(--ink-2); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 999px;
  font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform .14s var(--ease), background-color .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); width: 100%; }
.btn-quiet { background: var(--surface); color: var(--ink); }
.btn-quiet:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 8px 0; color: var(--ink); font-weight: 600;
        text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--ground);
}
.bar .btn { max-width: 608px; margin: 0 auto; display: flex; }

.toast {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 6; max-width: 608px; margin: 0 auto; padding: 14px 18px; border-radius: 18px;
  background: var(--accent); color: var(--on-accent); font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .22);  /* taste-skill-ignore: всплывающее уведомление парит над страницей */
  animation: rise .28s var(--ease);
}

/* ---------- каталог ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head .cart-link { flex: none; }
.tabs {
  position: sticky; top: 0; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px;
  margin: 24px calc(-1 * var(--gutter)) 0; padding: 10px var(--gutter);
  background: var(--ground);
}
.tab {
  flex: 1 1 auto; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer;
  transition: background-color .2s, color .2s, transform .14s var(--ease);
}
.tab:active { transform: scale(.96); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 12px; margin-top: 16px; }
.item { display: block; align-self: start; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.item .ph { aspect-ratio: 4 / 5; background: var(--surface); overflow: hidden; }
.item .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.item:hover .ph img { transform: scale(1.03); }
.item:active .ph img { transform: scale(.98); }
.item-name { margin-top: 10px; font: 700 17px/1.2 var(--display); letter-spacing: -0.015em;
             display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-price { margin-top: 6px; font-weight: 600; font-size: 15px; }
.item-price small { font-weight: 500; color: var(--ink-2); font-size: 14px; }
.item-in { margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--gold-ink); }
.item.wide { grid-column: 1 / -1; }
.item.wide .ph { aspect-ratio: 5 / 4; }
.item.wide .item-name { font-size: 24px; }
.item-hit { color: var(--gold-ink); font-weight: 600; }

.tariffs { display: grid; gap: 2px; }
.tariffs li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; background: var(--surface); }
.tariffs li:first-child { border-radius: 16px 16px 0 0; }
.tariffs li:last-child { border-radius: 0 0 16px 16px; }
.tariffs b { font-weight: 600; white-space: nowrap; }
.facts { display: grid; gap: 14px; }
.facts a { color: var(--ink); font-weight: 600; }

.colophon { margin-top: 72px; padding: 28px var(--gutter) 0; margin-left: calc(-1 * var(--gutter));
            margin-right: calc(-1 * var(--gutter)); background: var(--surface); }
.colophon .wordmark { font-size: clamp(40px, 13vw, 64px); padding-bottom: 28px; }
.colophon p { padding-bottom: 8px; color: var(--ink-2); font-size: 16px; }

/* ---------- товар ---------- */
/* Высота фото — от ширины (4:5), но не больше ~⅔ видимой области Telegram. Без aspect-ratio + max-height:
   в паре они сужают блок по ширине, и фото уезжает влево-вверх, когда приложение открыто не на весь экран. */
.product .hero {
  margin: -20px calc(-1 * var(--gutter)) 0; background: var(--surface); overflow: hidden;
  height: min(calc(min(100vw, 640px) * 1.25), max(calc(var(--tg-viewport-stable-height, 100vh) * .64), 340px));
}
.product .hero img { width: 100%; height: 100%; object-fit: cover; object-position: center; animation: settle 1.2s var(--ease) both; }
.product .title { margin-top: 22px; }
.price { margin-top: 10px; font-size: 20px; font-weight: 600; }
.price small { display: block; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.price .linked { display: block; font-size: 15px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }

.weigh { margin-top: 28px; padding: 20px; border-radius: 24px; background: var(--surface);
         display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; align-items: center; }
.wheel { width: 112px; height: 112px; grid-row: span 2; }
.wheel .rind { fill: var(--surface-2); }
.wheel .cut { fill: var(--gold); }
.wheel .extra { fill: var(--gold); }
.weigh-qty { font: 700 38px/1 var(--display); letter-spacing: -0.03em; }
.weigh-sum { font-size: 18px; font-weight: 600; }
.weigh-sum small { font-weight: 500; color: var(--ink-2); font-size: 14px; display: block; }
.weigh .stepper { grid-column: 1 / -1; margin-top: 12px; }
.weigh .note { grid-column: 1 / -1; margin-top: 4px; }
.weigh.pieces { grid-template-columns: 1fr; }

.stepper { display: flex; align-items: center; gap: 10px; }
.step {
  width: 52px; height: 52px; flex: none; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font: 600 24px/1 var(--text);
  transition: transform .12s var(--ease), opacity .2s;
}
.step:active { transform: scale(.9); }
.step[disabled] { opacity: .35; cursor: default; }
.stepper .val { flex: 1; text-align: center; font-weight: 600; font-size: 17px; }

.options { margin-top: 28px; }
.options h2, .about h2 { font: 700 19px/1.2 var(--display); letter-spacing: -0.015em; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--surface);
        font-weight: 500; cursor: pointer; transition: background-color .2s, transform .12s var(--ease); }
.chip:active { transform: scale(.96); }
.chip[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.options .note { margin-top: 10px; }

.about { margin-top: 32px; }
.about p { white-space: pre-line; }
.about p + p { margin-top: 12px; }

/* ---------- корзина ---------- */
.lines { margin-top: 24px; display: grid; gap: 24px; }
.line { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: start; }
.line .ph { aspect-ratio: 4 / 5; background: var(--surface); overflow: hidden; }
.line .ph img { width: 100%; height: 100%; object-fit: cover; }
.line-name { font: 700 17px/1.2 var(--display); letter-spacing: -0.015em; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.line-sum { margin-top: 4px; font-weight: 600; }
.line-sum small { color: var(--ink-2); font-weight: 500; font-size: 14px; }
.line .stepper { margin-top: 10px; }
.line .step { width: 44px; height: 44px; font-size: 20px; background: var(--surface); color: var(--ink); }
.line .stepper .val { flex: none; min-width: 72px; }
.line .remove { margin-left: auto; font-size: 14px; color: var(--ink-2); }
.total { margin-top: 32px; padding: 20px; border-radius: 24px; background: var(--surface); }
.total-sum { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
             font: 700 26px/1.1 var(--display); letter-spacing: -0.02em; }
.total .note { margin-top: 10px; }
.empty { margin-top: 32px; }
.empty .btn { margin-top: 24px; width: auto; }

/* ---------- оформление ---------- */
.form { margin-top: 28px; display: grid; gap: 36px; }
fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 14px; min-width: 0; }
legend { padding: 0; margin-bottom: 14px; font: 700 20px/1.2 var(--display); letter-spacing: -0.02em; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field label span { font-weight: 500; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%; min-height: 52px; padding: 14px 16px; border: 2px solid transparent; border-radius: 16px;
  background: var(--surface); outline: none; transition: border-color .2s, background-color .2s;
}
.field textarea { min-height: 104px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--gold); background: var(--ground); }
.field.bad input, .field.bad textarea { border-color: var(--danger); }
.field .err { margin-top: 6px; font-size: 14px; color: var(--danger); font-weight: 500; }

/* ---------- проверка и готово ---------- */
.review { margin-top: 24px; display: grid; gap: 2px; }
.review > div { padding: 14px 16px; background: var(--surface); display: flex; justify-content: space-between; gap: 16px; }
.review > div:first-child { border-radius: 18px 18px 0 0; } .review > div:last-child { border-radius: 0 0 18px 18px; }
.review dt { color: var(--ink-2); }
.review dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.done .title { margin-top: 12vh; }
.done .order-id { display: inline-block; margin-top: 18px; padding: 10px 16px; border-radius: 14px; background: var(--surface);
                  font-weight: 600; font-size: 20px; letter-spacing: .02em; }
.done .actions { margin-top: 32px; display: grid; gap: 10px; }

/* ---------- движение ---------- */
.in > * { animation: rise .5s var(--ease) both; }
.in > *:nth-child(2) { animation-delay: .06s; } .in > *:nth-child(3) { animation-delay: .12s; }
.in > *:nth-child(4) { animation-delay: .18s; } .in > *:nth-child(5) { animation-delay: .24s; }
.in > *:nth-child(n+6) { animation-delay: .3s; }
.grid .item { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms + 80ms); }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
@keyframes settle { from { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

@media (min-width: 560px) {
  :root { --gutter: 24px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .item.wide { grid-column: span 2; }
}
