*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #121212;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  text-wrap: pretty;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  --gallery-inline: clamp(16px, 2.5vw, 32px);
  display: flex;
  align-items: stretch;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 auto;
  /* Референс: при 1920px вьюпорта колонка 640px → масштаб min(640px, 100vw × 640/1920); мобайл — ≤900px */
  width: min(640px, calc(100vw * 640 / 1920));
  max-width: min(640px, 100%);
  align-self: stretch;
  box-sizing: border-box;
  padding: clamp(24px, 0.75rem + 2.2vh, 52px) clamp(16px, 0.5rem + 1.75vw, 44px) clamp(28px, 1rem + 2.8vh, 60px)
    clamp(16px, 0.5rem + 1.85vw, 44px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  transition: padding 0.22s ease;
}

.sidebar__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: flex-end;
  width: 40px;
  height: 40px;
  margin: 0 0 4px;
  padding: 0;
  border: 1px solid #333;
  border-radius: 10px;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sidebar__toggle:hover {
  background: #252525;
  border-color: #444;
}

.sidebar__toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.sidebar__toggle-icon {
  display: block;
  width: 8px;
  height: 8px;
  margin-left: 2px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.page--sidebar-collapsed .sidebar__toggle-icon {
  margin-left: 0;
  margin-right: 2px;
  transform: rotate(-135deg);
}

.sidebar__toggle-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  gap: clamp(36px, 5vw, 60px);
  width: 100%;
  max-width: 100%;
}

.page--sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  max-width: 0;
  flex: 0 0 0;
  padding: 0;
  margin: 0;
  overflow: visible;
  pointer-events: none;
  border: none;
}

.page--sidebar-collapsed .sidebar__inner {
  display: none;
}

.page--sidebar-collapsed .sidebar__toggle {
  pointer-events: auto;
  position: fixed;
  z-index: 30;
  left: max(var(--gallery-inline), env(safe-area-inset-left, 0px));
  top: max(12px, env(safe-area-inset-top, 0px));
  margin: 0;
  align-self: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.page--sidebar-collapsed .gallery {
  padding-left: max(var(--gallery-inline), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gallery-inline), env(safe-area-inset-right, 0px));
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

.intro {
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3.5vw, 32px);
  max-width: 100%;
}

.intro__profile {
  display: grid;
  grid-template-columns: 56px 1fr;
  column-gap: 14px;
  align-items: center;
}

.intro__avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  background: #1e1e1e;
}

.intro__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.intro__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.intro__name {
  margin: 0;
  font-size: clamp(1.35rem, 1.1rem + 1.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.intro__role {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.intro__tagline {
  margin: 0;
  font-size: clamp(2rem, 1.8rem + 1.2vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.35;
}

.intro__tagline-strong {
  color: #fff;
}

.intro__tagline-muted {
  color: #a0a0a0;
  font-weight: 600;
}

.intro__status {
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes status-dot-pulse-online {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.35), 0 0 6px rgba(61, 220, 132, 0.45);
  }
  50% {
    opacity: 0.35;
    box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.08), 0 0 2px rgba(61, 220, 132, 0.1);
  }
}

@keyframes status-dot-pulse-away {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(232, 93, 93, 0.35), 0 0 6px rgba(232, 93, 93, 0.45);
  }
  50% {
    opacity: 0.35;
    box-shadow: 0 0 0 2px rgba(232, 93, 93, 0.08), 0 0 2px rgba(232, 93, 93, 0.1);
  }
}

.intro__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.25);
  animation: status-dot-pulse-away 2.4s ease-in-out infinite;
}

.intro__status--away .intro__status-dot {
  background: #e85d5d;
  animation-name: status-dot-pulse-away;
}

.intro__status--online .intro__status-dot {
  background: #3ddc84;
  animation-name: status-dot-pulse-online;
}

@media (prefers-reduced-motion: reduce) {
  .intro__status-dot {
    animation: none;
    opacity: 1;
  }
}

