/* ****** */
/* CRUMBS */
/* ****** */

.crumbs {
  max-width: initial;
}


/* ******* */
/* COLUMNS */
/* ******* */

.cols {
  display: flex;
  gap: var(--margin-grid);
}

.cols > * {
  width: 100%;
  margin-top: initial;
}

/* Для размещения скроллящегося телефона справа */
.cols:has(> [moveY="auto"]) {
  align-items: flex-start;
}


/* ******* */
/* BROWSER */
/* ******* */

.browser {
  background-color: var(--browser-color);
  /*width: calc(100% - 2rlh);*/
  width: min(100%, var(--w, 100%));
  border-radius: 3rlh;
  outline: 1rlh solid var(--browser-color);
  overflow: hidden;
  position: relative;
  /* Обнимаем картинку, если контейнер выше */
  height: min-content;
}

/* Кнопки в шапке */
.browser:before {
  content: "";
  /* Предыдущая реализация
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--background-color);
  position: absolute;
  -webkit-mask: url("/front/images/browserDots.svg") no-repeat;
  mask: url("/front/images/browserDots.svg") no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;*/
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 976 / 16;
  background:
    radial-gradient(ellipse 0.409836% 25% at 1.434426% 75%,
    var(--background-color) 99%, transparent 100%),
    radial-gradient(ellipse 0.409836% 25% at 2.868852% 75%,
    var(--background-color) 99%, transparent 100%),
    radial-gradient(ellipse 0.409836% 25% at 4.303279% 75%,
    var(--background-color) 99%, transparent 100%);
}

.browser>img,
.browser>picture,
.browser>video {
  margin-top: 2.3%;
  width: 100%;
}

.darkmode .browser,
.browser.darkmode {
  background-color: #2E2E2E;
  border-color: #242424;
}

/* ******* */
/* MASONRY */
/* ******* */

.masonry {
  display: flex;
  flex-wrap: wrap;
  gap: var(--margin-grid);
}


/* **** */
/* GRID */
/* **** */

/* БАЗОВЫЙ ГРИД */

.grid {
  display: grid;
  gap: var(--margin-grid);
  grid-template-columns: repeat(4, minmax(10px, 1fr));
  grid-auto-flow: dense;
}

.grid>* {
  /* Для карточек портфолио */
  position: relative;
  /* Чтобы контейнер обнимал внутренность, не вылазила анимация загрузки   */
  align-self: start;
  /* Чтобы карточки без картинок растягивались на весь грид */
  width: 100%;
  /* height: 100%; писать нельзя, чтобы карточки обнимали контент (ссылки в портфолио не кликались под текстом) */
}

.grid .s {
  grid-column: span 1;
}

.grid .m {
  grid-column: span 2;
}

.grid .l {
  grid-column: span 4;
}

.grid .xl {
  grid-column: span 2;
  grid-row: span 2;
}

@media (width > 800px) {
  .grid > .xl {
    grid-column: var(--xl-column, 1) / span 2;
    grid-row: var(--xl-row, auto) / span 2;
  }
}

.grid .container {
  overflow: hidden;
  position: relative;
  display: flex;
  user-select: none;
}

@media (max-width: 800px) {

  /* Две колонки на мобиле */
  .grid {
    grid-template-columns: repeat(2, minmax(10px, 1fr));
  }

  .grid .l {
    grid-column: span 2;
  }

}

/* КАРТОЧКИ SUPER */

.grid a.super {
  text-decoration: none;
  display: block;
}

/* Фон у пустых контейнеров */
.grid > .super > .container:empty {
  background-color: var(--box-color);
}

/* Фиксированные пропорции обложек */
.grid:has(> .super) {
  container-type: inline-size;
  /* Высота 1 ячейки = ширина / 0.6
     Ширина = шириина грида - 3 гэпа / 4 колонки
    (100cqw − 3 × 25rlh) / 4 / 0.6 
  */
  --super-cell-height: calc(41.6666667cqw - 31.25rlh);
}

.grid > .super.image,
.grid > .super > .container {
  height: var(--super-cell-height);
}

