/* ==========================================================================
   Portfolio — Максим Словогородский
   Source of truth: Figma page «Кейсы» (desktop 1920, mobile 390, case detail)
   ========================================================================== */

:root {
  /* Ink */
  --ink: #fff;
  --ink-80: rgba(255, 255, 255, .8);
  --ink-50: rgba(255, 255, 255, .5);
  --ink-40: rgba(255, 255, 255, .4);
  --tag-ink: #d3cac6;
  --dark-ink: #141210;

  /* Surfaces */
  --glass: rgba(255, 255, 255, .05);
  --glass-hi: rgba(255, 255, 255, .08);
  --chip-hi: rgba(255, 255, 255, .15);
  --well: rgba(0, 0, 0, .15);
  --line: rgba(255, 255, 255, .07);
  --track: rgba(255, 255, 255, .05);
  --thumb: #d9d9d9;
  --nav: rgba(33, 30, 33, .8);

  /* Skeleton */
  --sk-base: rgba(255, 255, 255, .055);
  --sk-hi: rgba(255, 255, 255, .13);
  --sk: linear-gradient(100deg, var(--sk-base) 30%, var(--sk-hi) 50%, var(--sk-base) 70%);

  /* Motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --spring: cubic-bezier(.34, 1.36, .64, 1);

  /* Layout */
  --gap: 16px;
  --panel-r: 32px;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scrollbar-gutter: stable;
  background: #0e0d0c;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { margin: 0; min-height: 100dvh; overflow-x: hidden; }
h1, h2, h3, p, ul, figure { margin: 0; padding: 0; font-weight: 400; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(211, 202, 198, .35); color: #fff; }

:focus-visible { outline: 2px solid rgba(255, 255, 255, .55); outline-offset: 3px; }

/* ==========================================================================
   Background (pre-blurred bitmaps, slow drift on the compositor)
   ========================================================================== */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg__layer {
  position: absolute; inset: 0; overflow: hidden;
  background-size: cover; background-position: center;
  will-change: opacity, transform;
}
.bg__layer--main { transform: scale(1.12); transition: transform 1.8s var(--ease-out); }
.bg__layer--main::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(120% 95% at 55% 35%, transparent 35%, rgba(8, 7, 6, .62) 100%),
    linear-gradient(rgba(10, 9, 8, .52), rgba(10, 9, 8, .52));
}
/* Two copies of the photo drift on long, out-of-phase loops: colour masses slowly morph */
.bg__drift {
  position: absolute; inset: -14%;
  background: url("../img/bg-main.webp") center / cover;
  will-change: transform;
  animation: drift-a 52s var(--ease-io) infinite alternate;
}
.bg__drift--b {
  opacity: .5;
  animation: drift-b 71s var(--ease-io) infinite alternate, breathe 37s var(--ease-io) infinite alternate;
}
@keyframes drift-a {
  0%   { transform: translate3d(-2.5%, -1.5%, 0) scale(1.02) rotate(-1.2deg); }
  50%  { transform: translate3d(2%, 1.5%, 0) scale(1.1) rotate(.6deg); }
  100% { transform: translate3d(-1%, 2.5%, 0) scale(1.05) rotate(1.4deg); }
}
@keyframes drift-b {
  0%   { transform: scaleX(-1) translate3d(3%, 2%, 0) scale(1.12) rotate(1.5deg); }
  50%  { transform: scaleX(-1) translate3d(-2%, -2%, 0) scale(1.04) rotate(-.8deg); }
  100% { transform: scaleX(-1) translate3d(1.5%, -3%, 0) scale(1.09) rotate(-1.8deg); }
}
@keyframes breathe { from { opacity: .28; } to { opacity: .62; } }
.bg__layer--pre {
  background-image:
    radial-gradient(120% 100% at 55% 30%, transparent 45%, rgba(8, 7, 6, .5) 100%),
    linear-gradient(rgba(0, 0, 0, .12), rgba(0, 0, 0, .12)),
    url("../img/bg-pre.webp");
  transition: opacity 1.3s var(--ease-io);
}
.is-loaded .bg__layer--main { transform: none; }
.is-loaded .bg__layer--pre { opacity: 0; }
.bg-settled .bg__layer { will-change: auto; }

.bg__noise {
  position: absolute; inset: 0; opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.6 -.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Preloader — alternating messages + real progress
   ========================================================================== */
.preloader {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  transition: opacity .55s var(--ease-out), transform .7s var(--ease-out), visibility 0s linear .7s;
}
.preloader__text {
  display: grid; height: 28px; overflow: hidden;
  font-size: 16px; line-height: 28px; color: var(--ink-80); letter-spacing: .005em;
  animation: pre-in .8s var(--ease-out) both;
}
.preloader__msg {
  grid-area: 1 / 1; justify-self: center; white-space: nowrap;
  opacity: 0; transform: translateY(100%);
  transition: opacity .45s var(--ease-out), transform .6s var(--ease-out);
}
.preloader__msg.is-active { opacity: 1; transform: none; }
.preloader__msg.is-leaving { opacity: 0; transform: translateY(-100%); }
.dots i { font-style: normal; animation: dot 1.4s infinite both; }
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
.preloader__bar {
  position: relative; width: 164px; height: 2px; overflow: hidden;
  background: rgba(217, 217, 217, .2); border-radius: 2px;
  animation: pre-in .8s .1s var(--ease-out) both;
}
.preloader__fill {
  position: absolute; inset: 0; background: var(--thumb);
  transform-origin: left center; transform: scaleX(0); will-change: transform;
}
.is-loaded .preloader { opacity: 0; transform: translateY(-14px); visibility: hidden; }
@keyframes pre-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes dot { 0%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ==========================================================================
   Layout
   ========================================================================== */
.page { min-height: 100dvh; }
.is-preloading .page { pointer-events: none; }

.layout {
  width: min(1280px, 100% - 64px);
  margin: 0 auto;
  padding: 32px 0 18px;
  display: grid; gap: var(--gap);
}
.home-top { display: grid; gap: var(--gap); min-width: 0; }
.home-top.is-morphing, .works.is-morphing { overflow: hidden; }

/* Block entrance via transitions, so hover transforms are never overridden */
.reveal {
  opacity: 0;
  transform: translate3d(0, 28px, 0) scale(.985);
  transition:
    opacity .8s var(--ease-out) calc(var(--d, 0) * 90ms),
    transform 1.1s var(--ease-out) calc(var(--d, 0) * 90ms);
}
.is-revealed .reveal { opacity: 1; transform: none; }
.reveal-done .reveal { transition: none; }

/* ==========================================================================
   Glass surface + pointer spotlight
   ========================================================================== */
.glass {
  position: relative; isolation: isolate;
  border-radius: var(--panel-r);
  background: var(--glass);
  -webkit-backdrop-filter: blur(32px) saturate(1.1);
  backdrop-filter: blur(32px) saturate(1.1);
}
.glass::before, .glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0;
  transition: opacity .6s var(--ease-out);
}
.glass::before {
  z-index: -1;
  background: radial-gradient(560px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .055), transparent 62%);
}
.glass::after {
  padding: 1px;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .22), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
@media (hover: hover) {
  .reveal-done .glass:hover::before, .reveal-done .glass:hover::after { opacity: 1; }
}

/* ==========================================================================
   Skeleton system — .is-loading on an ancestor turns every .ld into a shimmer
   ========================================================================== */
.ld {
  position: relative;
  transition:
    color .55s var(--ease-out) calc(var(--i, 0) * 70ms),
    background-color .55s var(--ease-out) calc(var(--i, 0) * 70ms);
}
.ld > * { transition: opacity .55s var(--ease-out) calc(var(--i, 0) * 70ms); }
.ld::after {
  content: ""; position: absolute; z-index: 2;
  inset: var(--sk-inset, .22em 0);
  border-radius: var(--sk-radius, 8px);
  background: var(--sk); background-size: 250% 100%;
  opacity: 0; pointer-events: none;
  transition: opacity .45s var(--ease-out) calc(var(--i, 0) * 70ms);
}
.is-loading .ld { color: transparent !important; background-color: transparent !important; }
.is-loading .ld > * { opacity: 0 !important; }
.is-loading .ld::after { opacity: 1; animation: shimmer 1.5s linear infinite; }

.ld--lines::after {
  inset: 0; border-radius: 0;
  -webkit-mask:
    linear-gradient(#000 0 0) 0 4px / 100% 12px no-repeat,
    linear-gradient(#000 0 0) 0 24px / 88% 12px no-repeat,
    linear-gradient(#000 0 0) 0 44px / 54% 12px no-repeat;
  mask:
    linear-gradient(#000 0 0) 0 4px / 100% 12px no-repeat,
    linear-gradient(#000 0 0) 0 24px / 88% 12px no-repeat,
    linear-gradient(#000 0 0) 0 44px / 54% 12px no-repeat;
}
@keyframes shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }

.media-sk { position: relative; background-color: var(--sk-base); }
.media-sk::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: var(--sk); background-size: 250% 100%;
  animation: shimmer 1.5s linear infinite;
  transition: opacity .6s var(--ease-out);
}
.is-sharp.media-sk::before, .is-sharp .media-sk::before { opacity: 0; animation: none; }

/* ==========================================================================
   Hero — one glass card: intro + photo with TG pill
   ========================================================================== */
.hero {
  min-height: 198px; padding: 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) 282px; gap: 24px;
}
.hero__info { align-self: center; padding: 0 24px; display: grid; gap: 24px; justify-items: start; min-width: 0; }
.hero__text { display: grid; gap: 4px; justify-items: start; }
.hero__name { font-size: 24px; line-height: 31px; letter-spacing: -.01em; width: fit-content; }
.hero__lead { font-size: 16px; line-height: 24px; font-weight: 300; color: var(--ink-80); width: fit-content; max-width: 100%; }

.chips { display: flex; flex-wrap: wrap; }
.chip {
  --sk-inset: 0; --sk-radius: 37px;
  font-size: 14px; line-height: 18px; padding: 10px 12px;
  border-radius: 37px; background-color: var(--glass-hi); cursor: default;
  transition:
    color .55s var(--ease-out) calc(var(--i, 0) * 70ms),
    background-color .55s var(--ease-out) calc(var(--i, 0) * 70ms),
    transform .45s var(--spring);
}
.reveal-done .chip { transition: background-color .3s var(--ease-out), transform .45s var(--spring); }
@media (hover: hover) {
  .reveal-done .chip:hover { background-color: var(--chip-hi); transform: translateY(-2px); }
}

/* white CTA (mobile hero) */
.tg-btn {
  --sk-inset: 0; --sk-radius: 16px;
  display: none; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; height: 50px; padding: 0 16px 0 12px;
  border-radius: 16px; background-color: #fff; color: var(--dark-ink);
  font-size: 14px; line-height: 18px;
  transition:
    color .55s var(--ease-out) calc(var(--i, 0) * 70ms),
    background-color .55s var(--ease-out) calc(var(--i, 0) * 70ms),
    transform .25s var(--ease-out);
}
.tg-btn svg { transition: transform .45s var(--spring); }
.tg-btn:active { transform: scale(.98); }
.tg-btn:active svg { transform: translate(2px, -2px); }

/* Avatar (tilt card) */
.avatar { height: 174px; perspective: 900px; }
.avatar__card {
  position: relative; height: 100%; overflow: hidden; isolation: isolate;
  border-radius: 32px;
  box-shadow: 2px 2px 21px rgba(0, 0, 0, .17);
  background: var(--sk-base);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .9s var(--ease-out), box-shadow .6s var(--ease-out);
  will-change: transform;
}
.avatar.is-tilting .avatar__card { transition: transform .18s linear, box-shadow .6s var(--ease-out); }
.avatar__card::before {
  content: ""; position: absolute; inset: 0; z-index: 5;
  background: var(--sk); background-size: 250% 100%;
  transition: opacity .6s var(--ease-out); pointer-events: none;
}
.avatar.is-loading .avatar__card::before { animation: shimmer 1.5s linear infinite; }
.avatar:not(.is-loading) .avatar__card::before { opacity: 0; }
.avatar__lqip, .avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar__lqip { background: center / cover; filter: blur(12px); transform: scale(1.15); }
.avatar__img { opacity: 0; transform: scale(1.08); transition: opacity .8s var(--ease-out), transform 1.4s var(--ease-out); }
.avatar:not(.is-loading) .avatar__img { opacity: 1; transform: scale(1); }
.avatar__glare {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(320px circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .22), transparent 55%);
  mix-blend-mode: soft-light; opacity: 0; transition: opacity .5s var(--ease-out);
}
@media (hover: hover) {
  .avatar:hover .avatar__card { box-shadow: 6px 18px 40px rgba(0, 0, 0, .32); }
  .avatar:not(.is-loading):hover .avatar__img { transform: scale(1.06); }
  .avatar:hover .avatar__glare { opacity: 1; }
}

.tg-pill {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 12px; border-radius: 16px;
  background: #fff; color: var(--dark-ink);
  font-size: 14px; line-height: 18px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  opacity: 0; transform: translateY(8px) scale(.9);
  transition: opacity .5s var(--ease-out) .25s, transform .6s var(--spring) .25s, box-shadow .3s var(--ease-out);
}
.avatar:not(.is-loading) .tg-pill { opacity: 1; transform: none; }
.tg-pill svg { transition: transform .45s var(--spring); }
@media (hover: hover) {
  .avatar:not(.is-loading) .tg-pill:hover { transform: scale(1.05); transition-delay: 0s; box-shadow: 0 10px 26px rgba(0, 0, 0, .28); }
  .tg-pill:hover svg { transform: translate(2px, -2px); }
}
.avatar:not(.is-loading) .tg-pill:active { transform: scale(.95); transition-delay: 0s; }

/* ==========================================================================
   About (accordion)
   ========================================================================== */
.about {
  --pad-y: 24px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .02);
  padding: var(--pad-y) 32px;
  transition: padding .65s var(--ease-out);
}
.about.is-open { --pad-y: 32px; }
.about__head {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; border-radius: 12px;
}
.about__head::before { content: ""; position: absolute; inset: calc(-1 * var(--pad-y)) -32px -12px; }
.about__title { font-size: 18px; line-height: 24px; width: fit-content; }
.about__toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 16px; line-height: 24px; color: var(--ink);
  transition: transform .2s var(--ease-out);
}
.about__label { display: inline-grid; overflow: hidden; height: 24px; text-align: right; }
.about__label-item { grid-area: 1 / 1; justify-self: end; transition: transform .5s var(--ease-out), opacity .4s var(--ease-out); }
.about__label-item--close { transform: translateY(100%); opacity: 0; }
.is-open .about__label-item--open { transform: translateY(-100%); opacity: 0; }
.is-open .about__label-item--close { transform: none; opacity: 1; }
.about__chevron { opacity: .5; transition: transform .6s var(--spring), opacity .3s var(--ease-out); }
.is-open .about__chevron { transform: rotate(180deg); }
@media (hover: hover) {
  .about__head:hover .about__chevron { opacity: 1; transform: translateY(2px); }
  .is-open .about__head:hover .about__chevron { transform: rotate(180deg) translateY(2px); }
}
.about__head:active .about__toggle { transform: scale(.97); }

.about__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .7s var(--ease-out); }
.is-open .about__body { grid-template-rows: 1fr; }
.about__inner { min-height: 0; overflow: hidden; }
.about__grid { padding-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr) 434px; gap: 24px; align-items: center; }
.about__main { padding: 10px 0; display: grid; gap: 16px; }
.about__heading { font-size: 24px; line-height: 32px; letter-spacing: -.01em; }
.about__text { font-size: 16px; line-height: 24px; font-weight: 300; color: var(--ink-80); max-width: 758px; }

