/* ==========================================================================
   Из IDS (https://github.com/intuition-tech/ids) — reset, флюидный
   font-size, утилиты композиции страницы (.ids__wrapper и т.п.) и базовая
   типографика (a/p/h1-h6/списки/таблицы...), перенесённые сюда как есть из
   ids/css/reset.css, settings.css, page-composition/layout.css и
   components/ids.css (Inter из settings.css не перенесён — не используется
   дизайном, см. DESIGN-SYSTEM.md). Папка ids/ больше не используется и
   удалена — обновлять эти блоки вручную из апстрима IDS при необходимости.

   Ниже — project-level base overrides поверх этого: они идут последними в
   файле, чтобы выигрывать каскад (font-family/font-weight — переменными
   проекта вместо литералов IDS).
   ========================================================================== */

/* --- ids/css/tokens/colors.css (частично, остальное — в tokens.css) --- */
body {
  color: var(--ids__text);
  background-color: var(--ids__background);
}

/* --- ids/css/reset.css --- */
body {
  margin: 0;
  font-synthesis: none;
}

*,
*:before,
*:after {
  box-sizing: border-box;

  &:focus:not(:focus-visible) {
    outline: none;
  }

  &:focus-visible {
    outline: var(--ids__border-width-m) solid var(--ids__link);
    outline-offset: 2px;
  }
}

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.15;
  margin: 0
}

img {
  display: block;
  width: 100%;
}

/* --- ids/css/settings.css ---
   @font-face/font-feature-values для Inter выпилены: дизайн (заголовок
   Times New Roman / тело Arial, см. tokens.css) дефолтный Inter из IDS
   никогда не использовал, а проектное правило font-family для body ниже
   и так его перекрывало — 380 КБ woff2 грузились впустую, никогда не
   рендерясь. Font-smoothing вместо этого перенесён в проектное правило
   body внизу этого файла. */

:root {
  --ids__density: 1.3;
}

body {
  font-size: 1em;
  line-height: var(--ids__density);
}