.intro__status-text {
  font-size: 14px;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.btn-brief {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  padding: 12px 16px;
  border-radius: 88px;
  background: #fff;
  color: #121212;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.05em;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-brief:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.rule {
  border: none;
  height: 1px;
  margin: 0;
  background: #2a2a2a;
  width: 100%;
}

.block__title {
  margin: 0 0 12px;
  font-size: clamp(1rem, 0.95rem + 0.35vw, 1.125rem);
  font-weight: 600;
  letter-spacing: -0.05em;
}

.block__text {
  margin: 0 0 12px;
  width: 100%;
  max-width: none;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stats__row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.stats__num {
  color: #fff;
}

.stats__sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.35;
  flex-shrink: 0;
}

.services {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.service-group__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.service-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.service-list li {
  position: relative;
  padding-left: 20px;
  margin-top: 4px;
  font-size: 16px;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.service-list li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a0a0a0;
}

.stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stack__item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stack__icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.stack__name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.5;
}

.stack__desc {
  font-size: 14px;
  line-height: 1.5;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.reviews {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.review {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}

.review__body {
  flex: 1;
  min-width: 0;
}

.review__avatar {
  width: 42px;
  height: 42px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.review__name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}

.review__role,
.review__text {
  margin: 0;
  width: 100%;
  max-width: none;
  font-size: 16px;
  line-height: 1.5;
  color: #a0a0a0;
  letter-spacing: -0.04em;
}

.review__role {
  margin-bottom: 8px;
}

.review__link {
  display: inline-block;
  margin: 0;
  width: 100%;
  max-width: none;
  font-size: 16px;
  line-height: 1.5;
  color: #a0a0a0;
  letter-spacing: -0.04em;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.review__link:hover {
  color: #fff;
}

.contacts__email {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
  color: inherit;
  text-decoration: none;
}

.contacts__email:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.contacts__social {
  display: flex;
  gap: 26px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.contacts__social a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Портфолио: квадратные карточки с обложкой; сетка как autolayout — repeat(auto-fill) с переносом строк.
   ≤900px — одна колонка; 901–1919 — две; от 1920 — три (минимальная ширина ячейки задаёт число колонок). */
.gallery {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  box-sizing: border-box;
  --gallery-gap: 4px;
  --gallery-cell-min: 100%;
  display: grid;
  gap: var(--gallery-gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gallery-cell-min)), 1fr));
  grid-auto-rows: auto;
  align-content: start;
  align-items: start;
  padding-top: max(0px, env(safe-area-inset-top, 0px));
  padding-right: max(var(--gallery-inline), env(safe-area-inset-right, 0px));
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  padding-left: max(0px, env(safe-area-inset-left, 0px));
}

@media (min-width: 901px) and (max-width: 1919px) {
  .gallery {
    --gallery-cell-min: calc((100% - var(--gallery-gap)) / 2);
  }
}

@media (min-width: 1920px) {
  .gallery {
    --gallery-cell-min: calc((100% - 2 * var(--gallery-gap)) / 3);
  }
}

/* Прямыми потомками grid только ячейки — высота строки = блок с aspect-ratio внутри (не ломается min-height grid-item). */
.gallery__cell {
  min-width: 0;
  align-self: start;
  justify-self: stretch;
}

.portfolio-card {
  display: block;
  width: 100%;
  margin: 0;
  position: relative;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: clamp(12px, 2.2vw, 20px);
  overflow: hidden;
  box-sizing: border-box;
  color: #fff;
  border: 0;
  padding: 0;
  background: #1a1a1a;
  cursor: default;
  text-decoration: none;
}

a.portfolio-card {
  cursor: pointer;
}

.portfolio-card--static {
  cursor: default;
}

.portfolio-card:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  z-index: 1;
}

.portfolio-card__cover {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.48s ease;
}

.portfolio-card__meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  gap: clamp(8px, 2vw, 16px);
  padding: clamp(12px, 3.5%, 20px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.38s ease;
}

.portfolio-card__title,
.portfolio-card__tag {
  font-size: clamp(0.75rem, 0.62rem + 0.55vw, 0.9375rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.portfolio-card__title {
  text-align: left;
  flex: 1;
  min-width: 0;
}

.portfolio-card__tag {
  text-align: right;
  flex-shrink: 0;
  max-width: 44%;
  color: rgba(255, 255, 255, 0.9);
}

@media (hover: hover) and (pointer: fine) {
  .portfolio-card__meta {
    opacity: 0;
  }

  .portfolio-card:hover .portfolio-card__meta,
  .portfolio-card:focus-within .portfolio-card__meta {
    opacity: 1;
  }

  .portfolio-card:hover .portfolio-card__cover,
  .portfolio-card:focus-within .portfolio-card__cover {
    transform: scale(1.02);
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-card__cover {
    transition-duration: 0.15s;
  }

  .portfolio-card__meta {
    transition-duration: 0.15s;
  }

  .portfolio-card:hover .portfolio-card__cover,
  .portfolio-card:focus-within .portfolio-card__cover {
    transform: none;
  }
}

@media (min-width: 901px) {
  .block,
  .contacts {
    padding-right: 20px;
  }

  html:has(.page),
  body:has(.page) {
    height: 100%;
    overflow: hidden;
  }

  .page {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .gallery {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Вертикальные отступы как у верха сайдбара — сверху и снизу одинаково */
    padding-top: max(clamp(24px, 0.75rem + 2.2vh, 52px), env(safe-area-inset-top, 0px));
    padding-bottom: max(clamp(24px, 0.75rem + 2.2vh, 52px), env(safe-area-inset-bottom, 0px));
  }

  .gallery::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}

.mobile-nav {
  display: none;
}

@media (max-width: 900px) {
  .block,
  .contacts,
  .intro > .block__text {
    padding-right: 12px;
  }

  .page {
    flex-direction: column;
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow: visible;
    scroll-padding-top: 1rem;
    scroll-padding-bottom: calc(20px + 3.5rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    width: 100%;
    max-width: none;
    overflow: visible;
    padding-top: max(1.25rem, env(safe-area-inset-top, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-bottom: clamp(2rem, 6vw, 2.75rem);
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    scroll-margin-top: 1rem;
  }

  .sidebar__toggle {
    display: none;
  }

  .sidebar__inner {
    max-width: none;
  }

  .intro__tagline {
    font-size: clamp(calc(21px * 0.95), calc(0.665rem + 3.724vw), calc(33.6px * 0.95));
  }

  .block__title {
    font-size: 18px;
  }

  .service-list li {
    font-size: 16px;
    margin-top: 8px;
  }

  .review__name,
  .review__role,
  .review__link {
    font-size: 16px;
  }

  .block__text,
  .review__role,
  .review__text,
  .service-list li,
  .stack__desc {
    line-height: 1.5;
  }

  .block__text,
  .review__role,
  .review__text,
  .review__link {
    max-width: none;
  }

  .gallery {
    overflow: visible;
    flex: none;
    width: 100%;
    --gallery-gap: var(--gallery-inline);
    padding-top: 0;
    padding-right: max(var(--gallery-inline), env(safe-area-inset-right, 0px));
    padding-bottom: calc(20px + 3.5rem + 20px + env(safe-area-inset-bottom, 0px));
    padding-left: max(var(--gallery-inline), env(safe-area-inset-left, 0px));
    scroll-margin-top: 1rem;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .mobile-nav__pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 74px;
    background: #1e1e1e;
    pointer-events: auto;
  }

  .mobile-nav__item {
    margin: 0;
    padding: 12px 16px;
    border: 0;
    border-radius: 63px;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: normal;
    color: #fff;
    letter-spacing: -0.04em;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .mobile-nav__item--active {
    background: #121212;
  }

  .mobile-nav__item:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
  }
}
