:root {
  color-scheme: dark;
  --page-bg: #000;
  --text: #f5f5f5;
  --muted: #d8d8d8;
  --card-grey: #d8d8d8;
  --card-pink: #ffa6a8;
  --card-radius: 16px;
  --gallery-gap-x: 32px;
  --gallery-gap-y: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--page-bg);
}

body {
  color: var(--text);
  font-family: "Inter", Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

.site-shell {
  display: grid;
  grid-template-columns: clamp(280px, 30.75vw, 443px) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  background: var(--page-bg);
}

/* Левая колонка не прокручивается вместе с видеогалереей. */
.sidebar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 100vh;
  padding: 16.7vh 28px 32px;
  background: #000;
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 250px;
  text-align: center;
}

.profile__avatar {
  display: grid;
  width: 122px;
  height: 122px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #d9d9d9;
}

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

.profile__handle {
  margin-top: 16px;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.045em;
}

.profile__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 17px;
  margin-top: 36px;
  font-size: 16px;
  line-height: 1.3;
}

.profile__links p {
  margin: 0;
}

.profile__links a {
  text-decoration: none;
  transition: opacity 180ms ease;
}

.profile__links a:hover {
  opacity: 0.65;
}

.socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
}

.socials__link {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  opacity: 0.92;
  transition: opacity 180ms ease, transform 180ms ease;
}

.socials__link:hover {
  opacity: 0.65;
  transform: translateY(-2px);
}

.socials__link svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.socials__link:nth-child(2) svg {
  fill: currentColor;
  stroke: none;
}

.socials__link .socials__dot {
  fill: currentColor;
  stroke: none;
}

/* Прокручивается только эта правая область. */
.gallery-panel {
  height: 100vh;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 40px 42px 48px;
  scrollbar-width: none;
}

.gallery-panel::-webkit-scrollbar {
  display: none;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: var(--gallery-gap-y) var(--gallery-gap-x);
  width: 100%;
}

.tile {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 9 / 16;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--card-radius);
  background: var(--card-grey);
  color: #fff;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.tile:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.tile__placeholder,
.tile__video,
.tile__shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tile__placeholder {
  background: var(--tile-color, var(--card-grey));
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tile__video {
  display: block;
  object-fit: cover;
  object-position: center;
  background: #171717;
  transition: transform 650ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tile__video[data-fit="contain"] {
  object-fit: contain;
}

.tile__shade {
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0) 48%,
    rgba(0, 0, 0, 0.2) 66%,
    rgba(0, 0, 0, 0.94) 100%
  );
  opacity: 0;
  transition: opacity 260ms ease;
}

.tile__title {
  position: absolute;
  z-index: 2;
  right: 20px;
  bottom: 21px;
  left: 20px;
  color: #fff;
  font-size: 15px;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.tile:hover .tile__shade,
.tile:focus-visible .tile__shade {
  opacity: 1;
}

.tile:hover .tile__title,
.tile:focus-visible .tile__title {
  opacity: 1;
  transform: translateY(0);
}

.tile:hover .tile__video,
.tile:hover .tile__placeholder {
  transform: scale(1.025);
}

/* Окно проекта. Фон страницы затемняется нативным backdrop диалога. */
.project-modal {
  position: fixed;
  width: min(864px, calc(100vw - 40px));
  height: min(715px, calc(100vh - 40px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 56px;
  overflow: visible;
  border: 4px solid #f5f5f5;
  border-radius: 16px;
  background: #000;
  color: #fff;
}

.project-modal::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(1px);
}

.modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 334px);
  align-items: stretch;
  gap: 42px;
  width: 100%;
  height: 100%;
}

.modal-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
}

.modal-details__title {
  max-width: 100%;
  margin: 0 0 28px;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.modal-details__description {
  max-width: 300px;
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-line;
}

.modal-details__link {
  display: inline-block;
  margin-top: 2px;
  color: #fff;
  font-size: 16px;
  line-height: 1.4;
  text-decoration: none;
  text-underline-offset: 4px;
  transition: opacity 180ms ease;
}

.modal-details__link:hover {
  opacity: 0.65;
  text-decoration: underline;
}

.modal-details__link[hidden] {
  display: none;
}

.modal-media {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: var(--card-pink);
}

.modal-media video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.modal-media__empty {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 24px;
  place-items: center;
  color: rgba(0, 0, 0, 0.55);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.modal-close {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0 0 3px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease;
}

.modal-close:hover {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.22);
}

@media (max-width: 1120px) and (min-width: 761px) {
  .site-shell {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .gallery-panel {
    padding-right: 28px;
    padding-left: 28px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
  }

  .project-modal {
    width: min(760px, calc(100vw - 36px));
    height: min(650px, calc(100vh - 36px));
    padding: 44px;
  }

  .modal-layout {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 290px);
    gap: 28px;
  }
}

@media (max-width: 760px) {
  .site-shell {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    padding: 34px 20px 28px;
  }

  .profile {
    max-width: 300px;
  }

  .profile__avatar {
    width: 82px;
    height: 82px;
  }

  .profile__handle {
    margin-top: 12px;
    font-size: 21px;
  }

  .profile__links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 22px;
    margin-top: 18px;
    font-size: 14px;
  }

  .socials {
    margin-top: 16px;
  }

  .gallery-panel {
    height: auto;
    overflow: visible;
    padding: 6px 16px 28px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .tile {
    border-radius: 12px;
  }

  .tile__shade {
    opacity: 0.78;
  }

  .tile__title {
    right: 12px;
    bottom: 13px;
    left: 12px;
    font-size: 12px;
    opacity: 1;
    transform: none;
  }

  .project-modal {
    width: calc(100vw - 24px);
    height: auto;
    max-height: calc(100dvh - 24px);
    padding: 34px 18px 20px;
    overflow-y: auto;
    border-width: 2px;
    border-radius: 14px;
  }

  .modal-layout {
    display: flex;
    flex-direction: column;
    gap: 22px;
    height: auto;
  }

  .modal-media {
    width: min(100%, 300px);
    height: min(52dvh, 460px);
    min-height: 220px;
    aspect-ratio: 9 / 16;
    align-self: center;
  }

  .modal-details {
    align-items: flex-start;
    text-align: left;
  }

  .modal-details__title {
    margin-bottom: 12px;
    font-size: 20px;
  }

  .modal-details__description {
    margin-bottom: 12px;
    font-size: 14px;
  }

  .modal-details__link {
    font-size: 14px;
  }

  .modal-close {
    top: 5px;
    right: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
