/* Лукоморье — витрина. Mobile-first, без внешних зависимостей. */
:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f4ede2;
  --text: #1f1b17;
  --muted: #6e655b;
  --line: #eadfce;
  --accent: #d4401a;
  --accent-ink: #ffffff;
  --accent-soft: #fde7de;
  --green: #2f6b4f;
  --green-soft: #e1efe7;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 8px 24px rgba(60, 35, 10, .07);
  --r: 18px;
  --hh: 120px; /* высота шапки — уточняется скриптом */
  --gut: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e;
    --surface: #1e1a16;
    --surface-2: #29231d;
    --text: #f4ece2;
    --muted: #a99d8f;
    --line: #342d25;
    --accent: #ff6a3d;
    --accent-ink: #1b0d06;
    --accent-soft: #3a2118;
    --green: #7fc6a0;
    --green-soft: #1d2d25;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
body.lock { overflow: hidden; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--gut); }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top__row { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand__mark { width: 34px; height: 34px; fill: var(--accent); }
.brand__mark .m-slice { fill: #ffd9a0; }
.brand__mark .m-dot { fill: var(--accent); }
.brand__name { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }

.search { position: relative; flex: 1 1 auto; min-width: 0; max-width: 420px; margin-left: auto; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); }

.phone { display: none; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; white-space: nowrap; padding: 0 6px; }
.phone svg { width: 18px; height: 18px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; }

.cartbtn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 40px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  transition: transform .15s ease;
}
.cartbtn:active { transform: scale(.96); }
.cartbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cartbtn__sum { display: none; }
.cartbtn__n {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--text); color: var(--bg); font-size: 12px; line-height: 20px; text-align: center;
}
.cartbtn.has .cartbtn__sum { display: inline; }
.cartbtn.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }

