/* ============================================================================
   common-core — header actions (search / sign-in / help)

   STRUCTURAL ONLY. Every colour and font comes from the brand's Crayon Box
   variables (design-system.css in the brand plugin). Nothing here may
   hardcode a brand value — ground rules 3 and 6.

   Fallbacks on the var() calls are neutral greys, not any brand's palette;
   they exist so the strip is still legible if a brand forgets a key, not as
   a default look.
   ============================================================================ */

.cc-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Rendered into wp_body_open and relocated by JS — kept out of the flow
   until the move lands so it never flashes at the top of the page. The JS
   removes this class immediately after relocating; if JS never runs, the
   strip stays hidden rather than appearing somewhere wrong. */
.cc-header-actions.is-pending {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cc-header-actions__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: var(--cc-font-body, sans-serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.cc-header-actions__btn:hover,
.cc-header-actions__btn:focus-visible {
  color: var(--cc-accent, #767676);
  text-decoration: none;
}

.cc-header-actions__btn:focus-visible {
  outline: 2px solid var(--cc-accent, #767676);
  outline-offset: 2px;
}

.cc-header-actions__icon { flex: none; }

/* ── Search ───────────────────────────────────────────────────────────── */

.cc-header-actions__search { position: relative; }

.cc-header-actions__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 100;
  min-width: 320px;
  padding: 10px;
  border: 1px solid var(--cc-border-subtle, #d9d9d9);
  border-radius: 12px;
  background: var(--cc-bg-subtle, #ffffff);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}

.cc-header-actions__panel[hidden] { display: none; }

.cc-header-actions__panel form {
  display: flex;
  gap: 8px;
  margin: 0;
}

.cc-header-actions__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--cc-border-subtle, #d9d9d9);
  border-radius: 999px;
  background: #ffffff;
  font-family: var(--cc-font-body, sans-serif);
  font-size: 15px;
  color: var(--cc-text, #1a1a1a);
}

.cc-header-actions__input:focus {
  border-color: var(--cc-accent, #767676);
  outline: none;
}

.cc-header-actions__submit {
  flex: none;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: var(--cc-accent, #444444);
  font-family: var(--cc-font-body, sans-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--cc-text, #1a1a1a);
  cursor: pointer;
}

.cc-header-actions__submit:hover { background: var(--cc-accent-hover, #2b2b2b); }

/* ── Bar mode ─────────────────────────────────────────────────────────────
   header_actions.search_mode = bar. The panel stops being a dropdown and
   becomes an inline field: no absolute positioning, no card chrome, no
   shadow. The submit button is visually hidden but stays in the DOM and
   focusable, so Enter submits and keyboard users still reach it — display:none
   would remove it from the accessibility tree entirely. */

.cc-header-actions__search--bar .cc-header-actions__panel {
  position: static;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.cc-header-actions__search--bar form {
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--cc-border-subtle, #d9d9d9);
  border-radius: 999px;
  background: #ffffff;
}

.cc-header-actions__search--bar .cc-header-actions__bar-icon {
  display: inline-flex;
  flex: none;
  color: var(--cc-text-muted, #6e6e73);
}

.cc-header-actions__search--bar .cc-header-actions__input {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 8px 0;
  width: 190px;
}

.cc-header-actions__search--bar .cc-header-actions__input:focus {
  outline: none;
}

.cc-header-actions__search--bar form:focus-within {
  border-color: var(--cc-accent, #767676);
}

.cc-header-actions__search--bar .cc-header-actions__submit {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.cc-header-actions__search--bar .cc-header-actions__submit:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  clip-path: none;
  padding: 8px 16px;
}

/* ── Narrow viewports ─────────────────────────────────────────────────── */

@media (max-width: 782px) {
  /* Labels drop, icons stay — the strip has to survive next to a logo and a
     cart icon on a phone. */
  .cc-header-actions__label { display: none; }
  .cc-header-actions__btn { padding: 8px; }
  .cc-header-actions__panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    min-width: 0;
  }
  /* Bar mode stays inline on mobile — the fixed positioning above is for the
     dropdown panel only, and would tear the bar out of the header. */
  .cc-header-actions__search--bar .cc-header-actions__panel {
    position: static;
    left: auto;
    right: auto;
  }
  .cc-header-actions__search--bar .cc-header-actions__input { width: 100%; min-width: 0; }
  .cc-header-actions__search--bar form { padding: 0 10px; }
}