.grid > .xl.super.image,
.grid > .xl.super > .container {
  /* Высота XL карточек */
  height: calc(var(--super-cell-height) + var(--super-cell-height) + var(--margin-grid));
}

/* Растягивание XL карточек на десктопе до низа текста */
@media screen and (width > 800px) {
  .grid > .xl.super {
    align-self: stretch;
    display: flex;
    flex-direction: column;
  }
  .grid > .xl.super > .container {
    flex-grow: 1;
  }
}

@media screen and (max-width: 800px) {
  .grid:has(> .super) {
    /* Ширина = шириина грида - 1 гэп / 2 колонки */
    --super-cell-height: calc(83.3333333cqw - 12.5rlh);
  }
  
  /* L в 2 раза выше на мобиле */
  .grid > .l.super > .container {
    height: calc(var(--super-cell-height) + var(--super-cell-height));
  }
}


.grid > .super > .container > .image {
  /* Растягиваем картинку на всю ячейку в Супере */
  height: initial;
  flex-grow: 1;
  /* Важно для выходящих за границу ячейки картинок в Хроме */
  min-width: 0;
}

.grid > .super > .container > .image > img,
.grid > .super > .container > .image > picture,
.grid > .super > .container > .image > video,
.grid > .super > .container > div:not(.caption):not(.image):not(.clientLogosContainer) {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Отступ между строками больше, если грид используется как колонки с текстом */
@media screen and (max-width: 800px) {
  .grid:has(.text) {
    row-gap: var(--margin-text);
  }
}

/* Склеиваем гриды, идущие друг за другом, кроме тех, что с текстом */
.grid + .grid:not(:has(.text)) {
  margin-top: var(--margin-grid);
}

/* Текстовые обложки */
.grid .container:has(> .textCover) {
  overflow: initial;
  aspect-ratio: initial!important;
  margin-top: 4rlh;
  height: initial!important;
}
.grid .container .textCover {
  hyphens: auto;
  overflow-wrap: break-word;
  word-break: normal;
}
.grid .container .textCover > .text + * {
  margin-top: var(--margin-text);
}


/* ******* */
/* BOX */
/* ******* */

.box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--margin-grid);
  gap: var(--margin-grid);
  background-color: var(--box-color);
}

.box > * {
  /* Чтобы содержимое не вываливалось из флекса */
  max-width: 100%;
}

.box.full {
  /* Потому что паддинги добавляют ширины */
  width: calc(100vw - 2* var(--margin-grid));
}

.box.transparent {
  background: none;
  padding: 0;
}

/* Одна колонка на мобиле */
@media screen and (max-width: 800px) {
  .cols.stack,
  .box.stack {
    flex-direction: column;
  }
  .grid.stack {
    grid-template-columns: 1fr!important;
  }
  /* Вертикальный отступ на мобиле */
  /*
  .cols.stack > div + *,
  .box.stack > div + * {
    margin-top: var(--margin-text);
  }*/
}


/* ******* */
/* OUTLINE */
/* ******* */

.outline {
  position: relative;
  --outline-color: #DFE1E1;
}

.outline::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--outline-color);
  border-radius: inherit;
}

.box .outline {
  --outline-color: #2E2E2E;
}

.outline.dark,
.darkmode .outline {
  --outline-color: #242424;
}


/* ******* */
/* DEVICES */
/* ******* */

/* Colors */
.device {
  --device-color: var(--box-color);
}

.box .device {
  --device-color: #DFE1E1;
}

.device.dark,
.darkmode .device {
  --device-color: #2E2E2E;
}

.darkmode .device.dark {
  --device-color: #242424;
}

.device {
  position: relative;
  overflow: hidden;
}

.device > .device-frame {
  position: absolute;
  top: 0;
  width: 100%;
  height: initial;
  z-index: 3;
  color: var(--device-color);
  pointer-events: none;
}

.device > img:not(.video-poster-overlay),
.device > picture,
.device > video {
  position: absolute;
  object-fit: cover;
  object-position: top;
}


/* General phone */
.device.phone {
  background-color: var(--device-color);
  width: min(100%, var(--w, 100%));
  border-radius: 16rlh;
  border: 7rlh solid var(--device-color);
  max-width: 250rlh;
}

