/* public/styles/components/spreads.css
   Extracted spreads/turns/tiles/photo-grid styles from public/styles/compat/legacy.css
   NOTE: This is a 1-to-1 extraction to preserve behavior. Do NOT refactor selectors/values here.
*/

/* Кнопка удаления разворота — DEPRECATED, use [data-remove-turn] instead */
.spread-remove,
.btn-remove-spread {
  padding: 6px 10px;
  border-radius: var(--fx-radius-pill, 999px) !important;
  border: 1px solid rgba(0,0,0,0.06);
  background: var(--fx-card);
  color: var(--bs-danger);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  min-width: 80px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.spread-remove:hover,
.btn-remove-spread:hover {
  background: var(--fx-card);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  color: color-mix(in srgb, var(--bs-danger), black 6%);
}

.turn-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--ink-secondary);
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.turn-arrow:hover {
  background-color: color-mix(in srgb, var(--surface), black 5%);
  text-decoration: none;
}

/* ================================
   Компоненты «выбор разворотов/фото"
   ================================ */

/* Базовая карточка разворота — обновлено для консистентности с демо */
.spread-card {
  border-radius: var(--fx-radius);
  border: 1px solid var(--fx-border);
  background: var(--fx-card);
  padding: 16px 18px 18px;
  margin-bottom: 24px;
  box-shadow: var(--fx-shadow-lg);
}

.spread-card + .spread-card { margin-top: 24px; }

/* Дополнительный (платный) разворот — фиолетовый акцент
   ВНИМАНИЕ: НЕ добавляем стили для .card-2025 внутри, чтобы избежать двойных рамок
   Применяется только к самой .spread-card или .extra-spread */
.spread-card.extra-spread {
  background: var(--fx-extra-bg);
  border-color: var(--fx-extra-border);
  box-shadow: 
    0 0 0 1px rgba(160,139,255,.25),
    0 6px 20px rgba(0,0,0,.08);
}

/* Шапка разворота */
.spread-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.spread-head-main {
  flex: 1;
  min-width: 0;
}

.spread-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.spread-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--surface);
  font-weight: 800;
  font-size: .9rem;
}

.spread-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--bs-body-color);
}

.spread-meta {
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--fx-muted);
}

.spread-desc {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--bs-body-color);
}

/* Бейджи для разворотов */
.spread-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--fx-radius-pill, 999px);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.spread-badge-extra {
  background: var(--fx-extra-accent);
  color: var(--surface);
}

.spread-badge-included,
.badge-included {
  background: var(--fx-included-bg) !important;
  color: var(--fx-included-color) !important;
}

/* Правая часть шапки (цена, действия) */
.spread-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Base pill badge styles — reusable across price badges, delete buttons, etc. */
.pill-badge,
.spread-price-pill,
.price-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 6px 10px;
  border-radius: var(--fx-radius-pill);
  border: 1px solid rgba(0,0,0,.06);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  line-height: 1;
}

.spread-price-pill,
.price-badge {
  text-align: right; /* price-specific alignment */
}

.spread-head-side .btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.spread-head-side [data-remove-turn],
.spread-head-side .btn[data-remove-turn],
.spread-head-side .btn.btn-outline-danger[data-remove-turn],
.spread-head-side .btn.btn-sm[data-remove-turn] {
  /* Inherit base pill-badge styles */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 80px !important;
  padding: 6px 10px !important;
  border-radius: var(--fx-radius-pill) !important;
  border: 1px solid rgba(0,0,0,.06) !important;
  background: var(--surface) !important;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.06) !important;
  /* Delete-specific styles */
  color: var(--bs-danger) !important;
  transition: transform .12s ease, box-shadow .12s ease;
}

.spread-head-side [data-remove-turn]:hover,
.spread-head-side .btn[data-remove-turn]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  background: var(--surface) !important;
  color: color-mix(in srgb, var(--bs-danger), black 6%) !important;
  border-color: rgba(0,0,0,.06) !important;
}