.grade { padding: 24px; border-radius: 24px; background: var(--glass); min-height: 225px; }
.stars { display: flex; }
.star { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 16px; color: rgba(255, 255, 255, .1); }
.star svg { display: block; width: 22px; height: 22px; transition: transform .6s var(--spring); }
.star--on { color: #fff; }
.star--on svg { opacity: 0; transform: scale(.4) rotate(-40deg); transition: transform .7s var(--spring), opacity .3s var(--ease-out); }
.is-open .star--on svg { opacity: 1; transform: none; transition-delay: calc(380ms + var(--s, 0) * 110ms); }
@media (hover: hover) {
  .is-open .grade:hover .star--on svg { transform: rotate(-14deg) scale(1.1); transition-delay: calc(var(--s, 0) * 60ms); }
}
.grade__title { margin-top: 12px; font-size: 18px; line-height: 23px; }
.grade__title span { color: var(--ink-50); }
.grade__text { margin-top: 12px; font-size: 16px; line-height: 24px; font-weight: 300; color: var(--ink-80); }

.a-item { opacity: 0; transform: translateY(14px); transition: opacity .25s var(--ease-out), transform .35s var(--ease-out); }
.is-open .a-item {
  opacity: 1; transform: none;
  transition:
    opacity .6s var(--ease-out) calc(140ms + var(--k, 0) * 80ms),
    transform .8s var(--ease-out) calc(140ms + var(--k, 0) * 80ms);
}

/* ==========================================================================
   Works panel (shared by home list and case detail)
   ========================================================================== */
.works { min-height: 482px; padding: 32px 32px 25px; display: flex; flex-direction: column; }
.is-case .works { min-height: 0; padding-bottom: 32px; }

.works__bar {
  flex: none; height: 60px;
  display: flex; align-items: center; gap: 0;
  padding: 0 12px 0 16px;
  border-radius: 16px; background: var(--well);
}

/* back button — grows in from zero width on case pages */
.back-wrap {
  flex: none; width: 0; height: 0; overflow: hidden;
  transition: width .6s var(--ease-out), height .6s var(--ease-out), margin .6s var(--ease-out);
}
.is-case .back-wrap { width: 36px; height: 36px; margin-right: 10px; }
.back {
  width: 36px; height: 36px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--chip-hi);
  opacity: 0; transform: scale(.6);
  transition: opacity .35s var(--ease-out), transform .55s var(--spring), background-color .25s;
}
.is-case .back { opacity: 1; transform: none; transition-delay: .12s; }
.back svg { flex: none; transition: transform .45s var(--spring); }
@media (hover: hover) {
  .back:hover { background-color: rgba(255, 255, 255, .24); }
  .back:hover svg { transform: translateX(-3px); }
}
.back:active { transform: scale(.9); transition-delay: 0s; }

