/* Coffee Point — витрина Mini App.
   Язык интерфейса: iOS. Системный шрифт платформы, шкала типографики Apple,
   матовые материалы, пружинная анимация. */

:root {
  /* Нейтрали чуть тёплые — под кофейный акцент, а не стерильно-серые */
  --ground: #f5f5f7;
  --surface: #ffffff;
  --surface-sunken: #ebebef;
  --label: #1d1d1f;
  --label-2: #6e6259;
  --label-3: #a8a099;
  --separator: rgba(60, 50, 45, 0.11);
  --accent: #8b4a2b;
  --accent-ink: #ffffff;
  --accent-tint: rgba(139, 74, 43, 0.1);
  --material: rgba(245, 245, 247, 0.72);
  --shadow-card: 0 1px 2px rgba(28, 20, 14, 0.05), 0 6px 20px rgba(28, 20, 14, 0.06);
  --shadow-bar: 0 8px 32px rgba(28, 20, 14, 0.18);

  --r-card: 20px;
  --r-group: 14px;
  --r-control: 11px;

  /* Кривая листов и переходов iOS */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000000;
    --surface: #1c1c1e;
    --surface-sunken: #2c2c2e;
    --label: #f5f5f7;
    --label-2: rgba(235, 229, 224, 0.6);
    --label-3: rgba(235, 229, 224, 0.36);
    --separator: rgba(235, 229, 224, 0.13);
    --accent: #f0a868;
    --accent-ink: #2a1608;
    --accent-tint: rgba(240, 168, 104, 0.16);
    --material: rgba(20, 20, 22, 0.72);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-bar: 0 8px 32px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --ground: #000000;
  --surface: #1c1c1e;
  --surface-sunken: #2c2c2e;
  --label: #f5f5f7;
  --label-2: rgba(235, 229, 224, 0.6);
  --label-3: rgba(235, 229, 224, 0.36);
  --separator: rgba(235, 229, 224, 0.13);
  --accent: #f0a868;
  --accent-ink: #2a1608;
  --accent-tint: rgba(240, 168, 104, 0.16);
  --material: rgba(20, 20, 22, 0.72);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-bar: 0 8px 32px rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  --ground: #f5f5f7;
  --surface: #ffffff;
  --surface-sunken: #ebebef;
  --label: #1d1d1f;
  --label-2: #6e6259;
  --label-3: #a8a099;
  --separator: rgba(60, 50, 45, 0.11);
  --accent: #8b4a2b;
  --accent-ink: #ffffff;
  --accent-tint: rgba(139, 74, 43, 0.1);
  --material: rgba(245, 245, 247, 0.72);
  --shadow-card: 0 1px 2px rgba(28, 20, 14, 0.05), 0 6px 20px rgba(28, 20, 14, 0.06);
  --shadow-bar: 0 8px 32px rgba(28, 20, 14, 0.18);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.35;
  background: var(--ground);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(110px + var(--safe-b));
  overscroll-behavior-y: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

/* ── навигация: компактный заголовок появляется при прокрутке ───────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  pointer-events: none;
}

.nav__bar {
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  opacity: 0;
  transition: opacity 0.25s ease, border-color 0.25s ease;
}

.nav--pinned .nav__bar {
  opacity: 1;
  border-bottom-color: var(--separator);
}

.nav__compact-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transform: translateY(4px);
  opacity: 0;
  transition: transform 0.3s var(--spring), opacity 0.25s ease;
}

.nav--pinned .nav__compact-title {
  transform: translateY(0);
  opacity: 1;
}

/* ── крупный заголовок ─────────────────────────────────────────────────── */

.masthead {
  padding: 8px 20px 18px;
  margin-top: -46px; /* заголовок уезжает под прозрачный навбар */
  padding-top: 62px;
}

.masthead__title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.023em;
  line-height: 1.1;
}

.masthead__sub {
  margin-top: 5px;
  font-size: 15px;
  color: var(--label-2);
  letter-spacing: -0.008em;
}

/* ── сегмент-контрол ───────────────────────────────────────────────────── */

.segmented {
  position: relative;
  display: flex;
  gap: 2px;
  margin: 0 16px 18px;
  padding: 2px;
  background: var(--surface-sunken);
  border-radius: var(--r-control);
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.segmented__indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  background: var(--surface);
  border-radius: 9px;
  box-shadow: 0 3px 8px rgba(28, 20, 14, 0.12), 0 1px 1px rgba(28, 20, 14, 0.04);
  transition: transform 0.32s var(--spring), width 0.32s var(--spring);
  will-change: transform, width;
}

