.gallery-header,
.gallery-hero {
  --gallery-paper: #f1ece4;
  --gallery-ink: #171615;
  --gallery-coral: #bd5549;
  --gallery-light: #f5f0e8;
  --gallery-line: rgba(23, 22, 21, 0.18);
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.gallery-header {
  position: absolute;
  z-index: 100;
  top: 0;
  right: max(24px, calc((100vw - 1240px) / 2));
  left: max(24px, calc((100vw - 1240px) / 2));
  height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--gallery-line);
  background: var(--gallery-paper);
}

.gallery-logo {
  justify-self: start;
  color: var(--gallery-ink);
  font-family: "Prata", serif;
  font-size: 25px;
  line-height: 1;
  text-decoration: none;
}

.gallery-logo span,
.gallery-header-action span {
  color: var(--gallery-coral);
}

.gallery-header-nav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.gallery-header-nav a,
.gallery-header-action {
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.gallery-header-nav a {
  color: rgba(23, 22, 21, 0.62);
  transition: color 160ms ease;
}

.gallery-header-nav a:hover,
.gallery-header-nav a:focus-visible,
.gallery-header-action:hover,
.gallery-header-action:focus-visible {
  color: var(--gallery-coral);
}

.gallery-header-action {
  justify-self: end;
  color: var(--gallery-ink);
}

.gallery-header-action span {
  margin-left: 7px;
}

.gallery-header .gallery-nav-toggle {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.gallery-header .gallery-nav-toggle span {
  position: absolute;
  right: 6px;
  width: 28px;
  height: 2px;
  margin: 0;
  background: var(--gallery-ink);
  border-radius: 999px;
  transform-origin: center;
  transition: top 220ms ease, width 220ms ease, transform 220ms ease;
}

.gallery-header .gallery-nav-toggle span:nth-child(1) {
  top: 15px;
}

.gallery-header .gallery-nav-toggle span:nth-child(2) {
  display: none;
}

.gallery-header .gallery-nav-toggle span:nth-child(3) {
  top: 27px;
  width: 20px;
}

.gallery-header .gallery-nav-toggle[aria-expanded="true"] span:nth-child(1),
.gallery-header .gallery-nav-toggle[aria-expanded="true"] span:nth-child(3) {
  top: 21px;
  width: 28px;
}

.gallery-header .gallery-nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg);
}

.gallery-header .gallery-nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg);
}

.gallery-header .gallery-nav-toggle:focus-visible {
  outline: 1px solid var(--gallery-coral);
  outline-offset: 2px;
}

.gallery-header .mobile-nav {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 5;
}

.gallery-hero {
  --gallery-phone-width: clamp(104px, 18vw, 210px);
  --gallery-phone-height: calc(var(--gallery-phone-width) * 2.1641);
  --gallery-phone-gap: clamp(18px, 3vw, 42px);
  --gallery-column-gap: clamp(10px, 3vw, 38px);
  position: relative;
  min-height: max(560px, 100svh);
  z-index: 2;
  overflow: visible;
  isolation: isolate;
  background: var(--gallery-paper);
  color: var(--gallery-ink);
  font-family: "Manrope", sans-serif;
}

.gallery-hero::after {
  content: "";
  position: absolute;
  z-index: -3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 37%;
  background: var(--ink);
}

.gallery-hero-copy {
  position: absolute;
  z-index: 20;
  top: clamp(112px, 13vh, 142px);
  left: max(24px, calc((100vw - 1240px) / 2));
  width: min(340px, 27vw);
  color: var(--gallery-ink);
  opacity: 1;
}

.gallery-hero-kicker {
  margin: 0 0 14px;
  color: #df776a;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.gallery-hero-copy h1 {
  margin: 0;
  color: var(--gallery-ink);
  font-family: "Prata", serif;
  font-size: clamp(32px, 2.8vw, 42px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.15;
}

.gallery-hero-copy h1 em {
  color: #df776a;
  font-weight: 400;
}

.gallery-hero-summary {
  max-width: 280px;
  margin: 18px 0 20px;
  color: rgba(23, 22, 21, 0.62);
  font-size: 13px;
  line-height: 1.55;
}

.gallery-hero-actions {
  width: min(280px, 100%);
}

.gallery-hero-primary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--gallery-coral);
  color: #fffaf5;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 180ms ease, transform 180ms ease;
}

