/* =============================================================================
   KI PEPTIDES — Global chrome: announcement bar + sticky header
   Styles the markup in header.php. Uses tokens/primitives from theme.css.
   No 1px sectioning borders — header/announcement separation is tonal +
   a subtle inset hairline. Rounded-full search + cart. Space Grotesk announce.
   ========================================================================== */

/* ── Announcement bar ───────────────────────────────────────────────────── */
.ki-announcement {
  background: var(--ki-primary);
  color: rgba(255, 255, 255, 0.92);
}
.ki-announcement .ki-container {
  display: flex;
  justify-content: center;
  padding-block: 15px;
}
.ki-announcement p {
  margin: 0;
  text-align: center;
  font-family: var(--ki-font-label);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
}

/* ── Header shell (sticky, light) ───────────────────────────────────────── */
.ki-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--ki-surface);
  /* Tonal separation, not a 1px line: a barely-there inset hairline below. */
  box-shadow: inset 0 -1px 0 rgba(209, 194, 207, 0.18);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
}

.ki-header__inner {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  min-height: var(--ki-header-h);
  padding-block: 0.75rem;
}

/* Logo — pushed to start; on desktop the toggle is hidden so logo leads. */
.ki-header__logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.ki-header__logo img {
  height: 23.04px; /* −20% again (was 28.8px; −36% from original 36px) */
  width: auto;
  display: block;
}
/* Logo swaps to the inverted (white-K) mark in dark mode — same one the footer uses. */
.ki-header__logo .ki-logo-img--dark { display: none; }
[data-theme="dark"] .ki-header__logo .ki-logo-img--light { display: none; }
[data-theme="dark"] .ki-header__logo .ki-logo-img--dark { display: block; }

/* ── Primary nav (desktop) ──────────────────────────────────────────────── */
.ki-header__nav {
  flex: 1;
  display: flex;
  justify-content: center;
}
.ki-menu {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 2.5vw, 2.25rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ki-menu li { margin: 0; }
.ki-menu li a {
  font-family: var(--ki-font-display);
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--ki-on-surface);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.ki-menu li a:hover,
.ki-menu li.current-menu-item > a,
.ki-menu li.current_page_item > a {
  color: var(--ki-secondary);
}

/* ── Right-side actions ─────────────────────────────────────────────────── */
.ki-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* Search — pill input */
.ki-header__search {
  position: relative;
  display: flex;
  align-items: center;
}
.ki-header__search input[type="search"] {
  width: clamp(150px, 16vw, 220px);
  height: 40px;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--ki-radius-pill);
  background: var(--ki-surface-high);
  box-shadow: var(--ki-hairline);
  font-family: var(--ki-font-display);
  font-size: 0.875rem;
  color: var(--ki-on-surface);
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}
.ki-header__search input[type="search"]::placeholder {
  color: var(--ki-on-surface-muted);
}
.ki-header__search input[type="search"]:focus {
  outline: none;
  background: var(--ki-surface-lowest);
  box-shadow: inset 0 0 0 1px var(--ki-secondary);
}

/* Account icon — match the cart's 44x44 tap box (no rule existed → bare 22px hit area) */
.ki-header__account {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--ki-on-surface);
  transition: color 0.2s ease;
}
.ki-header__account:hover { color: var(--ki-secondary); }
.ki-header__account svg { display: block; }

/* Theme toggle — matches the account/cart icon buttons; swaps sun/moon by mode. */
.ki-header__theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ki-on-surface);
  cursor: pointer;
  transition: color 0.2s ease;
}
.ki-header__theme:hover { color: var(--ki-secondary); }
.ki-header__theme svg { display: block; }
.ki-header__theme .ki-icon-sun { display: none; }
.ki-header__theme .ki-icon-moon { display: block; }
[data-theme="dark"] .ki-header__theme .ki-icon-sun { display: block; }
[data-theme="dark"] .ki-header__theme .ki-icon-moon { display: none; }

/* Cart icon + count bubble */
.ki-header__cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--ki-on-surface);
  transition: color 0.2s ease;
}
.ki-header__cart:hover { color: var(--ki-secondary); }
.ki-header__cart svg { display: block; }
.ki-header__cart-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ki-radius-pill);
  background: var(--ki-secondary);
  color: #fff;
  font-family: var(--ki-font-label);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
}

/* ── Hamburger toggle (mobile only) ─────────────────────────────────────── */
.ki-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.ki-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 0 auto;
  background: var(--ki-on-surface);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.ki-nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ki-nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.ki-nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile off-canvas drawer ───────────────────────────────────────────── */
.ki-mobile-nav {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(82vw, 340px);
  z-index: 110;
  background: var(--ki-surface);
  box-shadow: -12px 0 48px rgba(46, 0, 60, 0.12);
  padding: calc(var(--ki-header-h) + 1.5rem) 1.75rem 2rem;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.ki-mobile-nav:not([hidden]) { transform: translateX(0); }
/* Closed drawer is display:none — out of layout (no phantom scroll) and out of the focus/AT tree. JS removes [hidden] to open. */
.ki-mobile-nav[hidden] { display: none; }

.ki-mobile-nav .ki-menu--mobile {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
.ki-mobile-nav .ki-menu--mobile li a {
  display: block;
  padding: 1rem 0;
  font-size: 1.125rem;
  font-weight: 300;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: inset 0 -1px 0 rgba(209, 194, 207, 0.2);
}

/* Scrim behind the drawer (added/removed by ki-cart.js). */
.ki-nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgb(var(--ki-ink) / 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ki-nav-scrim.is-visible { opacity: 1; }

body.ki-nav-open { overflow: hidden; }

/* ── Responsive: collapse nav under ~900px → hamburger ──────────────────── */
@media (max-width: 900px) {
  /* When the desktop nav hides, the hamburger takes over. The cramped 120px
     search pill goes with it — search returns with the desktop nav above 900px. */
  .ki-header__nav { display: none; }
  .ki-nav-toggle { display: flex; }
  .ki-header__search { display: none; }
}
@media (max-width: 749px) {
  .ki-header__inner { gap: 0.75rem; position: relative; }
  /* True-center the logo between the hamburger (left) and the actions (right). */
  .ki-header__logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; }
  /* Tighten the announcement strip so the long offer copy isn't a tall 3-line block. */
  .ki-announcement .ki-container { padding-block: 11px; padding-inline: 1rem; }
  .ki-announcement p { letter-spacing: 0.1em; }
}

/* -----------------------------------------------------------------------------
 * Language switch — segmented EN/ES pill (Space Grotesk labels), tonal layering
 * (no 1px borders). Active option lifts onto the lowest surface in teal.
 * -------------------------------------------------------------------------- */
.ki-lang {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--ki-radius-pill);
  background: var(--ki-surface-high);
  box-shadow: var(--ki-hairline);
  font-family: var(--ki-font-label);
}
.ki-lang__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 0 0.5rem;
  border-radius: var(--ki-radius-pill);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ki-on-surface-muted);
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.ki-lang__opt:hover { color: var(--ki-on-surface); }
.ki-lang__opt.is-active {
  color: var(--ki-secondary);
  background: var(--ki-surface-lowest);
  font-weight: 600;
}

/* Drawer variant — top of the mobile menu, a touch larger + left-aligned. */
.ki-lang--mobile { margin: 0 0 1.5rem; }
.ki-lang--mobile .ki-lang__opt { min-width: 46px; height: 40px; font-size: 0.8rem; }

@media (max-width: 900px) {
  /* Desktop switch (in the header actions) gives way to the drawer copy. */
  .ki-header__actions .ki-lang { display: none; }
}