html {
  --mobile-font-size-min: 14;
  --mobile-font-size-max: 32;

  --desktop-font-size-min: 11.5;
  --desktop-font-size-max: 22.5;

  --mobile-viewport-min: 320;
  --mobile-desktop-breakpoint: 768;
  --desktop-viewport-max: 1500;

  font-size: calc(var(--mobile-font-size-min) * 1px);

  @media screen and (min-width: 320px) {
    font-size: calc(
      var(--mobile-font-size-min) * 1px +
        (var(--mobile-font-size-max) - var(--mobile-font-size-min)) *
        (
          (100vw - var(--mobile-viewport-min) * 1px) /
            (var(--mobile-desktop-breakpoint) - var(--mobile-viewport-min))
        )
    );
  }

  @media screen and (min-width: 768px) {
    font-size: calc(
      var(--desktop-font-size-min) * 1px +
        (var(--desktop-font-size-max) - var(--desktop-font-size-min)) *
        (
          (100vw - var(--mobile-desktop-breakpoint) * 1px) /
            (var(--desktop-viewport-max) - var(--mobile-desktop-breakpoint))
        )
    );
  }

  @media screen and (min-width: 1500px) {
    font-size: calc(var(--desktop-font-size-max) * 1px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* --- ids/css/page-composition/layout.css --- */
.ids__space {
  height: var(--ids__spacer-s);

  &.S {
    height: var(--ids__spacer-s);
  }
  &.M {
    height: var(--ids__spacer-m);
  }
  &.L {
    height: var(--ids__spacer-l);
  }
  &.XL {
    height: var(--ids__spacer-xl);
  }
}

.ids__wrapper {
  position: relative;
  width: 70%;
  margin: 0 auto;

  @media (width < 768px) {
    width: 100%;
    padding: 0 calc(var(--ids__density) * 0.6rem);
  }

  &.L {
    width: 85%;

    @media (width < 768px) {
      width: 100%;
      padding: 0 calc(var(--ids__density) * 0.6rem);
    }
  }
  &.XL {
    width: 100%;
    padding: 0 calc(var(--ids__density) * 0.75rem);

    @media (width < 768px) {
      padding: 0 calc(var(--ids__density) * 0.6rem);
    }
  }
  &.XXL {
    width: 100%;

    @media (width < 768px) {
      padding: 0;
    }
  }

  & .ids__text-width {
    width: 85%;

    @media (width < 768px) {
      width: 100%;
    }
  }
}

.ids__sequence {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: calc(var(--ids__density) * 0.4rem);
  --gap: 0rem;
  gap: var(--gap);

  &.gap-L {
    --gap: var(--ids__gap-l);
    margin-bottom: calc(var(--gap) * 1.5);
  }

  &.gap-M {
    --gap: var(--ids__gap-m);
    margin-bottom: calc(var(--gap) * 1.5);
  }

  &.gap-S {
    --gap: var(--ids__gap-s);
    margin-bottom: calc(var(--gap) * 1.5);
  }

  .ids__sequence-item {
    --columns: 4;
    width: calc((100% - var(--gap) * (var(--columns) - 1)) / var(--columns));

    @media (width < 768px) {
      --columns: 2;
    }
  }

  &.XL {
    .ids__sequence-item {
      --columns: 2;

      @media (width < 768px) {
        --columns: 1;
      }
    }
  }

  &.L {
    .ids__sequence-item {
      --columns: 3;

      @media (width < 768px) {
        --columns: 2;
      }
    }
  }

  &.S {
    .ids__sequence-item {
      --columns: 6;

      @media (width < 768px) {
        --columns: 3;
      }
    }
  }
}

.ids__rounded {
  border-radius: var(--ids__radius);
  corner-shape: squircle;
  overflow: hidden;
}

@supports not (corner-shape: squircle) {
  .ids__rounded {
    border-radius: 0;
    border-radius: initial;
    mask:
      url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="m0,1 c0,-1 0,-1 1,-1 l99,0 l0,100 l-100,0 Z"/></svg>') top left / calc(var(--ids__radius) * 100) no-repeat intersect,
      url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="m0,0 l99,0 c1,0 1,0 1,1 l0,99 l-100,0 l0,-100 Z"/></svg>') top right / calc(var(--ids__radius) * 100) no-repeat intersect,
      url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="m0,0 l100,0 l0,99 c0,1 -0,1 -1,1 l-99,0 Z"/></svg>') bottom right / calc(var(--ids__radius) * 100) no-repeat intersect,
      url('data:image/svg+xml;utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path d="m0,0 l100,0 l0,100 l-99,0 c-1,0 -1,-0 -1,-1 Z"/></svg>') bottom left / calc(var(--ids__radius) * 100) no-repeat intersect
    ;
  }
}

header,
footer {
  padding: calc(var(--ids__density) * 1rem);
}

/* --- ids/css/components/ids.css — базовая типографика, применяется через
   класс .ids на <body> (см. layout.html) --- */
.ids {
  & a {
    color: var(--ids__link);
    text-decoration: underline;
    will-change: color;
    text-decoration-thickness: var(--ids__border-width-s);
    text-underline-offset: 0.2em;
    text-decoration-skip-ink: none;
    text-decoration-color: color-mix(in srgb, var(--ids__link) 20%, transparent);
    transition:
      color var(--ids__duration-base) var(--ids__easing-base),
      text-decoration var(--ids__duration-base) var(--ids__easing-base);

    &:hover {
      color: var(--ids__hover);
      text-decoration-color: color-mix(in srgb, var(--ids__hover) 20%, transparent);
      transition:
        color var(--ids__duration-instant) var(--ids__easing-base),
        text-decoration var(--ids__duration-instant) var(--ids__easing-base);
    }
  }

  .ids__promo-link {
    display: flex;

    & a {
      display: inline-block;
      padding: 0.45em 0.6em 0.5em;
      border: var(--ids__border-width-s) solid color-mix(in srgb, var(--ids__text) 50%, transparent);
      border-right: 0;

      &:hover {
        background-color: color-mix(in srgb, var(--ids__hover) 10%, transparent);
      }

      &:first-child {
        border-radius: var(--ids__radius-m) 0 0 var(--ids__radius-m);
        padding-left: 1em;
      }

      &:last-child {
        border-radius: 0 var(--ids__radius-m) var(--ids__radius-m) 0;
        padding-right: 1em;
        border-right: var(--ids__border-width-s) solid color-mix(in srgb, var(--ids__text) 50%, transparent);
      }

      &.active {
        color: var(--ids__text);
        background-color: color-mix(in srgb, var(--ids__text) 5%, transparent);
        -webkit-text-decoration: none;
        text-decoration: none;
        cursor: default;
      }

      &.active::after {
        content: " ↓";
      }
    }
  }

  & p {
    margin-top: 0;
    margin-bottom: calc(var(--ids__density) * 0.4em);

    &.loud {
      font-size: 2em;
      line-height: 1.2;
    }

    &.huge {
      font-size: 6em;
      line-height: 1;

      @media (max-width: 767px) {
        &.huge {
          font-size: 3.2em;
        }
      }

      @media (max-width: 549.98px) {
        &.huge {
          font-size: 2.8em;
        }
      }
    }
  }

  & h1,
  & h2,
  & h3,
  & h4,
  & h5,
  & h6 {
    margin: 0;
    font-weight: 600;
  }

  & h1 {
    font-size: 3.6em;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: calc(var(--ids__density) / 1.3);
    margin-bottom: 0.4em;

    @media (width < 768px) {
      font-size: 2.6em;
    }

    &.S {
      font-size: 2.4em;
      font-weight: 650;
    }
    &.XS {
      font-size: 1.5em;
      font-weight: 600;
    }
  }

  & h2 {
    font-size: 2.4em;
    font-weight: 650;
    line-height: calc(var(--ids__density) / 1.2);
    margin-bottom: 0.5em;

    &.XS {
      font-size: 1.5em;
      font-weight: 600;
    }
  }

  & h3 {
    font-size: 1.5em;
    line-height: calc(var(--ids__density) / 1.1);
    margin-bottom: 0.6em;
  }

  & h4 {
    font-size: 1.1em;
    line-height: var(--ids__density);
    margin-bottom: 0.5em;
  }

  & h5 {
    font-size: 1em;
    line-height: var(--ids__density);
    margin-bottom: 0.5em;
  }

  & h6 {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: var(--ids__density);
    margin-bottom: 0.5em;
  }

  & strong,
  & b {
    font-weight: 600;
  }

  & mark {
    color: var(--ids__color-gray-950);
    background-color: var(--ids__mark);
  }

  & ul,
  & ol {
    margin: 0 0 calc(var(--ids__density) * 0.75em) 0;
    padding: 0;

    & li {
      position: relative;
      margin-bottom: calc(var(--ids__density) * 0.5em);
    }
  }

  & ul {
    & li {
      list-style-type: none;
      padding-left: calc(var(--ids__density) * 0.75em);

      &:before {
        position: absolute;
        left: 0;
        content: "⋅ ";
      }
    }
  }

  & ol {
    & li {
      list-style: decimal inside none;
    }
  }

  & blockquote {
    font-size: 1.4em;
    line-height: var(--ids__density);
    margin: 0;
    padding-left: calc(var(--ids__density) * 0.75em);
    margin-bottom: calc(var(--ids__density) * 1em);
  }

  & aside {
    margin: 0;
    margin-bottom: calc(var(--ids__density) * 0.5em);
    background: var(--ids__surface);
    padding-top: calc(var(--ids__density) * 0.4em);
    padding-right: calc(var(--ids__density) * 1.5em);
    padding-bottom: calc(var(--ids__density) * 0.4em);
    padding-left: calc(var(--ids__density) * 0.5em);
    border-radius: var(--ids__radius-s);

    @media (width < 768px) {
      padding-right: calc(var(--ids__density) * 0.75em);
    }
  }

  & code {
    font-size: 0.9em;
    letter-spacing: 0.02em;
    font-weight: 450;
    padding: 0.1em 0.25em;
    border-radius: var(--ids__radius-s);
    color: var(--ids__code);
    border: var(--ids__border-width-s) solid color-mix(in srgb, var(--ids__code) 10%, transparent);
    background: color-mix(in srgb, var(--ids__code) 10%, transparent);
  }

  & figure {
    margin: 0 0 calc(var(--ids__density) * 0.5em) 0;

    &.XXS,
    &.ids__figure__XXS {
      width: 25%;
    }
    &.XS,
    &.ids__figure__XS {
      width: 50%;
    }
    &.S,
    &.ids__figure__S {
      width: 75%;
    }

    & figcaption {
      margin-top: calc(var(--ids__density) * 0.25em);
      font-size: 0.8em;
      line-height: var(--ids__density);
      color: var(--ids__text-caption);
    }
  }

  & details {
    padding: 0.5em;
    cursor: pointer;
    border-radius: var(--ids__radius);

    & summary {
      padding-bottom: var(--ids__micro-padding);
    }
  }

  & table {
    border-spacing: 0;
    background-color: inherit;

    @media (max-width: 767px) {
      font-size: 0.7em;
    }

    thead {
      background-color: inherit;
    }

    tr {
      background-color: inherit;

      & th {
        position: sticky;
        top: 0px;
        text-align: left;
        border-bottom: var(--ids__border-width-m) solid var(--ids__text);
        padding-bottom: 0.3em;
        background-color: inherit;

        @media (max-width: 767px) {
          padding-top: 0.8em;
        }
      }

      & td {
        padding: 0.8em 0.5em 1em 0;
        border-bottom: var(--ids__border-width-s) solid color-mix(in srgb, var(--ids__text) 50%, transparent);
        vertical-align: top;
      }

      &:last-child {
        & td {
          border-bottom: none;
        }
      }
    }
  }

  & hr {
    border-top-color: var(--ids__border);
    border-bottom: 0;
  }
}

/* --- дальше — собственные оверрайды проекта поверх вендорного IDS выше --- */
body {
  font-family: var(--font-body-family);
  font-weight: var(--font-body-weight);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* иллюстрация guy намеренно вылезает за край вьюпорта (см. .gk__content
   в components.css) — обрезаем получившийся overflow вместо того, чтобы
   давать ему растить горизонтальный скроллбар. */
html,
body {
  overflow-x: hidden;
}
