:root {
  --paper: #f7f7f4;
  --ink: #11110f;
  --baseline-height: 1px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* A late-2000s personal-site header: a quiet rule and plain text links. */
.site-menu {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  padding-top: .7rem;
  pointer-events: none;
}

.site-menu__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: min(calc(100% - 2rem), 84rem);
  margin: 0 auto;
  padding-bottom: .5rem;
  color: #4e4e4a;
  font-family: "PT Sans", Arial, Helvetica, sans-serif;
  font-size: clamp(.68rem, .8vw, .78rem);
  line-height: 1;
  pointer-events: auto;
}

.site-menu a {
  color: inherit;
  text-decoration: none;
}

.site-menu__name {
  flex: 0 0 auto;
  padding-bottom: .3rem;
  border-bottom: 1px solid #b6b6b1;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .015em;
}

.site-menu__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .65rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid #b6b6b1;
}

.site-menu__links a {
  border-bottom: 1px solid transparent;
}

.site-menu__links a:hover,
.site-menu__links a:focus-visible,
.site-menu__links a.is-current {
  border-color: currentColor;
  color: var(--ink);
  outline: none;
}

.site-menu__links a.is-current { font-weight: 700; }

.site-menu__links .site-menu__external { color: #c33d3d; }

.caterpillar-baseline {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  height: var(--baseline-height);
  background: #93938e;
}

.route-screen:not(.is-active) { display: none; }

.route-screen.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.route-screen.is-entering {
  animation: screen-fade-in .28s ease both;
}

/* Mobile is a separate, quiet entry point: the desktop collage is intentionally
   replaced by a single framed menu so the imagery never competes for space. */
.mobile-menu-screen { display: none; }

.blank-page {
  position: relative;
  min-height: 100dvh;
  padding: max(3.75rem, clamp(1.4rem, 5vw, 5.5rem)) clamp(1rem, 4vw, 4rem);
  background: var(--paper);
  overflow: hidden;
}

.leaves-layer {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.leaf-stream {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--leaf-stream-left);
  width: 28%;
  background: url("assets/external/3649155w4v8zy8r8q-slow.gif") center top / 31rem auto repeat-y;
  opacity: var(--leaf-stream-opacity);
  animation: leaf-stream-drift var(--leaf-stream-duration) linear infinite;
  animation-delay: var(--leaf-stream-delay);
  pointer-events: none;
  will-change: background-position;
}

@keyframes leaf-stream-drift {
  from { background-position: center 0; }
  to { background-position: center 43.75rem; }
}

.back-button {
  position: relative;
  z-index: 1;
}

.archive-page {
  padding-top: max(3.75rem, clamp(1.25rem, 3vw, 2.25rem));
  padding-bottom: clamp(7rem, 16vw, 14rem);
}

.archive-header {
  display: flex;
  position: relative;
  z-index: 1;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  color: var(--ink);
}

.archive-header h2,
.archive-header .back-button {
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: clamp(.72rem, .9vw, .88rem);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1;
}

.archive-header .back-button {
  cursor: pointer;
}

.archive-header .back-button:hover,
.archive-header .back-button:focus-visible {
  outline: none;
  text-decoration: underline;
  text-underline-offset: .18em;
}

.gusya-archive {
  width: 95%;
  margin: clamp(3.5rem, 8vw, 7rem) auto 0;
}

.archive-item {
  width: 100%;
  margin: 0 0 clamp(2.75rem, 6vw, 5.5rem);
}

.archive-item img,
.archive-item video {
  display: block;
  width: 100%;
  height: auto;
}

/* Видео не должно быть выше видимой области — пропорции сохраняются. */
.archive-item--video video {
  width: auto;
  max-width: 100%;
  max-height: calc(100dvh - 9rem);
  margin-inline: auto;
  background: #000;
}

.archive-item figcaption {
  margin-top: .45rem;
  color: var(--ink);
  font-size: clamp(.68rem, .86vw, .8rem);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.archive-item:last-child { margin-bottom: 0; }

.archive-love-note {
  display: grid;
  justify-items: center;
  margin: clamp(4rem, 9vw, 7rem) 0 0;
  text-align: center;
}

.archive-love-note img {
  display: block;
  width: min(30rem, 85vw);
  height: auto;
}

.archive-love-note p {
  margin: .9rem 0 0;
  font-size: clamp(.9rem, 1.25vw, 1.2rem);
  letter-spacing: -.02em;
  line-height: 1.15;
}

.archive-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.7rem, 1vw, 1.15rem);
  margin-bottom: clamp(2.75rem, 6vw, 5.5rem);
}

