/* Site header (app/views/layouts/public/_header.html.erb). */
@layer sections {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--pl-green-100);
    color: var(--pl-green-950);
    border-bottom: 1px solid var(--pl-header-line-dark);
  }

  /* .pl-container supplies the 1216px column and the side gutters. */
  .site-header__nav {
    height: var(--pl-header-h);
    display: flex;
    align-items: center;
    gap: clamp(10px, 2.4vw, 28px);
  }

  /* Logo → #top */
  .site-header__home {
    flex: none;
    display: flex;
    align-items: center;
    height: 44px;
    padding-bottom: 3px;
    color: inherit;
  }

  .site-header__logo {
    display: block;
    width: 104px;
    height: 32px;
  }

  /*
   * Product and section links (hidden ≤900px by .pl-hide-md). They never
   * push the language pill and "Order" off the row: the block shrinks, a link
   * that does not fit wraps to a second row and that row is clipped. The
   * product links come first, so the section links are the ones to go.
   * The fit-links controller marks the wrapped links .is-clipped, so they also
   * leave the tab order and the accessibility tree.
   */
  .site-header__links {
    flex: 0 1 auto;
    min-width: 0;
    /* One 44px row plus 8px all round, so a link's focus ring is not clipped;
       the 24px row gap keeps a wrapped row out of that margin. */
    height: 60px;
    margin: 0 -8px;
    padding: 8px;
    overflow: hidden;
    /* clip where supported: a clipped link that gets the focus must not
       scroll the row away. */
    overflow: clip;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: center;
    gap: 24px 2px;
    font-size: 15px;
    font-weight: 600;
  }

  .site-header__link {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--pl-r-pill);
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
  }

  /* On the clipped second row (fit-links controller): not focusable, not read. */
  .site-header__link.is-clipped {
    visibility: hidden;
  }

  /* The product whose page is open. */
  .site-header__link[aria-current="page"] {
    background: var(--pl-fill-dark);
  }

  .site-header__actions {
    flex: none;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* ქარ / ENG pill: two links, the current language is dark green. */
  .site-header__langs {
    display: flex;
    gap: 2px;
    padding: 2px;
    border-radius: var(--pl-r-pill);
    background: var(--pl-fill-dark);
  }

  .site-header__lang {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 40px;
    padding: 0 11px;
    border-radius: var(--pl-r-pill);
    background: transparent;
    color: var(--pl-green-950);
    font-size: 13.5px;
    font-weight: 700;
    line-height: normal;
    text-decoration: none;
    white-space: nowrap;
  }

  /* 44px tall hit area over the pill's 2px padding and the gap between links. */
  .site-header__lang::before {
    content: "";
    position: absolute;
    inset: -2px -1px;
  }

  .site-header__lang[aria-current="true"] {
    background: var(--pl-green-950);
    color: var(--pl-paper);
  }

  /* Green "Order" → #checkout */
  .site-header__cta {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--pl-r-pill);
    background: var(--pl-green-800);
    color: var(--pl-paper);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
  }

  /*
   * Small phones: the 390px row (logo, pill, CTA) is 336px wide and would
   * scroll sideways below 380px. Inside the 480px breakpoint every size is a
   * clamp() that equals the normal value down to 380px, reaches 88×27 / 40px /
   * 8px / 14px at 360px and 78×24 / 6px / 12px at 320px.
   */
  @media (max-width: 480px) {
    .site-header__nav {
      gap: clamp(8px, 10vw - 28px, max(10px, 2.4vw));
    }

    .site-header__logo {
      /* height = width × 92.2 / 300, so 104×32 is kept exactly from 381px up. */
      width: clamp(78px, max(25vw - 2px, 80vw - 200px), 104px);
      height: clamp(24px, max(7.683vw - 0.615px, 24.587vw - 61.467px), 32px);
    }

    .site-header__lang {
      min-width: clamp(44px, 30vw - 68px, 46px);
      padding: 0 clamp(6px, max(5vw - 10px, 15vw - 46px), 11px);
    }

    .site-header__cta {
      padding: 0 clamp(12px, max(5vw - 4px, 30vw - 94px), 20px);
    }
  }
}
