:root {
  --bg: #141414;
  --fg: #fff;
  --muted: #8c8c8c;
  --faint: #555;
  --line: #262626;
  --pad: 16px;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font: inherit; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }
a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.label { color: var(--muted); margin-bottom: 12px; }

/* Навігація */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--pad);
  padding: 12px var(--pad);
  background: var(--bg);
}
.topbar a:hover { color: var(--muted); }
.topbar a:last-child { justify-self: end; }

main { padding: 0 var(--pad); }

/* Великий текст історії */

.big {
  font-size: clamp(22px, 2.5vw, 36px);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.chapter {
  max-width: 1100px;
  margin: 96px 0 48px;
}
.chapter.after { margin: 32px 0 64px; }
@media (max-width: 799px) { .chapter.after { margin: 24px 0 40px; } }

/* Про проєкт */

.about {
  display: grid;
  gap: 40px;
  margin: 40px 0 0;
}
.about p.big { max-width: 1100px; }

@media (min-width: 800px) {
  .about { grid-template-columns: 2fr 1fr; gap: 120px; }
}

/* Картинки */

.row {
  display: grid;
  gap: var(--pad);
  margin-bottom: var(--pad);
}
.row img {
  display: block;
  width: 100%;
  height: auto;
  /* background-image (розмита мініатюра) задається в розмітці */
  background-color: #1c1c1c;
  background-size: cover;
  background-position: center;
}
.row.pair img, .row.trio img { object-fit: cover; }

@media (min-width: 800px) {
  .row.pair { grid-template-columns: var(--cols, 1fr 1fr); }
  .row.trio { grid-template-columns: var(--cols, 1fr 1fr 1fr); }
  .row.half figure { width: calc(50% - var(--pad) / 2); margin: 0 auto; }
}

/* Скриншоти телефона: крупно, на прозорому (чорному) тлі */
.row.phones {
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(12px, 4vw, 64px);
  padding: clamp(24px, 5vw, 96px) clamp(0px, 6vw, 120px);
}
.row.phones img { background: none; }

/* Лого «сад» у навігації */
.topbar { align-items: center; }
.topbar .logo { display: inline-block; line-height: 0; }
.topbar .logo:hover { color: var(--fg); }
.topbar .logo svg { display: block; width: 52px; height: auto; overflow: visible; }

/* Стрілка «наступний проєкт» у навігації — товщина як у лінії лого */
.topbar .arrow { display: inline-block; line-height: 0; }
.topbar .arrow:hover { color: var(--fg); }
.topbar .arrow svg { display: block; }

/* Низ кейсу: кредити зліва, наступний проєкт справа */

.outro {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 48px var(--pad);
  margin: 120px 0 0;
  padding-bottom: 48px;
}
.credits li { padding: 1px 0; }

.next { display: block; text-align: right; margin-left: auto; }
.next .label { display: block; margin-bottom: 1px; }
.next .big { display: block; font-size: inherit; line-height: inherit; letter-spacing: normal; }
.next:hover .big { color: var(--muted); }

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: var(--pad);
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--faint);
}
footer a { color: var(--faint); }
footer a:hover { color: var(--muted); }