.device.phone > img:not(.video-poster-overlay),
.device.phone > picture:not(.video-poster-overlay),
.device.phone > video {
  position: static;
}


/* iPhone 15 */
.device.iphone-15,
.device.iphone-15-island {
  width: 211rlh;
}

/* Лучше бы использовать aspect-ratio: calc(211 / 440),
но сафари не обновляет пропорции при ресайзе. Поэтому так.
Марджин — процент деления высоты на ширину. */
.device.iphone-15:before,
.device.iphone-15-island:before {
  content: "";
  display: block;
  margin-top: 208.53080569%;
}

.device.iphone-15 > img:not(.video-poster-overlay),
.device.iphone-15 > picture,
.device.iphone-15 > video,
.device.iphone-15>.video-poster-overlay,
.device.iphone-15:after, /* Для лоадера */
.device.iphone-15-island > img:not(.video-poster-overlay),
.device.iphone-15-island > picture,
.device.iphone-15-island > video,
.device.iphone-15-island>.video-poster-overlay,
.device.iphone-15-island:after {
  width: calc(100% - 6.2%);
  height: calc(100% - 3%);
  left: 3.1%;
  top: 1.5%;
  border-radius: 6%;
  overflow: hidden;
}


/* Android */
.device.android {
  width: 211rlh;
}

.device.android:before {
  content: "";
  display: block;
  margin-top: 208.53080569%;
}

.device.android > img:not(.video-poster-overlay),
.device.android > picture,
.device.android > video,
.device.android>.video-poster-overlay,
.device.android:after {
  width: calc(100% - 6.2%);
  height: calc(100% - 3%);
  left: 3.1%;
  top: 1.5%;
  border-radius: 3%;
  overflow: hidden;
}

/* iPad 11 Horizontal */
.device.ipad-11-horizontal {
  width: 100%;
}

.box .device.ipad-11-horizontal {
  max-width: 640rlh;
}

.device.ipad-11-horizontal:before {
  content: "";
  display: block;
  margin-top: 71.875%;
}

.device.ipad-11-horizontal > img:not(.video-poster-overlay),
.device.ipad-11-horizontal > picture,
.device.ipad-11-horizontal > video,
.device.ipad-11-horizontal>.video-poster-overlay,
.device.ipad-11-horizontal:after {
  width: calc(100% - 6.6%);
  height: calc(100% - 9.2%);
  left: 3.3%;
  top: 4.6%;
}

/* iPad 11 Vertical */
.device.ipad-11-vertical {
  width: 100%;
  max-width: 701rlh;
}

.box .device.ipad-11-vertical {
  max-width: 460rlh;
}

.device.ipad-11-vertical:before {
  content: "";
  display: block;
  margin-top: 139.1304347826%;
}

.device.ipad-11-vertical > img:not(.video-poster-overlay),
.device.ipad-11-vertical > picture,
.device.ipad-11-vertical > video,
.device.ipad-11-vertical>.video-poster-overlay,
.device.ipad-11-vertical:after {
  height: calc(100% - 6.6%);
  width: calc(100% - 9.2%);
  top: 3.3%;
  left: 4.6%;
}

/* Terminal */
.device.terminal {
  width: 100%;
}

.box .device.terminal {
  width: 640rlh;
}

/* Убираем нижний отступ в боксе для терминала */
.box:has(.device.terminal) {
  padding-bottom: 0;
}

.device.terminal:before {
  content: "";
  display: block;
  margin-top: 80%;
}

.device.terminal > img:not(.video-poster-overlay),
.device.terminal > picture,
.device.terminal > video,
.device.terminal>.video-poster-overlay,
.device.terminal:after {
  height: calc(100% - 12.2%);
  width: calc(100% - 6.6%);
  top: 4%;
  left: 3.3%;
}


/* **** */
/* FORM */
/* **** */

form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--margin-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
label[for="file"],
.textarea-wrap>textarea,
.textarea-wrap::after {
  font-family: inherit;
  width: 100%;
  color: var(--text-color);
  font-size: var(--paragraph-font-size);
  line-height: var(--paragraph-line-height);
  margin-top: var(--paragraph-top-compensator);
  margin-bottom: var(--paragraph-bottom-compensator);

  padding: calc(var(--margin-grid-half) / 2) 0;
  /* 6rlh 0 */
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--text-color);
}

