/* Сторінка кейсу (Adaptis, FoodID та інші). Спільне з портфоліо: мови, кнопки, фінал.
   Колір кейсу задається змінною --tint на <body>. */

/* ---------- Перший екран ---------- */
.cs-hero {
  min-height: auto;
  padding: calc(60px + clamp(28px, 4vw, 52px)) 0 clamp(48px, 7vw, 96px);
  overflow-x: clip;
}

.cs-hero::before {
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 32%, transparent), transparent);
}

.cs-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px clamp(32px, 5vw, 80px);
  align-items: center;
}

.cs-hero__text {
  display: grid;
  gap: 24px;
  justify-items: start;
}

.cs-hero__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.cs-title {
  font-size: clamp(40px, 5.2vw, 80px);
  text-transform: none;
}

.cs-title .accent {
  background: linear-gradient(90deg, #fff 0%, color-mix(in srgb, var(--tint) 45%, #fff) 50%, var(--tint) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cs-title-row {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 22px);
}

.cs-logo {
  display: block;
  width: clamp(52px, 6vw, 84px);
  height: clamp(52px, 6vw, 84px);
  flex: none;
  border-radius: 22%;
  overflow: hidden;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.9);
  opacity: 0;
  animation: rise 0.8s var(--ease-out) 0.3s forwards;
}

.cs-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* прозорий знак ставимо на світлу плашку, інакше синій губиться на темному */
.cs-logo--tile {
  display: grid;
  place-items: center;
  background: #f4f6fb;
}

/* відступ процентами від самої плашки: padding у відсотках рахувався б від ширини рядка */
.cs-logo--tile img {
  width: 68%;
  height: 68%;
  object-fit: contain;
}

.cs-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cs-tags li {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font: 500 12px/1 var(--font-mono);
  color: var(--muted);
}

.cs-tags li:first-child {
  border-color: color-mix(in srgb, var(--tint) 60%, transparent);
  color: var(--text);
}

.cs-lead {
  margin: 0;
  max-width: 46ch;
  font-size: clamp(18px, 1.6vw, 21px);
  line-height: 1.55;
  color: #d6d6e2;
}

.cs-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cs-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: rgba(20, 20, 28, 0.7);
  color: var(--text);
  font: 600 15px/1 var(--font-body);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.35s var(--ease-spring);
}

.cs-link svg {
  width: 16px;
  height: 16px;
}

.cs-link:hover {
  border-color: var(--tint);
  transform: translateY(-2px);
}

.cs-link--main {
  background: var(--tint);
  border-color: transparent;
  color: #fff;
}

.cs-link--main:hover {
  border-color: transparent;
  filter: brightness(1.1);
}

/* обкладинка: фрейм на полотні, його можна потягнути */
.cs-cover {
  position: relative;
  cursor: grab;
  opacity: 0;
  animation: rise 0.9s var(--ease-out) 0.5s forwards;
}

.cs-cover .frame-label {
  margin: 0 0 10px 4px;
}

.cs-cover__img {
  aspect-ratio: 5 / 4;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 36px);
  border-radius: 24px;
  border: 1px solid var(--line-2);
  background:
    radial-gradient(70% 80% at 50% 10%, color-mix(in srgb, var(--tint) 45%, transparent), transparent 70%),
    radial-gradient(120% 90% at 50% 120%, color-mix(in srgb, var(--tint) 20%, transparent), transparent 70%),
    var(--panel);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.9);
  rotate: 2deg;
  transition: rotate 0.5s var(--ease-out), box-shadow 0.3s;
}

.cs-cover__img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.cs-cover:hover .cs-cover__img {
  rotate: 0deg;
  box-shadow: 0 0 0 1.5px var(--blue), 0 40px 80px -40px rgba(0, 0, 0, 0.9);
}

.cs-cover.is-dragging {
  cursor: grabbing;
  z-index: 10;
}

.cs-hero .cursor--mentor {
  right: 6%;
  bottom: 14%;
  --c: var(--tint);
}

/* ---------- Відео ---------- */
.cs-video {
  margin: 0;
}

.cs-video .frame-label {
  margin: 0 0 10px 4px;
}

.cs-video .yt {
  border: 1px solid var(--line-2);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.9);
}

/* ---------- Розділи кейсу ---------- */
.cs-body {
  padding-bottom: clamp(40px, 6vw, 80px);
}

.cs-sec {
  padding-block: clamp(56px, 8vw, 110px) 0;
}

.cs-sec__head {
  display: grid;
  grid-template-columns: clamp(60px, 7vw, 110px) minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px clamp(24px, 4vw, 56px);
  align-items: start;
  margin-bottom: clamp(28px, 4vw, 48px);
}