.seg {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.004em;
  color: var(--label-2);
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.seg--active {
  color: var(--label);
  font-weight: 600;
}

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

.catalog {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: card-in 0.45s var(--spring) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

/* Подложки товаров: светлое тонированное поле со свечением под предметом,
   у каждой категории свой оттенок. Тона задаются переменными, поэтому
   тёмная тема получает собственный набор, а не инверсию светлого */
.swatch {
  position: relative;
  height: 106px;
  display: grid;
  place-items: center;
  font-size: 44px;
  line-height: 1;
  background:
    radial-gradient(72% 62% at 50% 44%, var(--sw-glow) 0%, transparent 72%),
    linear-gradient(168deg, var(--sw-hi), var(--sw-lo));
  border-bottom: 0.5px solid var(--separator);
}

.swatch__glyph {
  filter: drop-shadow(0 5px 9px rgba(58, 38, 22, 0.22));
}

.swatch--coffee   { --sw-hi: #f7ece1; --sw-lo: #e3cdb8; --sw-glow: #fffaf4; }
.swatch--drinks   { --sw-hi: #fbeedd; --sw-lo: #f0d3b2; --sw-glow: #fffdf8; }
.swatch--desserts { --sw-hi: #fbebe9; --sw-lo: #eecfd2; --sw-glow: #fffafa; }
.swatch--beans    { --sw-hi: #eef2e4; --sw-lo: #d3ddc0; --sw-glow: #fbfdf6; }
.swatch--merch    { --sw-hi: #e9eef4; --sw-lo: #cbd7e4; --sw-glow: #f9fbfe; }
.swatch--other    { --sw-hi: #f0eeeb; --sw-lo: #dcd7d1; --sw-glow: #fdfcfb; }

@media (prefers-color-scheme: dark) {
  .swatch--coffee   { --sw-hi: #3a2b20; --sw-lo: #241a12; --sw-glow: #4c3728; }
  .swatch--drinks   { --sw-hi: #3d2c1c; --sw-lo: #261a10; --sw-glow: #52381f; }
  .swatch--desserts { --sw-hi: #3a262a; --sw-lo: #24171a; --sw-glow: #4d3036; }
  .swatch--beans    { --sw-hi: #2b331f; --sw-lo: #1a2013; --sw-glow: #3a4529; }
  .swatch--merch    { --sw-hi: #232c38; --sw-lo: #151b23; --sw-glow: #2f3c4c; }
  .swatch--other    { --sw-hi: #2e2b28; --sw-lo: #1c1a18; --sw-glow: #3d3936; }
  .swatch__glyph { filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.5)); }
}

:root[data-theme="dark"] .swatch--coffee   { --sw-hi: #3a2b20; --sw-lo: #241a12; --sw-glow: #4c3728; }
:root[data-theme="dark"] .swatch--drinks   { --sw-hi: #3d2c1c; --sw-lo: #261a10; --sw-glow: #52381f; }
:root[data-theme="dark"] .swatch--desserts { --sw-hi: #3a262a; --sw-lo: #24171a; --sw-glow: #4d3036; }
:root[data-theme="dark"] .swatch--beans    { --sw-hi: #2b331f; --sw-lo: #1a2013; --sw-glow: #3a4529; }
:root[data-theme="dark"] .swatch--merch    { --sw-hi: #232c38; --sw-lo: #151b23; --sw-glow: #2f3c4c; }
:root[data-theme="dark"] .swatch--other    { --sw-hi: #2e2b28; --sw-lo: #1c1a18; --sw-glow: #3d3936; }
:root[data-theme="dark"] .swatch__glyph { filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.5)); }

:root[data-theme="light"] .swatch--coffee   { --sw-hi: #f7ece1; --sw-lo: #e3cdb8; --sw-glow: #fffaf4; }
:root[data-theme="light"] .swatch--drinks   { --sw-hi: #fbeedd; --sw-lo: #f0d3b2; --sw-glow: #fffdf8; }
:root[data-theme="light"] .swatch--desserts { --sw-hi: #fbebe9; --sw-lo: #eecfd2; --sw-glow: #fffafa; }
:root[data-theme="light"] .swatch--beans    { --sw-hi: #eef2e4; --sw-lo: #d3ddc0; --sw-glow: #fbfdf6; }
:root[data-theme="light"] .swatch--merch    { --sw-hi: #e9eef4; --sw-lo: #cbd7e4; --sw-glow: #f9fbfe; }
:root[data-theme="light"] .swatch--other    { --sw-hi: #f0eeeb; --sw-lo: #dcd7d1; --sw-glow: #fdfcfb; }
:root[data-theme="light"] .swatch__glyph { filter: drop-shadow(0 5px 9px rgba(58, 38, 22, 0.22)); }

.card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 13px 13px;
}

.card__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.card__desc {
  flex: 1;
  font-size: 12.5px;
  line-height: 1.32;
  color: var(--label-2);
  letter-spacing: -0.003em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  min-height: 32px;
}

.card__price {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Кнопка «плюс» превращается в степпер — как в приложениях Apple */
.add {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s var(--spring), background 0.2s ease;
}

.add:active {
  transform: scale(0.88);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--accent-tint);
  border-radius: 16px;
  padding: 2px;
  animation: stepper-in 0.28s var(--spring) both;
}

@keyframes stepper-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

.stepper button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.18s var(--spring);
}

.stepper button:active {
  transform: scale(0.85);
}

.stepper__count {
  min-width: 20px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.empty {
  grid-column: 1 / -1;
  padding: 56px 0;
  text-align: center;
  font-size: 15px;
  color: var(--label-3);
}

.colophon {
  padding: 34px 20px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--label-3);
  letter-spacing: -0.002em;
}

/* ── нижняя панель корзины ─────────────────────────────────────────────── */

.bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(14px + var(--safe-b));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 8px 0 8px;
  border: none;
  border-radius: 26px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-bar);
  cursor: pointer;
  animation: bar-in 0.4s var(--spring) both;
  transition: transform 0.2s var(--spring);
}

.bar:active {
  transform: scale(0.975);
}

@keyframes bar-in {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
  }
}

.bar__count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar__label {
  flex: 1;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.bar__total {
  padding-right: 10px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── нижний лист ───────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fade-in 0.3s ease both;
}

.scrim[hidden],
.sheet[hidden],
.bar[hidden] {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -1px 0 var(--separator);
  animation: sheet-up 0.42s var(--spring) both;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

.sheet--closing {
  animation: sheet-down 0.3s var(--spring) both;
}

@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

.sheet__grabber {
  flex: 0 0 auto;
  width: 36px;
  height: 5px;
  margin: 7px auto 0;
  border-radius: 3px;
  background: var(--label-3);
  opacity: 0.5;
}

.sheet__scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(22px + var(--safe-b));
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
}

.sheet__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.019em;
}

.sheet__close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--label-2);
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.18s var(--spring);
}

.sheet__close:active {
  transform: scale(0.9);
}

/* Сгруппированные блоки — как inset grouped списки iOS */
.group {
  background: var(--surface);
  border-radius: var(--r-group);
  overflow: hidden;
}

.group + .group {
  margin-top: 8px;
}

.group-label {
  padding: 22px 14px 7px;
  font-size: 13px;
  color: var(--label-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  position: relative;
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 57px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.row__thumb {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  font-size: 19px;
  border-radius: 10px;
  border: none;
}

.row__info {
  flex: 1;
  min-width: 0;
}

.row__title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__meta {
  font-size: 13px;
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}

.summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 15px 14px 2px;
  font-size: 15px;
  color: var(--label-2);
}

.summary strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--label);
  letter-spacing: -0.018em;
  font-variant-numeric: tabular-nums;
}

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  position: relative;
}

.field + .field::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 0;
  height: 0.5px;
  background: var(--separator);
}

.field--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding-bottom: 13px;
}

.field--stack .field__name {
  flex: none;
}

.field--stack .field__input {
  min-height: 42px;
}

.field__name {
  flex: 0 0 92px;
  font-size: 15px;
  color: var(--label-2);
  letter-spacing: -0.008em;
}

.field__input {
  flex: 1;
  width: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: 16px;
  letter-spacing: -0.01em;
  resize: none;
  font-family: inherit;
}

.field__input::placeholder {
  color: var(--label-3);
}

.cta {
  width: 100%;
  margin-top: 22px;
  height: 52px;
  border: none;
  border-radius: var(--r-group);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.18s var(--spring), opacity 0.2s ease;
}

.cta:active {
  transform: scale(0.985);
}

.cta:disabled {
  opacity: 0.45;
  cursor: default;
}

.note {
  margin-top: 11px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  color: var(--label-3);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
