/* Дизайн повторяет меню на gamma.space: Helvetica Neue (Inter там, где её нет),
   фирменный оранжевый, тёплые нейтральные фоны и «тарелки» под фотографиями. */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('static/inter-display.woff2') format('woff2');
}

:root {
    --accent: #FD6333;
    --accent-ink: #BF400C;
    --accent-soft: rgba(253, 99, 51, 0.12);
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface-2: #F2EFEB;
    --text: #1A1816;
    --muted: #6B6660;
    --line: #E8E4E0;
    --plate: #E7EDF3;
    --on-accent: #FFFFFF;
    --danger: #C2361B;
    --radius: 22px;
    /* внутренний радиус концентричен внешнему: минус обводка и отступ карточки */
    --radius-inner: 15px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --font: 'Helvetica Neue', 'Inter', sans-serif;
    /* В полноэкранном режиме Telegram рисует свои кнопки поверх страницы:
       сверху — вырез экрана плюс их полоса, снизу — полоса жестов. Вне этого
       режима переменные равны нулю. */
    --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
    color-scheme: light;
}

html[data-theme="dark"] {
    --accent-ink: #FD6333;
    --accent-soft: rgba(253, 99, 51, 0.16);
    --bg: #1A1816;
    --surface: #24211E;
    --surface-2: #2C2926;
    --text: #FFFFFF;
    --muted: rgba(255, 255, 255, 0.58);
    --line: rgba(255, 255, 255, 0.1);
    --plate: #141210;
    color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { background: var(--bg); }
/* мини-апп не должен масштабироваться: ни двойным тапом, ни щипком */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* и не должен сдвигаться вбок: горизонтальной прокрутки у страницы нет,
   а «резинка» лент категорий не передаётся на всю страницу */
html { overflow-x: hidden; overscroll-behavior-x: none; }
body { overflow-x: clip; overscroll-behavior-x: none; }
body {
    font-family: var(--font);
    font-feature-settings: 'cv10';
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(96px + var(--safe-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

.view { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

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

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(18px + var(--safe-top)) 0 8px; }

/* подложка под системными кнопками Telegram, чтобы лента не просвечивала под ними */
.safe-cover {
    position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top); z-index: 6;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.logo { height: 20px; width: auto; }
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }
.top-label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.hero { padding: 26px 0 22px; }
.hero h1 { font-size: 38px; line-height: 1.05; font-weight: 200; letter-spacing: -0.02em; }
.hero-note { margin-top: 14px; color: var(--muted); }
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* Тумблер темы: капсула с солнцем и луной, круглый бегунок под активной иконкой */
.theme-toggle {
    position: relative; flex: none; width: 66px; height: 36px; margin-top: 4px;
    border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.theme-toggle .knob {
    position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    transition: transform 0.35s var(--ease);
}
.theme-toggle svg {
    position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px;
    color: var(--muted); transition: color 0.35s var(--ease);
}
.theme-toggle .sun { left: 9px; color: var(--accent-ink); }
.theme-toggle .moon { right: 9px; }
html[data-theme="dark"] .theme-toggle .knob { transform: translateX(30px); }
html[data-theme="dark"] .theme-toggle .sun { color: var(--muted); }
html[data-theme="dark"] .theme-toggle .moon { color: var(--accent); }
.hero-note.closed { color: var(--accent-ink); }

/* ---------- переключатели ---------- */

.sticky {
    position: sticky; top: var(--safe-top); z-index: 5;
    margin: 0 -16px; padding: 10px 16px 10px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}

.segmented {
    display: inline-flex; padding: 4px; gap: 2px;
    background: var(--surface-2); border-radius: 999px;
}
.segmented button {
    padding: 9px 20px; border-radius: 999px; color: var(--muted);
    transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

.chips {
    display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px;
    scrollbar-width: none; overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; padding: 8px 15px; border-radius: 999px; font-size: 14px;
    border: 1px solid var(--line); color: var(--text); white-space: nowrap;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.chip.active { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.chip small { color: var(--muted); margin-left: 4px; }
.chips-inline { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }

/* ---------- каталог ---------- */

.cat { padding-top: 26px; }
.cat h2 { font-size: 28px; font-weight: 300; letter-spacing: -0.01em; margin-bottom: 14px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
    display: flex; flex-direction: column; text-align: left;
    background: var(--sq-fill); border-radius: var(--radius); padding: 6px;
    border: 1px solid var(--sq-line);
    --sq-fill: var(--surface); --sq-line: var(--line);
}
.card-photo {
    aspect-ratio: 4 / 5; border-radius: var(--radius-inner); overflow: hidden; background: var(--plate);
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 10px 6px 4px; }
.card-name { font-size: 15px; line-height: 1.25; }
.card-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.card-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: auto; padding-top: 12px;
}
.price { font-weight: 500; white-space: nowrap; }

.row {
    display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
    background: var(--sq-fill); border: 1px solid var(--sq-line); border-radius: var(--radius);
    --sq-fill: var(--surface); --sq-line: var(--line);
    padding: 14px 14px 14px 16px; margin-bottom: 8px;
}
.row-main { flex: 1; min-width: 0; }
.row-ing { font-size: 13px; color: var(--muted); margin-top: 3px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* Плюс нарисован SVG, а цифры центрируются флексом: у текстового «+» и цифр
   своя линия шрифта, и по высоте строки они садятся ниже середины кружка. */
.add {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: var(--on-accent);
}
.add svg, .stepper svg, .card-stepper svg { width: 14px; height: 14px; }

/* «− 1 +» вместо плюса, когда позиция уже в корзине */
.card-stepper {
    display: inline-flex; align-items: center; flex: none; height: 34px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent-ink);
}
.card-stepper [data-step] {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 34px;
}
.card-qty { min-width: 16px; text-align: center; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.stepper button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; color: var(--muted);
}
.stepper span { min-width: 22px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }

.footnote { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 12px 10px; }

/* ---------- карточка позиции ---------- */

.backdrop {
    position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45);
    animation: fade 0.25s var(--ease);
}
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
    max-height: calc(100dvh - var(--safe-top) - 12px); overflow-y: auto; overscroll-behavior: contain;
    /* углы листа концентричны углам фото: радиус фото + отступ до него */
    background: var(--bg); border-radius: 40px 40px 0 0;
    padding: 16px 16px calc(110px + var(--safe-bottom));
    animation: rise 0.35s var(--ease);
}
.sheet-close {
    position: absolute; top: 26px; right: 26px; z-index: 2;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
}
/* фото меню сняты в 4:5 — в той же пропорции они показываются целиком, без обрезки */
.sheet-photo { aspect-ratio: 4 / 5; border-radius: 24px; overflow: hidden; background: var(--plate); }
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; }
.sheet h3 { font-size: 28px; font-weight: 300; line-height: 1.1; margin: 18px 0 8px; padding-right: 30px; }
.sheet .ing { color: var(--muted); font-size: 14px; }
.sheet .desc { margin-top: 10px; }
.opt-title { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.sheet .chips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
.sheet-qty { display: flex; align-items: center; justify-content: space-between; margin-top: 24px; }

.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; font-size: 17px; line-height: 36px; text-align: center;
    background: var(--surface-2);
}

/* ---------- корзина и оформление ---------- */

.page-head { display: flex; align-items: center; gap: 12px; padding: calc(16px + var(--safe-top)) 0 6px; }
.page-head h2 { flex: 1; font-size: 28px; font-weight: 300; }
.text-btn { color: var(--accent-ink); font-size: 14px; padding: 6px 0; }

.lines { margin-top: 10px; }
.line {
    display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.line-photo { width: 56px; height: 56px; border-radius: 14px; overflow: hidden; background: var(--plate); flex: none; }
.line-photo img { width: 100%; height: 100%; object-fit: cover; }
.line-main { flex: 1; min-width: 0; }
.line-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.line-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.line .stepper button { width: 30px; height: 30px; }
.total { display: flex; justify-content: space-between; padding: 16px 0 4px; font-size: 17px; }
.total b { font-weight: 500; }

.form { padding-top: 22px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span:first-child { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.input-shell {
    display: block; border: 1px solid var(--sq-line); background: var(--sq-fill); border-radius: 16px;
    --sq-fill: var(--surface); --sq-line: var(--line);
}
.input-shell:focus-within { --sq-line: var(--accent); }
.field.invalid .input-shell { --sq-line: var(--danger); }
.field input, .field textarea {
    display: block; width: 100%; border: 0; background: transparent;
    padding: 13px 14px; outline: none; resize: none; font-size: 16px;
}

.share-phone { align-self: flex-start; margin-top: -8px; }
.form-error { color: var(--danger); font-size: 14px; }

/* ---------- нижняя кнопка ---------- */

.bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    /* по бокам шире, чем отступ контента: кнопка чуть уже ленты, как поле ввода в Telegram */
    padding: 12px 24px calc(12px + var(--safe-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.primary {
    display: block; width: 100%; max-width: 608px; margin: 0 auto;
    background: var(--accent); color: var(--on-accent); border-radius: 999px;
    padding: 16px 20px; font-size: 16px; font-weight: 500; text-align: center;
    transition: opacity 0.2s, transform 0.15s;
}
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.45; }

/* ---------- заказ отправлен ---------- */

.view-center { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.view-center h2 { font-size: 30px; font-weight: 300; }
.view-center .primary { margin-top: 18px; max-width: 320px; }
.done-mark {
    width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
    font-size: 34px; line-height: 72px; animation: pop 0.5s var(--ease);
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

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

/* ---------- iOS-сглаживание углов (см. squircle.js) ---------- */

/* форму задаёт clip-path, обычное скругление больше не нужно */
.sq-on { border-radius: 0 !important; }

/* Обводка по той же форме: элемент залит цветом обводки, а ::before внутри рамки
   (он начинается сразу за ней) залит фоном и обрезан контуром на 1px меньше. */
.sq-stroke.sq-on {
    position: relative; isolation: isolate;
    border-color: transparent; background: var(--sq-line);
}
.sq-stroke.sq-on::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: var(--sq-fill); clip-path: var(--sq-inner);
}