/* URL — purely visual breadcrumb */
.url {
  --sk-inset: 1px 0; --sk-radius: 6px;
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  font-size: 16px; line-height: 21px; white-space: nowrap; overflow: hidden;
  cursor: default; user-select: none;
}
.url__host, .url__dim { color: var(--ink-40); }
.url__seg { color: var(--ink); transition: color .45s var(--ease-out); }
.is-case .url__seg { color: var(--ink-40); }
.url__case { color: var(--ink); }
.url__caret { flex: none; width: 1px; height: 18px; margin-left: 2px; background: var(--ink); animation: caret 1.1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* View switch */
.switch {
  --sk-inset: 0; --sk-radius: 10px;
  position: relative; display: flex; gap: 4px; border-radius: 10px; flex: none;
  transition: opacity .35s var(--ease-out), transform .5s var(--ease-out), visibility 0s;
}
.is-case .switch { opacity: 0; transform: scale(.9); visibility: hidden; transition: opacity .25s, transform .4s, visibility 0s .4s; }
.switch__thumb {
  position: absolute; top: 0; left: 0; width: 36px; height: 36px;
  border-radius: 10px; background: var(--chip-hi);
  transform: translateX(var(--tx, 40px)); transition: transform .55s var(--spring);
}
.switch[data-active="list"] .switch__thumb { --tx: 0px; }
.switch__btn { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.switch__btn svg { fill: #fff; opacity: .4; transition: opacity .25s var(--ease-out), transform .35s var(--spring); }
@media (hover: hover) { .switch__btn:hover svg { opacity: .85; } }
.switch__btn[aria-pressed="true"] svg { opacity: 1; }
.switch__btn:active svg { transform: scale(.82); }

.works__home { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.works__stage { position: relative; flex: 1; min-height: 0; margin-top: 24px; }

/* ---------- Grid of cards ---------- */
.cases { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.cases-empty { grid-column: 1 / -1; padding: 48px 8px; color: var(--ink-50); font-size: 16px; font-weight: 300; }

.case { min-width: 0; transition: opacity .45s var(--ease-out); }
.case__link { display: flex; flex-direction: column; border-radius: 24px; }
.case__link:focus-visible { outline-offset: 6px; }

.case__media {
  position: relative; flex: none; aspect-ratio: 189.33 / 185;
  border-radius: 38px; overflow: hidden; isolation: isolate;
  transform: translateZ(0);
  transition: transform .65s var(--ease-out), box-shadow .65s var(--ease-out);
}
.case__lqip, .case__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.case__lqip { z-index: 0; background: center / cover; filter: blur(10px); transform: scale(1.2); opacity: 0; transition: opacity .5s var(--ease-out); }
:is(.case, .row):not(.is-loading) .case__lqip { opacity: 1; }
.case__img { z-index: 1; opacity: 0; transform: scale(1.1); transition: opacity .7s var(--ease-out), transform 1.2s var(--ease-out); }
.is-sharp > .case__img { opacity: 1; transform: scale(1); }

.case__open {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(20, 18, 16, .42);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transform: scale(.5) rotate(-45deg);
  transition: opacity .3s var(--ease-out), transform .55s var(--spring);
}

.case__body { padding: 12px 8px 0; display: grid; gap: 4px; justify-items: start; }
.case__title { font-size: 18px; line-height: 23px; width: fit-content; transition: transform .5s var(--ease-out); }
.case__desc {
  font-size: 14px; line-height: 20px; font-weight: 300; color: var(--ink-80);
  height: 60px; width: 100%;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.case .tags { margin-top: 16px; padding-left: 4px; }
.tag {
  --sk-inset: 0; --sk-radius: 8px;
  font-size: 14px; line-height: 18px; color: var(--tag-ink);
  padding: 6px; border-radius: 8px; background-color: rgba(255, 255, 255, .04);
}
.row .tag { background-color: var(--glass-hi); }

@media (hover: hover) {
  .case:not(.is-loading) .case__link:hover .case__media { transform: translateY(-6px); box-shadow: 0 22px 36px -18px rgba(0, 0, 0, .65); }
  .case:not(.is-loading) .case__link:hover .case__img { transform: scale(1.06); transition: transform 1s var(--ease-out), opacity .7s; }
  .case:not(.is-loading) .case__link:hover .case__open { opacity: 1; transform: none; }
  .case:not(.is-loading) .case__link:hover .case__title { transform: translateX(2px); }
  .cases:has(.case:not(.is-loading) .case__link:hover) .case:not(:has(.case__link:hover)) { opacity: .5; }
}
.case__link:active .case__media { transform: translateY(-3px) scale(.97); transition-duration: .18s; }

/* ---------- List ---------- */
.list-wrap { position: relative; height: 341px; }
.list { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-right: 24px; scrollbar-width: none; }
.list::-webkit-scrollbar { display: none; }

.row__link {
  position: relative;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 24px 8px 25px; border-radius: 16px;
}
.row:first-child .row__link { padding-top: 12px; }
/* hover plate stays inside the row box, so nothing gets clipped by the scroller */
.row__link::before {
  content: ""; position: absolute; inset: 3px 0; z-index: -1; border-radius: 16px;
  background: rgba(255, 255, 255, .045);
  opacity: 0; transform: scale(.985);
  transition: opacity .35s var(--ease-out), transform .5s var(--ease-out);
}
.row:first-child .row__link::before { top: 0; }
.row__link::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); transition: opacity .35s var(--ease-out); }
.row:last-child .row__link::after { display: none; }
.row__thumb { position: relative; width: 48px; height: 48px; border-radius: 8px; overflow: hidden; isolation: isolate; transition: transform .5s var(--spring); }
.row__body { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.row__title { font-size: 18px; line-height: 23px; width: fit-content; }
.row__desc { font-size: 14px; line-height: 24px; font-weight: 300; color: var(--ink-80); width: fit-content; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .tags { transition: transform .55s var(--ease-out); }
.row__arrow {
  position: absolute; right: 8px; top: 50%;
  width: 32px; height: 32px; margin-top: -16px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, .1);
  opacity: 0; transform: translateX(-10px) scale(.7);
  transition: opacity .3s var(--ease-out), transform .5s var(--spring);
}
.row:first-child .row__arrow { margin-top: -22px; }
@media (hover: hover) {
  .row:not(.is-loading) .row__link:hover::before { opacity: 1; transform: none; }
  .row:not(.is-loading) .row__link:hover .row__thumb { transform: scale(1.08) rotate(-2deg); }
  .row:not(.is-loading) .row__link:hover .tags { transform: translateX(-44px); }
  .row:not(.is-loading) .row__link:hover .row__arrow { opacity: 1; transform: none; }
  .list:has(.row__link:hover) .row__link::after { opacity: .35; }
}
.row__link:active::before { transform: scale(.99); }

.scrollbar {
  position: absolute; top: 0; right: 0; bottom: 0; width: 2px;
  border-radius: 16px; background: var(--track);
  transition: width .25s var(--ease-out), background-color .25s, opacity .25s;
}
.scrollbar::before { content: ""; position: absolute; inset: 0 -8px; }
.scrollbar__thumb {
  position: absolute; top: 0; left: 0; right: 0;
  height: var(--th, 120px); border-radius: 13px; background: var(--thumb);
  transform: translateY(var(--ty, 0px)); cursor: grab; will-change: transform;
}
.scrollbar:hover, .scrollbar.is-dragging { width: 4px; background: rgba(255, 255, 255, .08); }
.scrollbar.is-dragging .scrollbar__thumb { cursor: grabbing; }
.list-wrap.no-scroll .scrollbar { opacity: 0; pointer-events: none; }

/* ==========================================================================
   Case detail
   ========================================================================== */
.works__case { margin-top: 24px; display: grid; gap: 32px; min-width: 0; }

.case-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 0 12px; }
.case-head__text { display: grid; gap: 16px; justify-items: start; min-width: 0; }
.case-head__title { font-size: 24px; line-height: 32px; letter-spacing: -.01em; width: fit-content; max-width: 100%; }
.case-head__desc { display: grid; gap: 12px; width: 100%; }
.case-head__desc.ld::after {
  inset: 0; border-radius: 0;
  -webkit-mask: repeating-linear-gradient(to bottom, transparent 0 6px, #000 6px 18px, transparent 18px 24px);
  mask: repeating-linear-gradient(to bottom, transparent 0 6px, #000 6px 18px, transparent 18px 24px);
}
.case-head__desc p { font-size: 16px; line-height: 24px; font-weight: 300; color: var(--ink-80); max-width: 1074px; }

/* «Сайт проекта» — icon tile + caption on desktop, white bar on mobile */
.site-link {
  display: grid; justify-items: center; gap: 8px; width: 102px;
  font-size: 16px; line-height: 24px; font-weight: 300; color: var(--ink-80);
  transition: color .3s var(--ease-out);
}
.site-link__icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--chip-hi);
  display: grid; place-items: center;
  transition: background-color .3s var(--ease-out), transform .5s var(--spring);
}
.site-link__icon svg { transition: transform .9s var(--ease-out); }
@media (hover: hover) {
  .site-link:hover { color: var(--ink); }
  .site-link:hover .site-link__icon { background-color: rgba(255, 255, 255, .26); transform: translateY(-2px); }
  .site-link:hover .site-link__icon svg { transform: rotate(160deg); }
}
.site-link:active .site-link__icon { transform: scale(.92); }

/* Gallery */
.gallery { position: relative; min-width: 0; }
.gallery__stage {
  position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 1216 / 644; border-radius: 24px;
  background-color: var(--well);
  cursor: zoom-in; touch-action: pan-y;
  transform: translateZ(0);
}
.gallery__stage.media-sk { background-color: var(--sk-base); }
.gallery__slide {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0; transform: translate3d(calc(var(--dir, 1) * 3%), 0, 0) scale(1.01);
  transition: opacity .6s var(--ease-out), transform .9s var(--ease-out);
  pointer-events: none;
}
.gallery__slide.is-active { opacity: 1; transform: none; z-index: 2; }
.gallery__slide.is-leaving { opacity: 0; transform: translate3d(calc(var(--dir, 1) * -3%), 0, 0) scale(.995); }
.gallery__slide img { width: 100%; height: 100%; object-fit: cover; object-position: top center; user-select: none; -webkit-user-drag: none; }
.gallery__zoom {
  position: absolute; z-index: 3; top: 16px; right: 16px;
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--nav); color: #fff;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  opacity: 0; transform: scale(.8);
  transition: opacity .3s var(--ease-out), transform .45s var(--spring);
  pointer-events: none;
}
@media (hover: hover) {
  .gallery__stage:hover .gallery__zoom { opacity: 1; transform: none; }
  .gallery__stage:hover .gallery__slide.is-active img { transform: scale(1.012); }
}
.gallery__slide img { transition: transform 1.2s var(--ease-out); }

.gallery__nav {
  position: absolute; z-index: 4; left: 50%; bottom: 24px;
  display: flex; gap: 6px; padding: 8px; border-radius: 16px;
  background: var(--nav);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  transform: translateX(-50%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}
.gallery__thumb {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; isolation: isolate;
  transition: transform .45s var(--spring);
}
.gallery__thumb img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s var(--ease-out); }
.gallery__thumb.is-sharp img { opacity: 1; }
.gallery__thumb::after {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit;
  background: rgba(0, 0, 0, .2);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .7);
  opacity: 0; transition: opacity .35s var(--ease-out);
}
.gallery__thumb[aria-selected="true"]::after { opacity: 1; }
@media (hover: hover) { .gallery__thumb:hover { transform: translateY(-3px); } }
.gallery__thumb:active { transform: scale(.92); }
.gallery__count { display: none; }

/* ==========================================================================
   Lightbox
   ========================================================================== */
.lightbox {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(12, 11, 10, .72);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  opacity: 0; transition: opacity .35s var(--ease-out);
}
.lightbox.is-on { opacity: 1; }
.lightbox__scroller { max-width: 100vw; max-height: 100dvh; padding: 72px 88px; overflow: auto; overscroll-behavior: contain; display: grid; place-items: center; }
.lightbox__img {
  max-width: min(1920px, calc(100vw - 176px)); max-height: calc(100dvh - 144px); width: auto; height: auto;
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  transform: scale(.96); opacity: 0;
  transition: transform .55s var(--ease-out), opacity .4s var(--ease-out);
}
.lightbox.is-on .lightbox__img { transform: none; opacity: 1; }
.lightbox__btn {
  position: fixed; z-index: 2;
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); color: #fff;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  transition: background-color .25s, transform .4s var(--spring);
}
@media (hover: hover) { .lightbox__btn:hover { background: rgba(255, 255, 255, .22); } }
.lightbox__btn:active { transform: scale(.9); }
.lightbox__close { top: 20px; right: 20px; }
.lightbox__prev { left: 20px; top: 50%; margin-top: -22px; }
.lightbox__next { right: 20px; top: 50%; margin-top: -22px; }
.lightbox__caption { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); font-size: 14px; line-height: 18px; color: var(--ink-80); white-space: nowrap; }
.lightbox.is-single .lightbox__prev, .lightbox.is-single .lightbox__next { display: none; }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer { padding: 24px 12px; display: grid; gap: 4px; justify-items: start; }
.footer__name { font-size: 16px; line-height: 21px; width: fit-content; }
.footer__copy { font-size: 14px; line-height: 18px; color: var(--ink-40); width: fit-content; max-width: 100%; }