/* ---------- разделы ---------- */
.cats { border-top: 1px solid var(--line); }
.cats__row {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  margin: 0 calc(var(--gut) * -1); padding-left: var(--gut); padding-right: var(--gut);
}
.cats__row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; height: 36px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- hero ---------- */
.hero { padding-top: 28px; padding-bottom: 8px; }
.hero h1 { font-size: clamp(28px, 6vw, 46px); line-height: 1.05; letter-spacing: -.03em; font-weight: 800; max-width: 18ch; }
.hero__lead { margin-top: 10px; color: var(--muted); max-width: 56ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chips li { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-weight: 600; font-size: 14px; }

/* ---------- меню ---------- */
.sec { padding-top: 28px; scroll-margin-top: calc(var(--hh) + 4px); }
.sec__title { font-size: clamp(22px, 4vw, 30px); font-weight: 800; letter-spacing: -.02em; margin-bottom: 14px; display: flex; align-items: baseline; gap: 10px; }
.sec__count { font-size: 14px; font-weight: 600; color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }

.card {
  display: grid; grid-template-columns: 112px 1fr; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow); text-align: left; padding: 0; width: 100%;
  transition: transform .15s ease, border-color .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.card__media { position: relative; background: var(--surface-2); min-height: 112px; }
.card__img, .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 12 12 48a42 42 0 0 0 40 0z' fill='none' stroke='%23b8a58f' stroke-width='3' stroke-linejoin='round' opacity='.7'/%3E%3Ccircle cx='27' cy='34' r='4' fill='%23b8a58f' opacity='.7'/%3E%3Ccircle cx='38' cy='40' r='3.4' fill='%23b8a58f' opacity='.7'/%3E%3C/svg%3E") center / 44px no-repeat,
    linear-gradient(135deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)));
}
.badge { position: absolute; top: 8px; left: 8px; z-index: 1; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.card__body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 12px; min-width: 0; }
.card__name { font-size: 17px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; overflow-wrap: anywhere; }
.card__desc { color: var(--muted); font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__foot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price { font-weight: 800; font-size: 18px; white-space: nowrap; }
.card__open { position: absolute; inset: 0; border: 0; background: none; z-index: 0; border-radius: var(--r); }
.card { position: relative; }
.card__media, .card__body { position: relative; z-index: 1; pointer-events: none; }
.card__foot { pointer-events: none; }
.card__foot .ctl { pointer-events: auto; }

.add {
  height: 38px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}
.add:hover { background: var(--accent); color: var(--accent-ink); }
.add:active { transform: scale(.95); }
.step { display: inline-flex; align-items: center; height: 38px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.step button { width: 38px; height: 38px; border: 0; background: none; color: inherit; font-size: 20px; font-weight: 700; line-height: 1; border-radius: 999px; }
.step output { min-width: 22px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }

.empty { padding: 56px 0; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 20px; margin-bottom: 6px; }
.empty a { color: var(--accent); font-weight: 700; }
.btn-link { margin-top: 14px; display: inline-block; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }

/* скелетон */
.skeleton { display: grid; gap: 14px; padding-top: 28px; grid-template-columns: 1fr; }
.skeleton::before, .skeleton::after, .skeleton i { content: ""; display: block; height: 112px; border-radius: var(--r); background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: sh 1.4s linear infinite; }
@keyframes sh { to { background-position: -150% 0; } }

/* ---------- подвал ---------- */
.foot { margin-top: 56px; padding: 36px 0 120px; background: var(--surface-2); border-top: 1px solid var(--line); }
.foot__grid { display: grid; gap: 28px; grid-template-columns: 1fr; }
.foot h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.foot p, .foot a { font-size: 15px; }
.foot a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.foot .big { font-size: 20px; font-weight: 800; text-decoration: none; display: block; line-height: 1.5; }
.foot .small { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- плавающая корзина (моб.) ---------- */
.mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px var(--gut) calc(10px + env(safe-area-inset-bottom)); pointer-events: none; }
.mbar__btn {
  pointer-events: auto; width: 100%; max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 18px 0 12px; border: 0; border-radius: 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px;
  box-shadow: 0 10px 30px rgba(212, 64, 26, .35);
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.mbar__n { min-width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.22); font-size: 15px; }
.mbar__t { flex: 1; text-align: left; }
.mbar__s { font-variant-numeric: tabular-nums; }

/* ---------- корзина ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 4, .5); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; z-index: 60; background: var(--bg); display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; height: min(94dvh, 100%); border-radius: 24px 24px 0 0;
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,.25); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 16px var(--gut) 8px; }
.drawer__head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.drawer__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--gut) calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

.lines { display: grid; gap: 4px; }
.line { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line__img { position: relative; width: 52px; height: 52px; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.line__name { font-weight: 600; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.line__sum { color: var(--muted); font-size: 14px; margin-top: 2px; }
.step.sm, .step.sm button { height: 34px; }
.step.sm button { width: 34px; }
.step.light { background: var(--surface-2); color: var(--text); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 18px 0 14px; border-radius: 14px; background: var(--surface-2); }
.seg button { height: 42px; border: 0; border-radius: 10px; background: none; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.form { display: grid; gap: 10px; grid-template-columns: repeat(6, 1fr); }
.field { display: grid; gap: 4px; grid-column: span 6; }
.field.s2 { grid-column: span 2; }
.field.s3 { grid-column: span 3; }
.field.s4 { grid-column: span 4; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field input:user-invalid { border-color: var(--danger); }
.addr[hidden] { display: none; }
.addr { display: contents; }

.check { grid-column: span 6; display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--muted); }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.check a { color: var(--text); }

.sum { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 6px; }
.sum div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 15px; }
.sum div.total { color: var(--text); font-weight: 800; font-size: 20px; padding-top: 6px; border-top: 1px dashed var(--line); }
.hint { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.err { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 600; font-size: 14px; }
.submit {
  margin-top: 14px; width: 100%; height: 54px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px;
}
.submit[disabled] { opacity: .45; cursor: not-allowed; }
.submit.busy { opacity: .7; cursor: progress; }

.cart-empty { padding: 48px 0; text-align: center; color: var(--muted); }
.cart-empty strong { display: block; font-size: 20px; color: var(--text); margin-bottom: 6px; }

.done { text-align: center; padding: 40px 8px; }
.done__ico { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; }
.done__ico svg { width: 38px; height: 38px; fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done h3 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.done p { color: var(--muted); margin-top: 8px; }

/* ---------- карточка блюда ---------- */
.pdlg { padding: 0; border: 0; background: var(--bg); color: var(--text); width: min(560px, 100vw); max-height: 100dvh; border-radius: 24px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.pdlg::backdrop { background: rgba(20, 12, 4, .55); }
.pdlg[open] { animation: pop .22s ease; }
@keyframes pop { from { transform: translateY(16px) scale(.98); opacity: 0; } }
.pdlg__media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.pdlg__x { position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(255,255,255,.9); color: #1f1b17; }
.pdlg__body { padding: 18px 20px 22px; display: grid; gap: 10px; max-height: 50dvh; overflow-y: auto; }
.pdlg__body h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.pdlg__body p { color: var(--muted); }
.pdlg__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; }
.pdlg__foot .price { font-size: 24px; }
.pdlg__foot .add { height: 46px; padding: 0 24px; background: var(--accent); color: var(--accent-ink); font-size: 16px; }
.pdlg__foot .step, .pdlg__foot .step button { height: 46px; }
.pdlg__foot .step button { width: 46px; }

.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px; box-shadow: var(--shadow); animation: rise .2s ease; }

/* ---------- планшет ---------- */
@media (min-width: 640px) {
  :root { --gut: 24px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .skeleton { grid-template-columns: repeat(2, 1fr); }
  .skeleton::before, .skeleton::after, .skeleton i { height: 130px; }
  .foot__grid { grid-template-columns: repeat(2, 1fr); }
  .cartbtn__sum { display: inline; }
}

/* ---------- десктоп ---------- */
@media (min-width: 960px) {
  .top__row { height: 68px; gap: 20px; }
  .phone { display: inline-flex; }
  .cats__row { margin: 0; padding-left: 0; padding-right: 0; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .skeleton { grid-template-columns: repeat(3, 1fr); }
  .card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .card__media { min-height: 0; aspect-ratio: 4 / 3; }
  .card:hover { transform: translateY(-3px); }
  .card__body { padding: 14px 16px 16px; }
  .card__desc { -webkit-line-clamp: 3; line-clamp: 3; min-height: calc(1.35em * 3); }
  .foot__grid { grid-template-columns: 1.2fr 1fr 1fr; }
  .foot { padding-bottom: 48px; }
  .mbar { display: none !important; }
  .toast { bottom: 28px; }

  .drawer {
    top: 0; left: auto; right: 0; bottom: 0; width: 460px; height: 100dvh; border-radius: 24px 0 0 24px;
    transform: translateX(105%); box-shadow: -10px 0 40px rgba(0,0,0,.25);
  }
  .drawer.open { transform: none; }
  .drawer__head { padding-top: 22px; }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .skeleton { grid-template-columns: repeat(4, 1fr); }
}

/* Альбомная ориентация телефона: не даём шапке съедать экран */
@media (max-height: 480px) and (orientation: landscape) {
  .top { position: static; }
  .sec { scroll-margin-top: 8px; }
}
