/* =========================================================
   mori — портфолио
   1. Токены и сброс
   2. Фон и зерно
   3. Прелоадер
   4. Курсор
   5. Навигация
   6. Hero
   7. Бегущая строка
   8. Секции: общее
   9. Обо мне
   10. Работы
   11. Стек
   12. Контакты
   13. Подвал
   14. Лайтбокс / наверх
   15. Анимации появления
   16. Адаптив
   ========================================================= */

/* ---------- 1. ТОКЕНЫ И СБРОС ---------- */
:root {
  --bg: #050507;
  --bg-soft: #0a0a10;
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #f3f3f5;
  --muted: #8a8a96;
  --muted-2: #5d5d68;

  --accent: #ff2b2b;
  --accent-soft: rgba(255, 43, 43, 0.14);
  --accent-2: #ff7a3d;
  --cold: #6c8cff;
  --cold-soft: rgba(108, 140, 255, 0.14);

  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 30px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --nav-h: 76px;
  --glow: 0 0 0 1px var(--line), 0 26px 60px -28px rgba(0, 0, 0, 0.9);
}

html[data-theme="light"] {
  --bg: #f2f0ec;
  --bg-soft: #ffffff;
  --surface: rgba(12, 12, 20, 0.025);
  --surface-2: rgba(12, 12, 20, 0.05);
  --line: rgba(12, 12, 20, 0.11);
  --line-strong: rgba(12, 12, 20, 0.22);
  --text: #0d0d12;
  --muted: #55555f;
  --muted-2: #86868f;
  --accent: #e01b1b;
  --accent-soft: rgba(224, 27, 27, 0.10);
  --cold: #3552d6;
  --cold-soft: rgba(53, 82, 214, 0.10);
  --glow: 0 0 0 1px var(--line), 0 26px 50px -30px rgba(20, 20, 40, 0.35);
}

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--accent) transparent;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.6s var(--ease-soft), color 0.6s var(--ease-soft);
}

body.is-locked { overflow: hidden; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul { list-style: none; }
em { font-style: normal; color: var(--accent); }
strong { font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 7px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 10px;
  border: 3px solid var(--bg);
}

/* ---------- 2. ФОН И ЗЕРНО ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-soft), var(--bg) 62%);
  transition: background 0.6s var(--ease-soft);
}

.bg__aurora {
  position: absolute;
  border-radius: 50%;
  /* было blur(90px): пятно и так мягкое из-за радиального градиента,
     а большой радиус заставляет растеризовать огромную область */
  filter: blur(44px);
  opacity: 0.5;
  /* translate — отдельное от transform свойство, поэтому не конфликтует
     с анимацией дрейфа. Сюда пишется сдвиг от курсора. */
  translate: var(--ax, 0px) var(--ay, 0px);
  will-change: transform, translate;
}
.bg__aurora--1 {
  width: 62vw; height: 62vw;
  top: -26vw; left: -14vw;
  background: radial-gradient(circle, rgba(255, 43, 43, 0.42), transparent 66%);
  animation: drift1 26s ease-in-out infinite;
}
.bg__aurora--2 {
  width: 54vw; height: 54vw;
  bottom: -22vw; right: -12vw;
  background: radial-gradient(circle, rgba(108, 140, 255, 0.36), transparent 66%);
  animation: drift2 32s ease-in-out infinite;
}
.bg__aurora--3 {
  width: 40vw; height: 40vw;
  top: 42%; left: 46%;
  background: radial-gradient(circle, rgba(255, 122, 61, 0.24), transparent 68%);
  animation: drift3 38s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(8vw, 6vw, 0) scale(1.16); }
}
@keyframes drift2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.05); }
  50% { transform: translate3d(-9vw, -5vw, 0) scale(0.9); }
}
@keyframes drift3 {
  0%, 100% { transform: translate3d(-50%, -50%, 0) scale(1); }
  33% { transform: translate3d(-38%, -60%, 0) scale(1.2); }
  66% { transform: translate3d(-60%, -42%, 0) scale(0.95); }
}

.bg__grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 76px 76px;
  opacity: 0.5;
  mask-image: radial-gradient(100% 76% at 50% 26%, #000 12%, transparent 78%);
  -webkit-mask-image: radial-gradient(100% 76% at 50% 26%, #000 12%, transparent 78%);
  animation: gridpan 44s linear infinite;
}
@keyframes gridpan {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-76px, -76px, 0); }
}

.bg__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 40%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}
html[data-theme="light"] .bg__vignette {
  background: radial-gradient(120% 100% at 50% 40%, transparent 46%, rgba(60, 50, 40, 0.14) 100%);
}

.grain {
  position: fixed;
  /* было -50%: слой получался 200% вьюпорта — это гигабайты растра
     на большом экране. Сдвиг анимации всего 3%, поэтому хватает -12%. */
  inset: -12%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainmove 0.7s steps(3) infinite;
}
@keyframes grainmove {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}
html[data-theme="light"] .grain { opacity: 0.03; }

