/* ==========================================================================
   MUSKETEER — Layout: header, nav, drawer, footer, grids
   ========================================================================== */

/* --- Header --------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(250, 249, 246, 0.9);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  min-height: 4.5rem;
}

/* Brand lockup */
.brand { display: inline-flex; align-items: center; gap: 0.65rem; }
.brand__mark {
  width: 34px;
  height: 34px;
  color: var(--ink);
}
.brand__mark svg { width: 100%; height: 100%; display: block; }
.brand__word {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1;
}

/* Primary nav (desktop) */
.nav { justify-self: center; }
.nav__list { display: flex; align-items: center; gap: var(--space-4); list-style: none; }
.nav__link {
  position: relative;
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding-block: 0.4rem;
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--gold-deep);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}
.nav__link:hover::after,
.nav__link[aria-current="page"]::after { transform: scaleX(1); }

/* Dropdown */
.nav__item--has-menu { position: relative; }
.nav__menu {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%) translateY(6px);
  min-width: 14rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  padding: var(--space-2);
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nav__item--has-menu:hover .nav__menu,
.nav__item--has-menu:focus-within .nav__menu {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.nav__menu a {
  display: block;
  padding: 0.55rem 0.7rem;
  font-size: var(--step--1);
  letter-spacing: 0.06em;
}
.nav__menu a:hover { background: var(--paper-2); color: var(--gold-deep); }

/* Header actions */
.header-actions { justify-self: end; display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 999px;
  transition: background var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--paper-2); }
.icon-btn svg,
.icon-btn i {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}
.nav-toggle { display: none; }

/* --- Mobile drawer -------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(11, 11, 12, 0.5);
  z-index: var(--z-overlay);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) var(--ease);
}
.overlay.is-open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(86vw, 360px);
  height: 100dvh;
  z-index: var(--z-drawer);
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: var(--space-4);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
  overflow-y: auto;
}
.drawer.is-open { transform: translateX(0); }
.drawer__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.drawer__brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink); }
.drawer__mark { width: 30px; height: 30px; }
.drawer__mark svg { width: 100%; height: 100%; display: block; }
.drawer__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.2em;
  line-height: 1;
  text-transform: uppercase;
}
.drawer__list { list-style: none; display: flex; flex-direction: column; }
.drawer__list a {
  display: block;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--step-2);
}
.drawer__sub a { font-family: var(--font-ui); font-size: var(--step-0); padding-left: var(--space-3); }

/* Left-side variant (mobile filter panel) */
.drawer--left {
  right: auto; left: 0;
  border-left: 0; border-right: 1px solid var(--line);
  transform: translateX(-100%);
}

