/* ========================================
   СЕКЦИЯ CASES
   ======================================== */

.cases {
  padding: 56px 0 72px;
  background: var(--bg-alt, #f9fafb);
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

@media (min-width: 900px) {
  .cases { padding: 72px 0 88px; }
}

.cases-header {
  max-width: 100%;
  margin: 0 0 28px;
  text-align: left;
}

.cases-kicker {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2, #6b7280);
}

.cases-title {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text, #0f172a);
}

@media (min-width: 900px) {
  .cases-title { font-size: 28px; }
}

.cases-subtitle {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted, #4b5563);
}

/* ========================================
   СЕТКА КАРТОЧЕК
   ======================================== */

.cases-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .cases-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .cases-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}

/* ── Карточка ── */
.case-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.case-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.case-card:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

.case-card:nth-child(odd) {
  border-top: 3px solid #0ea5e9;
}

.case-card:nth-child(even) {
  border-top: 3px solid #fb923c;
}

/* ── Превью: 2 фото рядом ── */
.case-previews {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: #e5e7eb;
  /* aspect-ratio контролирует высоту всего блока */
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.case-previews img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
  user-select: none;
  pointer-events: none;
}

.case-card:hover .case-previews img {
  transform: scale(1.05);
}

/* Иконка просмотра поверх превью */
.case-previews::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    center / 28px 28px no-repeat,
    rgba(15, 23, 42, 0);
  transition: background-color 0.22s ease;
  pointer-events: none;
  border-radius: 0;
}

/* Чтобы ::after работал — нужен position: relative на previews */
.case-previews {
  position: relative;
}

.case-card:hover .case-previews::after {
  background-color: rgba(15, 23, 42, 0.3);
}

/* ── Текстовая часть ── */
.case-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.case-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.3;
}

.case-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted, #4b5563);
  flex: 1;
}

.case-btn {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #0ea5e9;
}

.case-card:nth-child(even) .case-btn {
  color: #fb923c;
}

/* ========================================
   МОДАЛЬНОЕ ОКНО — без изменений
   (image-modal уже есть в твоём файле)
   ======================================== */

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-modal.active {
  display: flex;
  opacity: 1;
}

.image-modal-backdrop {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1;
  pointer-events: none;
}

.image-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  cursor: pointer;
  z-index: 2;
}

.image-modal-content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y pinch-zoom;
}

.image-modal-img {
  max-width: 100%;
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  user-select: none;
  display: block;
}

.image-modal-close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  z-index: 20;
  transition: background 0.2s;
}

.image-modal-close:hover { background: rgba(255, 255, 255, 0.22); }

.image-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  z-index: 20;
  opacity: 0.85;
  transition: background 0.2s, opacity 0.2s;
}

.image-modal-nav:hover { background: rgba(255, 255, 255, 0.22); opacity: 1; }
.image-modal-prev { left: -68px; }
.image-modal-next { right: -68px; }

.image-modal-indicator {
  position: absolute;
  bottom: -44px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(15, 23, 42, 0.75);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  z-index: 20;
}

/* ── Мобильный модал ── */
@media (max-width: 768px) {
  .image-modal-close {
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.8);
    border-color: transparent;
  }

  .image-modal-nav {
    width: 40px;
    height: 40px;
    background: rgba(15, 23, 42, 0.8);
    border-color: transparent;
    opacity: 1;
  }

  .image-modal-prev { left: 8px; }
  .image-modal-next { right: 8px; }

  .image-modal-indicator {
    bottom: 10px;
    font-size: 12px;
    padding: 5px 12px;
  }

  .image-modal-img { max-height: 80vh; }
}

/* ========================================
   МОБИЛЬНАЯ ВЕРСИЯ СЕКЦИИ
   ======================================== */

@media (max-width: 768px) {
  .cases { padding: 40px 0 56px; }
  .cases-header { margin-bottom: 20px; }
  .cases-title { font-size: 22px; margin-bottom: 10px; }
  .cases-subtitle { font-size: 14px; }

  .case-body { padding: 12px 12px 14px; }
  .case-title { font-size: 14px; }
  .case-desc { font-size: 12px; }
  .case-btn { font-size: 12px; }
}

@media (max-width: 400px) {
  .cases-title { font-size: 20px; }
  .case-title { font-size: 13px; }
}

/* ========================================
   СКРЫТЫЕ КАРТОЧКИ + КНОПКА "ПОКАЗАТЬ ВСЕ"
   ======================================== */

/* Скрытые карточки — невидимы по умолчанию */
.case-card--hidden {
  display: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Когда список раскрыт — показываем с анимацией */
.cases-grid.is-expanded .case-card--hidden {
  display: flex;
}

/* Задержка для каждой следующей карточки — каскадный эффект */
.cases-grid.is-expanded .case-card--hidden:nth-child(3) {
  animation: caseReveal 0.35s ease 0.05s both;
}
.cases-grid.is-expanded .case-card--hidden:nth-child(4) {
  animation: caseReveal 0.35s ease 0.15s both;
}
.cases-grid.is-expanded .case-card--hidden:nth-child(5) {
  animation: caseReveal 0.35s ease 0.25s both;
}

@keyframes caseReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Кнопка "Показать все" */
.cases-more {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

/* Скрываем кнопку если скрытых карточек нет */
.cases-more.is-hidden {
  display: none;
}

.cases-more__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border: 1.5px solid rgba(148, 163, 184, 0.5);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #0f172a);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.cases-more__btn:hover {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
  background: #f0f9ff;
}

.cases-more__arrow {
  flex-shrink: 0;
  color: #0ea5e9;
  transition: transform 0.28s ease;
}

/* Стрелка вверх когда открыто */
.cases-more__btn[aria-expanded="true"] .cases-more__arrow {
  transform: rotate(180deg);
}

.cases-more__btn[aria-expanded="true"] .cases-more__text::after {
  content: 'Свернуть';
}

.cases-more__btn[aria-expanded="false"] .cases-more__text::after {
  content: 'Смотреть все кейсы';
}

/* Прячем статичный текст — управляем через ::after */
.cases-more__btn .cases-more__text {
  font-size: 0; /* скрываем оригинальный текст */
}

.cases-more__btn .cases-more__text::after {
  font-size: 14px;
}

/* Десктоп: показываем скрытые кейсы и убираем кнопку */
@media (min-width: 900px) {
  .case-card--hidden {
    display: flex;     /* у .case-card display: flex */
    opacity: 1;
    transform: none;
    transition: none;
  }

  .cases-more {
    display: none;
  }
}