/* ---------- 3. ПРЕЛОАДЕР ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.preloader.is-done { opacity: 0; visibility: hidden; }

.preloader__glow {
  position: absolute;
  width: 46vw; height: 46vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 43, 43, 0.34), transparent 62%);
  filter: blur(44px);
  animation: pulseGlow 2.6s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 1; }
}

.preloader__inner {
  position: relative;
  width: min(340px, 76vw);
  text-align: center;
}
.preloader__word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(52px, 13vw, 92px);
  letter-spacing: -0.04em;
  line-height: 1;
  display: flex;
  justify-content: center;
  gap: 0.02em;
}
.preloader__word span {
  display: inline-block;
  animation: dropIn 0.8s var(--ease) backwards;
  opacity: 0.96;
}
.preloader__word span:nth-child(1) { animation-delay: 0.05s; }
.preloader__word span:nth-child(2) { animation-delay: 0.14s; }
.preloader__word span:nth-child(3) { animation-delay: 0.23s; }
.preloader__word span:nth-child(4) { animation-delay: 0.32s; color: var(--accent); }
@keyframes dropIn {
  from { opacity: 0; transform: translateY(60%) rotate(6deg); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

.preloader__bar {
  margin: 26px 0 12px;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.preloader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px var(--accent);
  transition: width 0.2s linear;
}
.preloader__meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.preloader__num { color: var(--accent); }

/* ---------- 4. КУРСОР ---------- */
.cursor-ring,
.cursor-dot {
  position: fixed;
  top: 0; left: 0;
  z-index: 300;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s;
}
.cursor-ring {
  width: 38px; height: 38px;
  border: 1px solid var(--accent);
  margin: -19px 0 0 -19px;
  transition: width 0.28s var(--ease), height 0.28s var(--ease),
              margin 0.28s var(--ease), background 0.28s, opacity 0.3s,
              border-color 0.3s;
}
.cursor-dot {
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  background: var(--accent);
}
.cursor-ring.is-hover {
  width: 78px; height: 78px;
  margin: -39px 0 0 -39px;
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cursor-ring.is-down { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
body.has-cursor .cursor-ring,
body.has-cursor .cursor-dot { opacity: 1; }
body.has-cursor,
body.has-cursor * { cursor: none !important; }

/* ---------- 5. НАВИГАЦИЯ ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  /* прогресс растёт через transform, а не через width: width заставлял бы
     браузер пересчитывать раскладку на каждой прокрутке */
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
  z-index: 120;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--cold));
  box-shadow: 0 0 12px var(--accent);
}

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  transition: height 0.4s var(--ease), background 0.4s, border-color 0.4s;
  border-bottom: 1px solid transparent;
}
.nav.is-stuck {
  height: 64px;
  /* без backdrop-filter: размытие фона у закреплённой шапки пересчитывается
     на каждом кадре прокрутки и стоит дороже всего остального на странице */
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom-color: var(--line);
  box-shadow: 0 12px 34px -26px rgba(0, 0, 0, 0.95);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .nav.is-stuck { background: rgba(5, 5, 7, 0.9); }
  html[data-theme="light"] .nav.is-stuck { background: rgba(242, 240, 236, 0.92); }
}
.nav.is-hidden { transform: translateY(-100%); }

.nav__inner {
  width: min(1240px, 100% - 48px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav__logo {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.nav__logo-mark {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  margin-right: 8px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 17px;
  transform: translateY(3px);
  transition: transform 0.5s var(--ease), box-shadow 0.5s;
}
.nav__logo:hover .nav__logo-mark {
  transform: translateY(3px) rotate(-12deg) scale(1.08);
  box-shadow: 0 0 26px var(--accent);
}
.nav__logo-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.25; transform: scale(0.7); }
}

.nav__links { display: flex; gap: 4px; }
.nav__link {
  position: relative;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 999px;
  transition: color 0.3s;
  overflow: hidden;
}
.nav__link span { position: relative; z-index: 1; }
.nav__link::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-2);
  transform: scale(0.4);
  opacity: 0;
  transition: transform 0.45s var(--ease), opacity 0.3s;
}
.nav__link:hover, .nav__link.is-active { color: var(--text); }
.nav__link:hover::before, .nav__link.is-active::before { transform: scale(1); opacity: 1; }
.nav__link.is-active::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 3px;
  width: 5px; height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--accent);
}

.nav__actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle { display: grid; place-items: center; padding: 4px; }
.theme-toggle__track {
  position: relative;
  display: block;
  width: 52px; height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background 0.4s, border-color 0.4s;
}
.theme-toggle__thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.45s var(--ease);
}
html[data-theme="light"] .theme-toggle__thumb { transform: translateX(24px); }

.burger {
  display: none;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  position: relative;
}
.burger span {
  position: absolute;
  left: 12px;
  width: 18px; height: 1.6px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.4s var(--ease), opacity 0.3s, width 0.4s var(--ease);
}
.burger span:nth-child(1) { top: 15px; }
.burger span:nth-child(2) { top: 20.4px; width: 13px; }
.burger span:nth-child(3) { top: 25.8px; }
.burger.is-open span:nth-child(1) { transform: translateY(5.4px) rotate(45deg); }
.burger.is-open span:nth-child(2) { opacity: 0; width: 18px; }
.burger.is-open span:nth-child(3) { transform: translateY(-5.4px) rotate(-45deg); }

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  clip-path: circle(0% at calc(100% - 42px) 40px);
  transition: clip-path 0.75s var(--ease), visibility 0.75s var(--ease);
  visibility: hidden;
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .mobile-menu { background: rgba(5, 5, 7, 0.95); }
}
.mobile-menu.is-open { clip-path: circle(150% at calc(100% - 42px) 40px); visibility: visible; }

