/* stack.css — стек-карусель проектов для разделов Works и Photo.
 * Карточки в вертикальной "картотеке": активная в центре крупнее и ярче,
 * соседние выглядывают сверху/снизу и плавно уходят в фон.
 */

.stack {
  position: relative;
  width: 100%;
  height: calc(100vh - 168px);
  min-height: 560px;
  max-height: 860px;
  outline: none;
  /* Защита от случайной нативной прокрутки — мы перехватываем wheel руками. */
  overscroll-behavior: contain;
  touch-action: none;
}

.stack-stage {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  perspective-origin: 50% 50%;
  overflow: hidden;
}

/* Карточка — позиционируется через translate относительно центра сцены.
 * Жирная чёрная рамка и трёхколоночная сетка, как у hero на главной:
 *   [левая rail-колонка — имя бренда вертикально] [обложка] [правая edge — idx/год/→]
 */
.stack-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(1240px, 88%);
  height: min(80%, 760px);
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%);
  transition:
    transform 540ms cubic-bezier(.32, .8, .25, 1),
    opacity   400ms ease,
    box-shadow 320ms ease,
    border-color 240ms ease;
  background: var(--bg);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(10, 10, 10, 0.08);
  cursor: pointer;
  will-change: transform, opacity;
  display: grid;
  grid-template-columns: 1fr clamp(48px, 4.2vw, 64px);
  overflow: hidden;
  user-select: none;
}
.stack-card[data-active="1"] {
  box-shadow: none;
}
.theme-ink .stack-card { box-shadow: none; }
.theme-ink .stack-card[data-active="1"] { box-shadow: none; }

/* ── Левая rail-колонка: имя бренда вертикально ─────────────────── */
.stack-card-rail {
  border-right: 1px solid var(--ink);
  position: relative;
  overflow: hidden;
  background: var(--bg);
  transition: background .18s ease;
}
.stack-card:hover .stack-card-rail { background: var(--rule-soft); }
.stack-card-rail-title {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  white-space: nowrap;
  max-width: 78vh;
  font-family: var(--font-display);
  font-weight: 700;
  font-stretch: 75%;
  font-size: clamp(20px, 2vw, 32px);
  letter-spacing: -0.02em;
  text-transform: none;
  transition: color .22s ease;
}
.font-display .stack-card-rail-title { font-weight: 400; }
.stack-card[data-active="1"]:hover .stack-card-rail-title { color: var(--accent); }

/* ── Центр: обложка во всю площадь ─────────────────────────────── */
.stack-card-media {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--rule-soft);
}
.stack-card-media .mslot { width: 100%; height: 100%; position: absolute; inset: 0; }
.stack-card-media .mslot image-slot,
.stack-card-media .mslot .pf-img { width: 100%; height: 100%; }

/* Моно-пилюли в углах обложки — как на hero главной */
.stack-card-tl, .stack-card-bl {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  color: var(--ink);
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  pointer-events: none;
}
.stack-card-tl { left: 12px; top: 12px; }
.stack-card-bl { left: 12px; bottom: 12px; color: var(--ink-2); }
.stack-card-tl-idx { font-weight: 600; color: var(--ink); }
.stack-card-tl-rule {
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--ink);
  opacity: 0.5;
}
.stack-card-tl-title { color: var(--ink); }

/* CTA на активной карточке — крупная плитка снизу-справа */
.stack-card-cta {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  background: var(--ink);
  color: var(--bg);
  padding: 7px 11px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 1px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s ease 80ms, transform .3s ease 80ms;
}
.stack-card[data-active="1"] .stack-card-cta {
  opacity: 1;
  transform: translateY(0);
}

/* ── Правая edge-колонка: idx сверху, год вертикально, ↘ снизу ─── */
.stack-card-edge {
  border-left: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.stack-card-edge-mark {
  padding: 12px 6px;
  border-bottom: 1px solid var(--ink);
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.stack-card-edge-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  overflow: hidden;
}
.stack-card-edge-arrow { font-size: 10px; color: var(--ink); }
.stack-card-edge-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}
.stack-card-edge-corner {
  border-top: 1px solid var(--ink);
  padding: 9px 6px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
}

/* ── Мини-хедер над сценой: подпись раздела, счётчик и подсказка ── */
.stack-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0 2px;
  margin-bottom: 8px;
}
.stack-meta-label  { font-weight: 600; }
.stack-meta-rule   { flex: 1 1 auto; height: 1px; background: var(--rule); }
.stack-meta-count  { letter-spacing: 0.02em; text-transform: none; }
.stack-meta-now    { color: var(--ink); font-weight: 600; }
.stack-meta-hint   { font-size: 10px; letter-spacing: 0.08em; }

/* ── Стрелки ↑ ↓ ─────────────────────────────────────────────────── */
.stack-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 60;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.stack-nav:hover { border-color: var(--ink); }
.stack-nav:active { transform: translateX(-50%) scale(0.95); }
.stack-nav-up   { top: 10px; }
.stack-nav-down { bottom: 10px; }

/* ── Section frame: компактный head на странице-разделе ───────────── */
/* Используется на works / photo, чтобы освободить место под стек. */
.section-with-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: clamp(20px, 3vw, 36px);
}
.section-with-stack .photo-head { padding-top: 6px; padding-bottom: 0; }
/* На страницах-разделах прижимаем мини-хедер стека к основному меню — */
/* большой воздух из общего .proj-bar тут не нужен. Заодно гасим
   border-bottom у верхнего меню: единственной разделительной линией
   остаётся inline-rule внутри stack-meta. */
.section-with-stack > .proj-bar { margin-bottom: 0; border-bottom: 0; }
.section-with-stack .stack-meta { margin-bottom: 0; }

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .stack-card { transition: opacity 0.001ms !important; }
}

/* ── Малые экраны ───────────────────────────────────────────────── */
@media (max-width: 720px) {
  .stack { height: calc(100vh - 200px); min-height: 480px; }
  .stack-card {
    width: 94%;
    height: 76%;
    grid-template-columns: 1fr 42px;
  }
  .stack-card-rail-title { font-size: 16px; }
  .stack-card-tl, .stack-card-bl { font-size: 10px; padding: 4px 7px; }
  .stack-card-edge-mark { font-size: 11px; padding: 9px 4px; }
  .stack-card-edge-text { font-size: 10px; }
  .stack-rail { right: 8px; gap: 10px; font-size: 9px; }
  .stack-rail-track { width: 10px; height: 32vh; }
  .stack-rail-tick { width: 10px; }
  .stack-rail-count { font-size: 12px; }
  .stack-nav { width: 32px; height: 32px; }
}
