/* ===== 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%;
}

/* ----- Скачивание: два подписанных блока, обои и плитка -----
   Подпись блока сверху мелким серым, под ней кнопки форматов со значком
   скачивания. У JPG плитки рядом кнопка размера (длинная сторона). */

.ps-export {
  /* Над превью: подсказка и меню размера опускаются на сцену. */
  position: relative;
  z-index: 20;
  display: grid;
  gap: 5px;
}

.ps-export__label {
  padding-left: 2px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

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

.ps-dl {
  position: relative;
  height: 46px;
  padding: 0 16px 0 13px;
  border: 1px solid var(--ws-line);
  border-radius: 14px;
  background: #ffffff;
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.ps-dl:hover:not(:disabled) {
  background: #fafafa;
  transform: translateY(-2px);
}

.ps-dl:disabled {
  cursor: progress;
  color: #98a2b3;
}

.ps-dl__icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* JPG плитки и кнопка его размера — одна плашка из двух половин. */
.ps-dl-split {
  position: relative;
  display: inline-flex;
}

.ps-dl--joined {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.ps-dl--joined:hover:not(:disabled) {
  transform: none;
}

.ps-dl-size {
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--ws-line);
  border-left: 0;
  border-radius: 0 14px 14px 0;
  background: #fafafa;
  color: #667085;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.ps-dl-size:hover {
  background: #f2f3f5;
}

.ps-tile-menu {
  left: auto;
  right: 0;
  min-width: 250px;
}

/* Подсказка у кнопок скачивания: что именно окажется в файле. Только там,
   где есть наведение мышью, — на телефоне её роль играет сообщение после
   скачивания. */
@media (hover: hover) {
  .ps-dl[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 95;
    width: 270px;
    padding: 11px 13px;
    border-radius: 12px;
    background: #111827;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
    white-space: normal;
    text-align: left;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .ps-dl[data-tip]:hover::after,
  .ps-dl[data-tip]:focus-visible::after {
    opacity: 1;
    transform: none;
    transition-delay: 0.35s;
  }

  .ps-dl:disabled::after {
    display: none;
  }
}

/* ----- Карточки: 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(6, minmax(0, 1fr));
}

.ps-family__img {
  overflow: hidden;
}

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

/* Состав луга: кнопки-переключатели (чекбоксы), можно включить несколько
   сразу — в отличие от рядов-вариантов .ws-seg, где выбран один. */
.ps-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ps-chip {
  position: relative;
  cursor: pointer;
}

.ps-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.ps-chip span {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  background: #fafafa;
  color: #98a2b3;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.ps-chip:hover span {
  background: #f4f5f7;
}

.ps-chip input:checked + span {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #e3e3e3;
  color: var(--ws-ink);
}

.ps-chip input:focus-visible + span {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Настройки одного вида мотива — столбик с тем же шагом, что у карточки. */
.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(3, minmax(0, 1fr));
  }
}

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

  .ps-export {
    flex: 1 1 100%;
  }

  .ps-export__row .ps-dl,
  .ps-dl-split {
    flex: 1 1 0;
    justify-content: center;
  }

  .ps-dl-split .ps-dl {
    flex: 1 1 auto;
  }

  .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; }
}
