/* ==========================================================================
   Header
   ========================================================================== */

.coffee-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  height: var(--header-height);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-header);
  transition: background var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

/* WordPress admin bar sits above the fixed header when logged in */
.admin-bar .coffee-header {
  top: 32px;
}

@media screen and (max-width: 782px) {
  .admin-bar .coffee-header {
    top: 46px;
  }
}

.coffee-header.is-scrolled {
  background: var(--header-bg-scrolled);
  box-shadow: var(--shadow-md);
}

.coffee-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: var(--space-6);
}

/* Logo */
.coffee-header__logo {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: var(--space-3);
  flex-shrink: 0;
  transition: opacity var(--duration-fast);
}

.coffee-header__logo:hover {
  opacity: 0.8;
}

.coffee-header__logo-img {
  display: block;
  width: auto;
  height: 48px;
  max-width: 160px;
  object-fit: contain;
}

@media (min-width: 768px) {
  .coffee-header__logo-img {
    height: 56px;
  }
}

[data-theme="light"] .coffee-header__logo-img--dark,
:root:not([data-theme="dark"]) .coffee-header__logo-img--dark {
  display: none;
}

[data-theme="dark"] .coffee-header__logo-img--light {
  display: none;
}

.coffee-header__logo-mark {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  color: var(--color-accent);
}

.coffee-header__logo-text {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: clamp(1.625rem, 1.8vw, 1.875rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
  line-height: 1;
}

.coffee-header__logo-text span {
  color: var(--color-accent);
}

/* Navigation */
.coffee-header__nav {
  display: none;
}

@media (min-width: 1024px) {
  .coffee-header__nav {
    display: flex;
    align-items: center;
    align-self: stretch;
    gap: var(--space-2);
    height: 100%;
  }
}

.coffee-header__nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  height: 100%;
  padding: 0 var(--space-5);
  font-size: 1.3125rem;
  font-weight: 500;
  line-height: 1;
  color: var(--color-text-muted);
  border-radius: 0;
  transition: color var(--duration-fast), background var(--duration-fast);
}

.coffee-header__nav-link:hover,
.coffee-header__nav-link.is-active {
  color: var(--color-text);
  background: var(--color-accent-soft);
}

.coffee-header__nav-link.is-active::after {
  content: "";
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent);
}

/* Actions (lang, theme, cart) */
.coffee-header__actions {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: var(--space-3);
  height: 100%;
}

.coffee-header__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: color var(--duration-fast), background var(--duration-fast);
}

.coffee-header__action-btn:hover {
  color: var(--color-text);
  background: var(--color-accent-soft);
}

.coffee-header__action-btn svg {
  display: block;
  width: 26px;
  height: 26px;
}

/* Language switcher */
.coffee-header__lang {
  position: relative;
  display: flex;
  align-items: center;
  align-self: stretch;
  height: 100%;
}

.coffee-header__lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: var(--space-2);
  height: 100%;
  padding: 0 var(--space-5);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-muted);
  border-radius: 0;
  transition: color var(--duration-fast), background var(--duration-fast);
}

.coffee-header__lang-btn:hover,
.coffee-header__lang-btn[aria-expanded="true"] {
  color: var(--color-text);
  background: var(--color-accent-soft);
}

.coffee-header__lang-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast);
}

.coffee-header__lang-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.coffee-header__lang-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 140px;
  padding: var(--space-2);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--duration-fast), transform var(--duration-fast),
    visibility var(--duration-fast);
}

.coffee-header__lang-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.coffee-header__lang-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: color var(--duration-fast), background var(--duration-fast);
}

.coffee-header__lang-option:hover,
.coffee-header__lang-option.is-active {
  color: var(--color-text);
  background: var(--color-accent-soft);
}

.coffee-header__lang-flag {
  font-size: var(--text-base);
  line-height: 1;
}

/* Theme toggle icons */
.coffee-header__theme-icon--light,
.coffee-header__theme-icon--dark {
  transition: opacity var(--duration-fast);
}

[data-theme="light"] .coffee-header__theme-icon--dark,
[data-theme="dark"] .coffee-header__theme-icon--light {
  display: none;
}

/* Cart badge */
.coffee-header__cart {
  position: relative;
}

.coffee-header__cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  color: var(--color-text-inverse);
  background: var(--color-accent);
  border-radius: var(--radius-full);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.coffee-header__cart-badge.has-items {
  opacity: 1;
  transform: scale(1);
}

/* Mobile menu toggle */
.coffee-header__menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  color: var(--color-text);
  transition: background var(--duration-fast);
}

.coffee-header__menu-toggle:hover {
  background: var(--color-accent-soft);
}

@media (min-width: 1024px) {
  .coffee-header__menu-toggle {
    display: none;
  }
}

.coffee-header__menu-toggle svg {
  width: 26px;
  height: 26px;
}

.coffee-header__menu-icon--close {
  display: none;
}

.coffee-header__menu-toggle[aria-expanded="true"] .coffee-header__menu-icon--open {
  display: none;
}

.coffee-header__menu-toggle[aria-expanded="true"] .coffee-header__menu-icon--close {
  display: block;
}

/* Mobile drawer */
.coffee-header__mobile-nav {
  position: fixed;
  inset: var(--header-height) 0 0 0;
  z-index: 999;
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base), visibility var(--duration-base);
}

.admin-bar .coffee-header__mobile-nav {
  top: calc(var(--header-height) + 32px);
}

@media screen and (max-width: 782px) {
  .admin-bar .coffee-header__mobile-nav {
    top: calc(var(--header-height) + 46px);
  }
}

.coffee-header__mobile-nav.is-open {
  opacity: 1;
  visibility: visible;
}

.coffee-header__mobile-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  padding: var(--space-6);
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--duration-base) var(--ease-out);
  overflow-y: auto;
}

.coffee-header__mobile-nav.is-open .coffee-header__mobile-panel {
  transform: translateX(0);
}

.coffee-header__mobile-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.coffee-header__mobile-link {
  display: block;
  padding: var(--space-4);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: color var(--duration-fast), background var(--duration-fast);
}

.coffee-header__mobile-link:hover,
.coffee-header__mobile-link.is-active {
  color: var(--color-text);
  background: var(--color-accent-soft);
}

/* Spacer to offset fixed header (not used on front page) */
.coffee-header-spacer {
  height: var(--header-height);
}

.coffee-front-page .coffee-header-spacer {
  display: none;
  height: 0;
}

.coffee-hero-page .coffee-header-spacer {
  display: none;
  height: 0;
}