.mobile-menu__inner { display: flex; flex-direction: column; gap: 6px; padding: 0 32px; width: min(520px, 100%); }
.mobile-menu__link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 9vw, 46px);
  letter-spacing: -0.03em;
  color: var(--text);
  opacity: 0;
  transform: translateY(30px);
  transition: color 0.3s, transform 0.3s var(--ease);
  padding: 6px 0;
}
.mobile-menu.is-open .mobile-menu__link {
  opacity: 1;
  transform: none;
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease), color 0.3s;
}
.mobile-menu.is-open .mobile-menu__link:nth-child(1) { transition-delay: 0.16s; }
.mobile-menu.is-open .mobile-menu__link:nth-child(2) { transition-delay: 0.24s; }
.mobile-menu.is-open .mobile-menu__link:nth-child(3) { transition-delay: 0.32s; }
.mobile-menu.is-open .mobile-menu__link:nth-child(4) { transition-delay: 0.4s; }
.mobile-menu__link::before {
  content: attr(data-index);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
}
.mobile-menu__link:hover { color: var(--accent); transform: translateX(10px); }
.mobile-menu__tag {
  margin-top: 26px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.6s 0.5s;
}
.mobile-menu.is-open .mobile-menu__tag { opacity: 1; }

/* ---------- 6. HERO ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: calc(var(--nav-h) + 40px) 0 90px;
}
.hero__inner {
  width: min(1240px, 100% - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(30px, 5vw, 80px);
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 12px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow__pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #35d07f;
  box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.6);
  animation: ping 2s ease-out infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(53, 208, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 127, 0); }
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(64px, 15vw, 190px);
  line-height: 0.86;
  letter-spacing: -0.055em;
  margin-bottom: 22px;
  text-transform: lowercase;
}
.hero__title-line { display: block; }
.hero__title .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em) rotate(5deg);
  animation: charIn 1s var(--ease) forwards;
}
.hero__title .char:nth-child(1) { animation-delay: 0.12s; }
.hero__title .char:nth-child(2) { animation-delay: 0.20s; }
.hero__title .char:nth-child(3) { animation-delay: 0.28s; }
.hero__title .char:nth-child(4) { animation-delay: 0.36s; }
.hero__title .char:last-child { color: var(--accent); }
@keyframes charIn {
  to { opacity: 1; transform: none; }
}
body:not(.is-ready) .hero__title .char { animation-play-state: paused; }
body.is-ready .hero__title .char { animation-play-state: running; }

.hero__quote {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px;
  max-width: 34ch;
  margin-bottom: 22px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(17px, 2.1vw, 25px);
  line-height: 1.42;
  letter-spacing: -0.01em;
}
.hero__quote-mark {
  color: var(--accent);
  font-weight: 600;
  opacity: 0;
  transform: translateX(-7px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.hero__quote-mark--end { transform: translateX(7px); }
.hero__quote.is-done .hero__quote-mark { opacity: 1; transform: none; }
.hero__quote-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--accent);
  transform: translateY(0.16em);
  animation: caret 1s steps(1) infinite;
  transition: opacity 0.4s var(--ease);
}
.hero__quote.is-done .hero__quote-caret { opacity: 0; animation: none; }
@keyframes caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.hero__lead {
  max-width: 46ch;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: clamp(15px, 1.6vw, 17.5px);
}

.hero__tags { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 32px; }
.tag {
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--text);
  transition: transform 0.4s var(--ease), border-color 0.3s, background 0.3s, color 0.3s;
}
.tag:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.tag--hot { border-color: rgba(255, 43, 43, 0.5); background: var(--accent-soft); color: var(--accent); }
.tag--cold { border-color: rgba(108, 140, 255, 0.45); background: var(--cold-soft); color: var(--cold); }

.hero__cta { display: flex; flex-wrap: wrap; gap: 14px; }
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 28px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.35s var(--ease), color 0.4s, border-color 0.4s;
}
.btn svg { width: 18px; height: 18px; transition: transform 0.4s var(--ease); }
.btn:hover svg { transform: translateX(5px); }
.btn--primary {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 40px -16px var(--accent);
}
.btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  opacity: 0;
  transition: opacity 0.45s;
}
.btn--primary:hover::after { opacity: 1; }
.btn--ghost {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: var(--surface);
}
.btn--ghost::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--text);
  transform: translateY(101%);
  transition: transform 0.5s var(--ease);
}
.btn--ghost:hover { color: var(--bg); border-color: var(--text); }
.btn--ghost:hover::after { transform: translateY(0); }

/* аватар */
.hero__col--media { display: grid; place-items: center; perspective: 1100px; }
.avatar {
  position: relative;
  width: min(400px, 78vw);
  transform-style: preserve-3d;
}
.avatar__rings { position: absolute; inset: -14%; z-index: 0; }
.avatar__rings span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  animation: spin 18s linear infinite;
}
.avatar__rings span:nth-child(2) { inset: 8%; border-style: dashed; border-color: rgba(255, 43, 43, 0.28); animation-duration: 26s; animation-direction: reverse; }
.avatar__rings span:nth-child(3) { inset: 16%; border-color: rgba(108, 140, 255, 0.24); animation-duration: 34s; }
.avatar__rings span::before {
  content: "";
  position: absolute;
  top: -3px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar__frame {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: var(--glow), 0 40px 90px -40px rgba(0, 0, 0, 0.95);
  transform: translateZ(0);
}
.avatar__frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(255, 43, 43, 0.16) 100%);
  mix-blend-mode: screen;
}
.avatar__frame img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  filter: contrast(1.06) saturate(1.05) brightness(0.98);
  transition: transform 0.9s var(--ease), filter 0.6s;
}
.avatar:hover .avatar__frame img { transform: scale(1.05); filter: contrast(1.12) saturate(1.15) brightness(1.04); }
.avatar__scan {
  position: absolute;
  left: 0; right: 0;
  height: 34%;
  top: -34%;
  background: linear-gradient(180deg, transparent, rgba(255, 43, 43, 0.16), transparent);
  /* едет через transform: анимация top заставляла браузер пересчитывать
     раскладку и перерисовывать слой на каждом кадре */
  animation: scan 5.5s var(--ease-soft) infinite;
  will-change: transform;
  pointer-events: none;
}
@keyframes scan {
  0% { transform: translateY(0); }
  60%, 100% { transform: translateY(406%); }   /* 406% от своей высоты = 138% высоты рамки */
}

