/* ===== Pattern Studio (/pattern-studio) =====
   Только эта страница. Основа вида — wallpaper-studio.css (топбар, сцена,
   карточки, ползунки, переключатели, окно размеров): страница собрана из тех
   же классов ws-*. Плашки цветов (.preview-color-lock*) и окно редактора
   цвета (#modal) — из palette-legacy.css, как на /gradient-creator.
   Здесь только то, чего нет ни там, ни там. */

/* Сцена: картинку рисует SVG, поэтому фон сцены — не чёрный, как у обоев,
   а светлый, пока SVG не появился. */
.ps-stage {
  background: #f4f4f2;
}

.ps-stage__art,
.ps-stage__art svg,
.ps-peek__art,
.ps-peek__art svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ----- Карточки: Colors и Layout слева одна под другой, Flower справа ----- */

.ps-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "colors motif"
    "layout motif";
  align-items: start;
}

.ps-card--colors { grid-area: colors; }
.ps-card--motif { grid-area: motif; }
.ps-card--layout { grid-area: layout; }

/* Подписи длиннее, чем у обоев (Head size, Center size), — колонка шире,
   шрифт чуть меньше. */
.ps-page .ws-row,
.ps-page .ws-option {
  grid-template-columns: 96px minmax(0, 1fr) 52px;
}

.ps-page .ws-option {
  grid-template-columns: 96px minmax(0, 1fr);
}

.ps-page .ws-row__label {
  font-size: 14px;
}

.ps-page .ws-seg button {
  padding: 0 14px;
}

.ps-divider {
  height: 1px;
  background: #ececec;
}

.ps-hint {
  margin: -6px 0 0;
  color: var(--ws-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

/* ----- Число цветов и Shuffle ----- */

.ps-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ps-count__btn,
.ps-shuffle {
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #fafafa;
  color: #3f4654;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ps-count__btn {
  width: 34px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.ps-shuffle {
  margin-left: 8px;
  padding: 0 14px;
}

.ps-count__btn:hover:not(:disabled),
.ps-shuffle:hover:not(:disabled) {
  background: #f0f1f3;
}

.ps-count__btn:disabled {
  color: #c4c9d2;
  cursor: default;
}

.ps-count__value {
  min-width: 18px;
  color: var(--ws-ink);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* У .preview-color-locks в palette-legacy.css остался margin-top от старой
   вёрстки (как на /gradient-creator). */
.ps-color-locks {
  margin-top: 0;
}

/* Плашка фона отмечена короткой подписью справа от названия. */
.ps-color-locks .ps-bg-tag {
  margin-left: auto;
  padding-left: 6px;
  color: #97a0af;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Готовые палитры: полоска из ровных кусков, а не плавный переход. */
.ps-page .ws-palette__bar {
  display: flex;
  overflow: hidden;
}

.ps-page .ws-palette__bar span {
  flex: 1 1 0;
}

/* ----- Кнопка «Head» с маленькой картинкой головки ----- */

.ps-head-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ps-head-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* ----- Липкое превью -----
   Когда сцена ушла за верх экрана, сверху закрепляется её копия: настройки
   видны вместе с паттерном. Ширина — по пропорции кадра, не шире страницы. */

.ps-peek {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 8px 16px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ps-peek.is-visible {
  opacity: 1;
  transform: none;
}

.ps-peek__art {
  height: var(--ps-peek-h, min(30vh, 260px));
  width: auto;
  max-width: 100%;
  aspect-ratio: var(--ws-ar, 1.7778);
  border-radius: 10px;
  overflow: hidden;
}

/* ----- Карточки видов мотива -----
   Вид — как у карточек стилей Wallpaper Studio (.ws-style), только картинка
   в карточке — SVG, а не фон-картинка. */

.ps-families {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.ps-family__img {
  overflow: hidden;
}

.ps-family__img svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Настройки одного вида мотива — столбик с тем же шагом, что у карточки. */
.ps-panel {
  display: grid;
  row-gap: 18px;
}

/* ----- Выделенный мотив ----- */

.ps-stage__art use[data-slot] {
  cursor: grab;
}

.ps-stage__art:active use[data-slot] {
  cursor: grabbing;
}

/* Пока мотив выделен, слой превью ловит палец — иначе перетаскивание
   прокручивало бы страницу. Без выделения палец по превью листает страницу:
   первое касание мотива его только выделяет. */
.ps-stage__art.is-editing {
  touch-action: none;
}

.ps-selected {
  margin-top: 14px;
}

.ps-selected__hint {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  color: var(--ws-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
}

.ps-selected__body {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: #fafafa;
}

.ps-selected__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
}

.ps-selected__title {
  color: var(--ws-ink);
  font-size: 15px;
  font-weight: 800;
}

.ps-selected__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ps-mini-btn {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #e3e3e3;
  color: #3f4654;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.ps-mini-btn:hover {
  background: #f4f5f7;
}

.ps-mini-btn.is-on {
  background: #111827;
  box-shadow: none;
  color: #ffffff;
}

.ps-mini-btn--dark {
  background: #111827;
  box-shadow: none;
  color: #ffffff;
}

.ps-mini-btn--dark:hover {
  background: #1f2937;
}

.ps-selected .ws-seg button {
  background: #ffffff;
}

.ps-selected .ws-seg button.is-active {
  box-shadow: inset 0 0 0 1.5px #111827;
}

.ps-selected__sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px 28px;
}

.ps-selected__sliders .ws-row {
  grid-template-columns: 64px minmax(0, 1fr) 48px;
}

/* ----- Узкие экраны ----- */

@media (max-width: 900px) {
  .ps-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "colors"
      "motif"
      "layout";
  }
}

@media (max-width: 1100px) {
  .ps-families {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .ps-families {
    display: flex;
  }

  .ps-page .ws-row {
    grid-template-columns: 82px minmax(0, 1fr) 44px;
  }

  .ps-page .ws-option {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .ps-page .ws-row__label {
    font-size: 13px;
  }

  .ps-shuffle {
    margin-left: 2px;
  }

  .ps-peek__art {
    --ps-peek-h: 24vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ps-peek { transition: none; }
}