.spread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.spread-actions .btn { padding: 6px 8px; }

.spread-body {
  padding: 12px 14px;
  margin-top: 6px;
}

@media (max-width: 767.98px) {
  .spread-card {
    padding: 14px 12px 16px;
    /* Радиус остаётся 24px везде — консистентность */
  }
  
  .spread-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .spread-head-side {
    align-items: flex-start;
  }
}

.tips{
  background:var(--surface-2);
  border:1px solid var(--line);
  color:var(--ink);
  border-radius:var(--fx-radius); padding:12px 14px;
}

.spread-example-label {
  font-weight: 600;
  margin-bottom: 8px;
}

.spread-gallery-wrap {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.spread-gallery {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-behavior: smooth;
}

.spread-example-img {
  flex: 0 0 220px;
  border-radius: var(--fx-image-radius);
  background: var(--surface-2);
  object-fit: cover;
  height: 140px;
  box-shadow: var(--fx-image-shadow);
}

.spread-gallery-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: center;
}

.spread-nav-btn {
  width: 42px;
  height: 32px;
  border-radius: var(--fx-radius-pill, 999px);
  border: 1px solid var(--fx-border);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spread-nav-btn:hover {
  background: color-mix(in srgb, var(--fx-card), black 3%);
}

/* Комментарий к развороту */
.spread-comment {
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--fx-border);
  font-size: 0.9rem;
}

/* Выбранные фотографии */
.spread-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.spread-photo {
  width: 200px;
  border-radius: var(--fx-image-radius);
  background: var(--surface);
  border: 1px solid var(--fx-border);
  box-shadow: var(--fx-image-shadow);
  overflow: hidden;
  position: relative; /* for overlay buttons */
}

.spread-photo-img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
  border-radius: var(--fx-image-radius);
}

.photo-overlay-actions {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none; /* allow clicks to pass through container */
}

.photo-overlay-actions > * {
  pointer-events: all; /* re-enable for buttons */
}

.btn-photo-main,
.btn-photo-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px;
  border-radius: var(--fx-radius-pill);
  background: var(--surface); /* solid like demo, use token */
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  font-weight: 600;
  line-height: 1; /* match price badge */
  justify-content: center;
}

.btn-photo-main { color: var(--bs-body-color); }
.btn-photo-remove { color: var(--bs-danger); }

.btn-photo-main i { margin-right: 6px; }
.btn-photo-remove i { margin-left: 0; }

.btn-photo-main:hover { 
  transform: translateY(-2px); 
  color: var(--bs-warning); 
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}
.btn-photo-remove:hover { 
  transform: translateY(-2px); 
  color: color-mix(in srgb, var(--bs-danger), black 6%); 
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.btn-photo-main:disabled, .btn-photo-remove:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.turn-thumb-wrap {
  position: relative;
}

.spread-photo-foot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px; /* slightly larger for pill look */
  min-width: 72px; /* compact but consistent with other pills */
  border-radius: var(--fx-radius-pill);
  background: var(--surface); /* solid like demo */
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  font-weight: 700;
  justify-content: center;
}

.spread-photo-remove {
  opacity: .7;
  color: var(--fx-muted);
}

.spread-photo-remove:hover {
  opacity: 1;
  color: var(--bs-danger);
}

.chosen-row{ display:flex; gap:10px; overflow:auto; padding-bottom:4px; }
.photo-tile{ flex:0 0 auto; display:flex; flex-direction:column; align-items:center; gap:6px; }
.photo-thumb{
  height:120px; width:auto; object-fit:contain; background:var(--surface);
  border:1px solid var(--line); border-radius:var(--fx-image-radius);
}

img.lazy-pending{
  opacity:0;
  background:color-mix(in srgb,var(--surface),black 4%);
}
img.lazy-loaded{
  opacity:1;
  transition:opacity .2s ease-in-out;
  background:transparent;
}

