/* ─── Header ─────────────────────────────────────────────────────────────────
   Home: fixed + transparent, frosted after 80px (html.hdr-solid), slides
   away while scrolling down (html.hdr-hide). Inner pages: sticky, frosted.
   Mobile (< 992px): topics + search live in a dropdown panel (burger).
   ────────────────────────────────────────────────────────────────────────── */

.ha-hdr {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--bg-color) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 var(--line);
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s, box-shadow 0.6s;
}

.admin-bar .ha-hdr {
  top: 46px;

  @media (min-width: 783px) {
    top: 32px;
  }
}

.ha-hdr--home {
  position: fixed;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.hdr-solid .ha-hdr--home,
.menu-open .ha-hdr--home {
  background: color-mix(in srgb, var(--bg-color) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 var(--line);
}

.hdr-hide .ha-hdr {
  transform: translateY(-110%);
}

.ha-hdr__in {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 66px;

  @media (min-width: 640px) {
    gap: 22px;
    height: 78px;
  }
}

/* Logo */
.ha-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;

  img {
    width: auto;
    max-height: 48px;
  }
}

.ha-logo__mark {
  width: 28px;
  height: 28px;

  @media (min-width: 480px) {
    width: 34px;
    height: 34px;
  }

  circle {
    transform-origin: center;
    transform-box: fill-box;
    animation: ha-breathe 6s ease-in-out infinite;

    &:nth-child(2) {
      animation-delay: -2s;
    }

    &:nth-child(3) {
      animation-delay: -4s;
    }
  }
}

.ha-logo__t {
  font: 400 18px var(--f-h);
  letter-spacing: -0.02em;
  white-space: nowrap;

  b {
    margin-left: 2px;
    font-weight: 300;
    font-style: italic;
    color: var(--deep);
  }

  @media (min-width: 480px) {
    font-size: 20px;
  }

  @media (min-width: 640px) {
    font-size: 23px;
  }
}

/* Panel: dropdown on mobile, inline row on desktop */
.ha-hdr__panel {
  display: none;
  position: absolute;
  top: 100%;
  left: var(--gutter);
  right: var(--gutter);
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--surface-color) 94%, transparent);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  .menu-open & {
    display: flex;
  }

  @media (min-width: 992px) {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 22px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.ha-desks {
  flex: 1;
  min-width: 0;
}

.ha-desks__list {
  display: flex;
  flex-direction: column;
  gap: 2px;

  a {
    display: block;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    transition: background var(--hover-duration), color var(--hover-duration);

    &:hover {
      background: color-mix(in srgb, var(--surface-color) 80%, transparent);
      color: var(--ink);
    }
  }

  .current-menu-item > a,
  .current-menu-parent > a,
  [aria-current] {
    background: var(--tint-green);
    color: var(--deep);
  }

  @media (min-width: 992px) {
    flex-direction: row;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }

    a {
      padding: 8px 14px;
      font-size: 14.5px;
    }
  }
}

/* Header search */
.ha-search {
  position: relative;
  flex: none;

  input {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-color) 70%, transparent);
    color: var(--ink);
    font: 400 14px var(--f-b);
    transition: width 0.6s, box-shadow 0.6s;

    &:focus {
      outline: 0;
      box-shadow: var(--ring);
    }

    &::placeholder {
      color: var(--muted);
    }
  }

  button {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    display: grid;
    place-items: center;
  }

  svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  @media (min-width: 992px) {
    input {
      width: 120px;

      &:focus {
        width: 150px;
      }
    }
  }

  @media (min-width: 1200px) {
    input {
      width: 150px;

      &:focus {
        width: 190px;
      }
    }
  }
}

.ha-hdr__cta {
  margin-left: auto;
  padding: 9px 14px;
  font-size: 12.5px;

  @media (min-width: 640px) {
    padding: 11px 20px;
    font-size: 14px;
  }

  @media (min-width: 992px) {
    margin-left: 0;
  }
}

/* Burger */
.ha-burger {
  flex: none;
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-color) 70%, transparent);

  i {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 1.5px;
    border-radius: 2px;
    background: var(--ink);
    transition: transform 0.5s var(--timing);

    &:nth-of-type(1) {
      top: 16px;
    }

    &:nth-of-type(2) {
      top: 23px;
    }
  }

  &[aria-expanded="true"] i:nth-of-type(1) {
    transform: translateY(3.5px) rotate(45deg);
  }

  &[aria-expanded="true"] i:nth-of-type(2) {
    transform: translateY(-3.5px) rotate(-45deg);
  }

  /* No CTA button: the burger takes the right edge itself. */
  .ha-hdr__panel + & {
    margin-left: auto;
  }

  @media (min-width: 992px) {
    display: none;
  }
}