input:focus,
textarea:focus {
  outline: none;
}

::placeholder {
  color: var(--text-color);
  opacity: 0.2;
}

input {
  border-radius: 0;
}

textarea {
  resize: none;
}

form small,
form .small p {
  margin-left: 0;
  /* Убираем отжате воздуха у подписей, чтобы не торчали из формы */
}

/* ПЕРЕКЛЮЧАТЕЛЬ */

.switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--margin-grid-half);
  width: 100%;
}

.switch label {
  color: var(--text-color);
  font-size: var(--paragraph-font-size);
  line-height: var(--paragraph-line-height);
  margin-top: var(--paragraph-top-compensator);
  margin-bottom: var(--paragraph-bottom-compensator);
  position: relative;
}

/* Прячем оригинальный инпут */
.switch label input {
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: 1;
  cursor: pointer;
}

.switch label span {
  display: inline-block;
  padding-bottom: calc(var(--margin-grid-half) / 2);
  /* 6rlh */
}

.switch label input:hover+span {
  color: var(--hover-color);
}

/* Если хоть один инпут внутри свича выбран, скрываем все лейблы */
.switch:has(input:checked) label {
  display: none;
}

/* При этом тот лейбл, внутри которого выбран инпут, показываем с бордером */
.switch label:has(input:checked) {
  display: block;
  border-bottom: 1px solid var(--text-color);
  width: 100%;
}

/* ТЕКСТАРЕА, КОТОРАЯ РАСТЯГИВАЕТСЯ ПОД КОНТЕНТ */

.textarea-wrap {
  display: grid;
  width: 100%;
}

.textarea-wrap::after {
  /* Prevent jumpy behavior */
  content: attr(data-replicated-value) " ";
  /* This is how textarea text behaves */
  white-space: pre-wrap;
  /* Hidden from view, clicks, and screen readers */
  visibility: hidden;
}

.textarea-wrap>textarea {
  resize: none;
  overflow: hidden;
  border-radius: 0;
}

.textarea-wrap>textarea,
.textarea-wrap::after {
  grid-area: 1 / 1 / 2 / 2;
}

/* ВЫБИРАЛКА ФАЙЛОВ */

/* Прячем оригинальный инпут */
input[type="file"].input-file-original {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

/* Стилизуем лейбл после инпута */
input[type="file"].input-file-original+label {
  display: inline-block;
  cursor: pointer;
}

/* Селект инпута с клавиатуры */
input[type="file"].input-file-original:focus+label {
  color: var(--text-color) !important;
}

input[type="file"].input-file-original+label.empty {
  color: rgb(from var(--text-color) r g b / 0.2);
}

/* Фикс нажатия на тач-устройствах? */
input[type="file"].input-file-original+label * {
  pointer-events: none;
}

/* КНОПКА ОТПРАВКИ */

input[type="submit"] {
  color: var(--text-color);
  font-size: var(--paragraph-font-size);
  line-height: var(--paragraph-line-height);
  margin-top: var(--paragraph-top-compensator);
  margin-bottom: var(--paragraph-bottom-compensator);

  font-weight: normal;

  border: none;
  background: none;

  padding-top: calc(var(--margin-grid-half) / 1.2);
  /* 10rlh */
  padding-bottom: calc(var(--margin-grid-half) / 6);
  /* 2rlh*/
  padding-left: 0;
  padding-right: 0;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--text-color);

  width: fit-content;
}

input[type="submit"]:hover {
  border-color: var(--hover-color);
  color: var(--hover-color);
  cursor: pointer;
}


/* **** */
/* OUTS */
/* **** */

.outs {
  position: relative;
}

.outs-top-text,
.outs-top-lines,
.outs-bottom-text,
.outs-bottom-lines {
  display: flex;
  flex-basis: 0;
}

@media screen and (max-width: 800px) {
  .outs {
    hyphens: auto;
  }
}

.outs-top-text,
.outs-bottom-lines {
  align-items: flex-end;
}

