:root {
  --black: #000;
  --surface: #0b0b0c;
  --text: #f5f5f7;
  --muted: #86868b;
  --dim: #2c2c2e;
  --line: rgba(255, 255, 255, .08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1200px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* Шрифт Inter хранится на сайте (лицензия SIL Open Font License). Один файл — все начертания */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("assets/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@property --a { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--black); }
body {
  margin: 0;
  background: var(--black);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: #fff; color: #000; }
section[id] { scroll-margin-top: 64px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ===== Заставка ===== */
body.is-intro { overflow: hidden; }
.intro {
  position: fixed; inset: 0;
  z-index: 200;
  background: #000;
  overflow: hidden;
  transition: opacity 1.2s var(--ease), visibility 1.2s;
}
/* Размер и положение кадра задаёт script.js — так логотип одинаково читается
   и на вертикальном телефоне, и на широком мониторе. Поля вокруг кадра не видны:
   фон видео и страницы одинаково чёрный */
.intro__video {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.is-ready .intro { opacity: 0; visibility: hidden; pointer-events: none; }

/* Перелетающий логотип лежит поверх заставки, чтобы не исчезать вместе с её фоном */
.intro-logo {
  position: fixed;
  left: 0; top: 0;
  z-index: 202;
  max-width: none;
  opacity: 0;
  pointer-events: none;
}
.logo-flying .nav__logo img { opacity: 0; transition: none; }

/* Сайт появляется из темноты после заставки */
main, .footer { transition: opacity 1.2s var(--ease); }
.is-intro main, .is-intro .footer { opacity: 0; }

/* ===== Навигация ===== */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  border-bottom: 1px solid transparent;
}
.nav::before {
  content: "";
  position: absolute; inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  opacity: 0;
  transition: opacity .5s var(--ease);
}
.nav.is-scrolled::before { opacity: 1; }
.nav__logo img {
  height: 30px;
  width: auto;
  opacity: .9;
  transition: opacity .3s;
}
.nav__logo:hover img { opacity: 1; }

/* ===== Первый экран ===== */
.hero {
  --p: 0;
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 88px var(--gutter);
  overflow: hidden;
  /* На iPhone нижняя панель Safari висит поверх страницы: растягиваем первый экран под неё,
     чтобы следующий блок не просвечивал сквозь панель */
  min-height: 100lvh;
  padding-bottom: calc(88px + 100lvh - 100svh);
}
.hero__art {
  position: relative;
  width: min(78vw, 68svh, 760px);
  aspect-ratio: 1400 / 1242;
  opacity: calc(1 - var(--p) * 1.2);
  transform: translateY(calc(var(--p) * -50px)) scale(calc(1 - var(--p) * .1));
}
.aw { position: absolute; height: auto; max-width: none; }

/* Слова «пишутся» слева направо */
.aw--word {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--a) - 18%), transparent var(--a));
  mask-image: linear-gradient(90deg, #000 calc(var(--a) - 18%), transparent var(--a));
}
.is-ready .aw--word { animation: write var(--t) var(--d) cubic-bezier(.45, .05, .35, 1) forwards; }
@keyframes write { to { --a: 118%; } }

/* Сердце: проявляется цельным из мягкого размытия, вздрагивает и раскалывается.
   Размытие и вспышка — готовая картинка aw-heart-blur; CSS-фильтры не используются,
   потому что Safari не перерисовывает их анимацию кадр за кадром */
.aw--heart { aspect-ratio: 393 / 439; transform: scale(.9); }
.is-ready .aw--heart { animation: heartIn var(--t) var(--d) both; }
@keyframes heartIn {
  0%   { transform: scale(.9); animation-timing-function: cubic-bezier(.22, .61, .36, 1); }
  40%  { transform: scale(1); }
  70%  { transform: scale(1); }
  75%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.aw-heart-blur {
  position: absolute;
  height: auto;
  max-width: none;
  opacity: 0;
}
.is-ready .aw-heart-blur { animation: heartBlur var(--t) var(--d) both; }
@keyframes heartBlur {
  0%   { opacity: 0; transform: scale(1.12); animation-timing-function: cubic-bezier(.22, .61, .36, 1); }
  20%  { opacity: 1; transform: scale(1.03); }
  44%  { opacity: 0; transform: scale(1); }
  70%  { opacity: 0; transform: scale(1); animation-timing-function: cubic-bezier(.2, .9, .3, 1); }
  75%  { opacity: .7; transform: scale(1.06); animation-timing-function: ease-out; }
  92%  { opacity: 0; transform: scale(1.14); }
  100% { opacity: 0; transform: scale(1.14); }
}
.aw-half {
  position: absolute;
  height: auto;
  max-width: none;
  opacity: 0;
  transform-origin: 50% 100%;
  transform: translate(var(--cx), var(--cy)) rotate(0deg);
}
.is-ready .aw-half { animation: heartBreak var(--t) var(--d) both, halfIn var(--t) var(--d) both; }
@keyframes halfIn {
  0%, 14% { opacity: 0; }
  42%, 100% { opacity: 1; }
}
@keyframes heartBreak {
  0%, 60% { transform: translate(var(--cx), var(--cy)) rotate(0deg); }
  64%  { transform: translate(calc(var(--cx) + 1.4%), var(--cy)) rotate(calc(var(--r) * -1.2deg)); }
  67%  { transform: translate(calc(var(--cx) - 1.4%), var(--cy)) rotate(calc(var(--r) * 1.2deg)); }
  70%  { transform: translate(var(--cx), var(--cy)) rotate(0deg); animation-timing-function: cubic-bezier(.15, .9, .3, 1); }
  79%  { transform: translate(calc(var(--cx) * -.45), calc(var(--cy) * -.45)) rotate(calc(var(--r) * 7deg)); animation-timing-function: cubic-bezier(.4, 0, .3, 1); }
  90%  { transform: translate(calc(var(--cx) * .08), calc(var(--cy) * .08)) rotate(calc(var(--r) * -1.2deg)); }
  100% { transform: translate(0, 0) rotate(0deg); }
}


.hero__scroll {
  position: absolute;
  bottom: calc(clamp(28px, 5vh, 48px) + 100lvh - 100svh);
  left: 50%;
  width: 2px; height: 96px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--dim);
  overflow: hidden;
  opacity: 0;
}
.is-ready .hero__scroll { animation: fade 1s 5.6s both; }
.hero__scroll span {
  position: absolute;
  inset: 0;
  background: #fff;
  animation: drip 2.2s var(--ease) infinite;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drip { 0% { transform: translateY(-100%); } 60%, 100% { transform: translateY(100%); } }

/* ===== Портрет ===== */
.portrait {
  /* Отступ сверху больше нижней панели Safari на iPhone: под панелью остаётся чёрный фон */
  padding: clamp(140px, 20vh, 220px) var(--gutter) 0;
}
.portrait__frame {
  --p: 0;
  position: relative;
  margin: 0 auto;
  /* Фото проявляется, только когда до него долистали — у нижнего края экрана оно прозрачное */
  opacity: clamp(0, calc((var(--p) - .04) * 3), 1);
  /* Вертикальный кадр: растёт при прокрутке, но всегда помещается в экран */
  width: min(calc(42% + 18% * var(--p)), calc(58svh + 14svh * var(--p)));
  aspect-ratio: 4 / 5;
  border-radius: calc(36px - 14px * var(--p));
  overflow: hidden;
  background: var(--surface);
}
.portrait__frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  transform: scale(calc(1.15 - .15 * var(--p)));
  filter: brightness(calc(.55 + .35 * var(--p)));
}
.portrait__frame::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent 45%);
}
.portrait__caption {
  position: absolute;
  left: clamp(20px, 4vw, 56px);
  bottom: clamp(20px, 4vw, 48px);
  z-index: 1;
  display: flex;
  flex-direction: column;
  opacity: var(--p);
  transform: translateY(calc((1 - var(--p)) * 20px));
}
.portrait__name {
  font-size: clamp(28px, 4.5vw, 56px);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.05;
}

/* ===== Обо мне ===== */
.about {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(120px, 20vh, 220px) var(--gutter) clamp(100px, 16vh, 180px);
}
.about__text {
  margin: 0;
  max-width: 1000px;
  font-size: clamp(30px, 4.6vw, 60px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.035em;
}
.word { color: var(--dim); transition: color .45s var(--ease); }
.word.is-lit { color: var(--text); }
.about__signature {
  width: clamp(200px, 30vw, 380px);
  height: auto;
  margin: clamp(40px, 7vh, 72px) 0 0 auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.4s var(--ease), transform 1.4s var(--ease);
}
.about__signature.is-visible { opacity: .9; transform: none; }

/* ===== Заголовки секций ===== */
.section-title {
  margin: 0;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 600;
  letter-spacing: -.05em;
  line-height: 1;
}
.section-sub {
  margin: 16px 0 0;
  font-size: clamp(19px, 2.2vw, 26px);
  color: var(--muted);
  letter-spacing: -.015em;
}

/* ===== Кадры ===== */
.frames {
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(40px, 8vh, 80px) var(--gutter) clamp(120px, 20vh, 200px);
}
.grid {
  margin-top: clamp(48px, 8vh, 80px);
  columns: 3 300px;
  column-gap: clamp(8px, 1.2vw, 16px);
}
.grid__item {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: clamp(8px, 1.2vw, 16px);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  break-inside: avoid;
}
.grid__item img {
  width: 100%;
  height: auto;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 1s var(--ease), transform 1.2s var(--ease), filter .6s var(--ease);
}
.grid__item.is-loaded img { opacity: 1; transform: none; }
.grid__item:hover img { transform: scale(1.035); filter: brightness(1.08); }
.grid__item:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ===== География ===== */
.geo { padding-top: clamp(20px, 4vh, 40px); }
.geo__head { max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter); }
.geo__track {
  position: relative;
  height: 840vh;
  margin-top: clamp(8px, 2vh, 24px);
}
.geo__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.geo__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.geo__sticky::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(#000, transparent 16%, transparent 72%, rgba(0,0,0,.85) 94%, #000),
    radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,.55) 100%);
}
.geo__caption {
  position: absolute;
  z-index: 1;
  left: var(--gutter);
  right: var(--gutter);
  bottom: max(32px, env(safe-area-inset-bottom));
  max-width: 1440px;
  margin: 0 auto;
}
.geo__caption.is-in { animation: capIn .7s var(--ease) both; }
.geo__title {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 44px);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.1;
}
.geo__sub { margin: 6px 0 0; font-size: clamp(15px, 1.6vw, 19px); color: var(--muted); }
@keyframes capIn { from { opacity: 0; transform: translateY(12px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

.geo + .frames { padding-top: clamp(120px, 22vh, 240px); }

/* ===== Соцсети ===== */
.links {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(120px, 20vh, 200px);
}
.links__list {
  list-style: none;
  margin: clamp(48px, 8vh, 80px) 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.links__list li { border-bottom: 1px solid var(--line); }
.links__list a {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: clamp(22px, 3.5vw, 36px) 0;
  transition: padding .5s var(--ease);
}
.links__name {
  font-size: clamp(28px, 4.5vw, 52px);
  font-weight: 600;
  letter-spacing: -.04em;
  color: var(--muted);
  transition: color .4s var(--ease);
}
.links__handle { font-size: 16px; color: var(--muted); opacity: .9; transition: opacity .4s var(--ease), color .4s var(--ease); }
.links__arrow {
  font-size: clamp(22px, 3vw, 32px);
  color: var(--muted);
  transition: transform .5s var(--ease), color .4s var(--ease);
}
.links__list a:hover { padding-left: 12px; }
.links__list a:hover .links__name,
.links__list a:hover .links__arrow { color: #fff; }
.links__list a:hover .links__handle { opacity: 1; color: var(--text); }
.links__list a:hover .links__arrow { transform: translate(4px, -4px); }

/* ===== Подвал ===== */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px var(--gutter) 56px;
  border-top: 1px solid var(--line);
  color: #6e6e73;
  font-size: 12px;
  text-align: center;
}
.footer p { margin: 0; }
.footer__logo { height: 40px; width: auto; opacity: .45; }
.footer__note { max-width: 520px; font-size: 11px; color: #4a4a4f; }
.footer__note[hidden] { display: none; }

/* ===== Просмотр кадра ===== */
.viewer {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s var(--ease), visibility .5s;
}
.viewer.is-open { opacity: 1; visibility: visible; }
.viewer__img {
  max-width: min(92vw, 1600px);
  max-height: 84vh;
  object-fit: contain;
  border-radius: 12px;
  opacity: 0;
  transform: scale(.97);
  transition: opacity .5s var(--ease), transform .6s var(--ease);
}
.viewer__img.is-shown { opacity: 1; transform: none; }
.viewer__close, .viewer__nav {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  transition: background .3s;
}
.viewer__close:hover, .viewer__nav:hover { background: rgba(255, 255, 255, .2); }
.viewer__close { top: 20px; right: 20px; }
.viewer__close::before, .viewer__close::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 1.5px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(45deg);
}
.viewer__close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.viewer__nav { top: 50%; margin-top: -22px; }
.viewer__nav::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 10px; height: 10px;
  border-top: 1.5px solid #fff;
  border-left: 1.5px solid #fff;
}
.viewer__nav--prev { left: 20px; }
.viewer__nav--prev::before { transform: translate(-30%, -50%) rotate(-45deg); }
.viewer__nav--next { right: 20px; }
.viewer__nav--next::before { transform: translate(-70%, -50%) rotate(135deg); }
.viewer__count {
  position: absolute;
  bottom: 24px; left: 0; right: 0;
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ===== Появление ===== */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .aw--word { -webkit-mask-image: none; mask-image: none; }
  .aw--heart { transform: none; }
  .aw-half { opacity: 1; transform: none; }
  .aw-heart-blur { display: none; }
  .hero__scroll { opacity: 1; }
  .reveal, .about__signature { opacity: 1; transform: none; }
  .portrait__frame { width: min(60%, 72svh); border-radius: 22px; }
  .portrait__frame img { transform: none; filter: brightness(.9); }
  .portrait__caption { opacity: 1; transform: none; }
  .portrait__frame { opacity: 1; }
  .geo__track { height: auto; }
  .geo__sticky { position: relative; height: 85svh; }
}

/* ===== Телефон ===== */
@media (max-width: 700px) {
  .nav { height: 48px; }
  .nav__logo img { height: 26px; }
  .hero__art { width: min(88vw, 60svh); }
  .portrait__frame { width: calc(80% + 20% * var(--p)); border-radius: calc(28px - 12px * var(--p)); }
  .about__signature { margin-left: 0; }
  .grid { columns: 2 140px; }
  .grid__item { border-radius: 12px; }
  .links__list a { grid-template-columns: 1fr auto; row-gap: 2px; }
  .links__handle { grid-row: 2; font-size: 14px; }
  .links__arrow { grid-column: 2; grid-row: 1 / span 2; }
  .viewer__nav { display: none; }
  .viewer__img { max-width: 100vw; border-radius: 0; }
}
