/* Визуальный язык tsum.ru: шрифты Geometria/Lenta, палитра и раскладка оттуда же. */

@font-face {
  font-family: "Geometria";
  src: url("fonts/geometria-light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Geometria";
  src: url("fonts/geometria-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Geometria";
  src: url("fonts/geometria-medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Geometria";
  src: url("fonts/geometria-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Lenta";
  src: url("fonts/lenta-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #1b1b1b;
  --ink-soft: #6f757e;
  --ink-faint: #99a0ad;
  --line: #dadce1;
  --line-soft: #eceef1;
  --bg: #fff;
  --bg-soft: #f5f4f9;
  --bg-tint: #fcfbfd;
  --accent: #f94f0d;
  --sale: #eb4d3d;
  --radius: 4px;
  --pad: 16px;
  --tap: 48px;
  --font: "Geometria", -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Lenta", "Geometria", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  padding-top: env(safe-area-inset-top);
}

.topbar__main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px var(--pad);
}

.topbar__side { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__side--right { justify-content: flex-end; }

.topbar__section {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

/* Логотип ЦУМа: слово в оранжевой рамке и подпись под ней */
.logo { display: block; text-align: center; text-decoration: none; }

.logo__box {
  display: block;
  border: 2px solid var(--accent);
  padding: 5px 14px 3px;
  font-family: var(--display);
  font-size: 20px;
  line-height: 1;
  letter-spacing: .18em;
}

.logo__sub {
  display: block;
  margin-top: 3px;
  font-size: 7px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.topbar__link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 12px;
  text-decoration: none;
  color: var(--ink-soft);
  white-space: nowrap;
}

.topbar__link:hover { color: var(--accent); }

/* Меню разделов: по центру, активный подчёркнут акцентом, под ним - подкатегории */
.nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding: 0 var(--pad) 10px;
}

.nav--sub {
  gap: 4px 18px;
  padding-top: 8px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line-soft);
}

.nav__item {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 13px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.nav--sub .nav__item { font-size: 13px; color: var(--ink-soft); }
.nav__item:hover { color: var(--accent); }

.nav__item--active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.nav--sub .nav__item--active { color: var(--ink); }

@media (max-width: 719px) {
  .nav {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 18px;
  }

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

.page {
  width: 100%;
  padding: 0 var(--pad) calc(48px + env(safe-area-inset-bottom));
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- типографика */

.display {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: .04em;
  margin: 26px 0 6px;
  text-align: center;
}

.h1 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .03em;
  margin: 24px 0 6px;
}

.h2 { font-size: 15px; font-weight: 500; letter-spacing: .04em; margin: 0; }
.muted { color: var(--ink-soft); font-size: 13px; margin: 4px 0; }
code { background: var(--bg-soft); padding: 2px 5px; border-radius: 3px; font-size: 12px; }

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

.catalog__head { text-align: center; padding-bottom: 8px; }
.catalog__lead { color: var(--ink-soft); font-size: 13px; margin: 0 0 18px; }

.catalog__count {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin: 14px 0 0;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  margin: 0 calc(var(--pad) * -1);
  padding-left: var(--pad);
  padding-right: var(--pad);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }
.chips--wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chips--sub { padding-top: 0; }

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }


/* Кнопки фильтров как на tsum.ru: прямоугольник с оранжевой рамкой */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
}

.catalog__count { color: var(--ink-soft); font-size: 13px; margin: 0; text-align: center; }

/* Кнопки фильтров как на tsum.ru: прямоугольник с тонкой оранжевой рамкой */
.filter {
  appearance: none;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.filter--select {
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23f94f0d' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.filter:hover { background: #fff6f2; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px 12px;
  padding: 18px 0;
}

@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 34px 20px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1340px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.card { text-decoration: none; display: block; text-align: center; }

.card__media {
  position: relative;
  background: var(--bg);
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

/* Фото вписываем целиком: packshot у ЦУМа вытянутый (2000x3083), обрезка съедала крышки */
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity .25s;
}

.card__media img + img { position: absolute; inset: 0; opacity: 0; }

@media (hover: hover) {
  .card:hover .card__media img + img { opacity: 1; }
}

.card__badge {
  position: absolute;
  left: 0;
  top: 0;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  letter-spacing: .06em;
  padding: 4px 7px;
}

.card__brand {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 14px 0 5px;
}

.card__title {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__price { font-size: 14px; margin: 0; }
.card__price s { color: var(--ink-faint); margin-right: 6px; }

.catalog__more { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 0 32px; }

/* ---------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 13px 20px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s;
}

.btn:active { opacity: .75; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost { border-color: var(--line); }
.btn--full { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .35; cursor: default; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

/* ---------------------------------------------------------------- поля */

.select, .input {
  appearance: none;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  padding: 9px 12px;
  min-width: 0;
}

.select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236f757e' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.select:focus, .input:focus, .prompt:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.select--full, .input--full { width: 100%; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; }
.field { margin-bottom: 20px; }

.field--inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px var(--pad);
}

.field__label {
  display: block;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.field--inline .field__label { margin: 0; }

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

.product { display: grid; gap: 20px; padding-bottom: 24px; }

.product__gallery { display: grid; gap: 8px; grid-template-areas: "main" "thumbs"; }
.product__main { grid-area: main; aspect-ratio: 4 / 5; background: var(--bg); overflow: hidden; }
.product__main img { width: 100%; height: 100%; object-fit: contain; }

.product__thumbs { grid-area: thumbs; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.product__thumbs::-webkit-scrollbar { display: none; }

.product__thumb {
  flex: 0 0 auto;
  width: 62px;
  aspect-ratio: 4 / 5;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.product__thumb img { width: 100%; height: 100%; object-fit: contain; }
.product__thumb[aria-current="true"] { border-color: var(--ink); }

.product__brand {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: .06em;
  margin: 0 0 6px;
}

.product__title { font-size: 15px; font-weight: 400; color: var(--ink-soft); margin: 0 0 12px; }
.product__price { margin: 0 0 16px; font-size: 22px; font-weight: 500; }

.shade {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.shade__label { color: var(--ink-soft); font-size: 12px; }

.promo {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.4;
}

.product__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.specs { border-top: 1px solid var(--line-soft); margin: 20px 0 0; padding-top: 10px; }
.specs div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 13px; }
.specs dt { color: var(--ink-soft); margin: 0; }
.specs dd { margin: 0; text-align: right; }

.details { border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 12px; }
.details summary { cursor: pointer; font-size: 13px; min-height: 32px; }

.prompt {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  background: var(--bg-tint);
}

.backlink {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 0;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}

.backlink:hover { color: var(--accent); }

.prompt--tall { min-height: 55vh; margin-bottom: 16px; }
.settings { max-width: 780px; padding-bottom: 48px; }

/* На мобильном главное действие всегда под рукой */
@media (max-width: 859px) {
  .product__actions {
    position: sticky;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 10;
    background: var(--bg);
    padding-top: 8px;
    box-shadow: 0 -8px 16px rgba(255, 255, 255, .9);
  }
}

@media (min-width: 860px) {
  /* Карточка помещается в экран целиком: высоту считает флекс, без вычитания шапки на глаз */
  body.fit-screen { height: 100vh; height: 100dvh; overflow: hidden; }

  .page--fit { flex: 1; min-height: 0; overflow: hidden; padding-bottom: 0; }

  .product {
    grid-template-columns: minmax(0, 620px) minmax(340px, 440px);
    justify-content: center;
    gap: 40px;
    align-items: start;
    padding-top: 16px;
    height: 100%;
    padding-bottom: 0;
  }

  .product__gallery {
    grid-template-areas: "thumbs main";
    grid-template-columns: 62px minmax(0, 1fr);
    height: 100%;
    min-height: 0;
  }

  .product__thumbs { flex-direction: column; overflow-y: auto; overflow-x: hidden; max-height: 620px; }
  .product__main { height: 100%; max-height: 620px; aspect-ratio: auto; min-height: 0; }
  .product__info { height: 100%; overflow-y: auto; padding-right: 4px; padding-bottom: 16px; }
}

/* ---------------------------------------------------------------- шторка */

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(27, 27, 27, .45); }

.sheet__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  overflow: hidden;
}

.sheet__panel::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 38px;
  height: 4px;
  margin-left: -19px;
  border-radius: 2px;
  background: var(--line);
}

.sheet--full .sheet__panel { top: 0; border-radius: 0; max-height: 100dvh; }
.sheet--full .sheet__panel::before { display: none; }

@media (min-width: 720px) {
  .sheet__panel { left: auto; top: 0; width: 480px; border-radius: 0; max-height: 100vh; }
  .sheet__panel::before { display: none; }
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--pad) 13px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line-soft);
}

.sheet__body { padding: 20px var(--pad); overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet__body--flush { padding: 0; display: flex; flex-direction: column; }

.sheet__foot {
  display: flex;
  gap: 8px;
  padding: 12px var(--pad);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
}

.sheet__foot .btn { flex: 1; }

/* ---------------------------------------------------------------- камера */

.step { padding: 16px var(--pad) 20px; }
.step__actions { display: flex; gap: 8px; padding: 16px var(--pad) 0; }
.step__actions .btn { flex: 1; }
.step:not(#step-capture) .step__actions { padding-left: 0; padding-right: 0; }

.camera {
  position: relative;
  background: #000;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius);
}

.camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.camera__oval {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 62%;
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, .8);
  border-radius: 50%;
  pointer-events: none;
}

.camera__hint {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}

.preview img { width: 100%; border-radius: var(--radius); background: var(--bg-soft); }

.notice { background: var(--bg-soft); border-radius: var(--radius); padding: 12px; font-size: 13px; margin: 12px 0 0; }
.notice--error { border-left: 3px solid var(--sale); }
.hints { margin: 12px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.hints li { margin-bottom: 6px; }

.loader { display: flex; gap: 6px; justify-content: center; padding: 44px 0 12px; }
.loader span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }

@keyframes pulse { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------------------------------------------------------------- сравнение до/после */

.compare {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-soft);
  touch-action: pan-y;
}

.compare img { width: 100%; display: block; }
.compare__before { position: absolute; inset: 0; width: 50%; overflow: hidden; }
.compare__before img { height: auto; max-width: none; }  /* ширину задаёт tryon.js */

.compare__divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, .35);
  pointer-events: none;
}

.compare__divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(27, 27, 27, .35);
}

.compare__label {
  position: absolute;
  top: 10px;
  padding: 5px 10px;
  border-radius: 3px;
  background: rgba(27, 27, 27, .72);
  color: #fff;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity .15s;
}

.compare__label--before { left: 10px; }
.compare__label--after { right: 10px; background: var(--accent); }
.compare__label[hidden] { display: block; opacity: 0; }

.compare__range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.compare__range::-webkit-slider-thumb { appearance: none; width: 44px; height: 100%; background: transparent; cursor: ew-resize; }
.compare__range::-moz-range-thumb { width: 44px; height: 100%; border: 0; background: transparent; cursor: ew-resize; }

.compare__hint { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--ink-soft); }