/* ==========================================================================
   Narrower desktops / tablets
   ========================================================================== */
@media (max-width: 1180px) {
  .cases { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .cases { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr) 240px; }
  .about__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Mobile (Figma 390)
   ========================================================================== */
@media (max-width: 767px) {
  :root { --gap: 8px; --panel-r: 24px; }
  html { scrollbar-gutter: auto; }
  .bg__drift--b { display: none; } /* one drifting layer is plenty on phones */
  .glass { -webkit-backdrop-filter: blur(24px) saturate(1.1); backdrop-filter: blur(24px) saturate(1.1); }

  .layout { width: calc(100% - 15px); max-width: 520px; padding: 14px 0 env(safe-area-inset-bottom); }

  /* hero */
  .hero { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 8px 8px 20px; min-height: 0; }
  .avatar { order: -1; height: 174px; }
  .tg-pill { display: none; }
  .hero__info { padding: 0 12px; justify-items: center; text-align: center; gap: 24px; }
  .hero__text { justify-items: center; }
  .hero__name { font-size: 20px; line-height: 26px; }
  .hero__lead { font-size: 14px; line-height: 24px; }
  .chips { justify-content: center; }
  .tg-btn { display: flex; }

  /* about */
  .about { --pad-y: 16px; --pad-b: 16px; border-radius: 16px; padding: var(--pad-y) 8px var(--pad-b); transition: padding .65s var(--ease-out); }
  .about.is-open { --pad-y: 16px; --pad-b: 8px; }
  .about__head { padding: 0 4px 0 8px; }
  .about.is-open .about__head { padding-left: 4px; }
  .about__head::before { inset: -16px -8px -8px; }
  .about__title { font-size: 16px; line-height: 21px; }
  .about__toggle { font-size: 14px; }
  .about__grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .about__main { padding: 10px 4px 0; }
  .about__heading { font-size: 18px; line-height: 24px; letter-spacing: -.015em; }
  .about__heading .br-desk { display: none; }
  .about__text { font-size: 14px; line-height: 20px; }
  .grade { border-radius: 16px; min-height: 0; }
  .star { width: 24px; height: 24px; border-radius: 11px; }
  .star svg { width: 15.5px; height: 15.5px; }
  .grade__title { margin-top: 8px; font-size: 16px; line-height: 21px; }
  .grade__text { margin-top: 8px; font-size: 14px; line-height: 20px; }

  /* works */
  .works { min-height: 0; padding: 8px 8px 16px; }
  .is-case .works { padding-bottom: 16px; }
  .works__bar { height: auto; padding: 16px; }
  .switch { display: none; }
  .is-case .url__host { display: none; }
  .works__stage { margin-top: 24px; }
  .list-wrap { display: none !important; }
  .cases[hidden] { display: grid !important; }

  /* card → row: text left, image right */
  .cases { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .case__link { display: grid; grid-template-columns: minmax(0, 1fr) 115px; column-gap: 12px; align-items: start; }
  .case__media { grid-column: 2; grid-row: 1 / span 2; width: 115px; height: 97px; aspect-ratio: auto; border-radius: 24px; }
  .case__open { display: none; }
  .case__body { grid-column: 1; grid-row: 1; padding: 8px 4px 0; }
  .case__desc { height: 40px; -webkit-line-clamp: 2; }
  .case__desc.ld--lines::after {
    -webkit-mask: linear-gradient(#000 0 0) 0 4px / 100% 12px no-repeat, linear-gradient(#000 0 0) 0 24px / 70% 12px no-repeat;
    mask: linear-gradient(#000 0 0) 0 4px / 100% 12px no-repeat, linear-gradient(#000 0 0) 0 24px / 70% 12px no-repeat;
  }
  .case .tags { grid-column: 1; grid-row: 2; margin-top: 16px; padding-left: 0; }

  /* case detail */
  .works__case { gap: 24px; }
  .case-head { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 0; }
  .case-head__text { padding: 0 12px; }
  .case-head__title { font-size: 20px; line-height: 28px; font-weight: 500; letter-spacing: 0; }
  .case-head__desc p { font-size: 14px; line-height: 24px; }
  .site-link {
    display: flex; align-items: center; justify-content: space-between; width: 100%; margin: 0;
    height: 50px; padding: 0 12px; border-radius: 16px;
    background: #fff; color: var(--dark-ink); font-size: 14px; line-height: 18px; font-weight: 400;
    transition: transform .25s var(--ease-out);
  }
  .site-link__icon { order: 2; width: auto; height: auto; background: none; color: var(--dark-ink); }
  .site-link:active { transform: scale(.98); }
  .site-link:active .site-link__icon svg { transform: rotate(160deg); }
  .gallery { display: grid; gap: 12px; justify-items: center; }
  .gallery__stage { width: 100%; aspect-ratio: 359 / 190; border-radius: 16px; }
  .gallery__zoom { display: none; }
  .gallery__nav { position: static; transform: none; padding: 8px; border-radius: 16px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .gallery__thumb { width: 44px; height: 44px; border-radius: 8.5px; }

  /* lightbox: let wide screenshots be panned horizontally */
  .lightbox__scroller { width: 100vw; height: 100dvh; padding: 72px 12px; place-items: center start; }
  .lightbox__img { max-width: none; width: auto; height: min(62dvh, 520px); max-height: none; border-radius: 12px; }
  .lightbox__prev, .lightbox__next { top: auto; bottom: 16px; margin: 0; }
  .lightbox__prev { left: 16px; }
  .lightbox__next { right: 16px; }
  .lightbox__caption { bottom: 30px; max-width: calc(100vw - 140px); overflow: hidden; text-overflow: ellipsis; }

  /* footer */
  .footer { justify-items: center; text-align: center; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .bg__drift { animation: none !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; transition-delay: 0s !important;
  }
  .url__caret { animation: none; }
}
