/**
 * Header shop chrome: the account link (WMH-303), the cart and its count badge.
 *
 * Loaded on EVERY front-end page while the shop is on, not only on shop pages: the header is on
 * every page. Until WMH-303 it was loaded on cart/checkout/account only and the badge lived in the
 * shop bundle, so on the home page the count printed as bare text beside the cart and phones had
 * no cart at all.
 *
 * Compact header: corporate header-actions stay hidden below xl unless the shop cart control is
 * present, and the desktop search toggle stays in the drawer.
 */

/* Task 71: the server always renders the badge EMPTY (inc/shop/header-cart.php — production serves
   WP Rocket cached HTML, so a baked-in count would be somebody else's). WooCommerce's cart
   fragments replace it on the client, so `.is-empty` is the state a cached page ships with. */
.header-actions__cart,
.header-actions__account {
  position: relative;
}

.header-actions__count {
  position: absolute;
  top: -0.375rem;
  right: -0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.3125rem;
  border-radius: 0.5625rem;
  background-color: var(--theme-secondary-color);
  color: var(--theme-teal-darkest);
  font-size: var(--theme-micro-fs);
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.header-actions__count.is-empty {
  display: none;
}

/* WMH-303: a logged-in customer gets a small teal dot on the person, the badge's colour, so the
   header says "you are signed in" without a word. The label says the same to a screen reader. */
.header-actions__account.is-logged-in::after {
  content: "";
  position: absolute;
  right: -0.125rem;
  bottom: 0.125rem;
  width: 0.625rem;
  height: 0.625rem;
  border: 2px solid var(--theme-base-dark, #0b0e10);
  border-radius: 50%;
  background-color: var(--theme-secondary-color);
  pointer-events: none;
}

/* Safari :focus on the Warenkorb link + badge is 5px auto rgb(0, 103, 244).
   Tab focus is :focus, so :focus-visible alone never replaced it. The badge
   is inside this <a>; do not restyle the rest of the corporate header. */
a.header-actions__item.header-actions__cart:focus,
a.header-actions__item.header-actions__cart:focus-visible,
a.header-actions__item.header-actions__account:focus,
a.header-actions__item.header-actions__account:focus-visible {
  outline: 2px solid var(--theme-secondary-color);
  outline-offset: 2px;
}

@media (max-width: 1199.98px) {
  header .header-actions:has(.header-actions__cart),
  .site-header .header-actions:has(.header-actions__cart),
  .header .header-actions:has(.header-actions__cart) {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-left: auto;
  }

  header .header-actions:has(.header-actions__cart) + .header-phone,
  .site-header .header-actions:has(.header-actions__cart) + .header-phone {
    margin-left: 0;
  }

  header .header-actions:has(.header-actions__cart) > .header-search-toggle,
  .site-header .header-actions:has(.header-actions__cart) > .header-search-toggle {
    display: none;
  }

  .header-actions__cart,
  .header-actions__account {
    width: 2.1875rem;
    height: 2.1875rem;
    align-items: center;
    justify-content: center;
  }

  .header-actions__cart svg,
  .header-actions__account svg {
    width: 1.75rem;
    height: 1.75rem;
  }

  /* WMH-303: four icons now share the row with the logo (person, cart, phone, burger). The
     corporate row's 24px gaps left the burger — the only item allowed to shrink — 0px wide at
     320 and 30px at 360. One even 16px gap fits through 360 and reads as one group. */
  header .wrapper:has(> .header-actions > .header-actions__cart) {
    column-gap: 1rem;
  }
}

/* Below 360 (320 measured): 12px gaps and 32px boxes for person, cart and phone; the burger
   keeps its 35px. 107 + 32 + 12 + 32 + 32 + 35 + 3 x 12 = 286 within the 290 the row has. */
@media (max-width: 359.98px) {
  header .wrapper:has(> .header-actions > .header-actions__cart),
  header .header-actions:has(.header-actions__cart) {
    column-gap: 0.75rem;
  }

  header .wrapper:has(> .header-actions > .header-actions__cart) > .header-phone,
  .header-actions__cart,
  .header-actions__account {
    width: 2rem;
    height: 2rem;
  }
}

@media (min-width: 1200px) and (max-width: 1709.98px) {
  .page-header:has(.header-actions__cart) {
    --menu-fs: 0.9375rem;
    --menu-gap: 0.375rem;
    --menu-pill-x: 0.5625rem;
  }

  .page-header .wrapper:has(> .header-actions > .header-actions__cart) {
    gap: 1rem;
  }

  .page-header .wrapper:has(> .header-actions > .header-actions__cart) .site-logo img {
    height: 3.25rem;
  }

  .page-header .header-actions:has(.header-actions__cart) {
    gap: 1rem;
  }

  .page-header .header-actions:has(.header-actions__cart) .header-actions__item svg {
    width: 1.75rem;
    height: 1.75rem;
  }
}