.gallery-hero-primary span:last-child {
  color: #fffaf5;
  font-size: 18px;
  transition: transform 180ms ease;
}

.gallery-hero-primary:hover,
.gallery-hero-primary:focus-visible {
  background: #a9473e;
  transform: translateY(-1px);
}

.gallery-hero-primary:hover span:last-child,
.gallery-hero-primary:focus-visible span:last-child {
  transform: translateX(5px);
}

.gallery-hero-secondary {
  min-height: 39px;
  display: flex;
  align-items: center;
  padding-inline: 16px;
  border-bottom: 1px solid rgba(23, 22, 21, 0.35);
  color: var(--gallery-ink);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 180ms ease, border-color 180ms ease;
}

.gallery-hero-secondary:hover,
.gallery-hero-secondary:focus-visible {
  border-color: var(--gallery-coral);
  color: var(--gallery-coral);
}

.motion-stage {
  position: relative;
  min-height: max(560px, 100svh);
  overflow: hidden;
  perspective: 1500px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 110px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 110px), transparent 100%);
}

.stage-grid {
  display: none;
}

.gallery-world {
  position: absolute;
  z-index: 4;
  inset: 0;
  transform-origin: 50% 50%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 110px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 110px), transparent 100%);
  will-change: transform;
}

.gallery-hero + .ai-agent {
  position: relative;
  z-index: 1;
  padding-top: 96px;
}

.gallery-camera,
.gallery-columns {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-style: preserve-3d;
}

.gallery-camera {
  perspective: 1700px;
}

.gallery-columns {
  left: 56%;
  width: calc(var(--gallery-phone-width) * 3 + var(--gallery-column-gap) * 2);
  transform: translateX(-50%);
}

.phone-column {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--gallery-phone-width);
  transform-style: preserve-3d;
  will-change: transform;
}

.phone-column:nth-child(1) {
  left: 0;
  transform: rotateY(7deg) translateZ(-62px);
}

.phone-column:nth-child(2) {
  left: calc(var(--gallery-phone-width) + var(--gallery-column-gap));
  z-index: 3;
  transform: translateZ(46px);
}

.phone-column:nth-child(3) {
  left: calc((var(--gallery-phone-width) + var(--gallery-column-gap)) * 2);
  transform: rotateY(-7deg) translateZ(-62px);
}

.phone-track {
  position: absolute;
  inset: 0;
  width: 100%;
  row-gap: var(--gallery-phone-gap);
  will-change: transform;
}

.gallery-phone {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--gallery-phone-width);
  height: var(--gallery-phone-height);
  margin: 0;
  padding: 6px;
  overflow: visible;
  pointer-events: auto;
  background: #111;
  border: 1px solid #4b4844;
  border-radius: calc(var(--gallery-phone-width) * 0.14);
  box-shadow:
    0 28px 48px rgba(16, 15, 14, 0.24),
    0 6px 13px rgba(16, 15, 14, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transform-style: preserve-3d;
  will-change: transform;
}

.gallery-phone:nth-child(2n) {
  margin-left: 5px;
}

.gallery-phone:nth-child(3n) {
  margin-left: -5px;
}

.gallery-phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f6f2eb;
  border-radius: calc(var(--gallery-phone-width) * 0.115);
  box-shadow: inset 0 0 0 1px #050505;
}

.gallery-phone-screen img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Телефон — ссылка на шаблон. transform занят инлайновой раскладкой из
   script.js, поэтому наведение анимируем независимым свойством scale. */
a.gallery-phone {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  scale: 1;
  transition: scale 220ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 220ms ease,
    border-color 220ms ease;
}

