/**
 * Header — macarteimprimee.com
 * Topbar trust + navigation sticky + actions (cart, CTA) + mobile drawer
 * Dépend des variables de main.css (:root)
 */

/* ========== TOP BAR ========== */
.header-topbar {
  background: var(--p);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: 0.01em;
  overflow: hidden;
}

.header-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 32px;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.header-topbar__contact {
  display: none;
  align-items: center;
  gap: var(--space-sm);
}

.header-topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  transition: color var(--ease);
  white-space: nowrap;
}

.header-topbar__link:hover {
  color: #fff;
}

.header-topbar__sep {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.header-topbar__trust {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
  overflow: hidden;
}

.header-topbar__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
}

.header-topbar__badge svg {
  color: var(--s);
  flex-shrink: 0;
}

/* Mobile : 2 badges centrés, pas de contact */
@media (max-width: 479px) {
  .header-topbar__inner { justify-content: center; }
  .header-topbar__badge:nth-child(n+3) { display: none; }
  .header-topbar__badge { font-size: 0.7rem; }
}

/* Phablet : 3 badges, pas de contact */
@media (min-width: 480px) and (max-width: 767px) {
  .header-topbar__inner { justify-content: center; }
}

/* Tablette+ : contact à gauche, badges à droite */
@media (min-width: 768px) {
  .header-topbar__inner {
    justify-content: space-between;
    min-height: 36px;
  }
  .header-topbar__contact { display: flex; }
  .header-topbar { font-size: 0.8rem; }
}

/* ========== MAIN BAR (sticky) ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--b);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.site-header.is-scrolled {
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  border-color: transparent;
}

.header-main__inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 52px;
}

/* ========== LOGO ========== */
.header-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
  color: var(--p);
  flex-shrink: 0;
  margin-right: auto;
  transition: opacity var(--ease);
}

.header-logo:hover {
  opacity: 0.8;
  color: var(--p);
}

.header-logo__mark {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 5px;
}

.header-logo__text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  white-space: nowrap;
  line-height: 1.15;
  color: var(--p);
}

.header-logo__text strong {
  font-weight: 800;
}

/* ========== DESKTOP NAV ========== */
.header-nav {
  display: none;
}

.header-nav__list {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-nav__link {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--t);
  border-radius: var(--r);
  white-space: nowrap;
  transition: background var(--ease), color var(--ease);
  position: relative;
}

.header-nav__link::after {
  content: '';
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.15rem;
  height: 2px;
  border-radius: 2px;
  background: var(--cta);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-nav__link:hover {
  background: var(--al);
  color: var(--a);
}

.header-nav__link:hover::after {
  transform: scaleX(1);
}

.header-nav__link--active {
  color: var(--a);
  background: var(--al);
}

.header-nav__link--active::after {
  transform: scaleX(1);
  background: var(--a);
}

/* ========== ACTIONS (cart, CTA, phone) ========== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Phone icon : masqué par défaut, visible tablette uniquement */
.header-actions__phone {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--a);
  transition: background var(--ease), color var(--ease);
}

.header-actions__phone:hover {
  background: var(--al);
  color: var(--p);
}

.header-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  color: var(--t);
  transition: background var(--ease), color var(--ease);
}

.header-cart:hover {
  background: var(--al);
  color: var(--a);
}

.header-cart__badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--cta);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px #fff;
  animation: header-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes header-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* CTA : masqué mobile+tablette, visible desktop uniquement (pas de conflit avec .btn) */
.header-actions .header-cta {
  display: none;
  padding: 0.5rem 1.1rem;
  font-size: var(--text-sm);
  min-height: 38px;
  border-radius: var(--r);
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ========== MOBILE BURGER ========== */
.header-burger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: var(--r);
  background: transparent;
  cursor: pointer;
  transition: background var(--ease);
  flex-shrink: 0;
}

.header-burger:hover {
  background: var(--al);
}

.header-burger__line {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--p);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.header-burger[aria-expanded="true"] .header-burger__line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.header-burger[aria-expanded="true"] .header-burger__line:nth-child(2) {
  opacity: 0;
}

.header-burger[aria-expanded="true"] .header-burger__line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ========== RESPONSIVE : TABLETTE (640–899px) ========== */
@media (min-width: 640px) and (max-width: 899px) {
  .header-main__inner {
    gap: 0.5rem;
    min-height: 56px;
  }
  .header-logo__mark { width: 32px; height: 32px; }
  .header-logo__text { font-size: 1.05rem; }
  .header-logo { gap: 0.5rem; }
  .header-actions { gap: 0.35rem; }
  .header-actions__phone { display: inline-flex; }
  .header-cart { width: 40px; height: 40px; }
  .header-burger { width: 40px; height: 40px; }
}

/* ========== RESPONSIVE : DESKTOP (900px+) ========== */
@media (min-width: 900px) {
  .header-main__inner {
    gap: var(--space-md);
    min-height: 62px;
  }
  .header-logo__mark { width: 36px; height: 36px; }
  .header-logo__text { font-size: 1.15rem; }
  .header-logo { gap: 0.6rem; }
  .header-nav {
    display: flex;
    align-items: center;
    margin-right: auto;
    margin-left: var(--space-lg);
  }
  .header-actions { gap: 0.5rem; }
  .header-actions .header-cta { display: inline-flex; }
  .header-cart { width: 42px; height: 42px; }
  .header-cart__badge { top: 2px; right: 2px; min-width: 18px; height: 18px; font-size: 0.7rem; line-height: 18px; }
  .header-burger { display: none; }
}

/* ========== MOBILE DRAWER ========== */
.header-drawer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.header-drawer--open {
  pointer-events: auto;
  visibility: visible;
}

.header-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.header-drawer--open .header-drawer__backdrop {
  opacity: 1;
}

.header-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 88vw);
  background: var(--card);
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.header-drawer--open .header-drawer__panel {
  transform: translateX(0);
}

.header-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--b);
}

.header-drawer__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--p);
}

.header-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--r);
  background: var(--bg);
  color: var(--t);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.header-drawer__close:hover {
  background: var(--al);
  color: var(--a);
}

.header-drawer__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md) 0;
}

.header-drawer__link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem var(--space-lg);
  color: var(--p);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--ease);
  border-left: 3px solid transparent;
}

.header-drawer__link:hover {
  background: var(--bg);
  border-left-color: var(--a);
  color: var(--p);
}

.header-drawer__link-label {
  font-family: var(--font-heading);
  font-size: var(--text-base);
}

.header-drawer__link-hint {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--m);
}

.header-drawer__link--util {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  color: var(--m);
}

.header-drawer__link--util:hover {
  color: var(--p);
}

.header-drawer__cart-count {
  font-weight: 700;
  color: var(--cta);
}

.header-drawer__hr {
  border: none;
  border-top: 1px solid var(--b);
  margin: var(--space-sm) var(--space-lg);
}

.header-drawer__foot {
  padding: var(--space-lg);
  border-top: 1px solid var(--b);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: auto;
}

.header-drawer__cta {
  width: 100%;
  justify-content: center;
  min-height: 48px;
  font-size: var(--text-base);
  border-radius: var(--r);
}

.header-drawer__contact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.header-drawer__contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-sm);
  color: var(--m);
  transition: color var(--ease);
}

.header-drawer__contact-link:hover {
  color: var(--a);
}
