/* ============================================================
   ОФОРМЛЕНИЕ
   Белый лист, моноширинный шрифт, сетка кодов на главной.
   Величины ниже подобраны под ту же оптику, что у референса:
   кегль 16, межстрочный 24, зазор сетки 16, шапка 64.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink:    #000;
  --paper:  #fff;
  --dim:    #343434;   /* неактивный пункт в шапке */
  --muted:  #666;      /* подвал, цены, второстепенное. Чуть темнее,
                          чем было на белом: на --page прежний
                          #6e6e6e не дотягивал до нормы читаемости */
  --hair:   #d9d6d1;   /* волосяные линии. Тон подобран под серый
                          фон: на белом хватало #e8e8e8, но на
                          --page он бы полностью пропал */
  --wash:   #fafafa;   /* очень светлый: наведение, неактивное */
  --page:   #f0efed;   /* ФОН СТРАНИЦЫ под шапкой. Светлые вещи
                          не сливаются с ним, поэтому отдельные
                          серые плитки под снимками не нужны.
                          Тон меняется здесь, в одном месте. */
  --nav:    64px;      /* высота шапки */
  --gap:    16px;      /* зазор сетки и боковые поля */
  --font:   'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-top: var(--nav);
  background: var(--page);      /* серое поле под белой шапкой */
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
/* Рамка задаёт размер, снимок подстраивается под неё.
   Поэтому исходный размер PNG не влияет на вид ленты:
   и 400×400, и 3000×2200 покажутся одинаково.
   Способ вписывания задаётся в js/config.js. */
img { display: block; width: 100%; height: 100%; object-fit: var(--fit, contain); }

button {
  font: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  outline: none;
}

main { flex: 1; }

/* ---------- шапка: три зоны, фиксированная ---------- */

.hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--nav);
  padding: 12px var(--gap);
  background: var(--paper);     /* белая полоса поверх серого */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.nav-l { justify-self: start; }
.nav-c { justify-self: center; display: flex; gap: var(--gap); }
.nav-r { justify-self: end; }

.nav-plus { font-size: 22px; line-height: 24px; }

/* значок приближения: две полоски 2px. В обычном состоянии они
   образуют «+», в приближённом вертикальная доворачивается
   до горизонтали и остаётся «−». Переход 300 мс. */
.nav-zoom { position: relative; width: 16px; height: 24px; display: block; }
.nav-zoom i {
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform .3s;
}
.nav-zoom i:nth-child(1) { transform: translateY(-50%); }

/* По умолчанию вторая полоска стоит вертикально — значок «+».
   На главной JS перекрывает поворот inline-стилем при
   переключении плотности; анимацию даёт transition выше. */
.nav-zoom i:nth-child(2) { transform: translateY(-50%) rotate(90deg); }
/* Значок возврата на внутренних страницах: шеврон влево.
   Толщина обводки 2px и скруглённые концы — те же, что
   у полосок переключателя на главной, чтобы вес совпадал. */
.nav-back { display: flex; align-items: center; height: 24px; }
.nav-back svg { width: 16px; height: 16px; display: block; }
.nav-back path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-brand { font-weight: 500; }
.nav-dim { color: var(--dim); }
.hdr a:hover, .hdr button:hover { color: var(--muted); }

/* ---------- главная: сетка кодов ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--gap);
  padding: 0 var(--gap) 32px;
}
/* приближённое состояние — вдвое меньше колонок, фото крупнее */
.grid[data-zoom="1"] { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1000px) {
  .grid                 { grid-template-columns: repeat(4, 1fr); }
  .grid[data-zoom="1"]  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .grid                 { grid-template-columns: repeat(3, 1fr); }
  .grid[data-zoom="1"]  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .grid                 { grid-template-columns: repeat(2, 1fr); }
  .grid[data-zoom="1"]  { grid-template-columns: repeat(1, 1fr); }
}

/* ячейка: квадратное фото + код под ним, ничего больше */
.cell { display: block; }
.cell-img {
  aspect-ratio: 1 / 1;          /* строгий квадрат при любой картинке */
  padding: var(--shot-pad, 6%); /* вещь не упирается в края */
  transition: opacity .3s;
}
/* Цена теперь единственная подпись под снимком, поэтому она
   основным цветом, а не серым: серый в одиночку смотрелся бы
   выцветшим. Вернуть приглушённый — заменить на var(--muted). */
.cell-code { color: var(--ink); text-align: center; }
.cell:hover .cell-img { opacity: .55; }
.cell.is-out .cell-code { color: var(--muted); }

/* ---------- страница товара ---------- */
/* Одна колонка по центру страницы, много воздуха,
   минимум элементов: фото, код, название, цена, размер, кнопка. */

.pdp {
  max-width: 520px;
  margin: 0 auto;
  padding: 32px var(--gap) 80px;
  text-align: center;
}

/* Кадр намеренно небольшой: товар вместе с ценой, размером
   и кнопкой должен помещаться в один экран без прокрутки. */