.cs-num {
  font: 600 clamp(28px, 3.4vw, 44px)/1 var(--font-display);
  color: transparent;
  -webkit-text-stroke: 1.2px color-mix(in srgb, var(--tint) 70%, #fff);
  letter-spacing: -0.02em;
}

.cs-h {
  margin: 0;
  font: 600 clamp(24px, 2.6vw, 36px)/1.15 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.cs-p {
  margin: 0;
  font-size: clamp(16px, 1.3vw, 18px);
  line-height: 1.65;
  color: #c9c9d6;
}

.cs-media {
  display: grid;
  gap: clamp(16px, 2vw, 24px);
}

/* ряд однакової висоти: ширина кожного скріна пропорційна його співвідношенню сторін (--r),
   а весь ряд не вищий за --row-h, тому одинокий вертикальний скрін не роздувається на пів екрана */
.cs-row {
  --row-h: 580px;
  --gap: clamp(16px, 2vw, 24px);
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  width: 100%;
  max-width: calc(var(--sum) * var(--row-h) + (var(--n) - 1) * var(--gap));
  margin-inline: auto;
}

.cs-row > .cs-shot {
  flex: var(--r) 1 0;
  min-width: 0;
}

.cs-shot {
  width: min(100%, 620px);
  justify-self: center;
}

.cs-shot {
  margin: 0;
  display: grid;
  gap: 10px;
}

.cs-shot .frame-label {
  margin-left: 4px;
  font-size: 11px;
}

.cs-shot__img {
  position: relative;
  border-radius: clamp(14px, 1.8vw, 22px);
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--panel);
  transition: box-shadow 0.25s;
}

.cs-shot__img img {
  width: 100%;
}

/* петля з Vimeo: рамка тримає пропорцію, поки плеєр вантажиться */
.cs-shot__img--video {
  display: block;
  background:
    radial-gradient(60% 70% at 50% 40%, color-mix(in srgb, var(--tint) 22%, transparent), transparent 70%),
    var(--panel);
}

.cs-shot__img--video iframe,
.cs-shot__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.cs-shot__poster {
  object-fit: cover;
}

/* плеєр проявляється поверх обкладинки, коли петля справді пішла */
.cs-shot__img--video iframe {
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}

.cs-shot__img--video.is-playing iframe {
  opacity: 1;
}

/* наведення: шар виділяється, як у Figma */
.cs-shot:hover .cs-shot__img {
  box-shadow: 0 0 0 1.5px var(--blue);
}

.cs-shot:hover .frame-label {
  color: var(--blue);
}

/* ---------- Наступний кейс ---------- */
.cs-next {
  padding-top: clamp(40px, 6vw, 80px);
}

.cs-next__card {
  --tint: var(--next-tint);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 24px clamp(24px, 4vw, 56px);
  align-items: center;
  padding: clamp(24px, 4vw, 52px);
  border-radius: 28px;
  border: 1px solid var(--line-2);
  background:
    radial-gradient(70% 120% at 100% 0%, color-mix(in srgb, var(--tint) 34%, transparent), transparent 65%),
    var(--panel);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.5s var(--ease-spring);
}

.cs-next__card:hover {
  border-color: var(--tint);
  transform: translateY(-4px);
}

.cs-next__text {
  display: grid;
  gap: 16px;
  justify-items: start;
}

.cs-next__name {
  font: 700 clamp(36px, 5.6vw, 76px)/1 var(--font-display);
  letter-spacing: -0.03em;
}

.cs-next__go {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.cs-next__go svg {
  width: 18px;
  height: 18px;
  transition: translate 0.3s var(--ease-out);
}

.cs-next__card:hover .cs-next__go svg {
  translate: 4px 0;
}

.cs-next__img {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
}

.cs-next__img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.7s var(--ease-out);
}

.cs-next__card:hover .cs-next__img img {
  transform: scale(1.04) rotate(-1deg);
}

.cs-next__all {
  margin-top: 22px;
}

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
  .cs-hero__grid {
    grid-template-columns: 1fr;
  }

  .cs-cover {
    max-width: 560px;
  }

  /* ширину номера задаємо явно: інакше текст на всю ширину розтягує першу колонку */
  .cs-sec__head {
    grid-template-columns: clamp(56px, 9vw, 80px) minmax(0, 1fr);
  }

  .cs-sec__head .cs-sec__text {
    grid-column: 1 / -1;
  }

  .cs-next__card {
    grid-template-columns: 1fr;
  }

  .cs-next__img {
    order: -1;
  }
}

@media (max-width: 600px) {
  /* на телефоні в шапці немає місця для шляху «Портфоліо / кейс» */
  .topbar__crumb {
    display: none;
  }

  /* на телефоні по одному скріну, вертикальні вужчі, щоб не займали кілька екранів */
  .cs-row {
    flex-direction: column;
    max-width: none;
  }

  .cs-row > .cs-shot {
    flex: none;
    width: min(100%, calc(var(--r) * 70svh));
    align-self: center;
  }

  .cs-cover__img {
    rotate: 0deg;
  }

  .cs-hero .cursor--mentor {
    display: none;
  }

  .cs-link {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (hover: none) {
  .cs-shot:hover .cs-shot__img {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-cover,
  .cs-logo {
    opacity: 1;
    animation: none;
  }
}