a.gallery-phone:hover,
a.gallery-phone:focus-visible {
  scale: 1.04;
  border-color: var(--gallery-coral);
  box-shadow:
    0 36px 60px rgba(16, 15, 14, 0.3),
    0 8px 18px rgba(16, 15, 14, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

a.gallery-phone:focus-visible {
  outline: 2px solid var(--gallery-coral);
  outline-offset: 4px;
}

.gallery-phone-name {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  max-width: calc(var(--gallery-phone-width) + 40px);
  padding: 5px 10px;
  background: var(--gallery-ink);
  color: var(--gallery-light);
  border-radius: 999px;
  font-family: "Manrope", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  translate: -50% 4px;
  pointer-events: none;
  transition: opacity 180ms ease, translate 180ms ease;
}

a.gallery-phone:hover .gallery-phone-name,
a.gallery-phone:focus-visible .gallery-phone-name {
  opacity: 1;
  translate: -50% 0;
}

@media (prefers-reduced-motion: reduce) {
  a.gallery-phone,
  .gallery-phone-name {
    transition: none;
  }
}

.showcase-frame {
  width: 200%;
  height: 200%;
  transform: scale(0.5);
  transform-origin: 0 0;
}

.dynamic-island {
  position: absolute;
  z-index: 5;
  top: 1.6%;
  left: 50%;
  width: 29%;
  height: 4.1%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6%;
  background: #070707;
  border-radius: 999px;
  transform: translateX(-50%);
  box-shadow: 0 1px 2px rgba(255, 255, 255, 0.08) inset;
}

.dynamic-island i {
  width: 5px;
  height: 5px;
  background: #1d2b35;
  border: 1px solid #344b5d;
  border-radius: 50%;
}

.gallery-caption {
  position: absolute;
  z-index: 20;
  right: max(24px, calc((100vw - 1660px) / 2));
  bottom: 38px;
  width: 225px;
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 12px;
  align-items: start;
  color: var(--gallery-light);
  opacity: 1;
}

.gallery-caption span {
  padding-top: 5px;
  color: #df776a;
  font-size: 9px;
  font-weight: 700;
}

.gallery-caption p {
  margin: 0;
  color: var(--gallery-light);
  font-family: "Prata", serif;
  font-size: 17px;
  line-height: 1.35;
}

.gallery-caption-link {
  grid-column: 2;
  margin-top: 10px;
  color: #df776a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 160ms ease;
}

.gallery-caption-link:hover,
.gallery-caption-link:focus-visible {
  color: var(--gallery-light);
}

@media (min-width: 1280px) {
  .gallery-hero {
    --gallery-phone-width: clamp(158px, 17vw, 210px);
    --gallery-column-gap: clamp(18px, 2vw, 32px);
  }

  .gallery-hero-copy {
    width: clamp(340px, 20vw, 380px);
  }

  .gallery-hero-copy h1 {
    font-size: clamp(38px, 3vw, 42px);
  }

  .gallery-hero-summary {
    max-width: 350px;
  }

  .gallery-hero-actions {
    width: clamp(300px, 18vw, 320px);
  }

  .gallery-world {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 70px, #000 calc(100% - 110px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 70px, #000 calc(100% - 110px), transparent 100%);
  }

  .gallery-columns {
    left: calc(max(24px, (100vw - 1240px) / 2) + clamp(340px, 20vw, 380px) + clamp(36px, 4vw, 48px));
    transform: none;
  }

  .gallery-hero + .ai-agent {
    padding-top: 96px;
  }
}

@media (min-width: 701px) and (max-width: 1279px) {
  .gallery-hero {
    --gallery-phone-width: clamp(126px, 17vw, 190px);
    --gallery-phone-gap: clamp(20px, 3vw, 28px);
    --gallery-column-gap: clamp(14px, 2.4vw, 24px);
    min-height: max(560px, 100svh);
  }

  .gallery-hero::after {
    top: 61%;
    height: auto;
  }

  .motion-stage {
    min-height: max(560px, 100svh);
  }

  .gallery-hero-copy {
    top: 104px;
    right: 32px;
    left: 32px;
    width: auto;
  }

  .gallery-hero-copy h1 {
    font-size: clamp(35px, 5vw, 48px);
    line-height: 1.05;
  }

  .gallery-hero-copy h1 br {
    display: none;
  }

  .gallery-hero-copy h1 em {
    display: block;
    text-align: right;
  }

  .gallery-hero-summary {
    max-width: 430px;
    margin-top: 14px;
  }

  .gallery-hero-actions {
    width: min(520px, 100%);
  }

  .gallery-world {
    top: 390px;
    bottom: 0;
    transform-origin: 50% 0;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 34px, #000 calc(100% - 110px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 34px, #000 calc(100% - 110px), transparent 100%);
  }

  .gallery-columns {
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .gallery-hero + .ai-agent {
    padding-top: 84px;
  }

  .gallery-caption {
    display: none;
  }
}

@media (max-width: 1439px) {
  .gallery-caption {
    display: none;
  }
}

@media (max-width: 959px) {
  .gallery-header {
    grid-template-columns: 1fr auto;
  }

  .gallery-header-nav,
  .gallery-header-action {
    display: none;
  }

  .gallery-header .gallery-nav-toggle {
    display: flex;
    justify-self: end;
  }
}

@media (max-width: 700px) {
  .showcase-frame {
    width: 270%;
    height: 270%;
    transform: scale(0.37037);
  }

  .gallery-header {
    right: 16px;
    left: 16px;
    height: 62px;
    grid-template-columns: 1fr auto;
  }

  .gallery-logo {
    font-size: 22px;
  }

  .gallery-header-nav,
  .gallery-header-action {
    display: none;
  }

  .gallery-header .gallery-nav-toggle {
    display: flex;
    justify-self: end;
  }

  .gallery-hero {
    --gallery-column-gap: 10px;
    --gallery-phone-gap: 19px;
    min-height: max(560px, 100svh);
  }

  .gallery-hero::after {
    top: 545px;
    height: auto;
  }

  .motion-stage {
    min-height: max(560px, 100svh);
  }

  .gallery-world {
    top: clamp(320px, calc(232px + 22.6vw), 390px);
    bottom: 0;
    transform-origin: 50% 0;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 24px, #000 calc(100% - 90px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 24px, #000 calc(100% - 90px), transparent 100%);
  }

  .gallery-hero + .ai-agent {
    padding-top: 64px;
  }

  .stage-grid {
    inset: 62px 0 0;
  }

  .gallery-columns {
    left: 50%;
    top: -2%;
    bottom: 2%;
  }

  .gallery-phone {
    padding: 4px;
  }

  .dynamic-island i {
    width: 3px;
    height: 3px;
  }

  .gallery-caption {
    display: none;
  }

  .gallery-hero-copy {
    top: 82px;
    right: auto;
    bottom: auto;
    left: 16px;
    width: calc(100% - 32px);
    min-height: 0;
    padding: 0;
    background: transparent;
  }

  .gallery-hero-kicker {
    margin-bottom: 8px;
    font-size: 8px;
  }

  .gallery-hero-copy h1 {
    max-width: none;
    font-size: clamp(28px, 5vw, 34px);
    line-height: 1.08;
  }

  .gallery-hero-copy h1 br {
    display: none;
  }

  .gallery-hero-copy h1 em {
    display: block;
    text-align: right;
  }

  .gallery-hero-summary {
    display: block;
    max-width: 320px;
    margin: 12px 0 14px;
    font-size: 11px;
    line-height: 1.45;
  }

  .gallery-hero-actions {
    width: min(520px, 100%);
  }

  .gallery-hero-primary {
    min-height: 44px;
    padding: 0 13px;
    font-size: 10px;
  }

  .gallery-hero-primary span:last-child {
    font-size: 14px;
  }

  .gallery-hero-secondary {
    min-height: 32px;
    padding-inline: 13px;
    font-size: 10px;
  }
}

@media (max-width: 360px) {
  .gallery-hero {
    --gallery-phone-width: 100px;
    --gallery-column-gap: 8px;
  }

  .gallery-hero-copy h1 {
    font-size: 26px;
  }
}

@media (max-width: 340px) {
  .feature-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .feature-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 14px;
    padding: 16px;
  }

  .feature-icon {
    grid-row: 1 / span 2;
    margin: 0;
  }

  .feature-card h3 {
    margin-bottom: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-world,
  .stage-grid,
  .gallery-caption,
  .gallery-hero-copy {
    opacity: 1;
    animation: none !important;
  }

  .phone-column {
    animation: none !important;
  }
}
