/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }

/* ── TOKENS ────────────────────────────────────────────────── */
:root {
  --font: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  --c-page:    #e6e6e6;
  --c-white:   #ffffff;
  --c-t1:      #18181b;
  --c-t2:      #787878;
  --c-t3:      #4b4b4b;
  --c-ttag:    #52525b;
  --c-tag:     #f4f4f5;
  --c-border:  #e4e4e7;
  --c-sep:     #d3d3d3;
  --c-sep2:    #bdbdbd;
  --c-btn-sub: #acacac;
  --cw: 1100px;
  --px: max(20px, calc(50% - 550px));
  --r-card: 16px;
  --r-hero: 32px;
  --photo-size: 132px;
  --card-cover-h: 220px;
  --footer-bg: var(--c-white);
  --footer-radius: var(--r-hero) var(--r-hero) 0 0;
  --footer-padding-y: 24px;
  --footer-gap: 16px;
  --footer-name-color: #18181b;
  --footer-role-color: var(--c-t2);
  --footer-separator-color: var(--c-sep);
}

/* ── BASE ──────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--c-page);
  color: var(--c-t1);
  min-height: 100vh;
}

/* ── REVEAL ───────────────────────────────────────────────── */
@keyframes portfolio-reveal {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes portfolio-page-leave {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

html.page-enter-pending body {
  opacity: 0;
}

.reveal-pending {
  opacity: 0;
  transform: translateY(12px);
  will-change: opacity, transform;
}

.reveal-pending.reveal-visible {
  animation: portfolio-reveal 1.05s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--portfolio-reveal-delay, 0ms);
}

body.page-leaving > :not(script) {
  animation: portfolio-page-leave 0.32s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}

/* ── SEPARATOR ─────────────────────────────────────────────── */
.sep {
  display: inline-block;
  width: 2px;
  height: 16px;
  border-radius: 12px;
  background: var(--c-sep2);
  flex-shrink: 0;
}

.sep--inline {
  margin-inline: 4px;
  vertical-align: -3px;
}

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  cursor: pointer;
  white-space: nowrap;
}
.btn__surface {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
  filter: none;
  transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn:hover .btn__surface {
  box-shadow: none;
  filter: none;
  transform: scale(0.92);
}
.btn:active .btn__surface { transform: scale(0.90); }

@media (hover: none) {
  .btn__surface { transition-duration: 0.18s; }
  .btn:active .btn__surface { transform: scale(0.88); }
}

.btn--outline .btn__surface {
  border: 1px solid var(--c-border);
  background: var(--c-white);
  color: var(--c-t1);
}
.btn--outline .btn__surface svg path { stroke: var(--c-btn-sub); }
.btn__sub { color: var(--c-btn-sub); }

.btn--primary .btn__surface {
  background: var(--c-t1);
  color: var(--c-white);
  border: none;
}

/* ── HEADER ────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  padding: 24px var(--px);
  transition:
    background-color 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.header--scrolled {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: 1px solid rgba(228, 228, 231, 0.4);
}
.header__inner {
  max-width: var(--cw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header__logo {
  font-size: 20px;
  font-weight: 600;
  color: var(--c-t1);
}
.header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── HERO ──────────────────────────────────────────────────── */
.hero {
  background: var(--c-white);
  padding: 42px var(--px);
  border-radius: 0 0 var(--r-hero) var(--r-hero);
}
.hero__inner {
  max-width: var(--cw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 132px 1fr;
  grid-template-rows: auto auto;
  gap: 8px 32px;
}
.hero__photo {
  grid-column: 1;
  grid-row: 1 / 3;
  width: var(--photo-size);
  height: var(--photo-size);
  border-radius: 24px;
  overflow: hidden;
  background: rgba(139,139,139,0.2);
  align-self: start;
}
.hero__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
.hero__byline {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
}
.hero__name {
  font-size: 20px;
  font-weight: 500;
  color: var(--c-t1);
}
.hero__role {
  font-size: 20px;
  font-weight: 500;
  color: var(--c-t2);
}
.hero__headline {
  grid-column: 2;
  grid-row: 2;
  font-size: 36px;
  font-weight: 600;
  line-height: 1.12;
  color: var(--c-t1);
  align-self: start;
}
.hero__headline--muted {
  color: var(--c-t2);
}

/* ── CASES ─────────────────────────────────────────────────── */
.cases {
  padding: 48px var(--px);
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.cases__group {
  max-width: var(--cw);
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cases__title {
  font-size: 24px;
  font-weight: 500;
  color: #626262;
}
.cards {
  display: flex;
  gap: 24px;
}

/* ── CARD ──────────────────────────────────────────────────── */
.card {
  flex: 1 0 0;
  min-width: 0;
  position: relative;
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  background: var(--c-white);
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.card--link {
  cursor: pointer;
}
.card--link,
.card--wip {
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}
.card--link:hover,
.card--wip:hover {
  transform: scale(1.05);
}

/* Индикатор перехода для кликабельных карточек */
.card__link-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(24, 24, 27, 0.1);
  border-radius: 50%;
  background: var(--c-white);
  color: var(--c-t1);
  opacity: 1;
  visibility: visible;
  transform: scale(0.92);
  transition:
    opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.2s ease,
    color 0.2s ease;
  pointer-events: none;
}

.card__link-indicator svg {
  width: 55%;
  height: 55%;
}

@media (hover: hover) {
  .card--link:hover .card__link-indicator,
  .card--link:focus-visible .card__link-indicator {
    transform: scale(1.08);
  }
}

/* card cover */
.card__cover {
  height: var(--card-cover-h);
  position: relative;
  z-index: 0;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: var(--r-card) var(--r-card) 0 0;
}
.card__cover--purple { background: linear-gradient(225deg, #e5d9ff 0%, #bf9fff 50%, #9969ff 100%); }
.card__cover--orange { background: linear-gradient(225deg, #ffbf80 0%, #ffa74f 60%, #ff8e1d 100%); }
.card__cover--blue   { background: linear-gradient(135deg, #00538e 0%, #308ec7 50%, #60caff 100%); }
.card__cover--indigo { background: linear-gradient(135deg, #0011ff 0%, #5660f5 50%, #e4e4e4 100%); }
.card__cover--teal   { background: linear-gradient(135deg, #00cfd4 0%, #72dadc 50%, #e4e4e4 100%); }
.card__cover--green  { background: linear-gradient(135deg, #edf0e9 0%, #93a472 60%, #748b4a 100%); }

/* mockup images */
.card__mockup {
  position: absolute;
  pointer-events: none;
}

/* desktop laptops: плавают в обложке с отступами, не растягиваясь */
.card__mockup--desktop {
  max-width: calc(100% - 32px);
  max-height: calc(100% - 20px);
  width: auto;
  height: auto;
  left: 50%;
  bottom: 10px;
  top: auto;
  transform: translateX(-50%);
}


/* phones (BuildLog, 2HACK): с отступами по бокам, прилипает к низу */
.card__mockup--phones {
  max-width: calc(100% - 40px);
  max-height: 100%;
  width: auto;
  height: auto;
  left: 50%;
  bottom: 0;
  top: auto;
  transform: translateX(-50%);
}

/* mobile phones: полная ширина, клип снизу */
.card__mockup--mobile {
  width: auto;
  height: auto;
  max-width: 100%;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
}

/* iPad (DVS): центр обложки */
.card__mockup--ipad {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--card-cover-h);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Meditron: cover с фокусом на правой части где экран */
.card__mockup--cover {
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  object-fit: cover;
  object-position: right 55%;
}

/* 2HACK: two phones */
.card__mockup--phone-l {
  width: 157px;
  height: 341px;
  left: 17px;
  top: 17px;
  object-fit: cover;
}
.card__mockup--phone-r {
  width: 162px;
  height: 353px;
  left: 180px;
  top: 25px;
  object-fit: cover;
}

/* WIP overlay */
/* WIP overlay — только на обложке */
.card--wip .card__cover::after {
  content: attr(data-wip);
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.40);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 20px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transition:
    opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    -webkit-backdrop-filter 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 1;
}
.card--wip:hover .card__cover::after {
  opacity: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* card body */
.card__body {
  flex: 1 0 0;
  background: var(--c-white);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-radius: 0 0 var(--r-card) var(--r-card);
}
.card__tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tag {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--c-tag);
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ttag);
  white-space: nowrap;
}
.card__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card__title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.28;
  color: var(--c-t1);
}
.card__desc {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--c-t3);
}

/* ── FOOTER ────────────────────────────────────────────────── */
.footer {
  background: var(--footer-bg);
  border-radius: var(--footer-radius);
  padding: var(--footer-padding-y) var(--px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--footer-gap);
}
.footer__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--footer-role-color);
}
.footer__name > span:first-child { color: var(--footer-name-color); }
.footer .sep { background: var(--footer-separator-color); }
.footer__links {
  display: flex;
  gap: 20px;
}
.footer__links a {
  font-size: 20px;
  font-weight: 500;
  color: var(--c-t1);
  transition: color 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.footer__links a:hover { color: var(--c-t2); }

/* ── FOCUS VISIBLE ─────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--c-t1);
  outline-offset: 3px;
  border-radius: 4px;
}


/* ── RESPONSIVE: TABLET ────────────────────────────────────── */
@media (max-width: 900px) {
  .hero__headline { font-size: 32px; }
  .cards { flex-wrap: wrap; }
  .card { flex: 1 1 calc(50% - 6px); min-width: 280px; }
}

/* ── RESPONSIVE: MOBILE ────────────────────────────────────── */
@media (max-width: 640px) {
  /* Не скрываем первый кадр, пока deferred-скрипт готовит анимации. */
  html.page-enter-pending body { opacity: 1; }

  .reveal-pending.reveal-visible {
    animation-duration: 0.18s;
  }

  .header { padding: 16px var(--px); }
  .hero { padding: 28px var(--px); }

  /* строка 1: фото + имя/роль; строка 2: заголовок на всю ширину */
  .hero__inner {
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto auto;
    gap: 16px 16px;
  }
  .hero__photo {
    grid-column: 1;
    grid-row: 1;
    width: 80px;
    height: 80px;
    border-radius: 16px;
  }
  .hero__byline {
    grid-column: 2;
    grid-row: 1;
    flex-direction: column;
    gap: 1px;
    align-items: flex-start;
    align-self: center;
  }
  .hero__byline .sep { display: none; }
  .hero__name { font-size: 16px; }
  .hero__role { font-size: 16px; }
  .hero__headline {
    grid-column: 1 / 3;
    grid-row: 2;
    font-size: 22px;
  }

  .cases { padding: 24px var(--px); gap: 28px; }
  .cases__title { font-size: 18px; }
  .cards { flex-direction: column; }
  .card { flex: none; width: 100%; }

  /* На touch-экранах карточка не увеличивается, стрелка всегда видна */
  .card--link:hover,
  .card--wip:hover {
    transform: none;
  }
  .card--link,
  .card--wip {
    transition-duration: 0.18s;
  }
  .card--link:active,
  .card--wip:active {
    transform: scale(0.96);
  }
  .card__link-indicator {
    width: 44px;
    height: 44px;
    opacity: 1;
    transform: none;
  }
  .card--wip:active .card__cover::after {
    opacity: 1;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* ноутбуки на мобилке — чуть больше, немного ниже */
  .card__mockup--desktop {
    max-width: calc(100% - 16px);
    top: 18px;
    bottom: auto;
    transform: translateX(-50%);
  }


  /* iPad (DVS) — чуть крупнее на мобилке */
  .card__mockup--ipad {
    max-width: 108%;
    max-height: 108%;
    transform: translate(-50%, -50%) scale(1.04);
  }

  /* Meditron — зум по центру на мобилке */
  .card__mockup--cover {
    width: 100%;
    height: 100%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(1.05);
    object-position: center center;
  }

/* phones — отступы на мобилке */
  .card__mockup--phones {
    max-width: calc(100% - 32px);
    max-height: 100%;
  }

  /* 2HACK phones — отступы по бокам и сверху */
  .card__mockup--phone-l {
    width: calc(50% - 8px);
    height: calc(100% - 10px);
    left: 8px;
    top: 10px;
    object-fit: cover;
    object-position: center top;
  }
  .card__mockup--phone-r {
    width: calc(50% - 8px);
    height: calc(100% - 10px);
    left: 50%;
    top: 10px;
    object-fit: cover;
    object-position: center top;
  }


  .header__logo { font-size: 15px; }
  .btn__surface { padding: 12px 16px; font-size: 14px; border-radius: 12px; }
  .btn__sub { display: none; }

  /* Футер: одна строка, меньший размер, сепаратор виден */
  .footer__name { justify-content: center; gap: 6px; font-size: 14px; }
  .footer__links { flex-wrap: wrap; justify-content: center; gap: 12px; }
  .footer__links a { font-size: 16px; }

}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn__sub { transition: none; }
  html.page-enter-pending body { opacity: 1; }
  body.page-leaving > :not(script) { animation: none; }
  .reveal-pending { opacity: 1; transform: none; will-change: auto; }
  .reveal-pending.reveal-visible { animation: none; }
}