.photo-tools{ display:flex; gap:8px; align-items:center; }
.photo-tools .btn-icon{
  border:1px solid var(--line); background:var(--surface);
  border-radius:var(--fx-radius); padding:6px; width:36px; height:36px;
  display:inline-flex; align-items:center; justify-content:center;
}

.photo-tools .btn-icon[aria-pressed="true"]{
  border-color:color-mix(in srgb,var(--primary),white 40%);
  box-shadow:0 0 0 2px color-mix(in srgb,var(--primary),white 82%);
}

/* Photo tips rail (2 on mobile, 4 on desktop) */
.tips-scroll{
  display:flex; gap:12px; overflow-x:auto; scroll-snap-type:x mandatory;
  -webkit-overflow-scrolling:touch; padding-bottom:8px;
}
.tips-scroll::-webkit-scrollbar{ height:8px; }
.tip-item{ flex:0 0 calc((100% - 12px)/2); scroll-snap-align:start; }
@media (min-width: 992px){
  .tip-item{ flex-basis: calc((100% - 3*12px)/4); }
}
.tip-item img{ width:100%; height:100%; object-fit:cover; border-radius:var(--fx-image-radius); }
.tip-caption{ line-height:1.25; }

/* Spread tips (внутри карточек разворотов) — авто-ширина карточек, фикс-высота изображений, увеличенный зазор и тени */
.spread-tips .tips-scroll{
  display:flex;
  gap:32px; /* увеличенный зазор, синхронизирован с JS */
  overflow-x:auto;
  scroll-snap-type:x mandatory;
  -webkit-overflow-scrolling:touch;
  padding-bottom:8px;
}
.spread-tips .tips-scroll::-webkit-scrollbar{ height:8px; }
.spread-tips .tip-item{ flex:0 0 auto; scroll-snap-align:start; }
.spread-tips .tip-img{
  display:block;
  height:140px;   /* базовая высота */
  width:auto;     /* ширина по пропорциям */
  object-fit:cover;
  border-radius:var(--fx-image-radius); /* унифицировано: 24px */
  background: var(--bg);
  box-shadow:
    0 1px 2px rgba(0,0,0,.06),
    0 2px 4px rgba(0,0,0,.08);
}
@media (min-width: 992px){ .spread-tips .tip-img{ height:140px; } }

/* ================================
   Секции выбора фото / заголовки
   ================================ */
.turn-section{ padding:16px 0; background:var(--bg); }
.turn-head{ display:flex; align-items:flex-start; gap:12px; padding:12px 0; }
.turn-num{
  width:44px; height:44px; border-radius:var(--fx-radius);
  background:color-mix(in srgb,var(--surface),black 4%);
  border:1px solid var(--line);
  display:flex; align-items:center; justify-content:center; font-weight:800;
}
.turn-titles .turn-hint{ color:var(--muted); font-size:.95rem; }
.turn-actions{ display:flex; flex-wrap:wrap; gap:.5rem; }

/* Thumbnails under each turn (selected photos) */
.turn-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* works well with Bootstrap spacing */
  align-items: flex-start;
}