.avatar__badge {
  position: absolute;
  z-index: 2;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.9);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .avatar__badge { background: rgba(8, 8, 12, 0.9); }
  html[data-theme="light"] .avatar__badge { background: rgba(255, 255, 255, 0.92); }
}
.avatar__badge--1 { top: 8%; left: -12%; animation: float 6s ease-in-out infinite; }
.avatar__badge--2 { top: 32%; right: -14%; animation: float 7.5s ease-in-out infinite 0.6s; }
.avatar__badge--3 { bottom: 26%; left: -16%; animation: float 6.8s ease-in-out infinite 1.1s; }
.avatar__badge--4 { bottom: 6%; right: -10%; animation: float 8.2s ease-in-out infinite 0.3s; }
.avatar__badge--1 span { color: var(--accent); }
.avatar__badge--2 span { color: var(--cold); }
@keyframes float {
  0%, 100% { transform: translateY(0) translateZ(30px); }
  50% { transform: translateY(-14px) translateZ(30px); }
}

.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.hero__scroll-line {
  width: 1px;
  height: 46px;
  background: linear-gradient(var(--accent), transparent);
  animation: scrollLine 2.2s ease-in-out infinite;
}
@keyframes scrollLine {
  0% { transform: scaleY(0.2); transform-origin: top; opacity: 0; }
  40% { transform: scaleY(1); transform-origin: top; opacity: 1; }
  100% { transform: scaleY(0.2); transform-origin: bottom; opacity: 0; }
}

/* ---------- 7. БЕГУЩАЯ СТРОКА ---------- */
.marquee {
  position: relative;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee__track {
  display: flex;
  align-items: center;
  gap: 34px;
  width: max-content;
  animation: marquee 34s linear infinite;
}
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee__track span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(16px, 2.2vw, 26px);
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s;
}
.marquee__track span:hover { color: var(--accent); }
.marquee__sep { color: var(--accent) !important; font-size: 11px !important; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- 8. СЕКЦИИ: ОБЩЕЕ ---------- */
.section { position: relative; padding: clamp(80px, 12vh, 150px) 0; }
.container { width: min(1240px, 100% - 48px); margin: 0 auto; }

.section__head { margin-bottom: clamp(40px, 6vw, 70px); }
.section__index {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--accent);
}
.section__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.section__sub { margin-top: 12px; max-width: 52ch; color: var(--muted); font-size: clamp(14px, 1.6vw, 16.5px); }

/* ---------- 9. ОБО МНЕ ---------- */
.about__grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: clamp(30px, 5vw, 70px);
  align-items: start;
}
.about__text p { margin-bottom: 20px; color: var(--muted); font-size: clamp(15px, 1.65vw, 17px); }
.about__text p strong { color: var(--text); }
.about__list { display: grid; gap: 12px; margin-top: 28px; }
.about__list li {
  position: relative;
  padding: 15px 18px 15px 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14.5px;
  color: var(--muted);
  transition: transform 0.45s var(--ease), border-color 0.35s, background 0.35s, color 0.35s;
}
.about__list li b { color: var(--text); font-weight: 600; }
.about__list li::before {
  content: "";
  position: absolute;
  left: 18px; top: 50%;
  width: 9px; height: 9px;
  margin-top: -4.5px;
  border-radius: 3px;
  background: var(--accent);
  transform: rotate(45deg);
  transition: transform 0.45s var(--ease), box-shadow 0.4s;
}
.about__list li:hover {
  transform: translateX(8px);
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}
.about__list li:hover::before { transform: rotate(135deg) scale(1.15); box-shadow: 0 0 16px var(--accent); }

