/* Shared components (D2-08). Layer order is declared in base.css. */

@layer components {
  /* Containers: content width capped, gutter on both sides. */
  .container {
    width: min(100% - 2 * var(--gutter), var(--container));
    margin-inline: auto;
  }

  .container--narrow {
    width: min(100% - 2 * var(--gutter), var(--container-narrow));
  }

  .container--wide {
    width: min(100% - 2 * var(--gutter), var(--container-wide));
  }

  /* Display role — the only place weight 300 is allowed (L-0012). */
  .hero__title,
  .error-page__title {
    font-weight: 300;
    font-size: var(--fs-display);
    line-height: 1.1;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-wrap: balance;
  }

  /* Text links */
  a {
    color: inherit;
    text-decoration: none;
  }

  @media (hover: hover) {
    a:hover {
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 4px;
    }
  }

  a:focus-visible {
    outline: 2px solid var(--c-black);
    outline-offset: 2px;
    border-radius: 2px;
  }

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

  /* The one primary button. */
  /* Figma BTN: 43 px tall, hugging its label; label 15/21 below 1024 px, 16/22.4 from 1024 px. */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 43px;
    padding: 0 20px 0 25px;
    border: 0;
    border-radius: var(--radius-btn);
    background-color: var(--c-black);
    color: var(--c-white);
    font: 700 15px / 21px var(--font);
    text-decoration: none;
    white-space: nowrap;
    text-align: center;
    cursor: pointer;
    transition:
      background-color 150ms ease,
      transform 150ms ease;
  }

  @media (min-width: 1024px) {
    .btn {
      font-size: 16px;
      line-height: 22.4px;
    }

    /* Figma sets the 16/22.4 label 1 px lower in the 43 px box than Chrome centres it
       (measured on the hero, line, Become and Solution buttons; 15/21 below 1024 is exact). */
    .btn__label {
      position: relative;
      top: 1px;
    }
  }

  /* «Стати партнером» next to the price-list button and in Become: wider side padding. */
  .btn--wide {
    padding: 0 30px 0 35px;
  }

  .btn__arrow {
    flex: none;
    width: 19px;
    height: 15px;
    transition: transform 150ms ease;
  }

  @media (hover: hover) {
    .btn:hover {
      background-color: var(--c-ink);
      text-decoration: none;
    }

    .btn:hover .btn__arrow {
      transform: translateX(4px);
    }
  }

  .btn:focus-visible {
    outline: 2px solid var(--c-black);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--c-white);
    border-radius: var(--radius-btn);
  }

  .btn:active {
    background-color: var(--c-black);
    transform: translateY(1px);
  }

  .btn:disabled,
  .btn[aria-disabled="true"] {
    background-color: var(--c-disabled);
    cursor: not-allowed;
    transform: none;
  }

  .btn:disabled .btn__arrow,
  .btn[aria-disabled="true"] .btn__arrow {
    transform: none;
  }

  .btn[aria-busy="true"] {
    cursor: progress;
  }

  @media (prefers-reduced-motion: reduce) {
    .btn,
    .btn__arrow {
      transition: none;
    }

    .btn:hover .btn__arrow,
    .btn:active {
      transform: none;
    }
  }

  /* Skip link: hidden until focused. */
  .skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 100;
    padding: var(--space-2) var(--space-3);
    background: var(--c-white);
    color: var(--c-black);
    font-size: var(--fs-small);
    line-height: var(--lh-small);
    font-weight: 700;
    transform: translateY(calc(-100% - var(--space-4)));
  }

  .skip-link:focus {
    position: fixed;
    transform: none;
  }

  /* Skip-link target: <main id="main" tabindex="-1"> is a container, not a control; the focus
     move itself confirms the skip link, so it shows no ring (05-UI-SPEC carry f). */
  main:focus {
    outline: none;
  }

  /* Error pages (404; the 500 page inlines its own copy of these values). */
  .error-page {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding-block: var(--space-8);
  }

  @media (min-width: 1024px) {
    .error-page {
      padding-block: var(--space-10);
    }
  }

  .error-page__inner {
    text-align: center;
  }

  .error-page__logo {
    display: inline-block;
  }

  .error-page__logo img {
    width: 200px;
    height: 16px;
  }

  @media (min-width: 768px) {
    .error-page__logo img {
      width: 225px;
      height: 18px;
    }
  }

  .error-page__title {
    margin-top: var(--space-7);
  }

  .error-page__text {
    margin-top: var(--space-4);
  }

  .error-page__actions {
    margin-top: var(--space-5);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    align-items: center;
  }

  .error-page__link {
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
}