/* Highlight invalid spread card: subtle red glow + border change */
.highlight-invalid {
  box-shadow: 0 0 0 4px rgba(220,53,69,0.12) !important;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Button flash animation for focus on '+ Выбрать фото' */
.btn-flash {
  animation: btnFlashAnim 0.36s ease-in-out;
}
@keyframes btnFlashAnim {
  0% { transform: translateY(0); box-shadow: none; }
  40% { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(255,193,7,0.45); }
  100% { transform: translateY(0); box-shadow: none; }
}
.turn-thumb {
  height: 270px;
  width: auto;
  object-fit: cover;
  border-radius: var(--fx-image-radius); /* унифицировано: 24px */
  cursor: pointer;
  max-width: 100%;
  /* subtle shadow to separate from background */
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Optional focus outline for accessibility when navigating via keyboard */
.turn-thumb:focus {
  outline: 2px solid rgba(13,110,253,0.6); /* bootstrap primary */
  outline-offset: 2px;
}

/* Плитка */
.tiles{ display:grid; grid-template-columns:repeat(2,1fr); gap:.75rem; }
@media (min-width: 768px){ .tiles{ grid-template-columns:repeat(3,1fr); } }
@media (min-width: 992px){ .tiles{ grid-template-columns:repeat(4,1fr); } }
.tile{
  position:relative; overflow:hidden; border-radius:var(--fx-radius);
  border:1px solid var(--line); background:#000;
}
.tile-img{ width:100%; height:100%; aspect-ratio:4/5; object-fit:cover; display:block; }
.tile-toolbar{
  position:absolute; inset:auto 8px 8px 8px; display:flex; gap:.35rem; justify-content:center;
  background:linear-gradient(to top, rgba(0,0,0,.45), rgba(0,0,0,0));
  padding:.35rem .4rem; border-radius:var(--fx-radius);
}
/* (icon-btn moved to /styles/components/controls.css) */
.tile-caption{
  position:absolute; left:8px; top:8px; padding:.2rem .45rem; font-size:.85rem;
  color:var(--surface); background:rgba(0,0,0,.45); border-radius:var(--fx-radius);
}

/* Рамки статусов (будут назначаться классами из JS) */
.tile-on-current{ outline:6px solid var(--primary); outline-offset:-3px; }
.tile-on-other{ outline:3px solid color-mix(in srgb, var(--line), black 40%); outline-offset:-3px; }
.tile-selected-temp{ outline:3px dashed var(--primary); outline-offset:-3px; }

/* When a tile is occupied by a photo assigned to another turn, make the image dimmer
   and disable transitions so the change is immediate (no flicker/animation). */
#gallery.gallery--select-mode .masonry-item.tile-on-other img{
  opacity: .5 !important;
  transition: none !important;
  -webkit-transition: none !important;
}

/* Inline spread types section (replaces offcanvas) */
.spread-types-inline {
  margin-top: 1rem;
  scroll-margin-top: 2rem;
}
.spread-types-inline .card-2025 {
  animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Кнопка-разделитель между разворотами ===== */
.spread-inserter {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .75rem;
}

.spread-inserter-line {
  height: 1px;
  background: linear-gradient(90deg, rgba(0,0,0,.06), rgba(0,0,0,.12), rgba(0,0,0,.06));
}

.spread-inserter-cta {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  padding: .5rem .75rem;
  text-align: center;
}

.btn-add-spread {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border-radius: 999px;
  padding-inline: 1rem 1.1rem;
  font-weight: 600;
  position: relative;
}

/* Плюс — аккуратный кружок */
.btn-add-spread .btn-plus {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  line-height: 1;
  font-size: 1rem;
}

/* Небольшой «пульс» чтобы кнопка не терялась (мягкий, не мешает) */
.btn-add-spread::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(13,110,253,.25); /* использует цвет primary */
  animation: spreadPulse 2.6s ease-out infinite;
  pointer-events: none;
  opacity: .8;
}
@keyframes spreadPulse {
  0%   { box-shadow: 0 0 0 0 rgba(13,110,253,.25); }
  70%  { box-shadow: 0 0 0 14px rgba(13,110,253,0); }
  100% { box-shadow: 0 0 0 14px rgba(13,110,253,0); }
}

/* Мобильная адаптация: делаем шире и убираем лишнюю «декорацию» */
@media (max-width: 576px) {
  .spread-inserter {
    grid-template-columns: 1fr;
    gap: .5rem;
  }
  .spread-inserter-line { display: none; }
  .spread-inserter-cta {
    width: 100%;
    border-radius: 16px;
  }
  .btn-add-spread {
    width: 100%;
    justify-content: center;
    padding-block: .625rem;
  }
}