.about__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.stat {
  position: relative;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.5s var(--ease), border-color 0.4s, background 0.4s;
}
.stat::before {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  transition: transform 0.6s var(--ease);
}
.stat:nth-child(even)::before { background: radial-gradient(circle, var(--cold-soft), transparent 68%); }
.stat:hover { transform: translateY(-7px); border-color: var(--line-strong); background: var(--surface-2); }
.stat:hover::before { transform: scale(1.7) translate(-12%, -12%); }
.stat__value {
  position: relative;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 4.6vw, 52px);
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}
.stat__label { position: relative; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- 10. РАБОТЫ ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 34px; }
.filter {
  padding: 9px 19px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s, background 0.3s, transform 0.4s var(--ease);
}
.filter:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-2px); }
.filter.is-active { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 10px 30px -14px var(--accent); }

.works__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto;
  gap: clamp(16px, 2.4vw, 28px);
  align-items: stretch;
}
.card--big { grid-column: span 2; }
.card--tall { grid-row: span 2; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: border-color 0.5s, box-shadow 0.6s, transform 0.6s var(--ease), opacity 0.5s;
  box-shadow: 0 24px 60px -46px rgba(0, 0, 0, 0.9);
  will-change: transform;
}
.card.is-hidden { display: none; }
.card.is-filtered-out { opacity: 0; transform: scale(0.9); filter: blur(7px); }
.card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 34px 80px -44px rgba(255, 43, 43, 0.28), 0 0 0 1px var(--line);
}
.card__glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(255, 43, 43, 0.16), transparent 65%);
  pointer-events: none;
  z-index: 2;
}
.card:hover .card__glow { opacity: 1; }

.card__media {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
}
.card__slider { position: relative; display: grid; }
.card__slider img {
  grid-area: 1 / 1;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.7s var(--ease), transform 1.1s var(--ease), filter 0.5s;
  filter: saturate(0.85) brightness(0.86);
}
.card--tall .card__media { flex: 1; min-height: 250px; }
.card--tall .card__slider { height: 100%; }
.card--tall .card__slider img { aspect-ratio: auto; height: 100%; }
.card__slider img.is-active { opacity: 1; transform: scale(1); }
.card:hover .card__slider img.is-active { transform: scale(1.05); filter: saturate(1.05) brightness(1); }

.card__media-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, 0.72) 100%);
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 3;
}
.card__media:hover .card__media-overlay { opacity: 1; }
.card__zoom {
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  transform: translateY(14px) scale(0.94);
  transition: transform 0.55s var(--ease);
}
.card__media:hover .card__zoom { transform: none; }

.card__dots {
  position: absolute;
  left: 16px; bottom: 14px;
  z-index: 4;
  display: flex;
  gap: 7px;
}
.card__dots button {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: width 0.45s var(--ease), background 0.3s;
}
.card__dots button.is-active { width: 22px; border-radius: 4px; background: var(--accent); }

.card__body { padding: 24px 26px 28px; display: flex; flex-direction: column; flex: 1; }
.card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card__num { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.18em; color: var(--accent); }
.card__year { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-2); }
.card__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 2.6vw, 32px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 12px;
  transition: color 0.35s;
}
.card:hover .card__title { color: var(--accent); }
.card__desc { color: var(--muted); font-size: 14.5px; margin-bottom: 20px; }
.card__stack { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.card__stack li {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s, transform 0.4s var(--ease);
}
.card:hover .card__stack li { color: var(--text); border-color: var(--line-strong); }
.card__stack li:hover { transform: translateY(-2px); color: var(--accent); border-color: var(--accent); }

/* ---------- 11. СТЕК ---------- */
.stack__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 40px;
  margin-bottom: 46px;
}
.skill { position: relative; }
.skill__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 11px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.skill__head span:first-child { color: var(--text); letter-spacing: 0.02em; }
.skill__pct { color: var(--accent); }
.skill__bar {
  position: relative;
  height: 5px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.skill__bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px -2px var(--accent);
  transition: width 1.4s var(--ease);
}
.skill__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 22px, var(--bg) 22px 24px);
  opacity: 0.55;
  pointer-events: none;
}

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  transition: color 0.35s, border-color 0.35s, background 0.35s, transform 0.45s var(--ease);
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-4px) rotate(-1.5deg);
}