.outs-bottom-text,
.outs-top-lines {
  align-items: flex-start;
}

.outs-top-lines,
.outs-bottom-lines {
  height: 0;
  width: 100%;
  /* Поднимаем линии над каринкой */
  z-index: 2;
  /* Важно для Сафари */
  position: relative;
  /* Отступ между нижними линиями и текстом */
  margin-bottom: 3rlh;
}

.outs .image {
  margin-top: var(--margin-grid);
  margin-bottom: var(--margin-grid);
}

.outs .line::after {
  content: "";
  display: block;
}

/* Отступ межту текстом и выноской */
.outs-top-lines .line::after {
  top: calc(var(--margin-grid) / 3);
}

.outs-bottom-lines .out {
  bottom: calc(var(--margin-grid) / 3);
}

.outs .out {
  margin: 0;
  display: flex;
  justify-content: center;
  text-align: center;
  max-width: none;
  /* Убираем ограничение ширины для выносок */
  position: relative;
  /* Чтобы задавать высоту выноски процентом от ширины родителя */
}

.outs .out small,
.outs .out .small p {
  width: 100%;
}

.outs .line::after {
  border-left: 1px solid var(--text-color);
  box-sizing: border-box;

  /* Чтобы задавать высоту выноски процентом от ширины родителя */
  position: absolute;
  height: 100%;
}


/* **** */
/* Darkmode */
/* **** */

/* Фон блоков в тёмной теме, кроме браузеров, меню, логотипа */
.darkmode:not(.browser, menu, .menuGlobal, .logo) {
  background-color: var(--background-color);
}


/* **** */
/* Lists */
/* **** */
ol {
  list-style-position:inside;
}

ol li:not(:first-child),
ul li:not(:first-child) {
  margin-top: calc(var(--margin-text) + var(--paragraph-top-compensator));
}


/* **** */
/* Highlight */
/* **** */
mark {
  background-color: rgb(from var(--hover-color) r g b / 0.1);
  color: var(--hover-color);
  padding: 0 4rlh;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
mark a {
  color: inherit;
  text-decoration-color: inherit;
}

/* Компенсируем падинг */
p:has(mark),
h1:has(mark),
h2:has(mark),
h3:has(mark),
small:has(mark),
.small p:has(mark) {
  margin-left: calc(-4rlh - 0.07em);
}


/* **** */
/* Private blocks */
/* **** */
.private:not(.text, .header, .caption, menu, .loginLink) {
  position: relative;
}
.private:not(.text, .header, .caption, menu, .loginLink)::before {
  content: "";
  position: absolute;
  background-color: var(--private-color);
  z-index: -1;
}
@media screen and (max-width: 800px) {
  .private:not(.text, .header, .caption, menu, .loginLink)::before {
    top: calc(-1 * var(--margin-grid));
    left: calc(-1 * var(--margin-grid));
    width: calc(100% + 2 * var(--margin-grid));
    height: calc(100% + 2 * var(--margin-grid));
  }
}
@media screen and (min-width: 801px) {
  .private:not(.text, .header, .caption, menu, .loginLink)::before {
    top: -12.5rlh;
    left: -12.5rlh;
    width: calc(100% + 25rlh);
    height: calc(100% + 25rlh);
  }
}

.private mark {
  background-color: var(--private-color);
  color: inherit;
}

.privatePage {
  background-color: var(--private-color);
}

.grid > .super.privateCover > .caption span,
.grid > .super.privateCover .textCover span {
  color: var(--private-color);
  filter: contrast(.95);
  position: relative;
  top: 1rlh;
}


/* **** */
/* Archived projects */
/* **** */

/* Крестик */
.archiveHeader span,
.archiveCover span {
  font-size: 0.6em;
  line-height: 0;
  position: relative;
  top: -0.4em;
}
/* Текстовые карточки занимают всю ширину */
.archiveCover:has(.textCover) {
  grid-column: 1 / 5;
}
@media screen and (max-width: 800px) {
  .archiveCover:has(.textCover) {
    grid-column: 1 / 3;
  }
}

/* Пилюля с датой архивной работы */
.archiveLabel p {
  position: relative;
  width: fit-content;
  --text-color: var(--hover-color);
}
