@import url('https://fonts.googleapis.com/css2?family=TikTok+Sans:wght@400;700&family=Tiny5&display=swap');

/* =========================================
   ОБЩЕЕ И ДЕСКТОП — МАКЕТ 910 PX
   ========================================= */
* { box-sizing: border-box; }
body { margin: 0; background: #393EED; color: #fff; font-family: 'TikTok Sans', sans-serif; }
h1, h2, p { margin: 0; }
.portfolio { width: 910px; max-width: 910px; margin: 0 auto; padding-top: 60px; }

.hero { margin-bottom: 120px; }
.hero h1 {
  position: relative; left: -5px; width: max-content;
  font-size: 103.85px; font-weight: 700; line-height: .8;
  text-transform: uppercase; white-space: nowrap;
  transform: scaleX(.95); transform-origin: left center;
}
.hero-content { display: flex; gap: 20px; margin-top: 32px; }
.hero-left { display: flex; flex-direction: column; justify-content: space-between; width: 600px; }
.hero-description {
  position: relative; top: -12px; font-size: 26px; line-height: 1.2;
  transform: scaleX(.941); transform-origin: left center;
}

/* Фото и векторная надпись */
.portrait-card {
  position: relative; flex-shrink: 0; width: 290px; height: 327px;
  overflow: hidden; background: #EC3F39;
}
.portrait-label-box { position: absolute; top: 5px; left: 5px; z-index: 1; width: 280px; pointer-events: none; }
.portrait-label-svg { display: block; width: 100%; height: auto; }
.portrait-label-fragments { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.portrait-label-fragment { position: absolute; width: 7px; height: 7px; background: #fff; }
.portrait {
  position: absolute; bottom: 0; left: 0; z-index: 2;
  width: 290px; height: 273px; object-fit: contain;
}
.portrait-label-bottom {
  position: absolute; left: 5px; bottom: 0; z-index: 3;
  display: block; width: 280px; height: auto;
  opacity: 0; transform: translateY(110%); pointer-events: none;
}

/* Контактные кнопки и SVG-стрелки */
.contacts { display: flex; gap: 20px; }
.contact-button {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  width: 290px; height: 57px; background: #fff; color: #000;
  font-family: 'Tiny5', monospace; font-size: 32px;
  text-decoration: none; text-transform: uppercase;
}
.arrow { display: inline-block; flex-shrink: 0; background: currentColor; }
.arrow-small {
  width: 12px; height: 21px;
  -webkit-mask: url('assets/images/arrow-small.svg') center / contain no-repeat;
  mask: url('assets/images/arrow-small.svg') center / contain no-repeat;
}
.arrow-big {
  width: 16px; height: 28px;
  -webkit-mask: url('assets/images/arrow-big.svg') center / contain no-repeat;
  mask: url('assets/images/arrow-big.svg') center / contain no-repeat;
}

/* Переворачивающиеся карточки */
.flip-card { position: relative; perspective: 1200px; }
.flip-inner {
  position: relative; display: block; width: 100%; height: 100%;
  color: inherit; text-decoration: none;
  transform-style: preserve-3d; transition: transform .2s ease-in-out;
}
.flip-front, .flip-back {
  position: absolute; inset: 0; width: 100%; height: 100%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flip-back { display: flex; transform: rotateX(180deg); background: #C96340; color: #fff; }

/* На десктопе наведение — переворот; фокус с клавиатуры — тоже */
@media (min-width: 768px) {
  .flip-card:focus-within:not(.flip-reset) .flip-inner { transform: rotateX(180deg); }
}
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .flip-card:hover:not(.flip-reset) .flip-inner { transform: rotateX(180deg); }
}

/* Обо мне */
.about { width: 100%; height: 500px; background: transparent; }
.about-front { background: #000; color: #fff; }
.about-link {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  width: 100%; height: 100%; padding-bottom: 72px;
  font-family: 'Tiny5', monospace; font-size: 48px; line-height: 1.1;
  text-transform: uppercase;
}
.about-text { position: relative; left: 5px; }
.about.flip-card .about-back {
  display: flex; flex-direction: column; justify-content: flex-start;
  gap: 40px; padding: 30px 50px 50px 40px;
  background: #fff; color: #000;
}
.about-back p {
  width: 106.3%; font-size: 26px; line-height: 1.3;
  transform: scaleX(.941); transform-origin: left top;
}
.about-school-link {
  color: inherit; text-decoration: underline; text-underline-offset: 6px;
  text-decoration-thickness: .5px; transition: background-color .15s ease;
}
.about-school-link:hover, .about-school-link:focus-visible { background: #EC3F39; }

/* Сетка проектов на 910 колонок, рассчитана на точные размеры 606/304/455 */
.projects { display: grid; grid-template-columns: repeat(910, minmax(0, 1fr)); gap: 0; margin-top: 120px; }
.projects > .flip-card { height: 304px; min-width: 0; }
.project {
  display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0; height: 304px; padding: 40px;
  text-decoration: none; color: #fff;
}
.project h2 {
  display: flex; align-items: center; gap: 16px;
  font-family: 'Tiny5', monospace; font-size: 48px; font-weight: 400;
  line-height: 1.1; text-transform: uppercase; white-space: nowrap;
}
.project p { font-size: 24px; line-height: 1.2; transform: scaleX(.941); transform-origin: left center; }

.project-murnorka, .project-student { grid-column: 1 / -1; }
.project-upravlyayka { grid-column: span 606; color: #000; }
.project-march { grid-column: span 304; }
.project-poster-one, .project-poster-two { grid-column: span 455; }
.project-poster-one { color: #000; }
.project-poster-two { color: #F2D657; }

.project-murnorka .flip-front { background: #C96340; color: #fff; }
.murnorka-back-info { display: flex; flex-direction: column; justify-content: space-between; width: 40%; padding: 40px; }
.murnorka-back-info h2 {
  display: flex; align-items: center; gap: 16px;
  font-family: 'Tiny5', monospace; font-size: 48px; font-weight: 400;
  line-height: 1.1; text-transform: uppercase; white-space: nowrap;
}
.murnorka-back-info p { font-size: 24px; line-height: 1.2; }
.project-murnorka .flip-back img { display: block; width: 60%; height: 100%; object-fit: cover; }
.mobile-caption { display: none; }

.project-upravlyayka .flip-front, .project-upravlyayka .flip-back { background: #36B99D; color: #000; }
.project-march .flip-front, .project-march .flip-back { background: #83266F; color: #fff; }
.project-poster-one .flip-front, .project-poster-one .flip-back { background: #C8E2F1; color: #000; }
.project-poster-two .flip-front, .project-poster-two .flip-back { background: #24573E; color: #F2D657; }

.upravlyayka-back, .march-back, .poster-back {
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: space-between; padding: 40px;
}
.upravlyayka-back h2, .march-back h2, .poster-back h2 {
  display: flex; align-items: center; gap: 16px;
  font-family: 'Tiny5', monospace; font-size: 48px; font-weight: 400;
  line-height: 1.1; text-transform: uppercase; white-space: nowrap;
}
.upravlyayka-back img, .march-back img, .poster-back img {
  display: block; width: 100%; height: 130px; object-fit: cover;
}
.upravlyayka-back p, .march-back p, .poster-back p {
  font-size: 24px; line-height: 1.2; transform: scaleX(.941); transform-origin: left center;
}
.march-back p { white-space: nowrap; }
.project-poster-one .poster-back img { object-position: center 86%; }

/* Кто студент: 3 × 2 на десктопе */
.project-student .flip-front { background: #EB438C; color: #fff; }
.student-back {
  display: grid; grid-template-columns: repeat(3, 302px);
  grid-template-rows: repeat(2, 151px); gap: 2px; padding: 0; background: #EB438C;
}
.student-back a { display: block; width: 302px; height: 151px; overflow: hidden; }
.student-back img { display: block; width: 100%; height: 100%; object-fit: cover; }
.student-cover { position: relative; overflow: hidden; cursor: pointer; }
.student-cover span {
  position: absolute; bottom: 12px; z-index: 1;
  color: #fff; font-size: 16px; font-weight: 700;
  line-height: 1.2; white-space: nowrap;
}
.student-cover.align-left span { left: 18px; }
.student-cover.align-right span { right: 18px; }
.student-cover img { transition: transform .2s ease; transform-origin: center; }
@media (hover: hover) and (pointer: fine) {
  .student-cover:hover img, .student-cover:focus-visible img { transform: scale(1.05); }
}

/* Подвал */
.footer { display: flex; justify-content: space-between; align-items: center; margin-top: 120px; padding-bottom: 60px; }
.footer-info { display: flex; flex-direction: column; gap: 12px; }
.footer-info p { font-size: 16px; line-height: 1.1; }
.footer-contacts { display: flex; gap: 24px; }
.footer-contacts a {
  display: flex; align-items: center; justify-content: center;
  width: 80px; height: 48px; background: #fff;
}
.footer-contacts img { display: block; max-width: 100%; max-height: 100%; mix-blend-mode: multiply; }
.contact-button, .footer-contacts a {
  position: relative; box-shadow: none;
  transition: background-color .15s ease, transform .12s ease;
}
.contact-button:hover, .footer-contacts a:hover,
.contact-button:focus-visible, .footer-contacts a:focus-visible { background: #EC3F39; }
.contact-button:active, .footer-contacts a:active { transform: translate(2px, 2px); }

/* Модальное окно находится ВНЕ масштабируемой колонки */
.lightbox {
  position: fixed; inset: 0; width: 100%; max-width: 100%;
  height: 100%; max-height: 100%; margin: 0; padding: 40px;
  border: 0; background: transparent; overflow: auto;
}
.lightbox::backdrop { background: rgba(0,0,0,.85); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox-image { display: block; max-width: 100%; max-height: calc(100dvh - 80px); width: auto; height: auto; object-fit: contain; }
.lightbox-close {
  position: fixed; top: 20px; right: 24px; z-index: 1;
  padding: 0; border: 0; background: transparent;
  color: #fff; font-size: 40px; cursor: pointer;
}

/* Эффекты фотографии — только устройства с настоящим наведением */
@keyframes portrait-colors {
  0%, 24.99% { background: #C96340; }
  25%, 49.99% { background: #36B99D; }
  50%, 74.99% { background: #83266F; }
  75%, 100% { background: #EB438C; }
}
@keyframes portrait-label-fall {
  from { transform: translate3d(0,0,0); }
  to { transform: translate3d(var(--dx,0px),var(--fall,300px),0); }
}
@keyframes designer-pop-up {
  0% { opacity: 0; transform: translateY(110%); }
  5% { opacity: 1; }
  45% { transform: translateY(-40px); }
  75% { transform: translateY(12px); }
  88% { transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}
@media (hover: hover) and (pointer: fine) {
  .portrait-card:hover { animation: portrait-colors .8s linear infinite; }
  .portrait-card:hover .portrait-label-svg { opacity: 0; }
  .portrait-card:hover .portrait-label-fragments { opacity: 1; }
  .portrait-card:hover .portrait-label-fragment {
    animation: portrait-label-fall .55s cubic-bezier(.45,0,1,1) forwards;
    animation-delay: var(--delay,0s);
  }
  .portrait-card:hover .portrait-label-bottom { animation: designer-pop-up .5s ease-out .55s both; }
}

/* Элементы аккордеона не отображаются на десктопе */
.about-toggle, .project-mobile-toggle { display: none; }

/* =========================================
   МОБИЛЬНАЯ КОМПОНОВКА
   УЗКОЕ ОКНО ИЛИ ОСНОВНОЙ СЕНСОРНЫЙ ВВОД
   Одно и то же условие используется в JS.
   ========================================= */
@media (max-width: 767px), (pointer: coarse) {
  .portfolio { width: calc(100% - 40px); max-width: 600px; padding-top: 24px; zoom: 1 !important; }

  /* Первый экран: размеры 360 px -> 320 px рабочая колонка */
  .hero { margin-bottom: 20px; }
  .hero h1 {
    left: -2px; font-size: clamp(31.94px, calc(11.40625vw - 4.5625px), 68.44px);
    line-height: .9; transform: scaleX(.95); transform-origin: left center;
  }
  .hero-content {
    display: grid; grid-template-columns: minmax(0,1fr) 37.5%;
    grid-template-areas: 'description portrait' 'contacts contacts';
    column-gap: 10px; row-gap: 8px; margin-top: 11px; align-items: start;
  }
  .hero-left { display: contents; }
  .hero-description {
    grid-area: description; position: static; top: auto;
    width: 106.3%; font-size: clamp(14px,3.889vw,18.67px); line-height: 1.214;
    transform: scaleX(.941); transform-origin: left top;
  }
  .portrait-card { grid-area: portrait; width: 100%; height: auto; aspect-ratio: 8 / 9; margin-top: 4px; }
  .portrait { width: 100%; height: auto; object-fit: cover; }
  .portrait-label-box { top: 2px; left: 2px; width: calc(100% - 4px); }
  .portrait-label-bottom { left: 2px; width: calc(100% - 4px); }
  .contacts { grid-area: contacts; width: 100%; gap: 14px; }
  .contact-button {
    flex: 1 1 0; min-width: 0; width: auto;
    height: clamp(30px,7.5vw,44px); gap: 8px;
    font-size: clamp(16px,4.445vw,23px);
  }
  .contact-button .arrow-small { width: 6.86px; height: 12px; }

  /* Обо мне */
  .about.flip-card {
    display: grid; grid-template-rows: 46px 0fr;
    width: 100%; height: auto; perspective: none; background: #000;
    transition: grid-template-rows .24s ease;
  }
  .about.flip-card.is-open { grid-template-rows: 46px 1fr; }
  .about-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; height: 46px; padding: 0 14px 0 10px;
    border: 0; background: #000; color: #fff;
    font-family: 'Tiny5',monospace; font-size: 24px; font-weight: 400;
    line-height: 1.1; text-transform: uppercase; text-align: left; cursor: pointer;
  }
  .about-toggle .about-toggle-arrow {
    width: 9px; height: 16px; transform: rotate(90deg);
    transform-origin: center; transition: transform .22s ease;
  }
  .about.is-open .about-toggle-arrow { transform: rotate(-90deg); }
  .about.flip-card .flip-inner {
    display: block; width: 100%; height: auto; min-height: 0;
    overflow: hidden; transform: none !important; transform-style: flat; transition: none;
  }
  .about.flip-card .about-front { display: none; }
  .about.flip-card .about-back {
    position: static; display: flex; flex-direction: column; gap: 0;
    width: 100%; height: auto; min-height: 0; overflow: hidden;
    padding: 0 10px; background: #000; color: #fff;
    transform: none; backface-visibility: visible;
  }
  .about.flip-card .about-back p {
    width: min(270px, calc(100% - 30px));
    margin: 0; font-size: 14px; line-height: 1.4; transform: none;
  }
  .about.flip-card .about-back p:first-child { margin-top: 6px; }
  .about.flip-card .about-back p + p { margin-top: 10px; }
  .about.flip-card .about-back p:last-child { margin-bottom: 25px; }
  .about-school-link { text-underline-offset: 3px; text-decoration-thickness: .35px; }

  /* Общая мобильная сетка проектов: одна колонка */
  .projects { grid-template-columns: minmax(0,1fr); margin-top: 40px; }
  /* В закрытом состоянии высота зависит от заголовка и числа строк описания. */
  .projects > .flip-card {
    display: grid; grid-column: 1 / -1; grid-template-rows: auto 0fr;
    width: 100%; height: auto; min-width: 0; perspective: none;
    transition: grid-template-rows .24s ease;
  }
  /* При раскрытии строка заголовка остаётся высотой 46px. */
  .projects > .flip-card.is-open { grid-template-rows: auto 1fr; }

  .project-murnorka { background: #C96340; color: #fff; }
  .project-upravlyayka { background: #36B99D; color: #000; }
  .project-march { background: #83266F; color: #fff; }
  .project-student { background: #EB438C; color: #fff; }
  .project-poster-one { background: #C8E2F1; color: #000; }
  .project-poster-two { background: #24573E; color: #F2D657; }

  .project-mobile-toggle {
    display: flex; flex-direction: column; justify-content: space-between;
    width: 100%; height: auto; min-height: 77px; min-width: 0;
    gap: 8px; padding: 10px; border: 0; background: transparent;
    color: inherit; text-align: left; cursor: pointer;
  }
  /* Открыто: только название и стрелка, подпись скрывается. */
  .projects > .flip-card.is-open .project-mobile-toggle {
    height: 46px; min-height: 46px; gap: 0;
  }
  .project-mobile-heading {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; width: 100%; font-family: 'Tiny5',monospace;
    font-size: 24px; line-height: 1.1; text-transform: uppercase;
  }
  .project-mobile-summary { font-size: 14px; line-height: 1.2; }
  .projects > .flip-card.is-open .project-mobile-summary { display: none; }
  .project-mobile-arrow-wrap { position: relative; display: block; flex-shrink: 0; width: 16px; height: 16px; }
  .project-mobile-arrow {
    position: absolute; top: 0; left: 3.5px; width: 9px; height: 16px;
    transform: rotate(90deg); transition: transform .22s ease;
  }
  .projects > .flip-card.is-open .project-mobile-arrow { transform: rotate(-90deg); }
  .project-mobile-toggle:focus-visible, .about-toggle:focus-visible {
    outline: 2px solid currentColor; outline-offset: -3px;
  }

  .projects > .flip-card > .flip-inner {
    display: block; width: 100%; height: auto; min-height: 0;
    overflow: hidden; transform: none !important; transform-style: flat; transition: none;
  }
  .projects > .flip-card .flip-front { display: none; }
  .projects > .flip-card .flip-back {
    position: static; display: flex; flex-direction: column;
    align-items: stretch; justify-content: flex-start; gap: 8px;
    width: 100%; height: auto; padding: 0 10px 10px;
    transform: none; backface-visibility: visible;
  }
  .projects > .flip-card .flip-back h2 { display: none; }
  .projects > .flip-card .flip-back p { font-size: 14px; line-height: 1.2; transform: none; }
  .projects > .flip-card .flip-back img {
    display: block; width: 100%; height: auto;
    aspect-ratio: 5 / 2; object-fit: cover;
  }
  .projects > .flip-card .flip-back .murnorka-back-info { display: block; width: 100%; padding: 0; order: 1; }
  .projects > .project-murnorka .flip-back img { order: 0; aspect-ratio: 2.12; object-position: center 65%; }
  .desktop-caption { display: none; }
  .mobile-caption { display: inline; }
  .project-march .march-back img { object-position: center 30%; }
  .project-poster-one .poster-back img { object-position: center 86%; }
  .project-poster-two .poster-back img { object-position: center; }

  /* Кто студент: две колонки без общей нижней подписи */
  .projects > .project-student .student-back {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    grid-template-rows: none; grid-auto-rows: auto; gap: 0; padding: 0;
    background: #EB438C;
  }
  .projects > .project-student .student-back a {
    width: 100%; height: auto; min-width: 0; aspect-ratio: 2 / 1; overflow: hidden;
  }
  .projects > .project-student .student-back img {
    width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover;
  }
  .projects > .project-student .student-cover span {
    position: absolute; bottom: 5px; left: auto; right: 10px;
    padding: 0 2px; color: #000; font-size: 12px;
    font-weight: 700; line-height: 1.1; white-space: nowrap;
  }
  .cover-shuplyak span { background: #BDD92F; }
  .cover-panfilova span { background: #6A52A0; }
  .cover-sichkar span { background: #DB57A0; }
  .cover-kostareva span { background: #0493CB; }
  .cover-matveeva span { background: #EF1C47; }
  .cover-anatsko span { background: #FE6F94; }

  /* Подвал */
  .footer { gap: 12px; margin-top: 40px; padding-bottom: 20px; }
  .footer-info { min-width: 0; gap: 12px; }
  .footer-info p { font-size: 12px; line-height: 1.1; }
  .footer-contacts { flex-shrink: 0; gap: 16px; }
  .footer-contacts a { width: 60px; height: 36px; }
}

/* На телефонах 360–479 ширина и кегль биографии растут вместе */
@media (min-width: 360px) and (max-width: 479px) {
  .about.flip-card .about-back p { width: min(100%,75vw); font-size: clamp(14px,3.889vw,18.67px); }
}
/* Широкий телефон/планшет: кегль фиксирован, ширина строки растёт */
@media (min-width: 480px) and (max-width: 767px), (min-width: 768px) and (pointer: coarse) {
  .about.flip-card .about-back p {
    width: min(100%,calc(100vw - 120px)); font-size: 18.67px; line-height: 1.4;
  }
}

/* Снижение анимаций по системной настройке */
@media (prefers-reduced-motion: reduce) {
  .flip-inner, .about.flip-card, .projects > .flip-card,
  .about-toggle-arrow, .project-mobile-arrow,
  .contact-button, .footer-contacts a, .student-cover img { transition: none !important; }
  .portrait-card:hover { animation: none !important; }
  .portrait-card:hover .portrait-label-svg { opacity: 1; }
  .portrait-card:hover .portrait-label-fragments { opacity: 0; }
  .portrait-card:hover .portrait-label-fragment,
  .portrait-card:hover .portrait-label-bottom { animation: none !important; opacity: 0; }
}

/* Анимация фотографии по тапу */

@media (prefers-reduced-motion: no-preference) {

  .portrait-card.portrait-tapped {
    animation: portrait-colors 0.8s linear infinite;
  }

  .portrait-card.portrait-tapped .portrait-label-svg {
    opacity: 0;
  }

  .portrait-card.portrait-tapped .portrait-label-fragments {
    opacity: 1;
  }

  .portrait-card.portrait-tapped .portrait-label-fragment {
    animation: portrait-label-fall
      0.55s cubic-bezier(0.45, 0, 1, 1) forwards;

    animation-delay: var(--delay, 0s);
  }

  .portrait-card.portrait-tapped .portrait-label-bottom {
    animation: designer-pop-up
      0.5s ease-out 0.55s both;
  }

}

/* =========================================
   FIREFOX — СТРЕЛКИ В УЗКОМ ОКНЕ
   ========================================= */

@supports (-moz-appearance: none) {

  @media (max-width: 767px) and (hover: hover) and (pointer: fine) {

    /* Обо мне */

    .about-toggle {
      padding-right: 10px;
    }

    .about-toggle .about-toggle-arrow {
      width: 16px;
      height: 28px;
      transform: rotate(90deg) scale(0.5714286);
    }

    .about.is-open .about-toggle-arrow {
      transform: rotate(-90deg) scale(0.5714286);
    }

    /* Проектные карточки */

    .project-mobile-arrow-wrap .project-mobile-arrow {
      top: -6px;
      left: 0;

      width: 16px;
      height: 28px;

      transform: rotate(90deg) scale(0.5714286);
    }

    .projects > .flip-card.is-open .project-mobile-arrow {
      transform: rotate(-90deg) scale(0.5714286);
    }

  }
}