/* ---------- 12. КОНТАКТЫ ---------- */
.contact__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  max-width: 560px;
}
.contact__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.5s var(--ease), border-color 0.4s, background 0.4s;
}
.contact__card::before {
  content: "";
  position: absolute;
  inset: auto -20% -70% auto;
  width: 170px; height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  transition: transform 0.6s var(--ease);
}
.contact__card:hover { transform: translateY(-8px); border-color: var(--line-strong); background: var(--surface-2); }
.contact__card:hover::before { transform: scale(1.9); }
.contact__label { position: relative; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.contact__value { position: relative; font-size: clamp(16px, 1.9vw, 20px); font-weight: 600; letter-spacing: -0.01em; }
.contact__arrow { position: absolute; top: 24px; right: 24px; font-size: 18px; color: var(--muted); transition: transform 0.45s var(--ease), color 0.3s; }
.contact__card:hover .contact__arrow { transform: translate(4px, -4px); color: var(--accent); }
.contact__copy {
  position: relative;
  margin-top: 10px;
  align-self: flex-start;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.contact__copy:hover { color: var(--accent); border-color: var(--accent); }
.contact__copy.is-copied { color: #0b0b0f; background: var(--accent); border-color: var(--accent); }
.contact__note { margin-top: 26px; font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }

/* ---------- 13. ПОДВАЛ ---------- */
.footer {
  position: relative;
  border-top: 1px solid var(--line);
  padding: 38px 0;
  background: var(--surface);
}
.footer__inner {
  width: min(1240px, 100% - 48px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.footer__left { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.footer__logo { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.03em; }
.footer__logo span { color: var(--accent); }
.footer__copy { font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }
.footer__tag {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.3s;
}
.footer__tag:hover { color: var(--text); }
.footer__right a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  transition: color 0.3s;
}
.footer__right a:hover { color: var(--accent); }

/* ---------- 14. ЛАЙТБОКС / НАВЕРХ ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 60px 80px;
  background: rgba(3, 3, 5, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s var(--ease), visibility 0.45s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox__stage {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: scale(0.94);
  transition: transform 0.5s var(--ease);
}
.lightbox.is-open .lightbox__stage { transform: none; }
.lightbox__stage img {
  max-width: min(1180px, 100%);
  max-height: 76vh;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.95);
  object-fit: contain;
}
.lightbox__stage figcaption {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #b9b9c2;
  text-align: center;
}
.lightbox__close {
  position: absolute;
  top: 24px; right: 28px;
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 17px;
  transition: background 0.3s, transform 0.4s var(--ease), border-color 0.3s;
}
.lightbox__close:hover { background: var(--accent); border-color: var(--accent); transform: rotate(90deg); }
.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  transition: background 0.3s, transform 0.4s var(--ease), border-color 0.3s;
}
.lightbox__nav:hover { background: var(--accent); border-color: var(--accent); }
.lightbox__nav--prev { left: 22px; }
.lightbox__nav--next { right: 22px; }
.lightbox__nav--prev:hover { transform: translateY(-50%) translateX(-4px); }
.lightbox__nav--next:hover { transform: translateY(-50%) translateX(4px); }
.lightbox__counter {
  position: absolute;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #9a9aa4;
}

.to-top {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 80;
  width: 48px; height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.4s, visibility 0.4s, transform 0.5s var(--ease), background 0.3s, color 0.3s;
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .to-top { background: rgba(8, 8, 12, 0.94); }
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top svg { width: 20px; height: 20px; transition: transform 0.4s var(--ease); }
.to-top:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.to-top:hover svg { transform: translateY(-4px); }

/* ---------- 15. АНИМАЦИИ ПОЯВЛЕНИЯ ---------- */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 34px, 0);
  /* без blur: размытие на крупных блоках — самая дорогая часть появления,
     а opacity и transform считаются на видеокарте почти бесплатно */
  transition:
    opacity 0.9s var(--ease),
    transform 1s var(--ease);
}
/* сторона, с которой вылетает блок */
[data-reveal="left"]  { transform: translate3d(-56px, 12px, 0); }
[data-reveal="right"] { transform: translate3d(56px, 12px, 0); }
[data-reveal="up"]    { transform: translate3d(0, 56px, 0); }
[data-reveal="scale"] { transform: scale(0.9); }

[data-reveal].is-visible:not([data-tilt]) { opacity: 1; transform: none; }
/* слой под появление выделяем только на время самой анимации: держать
   промоушен на всех 25 блоках постоянно — это лишняя память и работа */
[data-reveal].is-visible:not(.is-settled) { will-change: opacity, transform; }
[data-reveal].is-settled { will-change: auto; }

/* Согласование появления и 3D-наклона: оба эффекта пишут в transform,
   поэтому собираем его из переменных. */
[data-tilt] {
  --rx: 0deg;
  --ry: 0deg;
  --rise: 0px;
  --px: 0px;
  --py: 0px;
  --scale: 1;
  transform:
    perspective(1100px)
    rotateX(var(--rx))
    rotateY(var(--ry))
    translate3d(var(--px), calc(var(--py) + var(--rise)), 0)
    scale(var(--scale));
  transition:
    transform 0.85s var(--ease),
    opacity 0.85s var(--ease),
    border-color 0.5s,
    box-shadow 0.6s;
}
[data-tilt][data-reveal] { --rise: 34px; }
[data-tilt][data-reveal].is-visible { --rise: 0px; opacity: 1; }
[data-tilt].is-tilting {
  transition:
    transform 0.14s linear,
    opacity 0.2s linear,
    border-color 0.5s,
    box-shadow 0.6s;
}
.avatar[data-tilt] { --scale: 1; }

/* ---------- 16. АДАПТИВ ---------- */
@media (max-width: 1180px) {
  .works__grid { grid-template-columns: repeat(2, 1fr); }
  .card--big { grid-column: span 2; }
  .card--tall { grid-row: auto; grid-column: span 2; }
  .card--tall .card__media { flex: none; min-height: 0; }
  .card--tall .card__slider { height: auto; }
  .card--tall .card__slider img { aspect-ratio: 16 / 10; height: auto; }
}

@media (max-width: 1080px) {
  .hero__inner { grid-template-columns: 1fr; gap: 54px; }
  .hero__col--media { order: -1; }
  .avatar { width: min(320px, 68vw); }
  .hero__scroll { display: none; }
  .about__grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav__links { display: none; }
  .burger { display: block; }
  .stack__grid { grid-template-columns: 1fr; }
  .works__grid { grid-template-columns: 1fr; }
  .card--big, .card--tall { grid-column: auto; grid-row: auto; }
  .lightbox { padding: 70px 20px; }
  .lightbox__nav { width: 44px; height: 44px; font-size: 22px; }
  .lightbox__nav--prev { left: 8px; }
  .lightbox__nav--next { right: 8px; }
}

@media (max-width: 640px) {
  .container, .nav__inner, .hero__inner, .footer__inner { width: min(100%, 100% - 32px); }
  .about__stats { grid-template-columns: 1fr 1fr; }
  .contact__grid { grid-template-columns: 1fr; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
  .card__body { padding: 20px 20px 24px; }
  .to-top { right: 16px; bottom: 16px; }
  .avatar__badge--1 { left: -4%; }
  .avatar__badge--3 { left: -6%; }
}

/* на тач-устройствах прячем курсор */
@media (hover: none), (pointer: coarse) {
  .cursor-ring, .cursor-dot { display: none !important; }
}

/* ---------- 16.1. БЕЗ JS ВСЁ ДОЛЖНО БЫТЬ ВИДНО ----------
   Все появления и каскады запускает скрипт. Если он не выполнился,
   показываем контент как есть, вместо пустого экрана. */
html:not(.js) [data-reveal],
html:not(.js) [data-stagger] > * {
  opacity: 1;
  transform: none;
  filter: none;
  animation: none;
}

/* ---------- 17. ЭФФЕКТЫ: БЛЮР, ВЫЛЕТЫ, БЛИКИ ---------- */

/* 17.1. Каскадное появление детей контейнера.
   Ключевое: animation-fill-mode — только backwards. Пока анимация не
   запущена, видно «начальное» состояние; когда закончилась, элемент
   возвращается к своим обычным стилям, поэтому hover-трансформации
   (наклон, подъём) продолжают работать. */
[data-stagger] > * {
  --i: 0;
  animation: staggerIn 0.92s var(--ease) backwards;
  animation-delay: calc(var(--i) * var(--step, 85ms));
  animation-play-state: paused;
}
[data-stagger].is-visible > * { animation-play-state: running; }
@keyframes staggerIn {
  from { opacity: 0; transform: translate3d(0, 30px, 0) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* 17.2. Заголовки секций: слова выезжают по очереди, с блюром и наклоном */
.section__title[data-reveal] { opacity: 1; transform: none; filter: none; }
.section__title .w { display: inline-block; }
.section__title .w__i {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 44%, 0) rotate(4deg);
  filter: blur(7px);
  transition:
    opacity 0.75s var(--ease),
    transform 1.05s var(--ease),
    filter 0.85s var(--ease);
  transition-delay: calc(var(--i, 0) * 95ms);
  will-change: opacity, transform;
}
.section__title.is-visible .w__i { opacity: 1; transform: none; filter: blur(0); }
.section__title.is-settled .w__i { will-change: auto; }

/* 17.3. Кнопки: пробегающий блик, рябь от нажатия, отклик */
.btn::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 28%, rgba(255, 255, 255, 0.42) 48%, transparent 68%);
  transform: translateX(-140%);
  opacity: 0;
  transition: transform 0.9s var(--ease), opacity 0.4s;
}
.btn:hover::before,
.btn:focus-visible::before { transform: translateX(140%); opacity: 1; }
.btn:active { transform: scale(0.955); }

.ripple {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 70%);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleOut 0.8s var(--ease) forwards;
}
@keyframes rippleOut {
  from { transform: translate(-50%, -50%) scale(0); opacity: 0.9; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* 17.4. Карточка работы: бегущая рамка, блик по обложке */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.55s;
  background: conic-gradient(from var(--ang, 0deg),
      transparent 0deg 150deg,
      var(--accent) 205deg,
      var(--cold) 255deg,
      transparent 315deg 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}
.card:hover::after { opacity: 1; animation: borderSpin 6.5s steps(28) infinite; }
/* steps: рамка перерисовывается не 60 раз в секунду, а 28 раз за 6.5 с.
   На однопиксельном градиенте шаги незаметны, а нагрузка падает в ~14 раз. */
@keyframes borderSpin { to { --ang: 360deg; } }
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.card__media::after {
  content: "";
  position: absolute;
  inset: -25%;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.17) 50%, transparent 62%);
  transform: translateX(-130%) rotate(7deg);
  transition: transform 1.2s var(--ease);
}
.card:hover .card__media::after { transform: translateX(130%) rotate(7deg); }

/* сетка работ: наведённая карточка в фокусе, остальные притухают.
   Без filter: blur — размытие трёх больших карточек перерисовывало
   полтора миллиона пикселей на каждом кадре. */
@media (hover: hover) and (pointer: fine) {
  .works__grid:hover .card:not(:hover):not(.is-filtered-out) {
    opacity: 0.42;
    transform: scale(0.982);
  }
}

/* 17.5. Подсветка, которая ходит за курсором */
.stat, .contact__card, .chip, .filter { --mx: 50%; --my: 50%; isolation: isolate; }
.stat::after,
.contact__card::after,
.chip::after,
.filter::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s;
  background: radial-gradient(220px circle at var(--mx) var(--my), var(--accent-soft), transparent 72%);
}
.stat:hover::after,
.contact__card:hover::after,
.chip:hover::after,
.filter:hover::after { opacity: 1; }

/* рябь и блик не должны вылезать за пределы кнопок-таблеток */
.filter, .chip, .tag { position: relative; overflow: hidden; }
.to-top { overflow: hidden; }

/* 17.6. Навигация: подчёркивание выезжает слева */
.nav__link span::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: -4px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.55s var(--ease);
}
.nav__link:hover span::after,
.nav__link.is-active span::after { transform: scaleX(1); }