.pdp-media { max-width: 420px; margin: 0 auto; }
.shot { display: none; aspect-ratio: 1 / 1; padding: var(--shot-pad, 6%); }
.shot.is-on { display: block; }

/* Снимок кликабелен — открывается во весь экран */
.shot { cursor: zoom-in; }

/* ---------- просмотр во весь экран ---------- */

.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 72px var(--gap);
  background: var(--page);
  cursor: zoom-out;
}
.lb.is-on { display: flex; }

/* перебивает общее правило img{width:100%;height:100%} */
.lb img {
  width: auto;
  height: auto;
  max-width: min(92vw, 1000px);
  max-height: 100%;
  object-fit: contain;
}

.lb-x {
  position: absolute;
  top: 24px;
  right: var(--gap);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.lb-x i {
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
}
.lb-x i:nth-child(1) { transform: translateY(-50%) rotate(45deg); }
.lb-x i:nth-child(2) { transform: translateY(-50%) rotate(-45deg); }

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lb-prev { left: 4px; }
.lb-next { right: 4px; }
.lb-nav svg { width: 16px; height: 16px; display: block; }
.lb-nav path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lb-nav:hover { opacity: .55; }

.lb-count {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 600px) {
  .lb { padding: 64px 8px; }
  .lb-nav { width: 36px; }
}

.thumbs { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.thumb { width: 48px; aspect-ratio: 1 / 1; opacity: .35; transition: opacity .3s; }
.thumb.is-on, .thumb:hover { opacity: 1; }

/* Кегль здесь мельче общего (16/24), а колонка уже страницы:
   текст не спорит с фотографией за внимание, и кнопка не
   растягивается во всю ширину под крупным снимком. */
.pdp-info {
  max-width: 320px;
  margin: 20px auto 0;
  font-size: 14px;
  line-height: 20px;
}
.pdp-code  { margin: 0 0 6px; color: var(--muted); }
.pdp-name  { margin: 0; font-size: 14px; font-weight: 400; }
.pdp-price { margin: 2px 0 0; color: var(--dim); }

.pdp-desc {
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--hair);
  max-width: 40ch;
  text-transform: none;
  color: var(--muted);
}

.lbl { margin: 20px 0 8px; color: var(--muted); }
.sizes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.size {
  min-width: 44px;
  padding: 5px 10px;
  border: 1px solid var(--hair);
  transition: border-color .3s, background .3s;
}
.size:hover { border-color: var(--ink); }
.size.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--ink);
  color: var(--paper);
  transition: opacity .3s;
}
.btn:hover { opacity: .7; }
.btn[disabled] { background: none; color: var(--muted); border: 1px solid var(--hair); cursor: not-allowed; }
.btn-ghost { background: none; color: var(--ink); border: 1px solid var(--hair); margin-top: 8px; }

.hint { min-height: 24px; margin: 16px 0 0; color: var(--muted); }
.hint a { text-decoration: underline; color: var(--ink); }

/* ---------- корзина ---------- */
/* Тоже одна колонка по центру, той же ширины, что и товар. */

.cart-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 56px var(--gap) 96px;
}

.page-head { max-width: 520px; margin: 0 auto; padding: 56px var(--gap) 0; text-align: center; }
.page-head h1 { margin: 0; font-size: 16px; font-weight: 400; }

.line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--gap);
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--hair);
  text-align: left;
}
.line:first-child { border-top: 1px solid var(--hair); }
/* нижнюю границу последней строки не рисуем — разделителем
   служит верхняя линия блока с итогом */
.line:last-child { border-bottom: 0; }
.line-img { aspect-ratio: 1 / 1; }
.line-main { display: flex; flex-direction: column; gap: 2px; }
.line-size { color: var(--muted); }
.line-end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.line-del { color: var(--muted); text-decoration: underline; }
.line-del:hover { color: var(--ink); }

.qty { display: flex; align-items: center; border: 1px solid var(--hair); width: max-content; margin-top: 6px; }
.qty button { width: 26px; height: 22px; }
.qty button:hover { background: var(--wash); }
.qty span { min-width: 26px; text-align: center; }

.sum { margin-top: 32px; }
.sum-row { display: flex; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--ink); }
.sum-note { margin: 12px 0 0; color: var(--muted); text-transform: none; text-align: center; }

.empty { padding: 120px var(--gap); text-align: center; color: var(--muted); }
.empty a { color: var(--ink); text-decoration: underline; }

/* ---------- текстовая страница ---------- */

.doc { max-width: 60ch; padding: 0 var(--gap) 64px; }
.doc h1 { font-size: 16px; font-weight: 400; margin: 0 0 24px; }
.doc h2 { font-size: 16px; font-weight: 400; margin: 32px 0 8px; color: var(--muted); }
.doc p, .doc li { text-transform: none; color: var(--dim); }
.doc ul { padding-left: 20px; margin: 0; }
.doc a { text-decoration: underline; }

/* ---------- подвал ---------- */

.ftr { padding: 0 var(--gap) 32px; }
.ftr-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); font-size: 14px; color: var(--muted); }
.ftr-nav a:hover { color: var(--ink); }