/* --- Mini-cart drawer ----------------------------------------------------- */
.drawer--cart { width: min(92vw, 420px); display: flex; flex-direction: column; padding: 0; }
.mini-cart__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.mini-cart__items { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--space-4); }
.mini-cart__line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
}
.mini-cart__media { aspect-ratio: 3/4; background: var(--paper-3); overflow: hidden; }
.mini-cart__media img { width: 100%; height: 100%; object-fit: cover; }
.mini-cart__name { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.1; }
.mini-cart__meta { font-size: var(--step--1); color: var(--text-muted); margin-top: 2px; }
.mini-cart__line .qty { margin-top: var(--space-2); }
.mini-cart__remove { font-size: var(--step--1); color: var(--text-muted); border-bottom: 1px solid currentColor; }
.mini-cart__remove:hover { color: var(--danger); }
.mini-cart__foot { padding: var(--space-4); border-top: 1px solid var(--line); background: var(--paper); }
.mini-cart__ship { font-size: var(--step--1); color: var(--text-muted); margin-bottom: var(--space-3); }
.mini-cart__progress { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.mini-cart__progress i { display: block; height: 100%; background: var(--gold-deep); transition: width var(--dur) var(--ease); }
.mini-cart__subtotal { display: flex; justify-content: space-between; font-family: var(--font-display); font-size: var(--step-1); margin-bottom: var(--space-3); }
.mini-cart__empty { padding: var(--space-6) var(--space-4); text-align: center; }

/* --- Footer --------------------------------------------------------------- */
.site-footer {
  background: var(--ink);
  color: var(--paper);
  padding-block: var(--space-6) var(--space-4);
}
.site-footer a { color: var(--paper); }
.site-footer a:hover { color: var(--gold); }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: var(--space-5);
}
.footer-col h3 {
  font-family: var(--font-ui);
  font-size: var(--step--1);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-3);
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.footer-col ul a { font-size: var(--step--1); color: #cfcdc6; }
.footer-brand__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.footer-brand__mark {
  width: 38px;
  height: 38px;
  color: var(--gold);
}
.footer-brand__mark svg { width: 100%; height: 100%; display: block; }
.footer-brand__word {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.footer-brand p { color: #b6b4ad; font-size: var(--step--1); margin-top: var(--space-2); }
.newsletter { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.newsletter .input { background: transparent; border-color: var(--line-dark); color: var(--paper); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-dark);
  font-size: var(--step--1);
  color: #9b9992;
}
.footer-bottom__links { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* --- Product grid --------------------------------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6) var(--space-4);
}

/* --- Breadcrumb ----------------------------------------------------------- */
.breadcrumb { padding-block: var(--space-3); font-size: var(--step--1); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; color: var(--text-muted); }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 0.5rem; color: var(--line); }
.breadcrumb a:hover { color: var(--gold-deep); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 880px) {
  .nav { display: none; }
  .nav-toggle { display: grid; }
  .site-header__inner { grid-template-columns: auto 1fr auto; }
  .brand { justify-self: start; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  /* One-up product cards turn any grid into a ~700px-per-item scroll; two-up is
     the shape shoppers expect on a phone and keeps four cards on screen. */
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-2);
  }
  /* Drawer links: real 48px rows rather than text-height hit areas. */
  .drawer__list a { padding: var(--space-3) var(--space-1); min-height: 48px; }
  .drawer__sub a { font-size: var(--step-0); }
  .footer-col ul { gap: 0; }
  .footer-col ul a { display: block; padding-block: 0.55rem; }
  .footer-bottom { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-4); }
  .site-header__inner {
    gap: var(--space-1);
    min-height: 3.75rem;
    padding-inline: var(--space-3);
  }
  .brand { gap: 0.45rem; }
  .brand__mark {
    width: 28px;
    height: 28px;
  }
  .brand__word {
    font-size: 1.18rem;
    letter-spacing: 0.16em;
  }
  /* Keep the 44px touch target but let the buttons overlap the header's own
     inline padding, so three of them still fit beside the wordmark. */
  .header-actions { gap: 0; margin-right: calc(var(--space-2) * -1); }
  .icon-btn {
    width: 44px;
    height: 44px;
  }
  .nav-toggle { margin-left: calc(var(--space-2) * -1); }
  .header-actions .icon-btn--search { display: none; }
  /* The badge hangs 10px outside its button, which clears the viewport once the
     actions are pulled into the header's padding — tuck it back inside. */
  .header-actions .badge { top: 0; right: 0; }
  /* The footer wordmark's 0.2em tracking overruns a one-column footer. */
  .footer-brand__word { font-size: 1.5rem; letter-spacing: 0.16em; }
  .footer-brand__mark { width: 32px; height: 32px; }
}

/* Smallest phones (320px class): the brand lockup plus two 44px actions is the
   binding constraint, so the wordmark gives up the last of its tracking. */
@media (max-width: 380px) {
  .brand__word { font-size: 1.05rem; letter-spacing: 0.12em; }
  .brand__mark { width: 26px; height: 26px; }
  .site-header__inner { gap: 0; padding-inline: var(--space-2); }
}