/* 17.7. Номер секции: линия растёт после появления */
.section__index { display: flex; align-items: center; gap: 12px; }
.section__index::after {
  content: "";
  height: 1px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), transparent);
  transition: width 1.2s var(--ease) 0.25s;
}
.section__index.is-visible::after { width: min(130px, 26vw); }

/* 17.8. Полоски навыков: пробегающий отблеск */
.skill__bar span { position: relative; overflow: hidden; }
.skill__bar span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: translateX(-110%);
  animation: shimmer 2.9s ease-in-out 1.2s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-110%); }
  45%, 100% { transform: translateX(110%); }
}

/* 17.9. Лайтбокс: выезд из блюра */
.lightbox__stage {
  transform: translateY(20px) scale(0.93);
  filter: blur(10px);
  transition: transform 0.62s var(--ease), filter 0.6s var(--ease);
}
.lightbox.is-open .lightbox__stage { transform: none; filter: blur(0); }
.lightbox__stage figcaption {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s var(--ease) 0.15s, transform 0.55s var(--ease) 0.15s;
}
.lightbox.is-open .lightbox__stage figcaption { opacity: 1; transform: none; }

/* 17.10. Смена темы: круг расширяется от кнопки */
.theme-wipe {
  position: fixed;
  z-index: 9999;
  border-radius: 50%;
  pointer-events: none;
  left: var(--wx, 50%);
  top: var(--wy, 50%);
  width: var(--wd, 0px);
  height: var(--wd, 0px);
  margin-left: calc(var(--wd, 0px) / -2);
  margin-top: calc(var(--wd, 0px) / -2);
  transform: scale(0);
  opacity: 1;
  transition: transform 0.68s var(--ease), opacity 0.5s ease;
}
.theme-wipe.is-on { transform: scale(1); }
.theme-wipe.is-off { opacity: 0; }