.archive-pair .archive-item { margin: 0; }

@media (max-width: 560px) {
  .gusya-archive { width: 100%; }

  .archive-pair { gap: .5rem; }
}

@keyframes screen-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.poster {
  min-height: 100dvh;
  padding: 0 clamp(0rem, 3.25vw, 4rem);
}

.poster { transition: opacity .28s ease; }

.hero {
  position: relative;
  isolation: isolate;
  width: min(100%, 84rem);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding: 0;
}

h1 {
  position: absolute;
  z-index: 2;
  inset: 0;
  margin: 0;
  font-family: "PT Sans Narrow", "Arial Narrow", Arial, sans-serif;
  font-size: clamp(1rem, 1.85vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: .86;
  text-transform: uppercase;
  white-space: nowrap;
}

.title-block {
  position: absolute;
  display: block;
}

.title-block--one { top: 11%; left: -.25%; }
.title-block--two { top: 16%; left: 35%; }
.title-block--three { top: 39%; right: -1%; }
.title-block--four { top: 53%; left: 29%; }

/* Слова остаются частью исходных строк, пока не «отлипнут» от плаката. */
.hero-word { display: inline-block; }

.hero-word:hover { color: #b9b9b4; }

.hero-word.is-loose {
  --word-x: 0px;
  --word-y: 0px;
  --word-tilt: 0deg;
  position: relative;
  pointer-events: none;
  transform: translate3d(var(--word-x), var(--word-y), 0) rotate(var(--word-tilt));
  transform-origin: center;
  white-space: nowrap;
  will-change: transform;
}

.hero-word.is-gone { opacity: 0; }

/* Меню повторяет набор плаката: цвет меняется, но не появляется отдельный UI-слой. */
.rainbow-menu {
  position: absolute;
  z-index: 4;
  top: 66%;
  left: 52%;
  display: grid;
  gap: .02em;
  width: max-content;
  transform: translate(-50%, -50%);
  transform-origin: 50% 50%;
}

.menu-item {
  display: block;
  font-family: "PT Sans", Arial, Helvetica, sans-serif;
  font-size: clamp(.9rem, 1.25vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -.055em;
  line-height: .86;
  text-decoration: none;
  transition: transform .14s steps(2, end), color .14s steps(2, end);
}

.menu-item:hover,
.menu-item:focus-visible {
  outline: none;
  color: var(--ink);
  transform: translateX(.18rem);
  text-decoration: underline;
  text-decoration-thickness: .09em;
  text-underline-offset: .1em;
}

.menu-item:active { transform: translateX(.08rem); }

.menu-item-pink { color: #dc4a82; }
.menu-item-orange { color: #df7b2d; }
.menu-item-yellow { color: #bd8b00; }
.menu-item-green { color: #609820; }
.menu-item-blue { color: #168f99; }
.menu-item-violet { color: #7760b8; }

.stretch {
  display: inline-block;
  margin-right: 3em;
  transform: scaleX(1.5);
  transform-origin: left center;
}

.stock-photo {
  position: absolute;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  filter: none;
}

.stock-photo > img {
  display: block;
  width: 100%;
  height: auto;
}

/* Короткий фотоснимок появляется выше плакатного текста, но не перехватывает жесты. */
.baby-flash {
  --flash-rotation: 0deg;
  position: absolute;
  z-index: 3;
  width: clamp(4.5rem, 8vw, 7rem);
  aspect-ratio: 3 / 4;
  border: 1px solid var(--ink);
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, -50%, 0) rotate(var(--flash-rotation)) scale(.88);
  transition: opacity 55ms linear, transform 55ms linear;
  will-change: opacity, transform;
}

.baby-flash.is-visible {
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) rotate(var(--flash-rotation)) scale(1);
}

/* The generated closed-eye photograph is a second frame, not a painted overlay. */
.child-blink .blink-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  opacity: 0;
  animation: blink-frame 7.2s steps(1, end) infinite;
  will-change: opacity;
}

.child-blink-pair .blink-frame { animation-delay: .6s; }
.child-blink-sit .blink-frame { animation-delay: 2.8s; }
.child-blink-small .blink-frame { animation-delay: 5s; }

@keyframes blink-frame {
  0%, 90%, 100% { opacity: 0; }
  92%, 94% { opacity: 1; }
  96% { opacity: 0; }
}

.stock-photo-pair {
  top: -4%;
  left: 42%;
  width: clamp(16rem, 30vw, 30rem);
  filter: saturate(.72) contrast(.91) blur(.12px);
  transform: rotate(-4deg);
}

.stock-photo-sit {
  bottom: -8%;
  left: 7%;
  width: clamp(14rem, 22vw, 24rem);
  transform: rotate(-6deg);
}

.stock-photo-small {
  right: 23%;
  bottom: 8%;
  width: clamp(8rem, 14vw, 14rem);
  transform: rotate(3deg);
}

.caterpillar-track {
  /* Гуся относится к окну, а не к макету: на любом экране она остаётся у нижнего края. */
  position: fixed;
  z-index: 5;
  /* Едет по тонкой линии внизу окна. */
  bottom: calc(var(--baseline-height) + env(safe-area-inset-bottom, 0px));
  left: 0;
  width: clamp(9rem, 17vw, 16rem);
  pointer-events: none;
  animation: crawl-across 58s steps(30, end) infinite;
  will-change: transform;
}

.caterpillar-motion {
  animation: caterpillar-wiggle 1.93s steps(1, end) infinite;
  transform-origin: 50% 80%;
  will-change: transform;
}

.caterpillar-bubble {
  position: absolute;
  z-index: 1;
  top: -2.9rem;
  left: 54%;
  min-width: 5.8rem;
  padding: .38rem .5rem .32rem;
  border: 2px solid var(--ink);
  background: #fff5f7;
  box-shadow: .2rem .2rem 0 #ff91b1;
  color: var(--ink);
  font-family: "Comic Sans MS", "Trebuchet MS", cursive;
  font-size: clamp(.75rem, 1.25vw, .98rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  opacity: 0;
  transform: translateY(.45rem) rotate(-2deg) scale(.86);
  visibility: hidden;
  pointer-events: none;
}

.caterpillar-bubble::after {
  position: absolute;
  bottom: -.56rem;
  left: .9rem;
  width: .72rem;
  height: .72rem;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: #fff5f7;
  content: "";
  transform: rotate(45deg);
}

.caterpillar-bubble.is-visible {
  visibility: visible;
  animation: bubble-pop .24s steps(2, end) both;
}

.caterpillar-bubble.first-greeting {
  animation: first-greeting 3.4s steps(2, end) 8.5s both;
}

.caterpillar {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center;
  animation: turn-around 58s steps(1, end) infinite;
  will-change: transform;
}

@keyframes crawl-across {
  0%, 3.5% { transform: translateX(calc(-100% - 1rem)); }
  42% { transform: translateX(calc(100vw - 100%)); }
  /* Останавливается у края примерно на две секунды перед выходом. */
  45.5% { transform: translateX(calc(100vw - 100%)); }
  49% { transform: translateX(calc(100vw + 1rem)); }
  54%, 55.5% { transform: translateX(calc(100vw + 1rem)); }
  94% { transform: translateX(0); }
  97.5% { transform: translateX(0); }
  100% { transform: translateX(calc(-100% - 1rem)); }
}

@keyframes caterpillar-wiggle {
  0% { transform: translateY(0) rotate(2deg); }
  25% { transform: translateY(-.42rem) rotate(-2.5deg); }
  50% { transform: translateY(.12rem) rotate(1deg); }
  75% { transform: translateY(-.22rem) rotate(-1.5deg); }
  100% { transform: translateY(0) rotate(2deg); }
}

@keyframes bubble-pop {
  from { opacity: 0; transform: translateY(.45rem) rotate(-2deg) scale(.86); }
  to { opacity: 1; transform: translateY(0) rotate(-2deg) scale(1); }
}

@keyframes first-greeting {
  0% { visibility: hidden; opacity: 0; transform: translateY(.45rem) rotate(-2deg) scale(.86); }
  1%, 88% { visibility: visible; opacity: 1; transform: translateY(0) rotate(-2deg) scale(1); }
  100% { visibility: hidden; opacity: 0; transform: translateY(.45rem) rotate(-2deg) scale(.86); }
}

@keyframes turn-around {
  0%, 49% { transform: rotateY(0deg); }
  54% { transform: rotateY(180deg); }
  55.5%, 97.5% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .caterpillar-track {
    transform: translateX(42vw);
    animation: none;
  }

  .caterpillar-motion,
  .caterpillar,
  .child-blink .blink-frame { animation: none; }

  .caterpillar-bubble { display: none; }
}

@media (max-width: 760px) {
  html,
  body,
  .poster,
  .hero {
    background: #fff;
  }

  body { min-width: 0; }

  .site-menu,
  .caterpillar-baseline { display: none; }

  .blank-page { padding-top: max(4.4rem, clamp(1.4rem, 5vw, 5.5rem)); }

  .archive-page { padding-top: max(4.4rem, clamp(1.25rem, 3vw, 2.25rem)); }

  .poster { padding: 0; }

  .hero {
    display: grid;
    min-height: 100dvh;
    place-items: center;
    padding: clamp(1.25rem, 7vw, 2.5rem);
  }

  .hero > :not(.mobile-menu-screen) { display: none; }

  .mobile-menu-screen {
    position: relative;
    display: grid;
    width: min(100%, 31rem);
    aspect-ratio: 490 / 372;
    place-items: center;
    background: url("assets/mobile-menu-frame.png") center / 100% 100% no-repeat;
  }

  .mobile-menu-screen__links {
    display: grid;
    width: 60%;
    gap: clamp(.35rem, 1.9vw, .65rem);
    text-align: center;
  }

  .mobile-menu-screen__links a {
    display: block;
    padding: clamp(.28rem, 1.35vw, .52rem) .5rem;
    border: 1px solid transparent;
    font-family: "PT Sans", Arial, Helvetica, sans-serif;
    font-size: clamp(.8rem, 3.1vw, 1.04rem);
    font-weight: 700;
    letter-spacing: -.055em;
    line-height: .86;
    text-decoration: none;
    transition: transform .14s steps(2, end), color .14s steps(2, end);
  }

  .mobile-menu-screen__links a:hover,
  .mobile-menu-screen__links a:focus-visible {
    border-color: transparent;
    color: var(--ink);
    outline: none;
    text-decoration: underline;
    text-decoration-thickness: .09em;
    text-underline-offset: .1em;
    transform: translateX(.18rem);
  }

  .mobile-menu-screen__links a:active { transform: translateX(.08rem); }

  .mobile-menu-screen__links a:nth-child(1) { color: #dc4a82; }
  .mobile-menu-screen__links a:nth-child(2) { color: #df7b2d; }
  .mobile-menu-screen__links a:nth-child(3) { color: #bd8b00; }
  .mobile-menu-screen__links a:nth-child(4) { color: #609820; }

  h1 {
    font-size: clamp(.9rem, 3.75vw, 1.75rem);
    line-height: .9;
  }

  .title-block--one { top: 10%; left: 0; }
  .title-block--two { top: 20%; left: 12%; }
  .title-block--three { top: 35%; right: -8%; }
  .title-block--four { top: 50%; left: 16%; }

  .stock-photo-pair { top: -1%; left: 27%; width: 72vw; }
  .stock-photo-sit { bottom: -4%; left: -8%; width: 68vw; }
  .stock-photo-small { right: 18%; bottom: 10%; width: 37vw; }
  .baby-flash { width: clamp(3.75rem, 18vw, 5.5rem); }
  .caterpillar-track { width: 44vw; }
  .caterpillar-bubble { top: -2.6rem; left: 48%; }

  .rainbow-menu {
    top: 63%;
    left: 49%;
    gap: .2rem;
  }

  .menu-item {
    font-size: clamp(.84rem, 3.1vw, 1.35rem);
    line-height: .9;
  }
}

@media (max-width: 440px) {
  .archive-item figcaption { font-size: .68rem; }
}