/* Посилання в «Про проєкт» */
.links-label { margin-top: 40px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block;
  padding: .1em .6em .14em;
  border-radius: 999px;
  background: #2b2b2b;
  color: var(--fg);
  transition: background-color .15s;
}
.chip:hover { background: #3a3a3a; }

/* Відео */
.row video { display: block; width: 100%; height: auto; background-color: #1c1c1c; background-size: cover; background-position: center; }
.row.pair video, .row.trio video { object-fit: cover; }

/* Вікно браузера: довгий скриншот сторінки прокручується всередині */
.browser {
  container-type: inline-size;
  overflow: hidden;
  border-radius: max(8px, 1cqw);
  background: #ececec;
}
.browser__bar {
  position: relative;
  display: flex;
  align-items: center;
  height: max(22px, 3cqw);
  padding: 0 max(10px, 1.3cqw);
  background: #ececec;
}
.browser__dots { display: flex; gap: max(5px, .65cqw); }
.browser__dots i { width: max(7px, .9cqw); height: max(7px, .9cqw); border-radius: 50%; background: #ff5f57; }
.browser__dots i:nth-child(2) { background: #febc2e; }
.browser__dots i:nth-child(3) { background: #28c840; }
.browser__url {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: 34%;
  padding: max(2px, .3cqw) 2cqw;
  border-radius: max(5px, .6cqw);
  background: #fff;
  color: #6e6e6e;
  font-size: max(10px, 1.1cqw);
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}
.browser__view { aspect-ratio: 16 / 10; overflow: hidden; background: #fff; }
.browser__page img { display: block; width: 100%; height: auto; }
.browser__page.is-scrolling {
  will-change: transform;
  animation: browser-scroll var(--dur) cubic-bezier(.45, 0, .55, 1) infinite;
  animation-play-state: paused;
}
.browser__page.is-scrolling.is-visible { animation-play-state: running; }
@keyframes browser-scroll {
  0%, 6% { transform: translateY(0); }
  80%, 86% { transform: translateY(var(--scroll)); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .browser__page.is-scrolling { animation: none; }
}

/* Повноекранний кадр («сцена»): вікно браузера займає ~70% площі по центру */
.stage {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  margin-bottom: var(--pad);
  background: var(--stage, #e8e8e8);
}
.stage .browser {
  height: 84%;
  width: auto;
  aspect-ratio: 1.527;
  box-shadow: 0 2.5cqw 6cqw rgba(0, 0, 0, .16);
}
.stage .browser__view video { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.stage--clear { aspect-ratio: auto; background: transparent; padding: clamp(24px, 4vw, 64px) 0; }
main > .stage:first-child { margin-top: 4px; }

/* Живі фрагменти сайту (iframe з копією сайту) */
.live-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--pad);
  margin-bottom: var(--pad);
}
.live {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: clamp(12px, 1.4vw, 20px);
  background: #f5f6f7;
}
.live iframe {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.live.is-ready iframe { opacity: 1; }
.live--wide { grid-column: span 2; aspect-ratio: auto; }
.live--view { aspect-ratio: 16 / 10; border-radius: 0; background: #fff; }
@media (max-width: 799px) {
  .live-grid { grid-template-columns: 1fr; }
  .live--wide { grid-column: auto; aspect-ratio: 2 / 1; }
}

/* Дошка звуків Alpacked: два ряди по три, по центру */
.soundboard__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  justify-content: center;
  gap: 12px;
}
.soundboard__btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  min-height: 132px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: #262626;
  color: var(--fg);
  font: inherit;
  text-align: left;
  vertical-align: top;
  cursor: pointer;
  transition: background-color .15s, transform .15s;
}
/* Підпис під кнопками — як футер */
.soundboard__caption { grid-column: 1 / -1; margin: 4px 0 0; font-size: 14px; letter-spacing: 0.03em; color: var(--faint); }
.soundboard__btn:hover { background: #303030; }
.soundboard__icon { width: 24px; height: 24px; flex: none; }
.soundboard__btn:active { transform: scale(.97); }
.soundboard__btn.is-playing { animation: sb-flash .5s ease-out; }
@keyframes sb-flash { 0% { background: #4a4a4a; } 100% { background: #262626; } }
@media (max-width: 599px) {
  .soundboard__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Розділ без абзацу: просто відступ перед картинками */
.chapter-gap { height: 64px; }
@media (max-width: 799px) { .chapter-gap { height: 32px; } }

/* Поява на завантаженні: блоки по черзі піднімаються на 8px і проявляються */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stagger > *, .appear-1, .appear-2, .appear-3 { animation: fade-up .5s ease both; }
.stagger > :nth-child(2) { animation-delay: .05s; }
.stagger > :nth-child(3) { animation-delay: .1s; }
.stagger > :nth-child(4) { animation-delay: .15s; }
.stagger > :nth-child(5) { animation-delay: .2s; }
.stagger > :nth-child(6) { animation-delay: .25s; }
.stagger > :nth-child(n+7) { animation-delay: .3s; }
.appear-1, .stagger > .appear-1 { animation-delay: .35s; }
.appear-2 { animation-delay: .4s; }
.appear-3 { animation-delay: .45s; }
/* Логотип малюється лінією; довжину кожного штриха (--len) рахує drawLogo() */
@keyframes logo-draw { 0% { stroke-dashoffset: var(--len); opacity: 0; } 1% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .stagger > *, .appear-1, .appear-2, .appear-3 { animation: none; }
}

/* Футер на мобілці — лінки стовпчиком */
@media (max-width: 799px) {
  footer { flex-direction: column; gap: 4px; }
}

/* Скруглені кути контейнерів у кейсах */
:root { --radius: clamp(12px, 1.4vw, 20px); }
.row img, .row video, .row.phones, .stage, .alogo { border-radius: var(--radius); }
.stage, .alogo { overflow: hidden; }
/* усередині вікна браузера кути дає саме вікно */
.browser img, .browser video, .stage .browser__view video, .row.phones img { border-radius: 0; }
@supports (corner-shape: squircle) {
  .row img, .row video, .row.phones, .stage, .alogo, .live { corner-shape: squircle; }
}

/* Нічого не вилазить за ширину екрана (iOS Safari інколи не обрізає масштабовані iframe) */
main { overflow-x: clip; }
@supports not (overflow: clip) { main { overflow-x: hidden; } }

/* Фрейми айдентики: логотип/знак по центру на кольорі бренду */
.brand-frame { background: var(--stage); }
.brand-frame__logo svg { display: block; width: 100%; height: auto; }
.brand-frame--wide { aspect-ratio: 1920 / 814; }
.lottie-tile { aspect-ratio: 1; border-radius: 22%; background: #fff; display: grid; place-items: center; }
.lottie-tile .lottie { width: 62%; aspect-ratio: 512 / 491; }
.lottie svg { display: block; }

.lottie--fill { position: absolute; inset: 0; width: 100%; height: 100%; }
.lottie--fill svg { width: 100% !important; height: 100% !important; }
.brand-frame { position: relative; overflow: hidden; }

/* Шапка кейсу: не закріплена; лого як на головній, праворуч — «Заповнити форму». Далі назва і короткий опис */
.casehead {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--pad); padding: var(--pad);
  background: var(--bg);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}
/* при скролі вниз шапка ховається, при скролі назад — повертається */
.casehead.is-hidden { transform: translateY(-100%); }
.casehead .logo { display: inline-block; line-height: 0; color: var(--fg); }
.casehead .logo svg { display: block; width: 72px; height: auto; overflow: visible; }
.casehead__cta { font-size: 18px; padding: .45em 1em .5em; }
.casetitle { padding: clamp(48px, 9vw, 128px) 0 clamp(32px, 4vw, 56px); }
.casetitle h1 { margin: 0; font-size: clamp(40px, 5.6vw, 88px); line-height: 1.02; letter-spacing: -0.025em; font-weight: 400; }
.casetitle p { margin: clamp(16px, 2vw, 28px) 0 0; max-width: 36em; font-size: clamp(18px, 1.7vw, 26px); line-height: 1.3; letter-spacing: -0.01em; }

/* «Що робили» — чипи як наша кнопка «Заповнити форму» */
.services { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.services .chip { font-size: 18px; padding: .45em 1em .5em; }