/* 17.11. Hero мягко растворяется при прокрутке.
   Значения ставит скрипт прямо в style.transform/opacity: переменная
   --hero-p наследовалась бы всеми потомками и пересчитывала всё
   поддерево hero на каждом кадре прокрутки. */
.hero__inner { will-change: transform, opacity; }

/* 17.12. Возврат карточек после фильтра */
.card.is-returning {
  animation: cardIn 0.85s var(--ease) backwards;
  animation-delay: var(--rd, 0ms);
}
@keyframes cardIn {
  from { opacity: 0; transform: translate3d(0, 26px, 0) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* ---------- ПОЧЕМУ ТУТ НЕТ ПРЕДПОЧТЕНИЯ «МЕНЬШЕ ДВИЖЕНИЯ» ----------
   Сайт сознательно не слушает prefers-reduced-motion: анимации здесь —
   часть замысла, и решено показывать их всем. Если однажды понадобится
   вернуть уважение к системной настройке, сюда возвращается блок:

     @media (prefers-reduced-motion: reduce) {
       *, *::before, *::after {
         animation-duration: 0.01ms !important;
         animation-iteration-count: 1 !important;
         transition-duration: 0.01ms !important;
         scroll-behavior: auto !important;
       }
       [data-reveal] { opacity: 1; transform: none; filter: none; }
       [data-stagger] > * { animation: none !important; }
       .hero__inner { transform: none; opacity: 1; }
       .card__slider img { opacity: 1; }
       .card__slider img:not(.is-active) { display: none; }
     }

   И в js/main.js заменить reduceMotion = false на чтение matchMedia. */

@media print {
  .nav, .preloader, .bg, .grain, .cursor-ring, .cursor-dot,
  .marquee, .to-top, .scroll-progress, .hero__scroll { display: none !important; }
  body { background: #fff; color: #000; }
}
