/*
 * Shelf Header
 *
 * The header has two layout states:
 * - PC (768px and wider): logos and primary navigation on the left.
 * - H5 (767px and narrower): menu trigger on the left.
 *
 * Store actions stay on the right in both states.
 */

:root {
  --shelf-header-height: 77px;
  --shelf-header-padding: 24px;
  --shelf-header-text: #171717;
  --shelf-header-muted: #6b7280;
  --shelf-header-primary: #5e71ff;
  --shelf-header-border: rgb(0 0 0 / 6%);
}

/* Header shell and its four logical regions. */
.shelf-header {
  position: fixed;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 50;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--shelf-header-height);
  padding: 0 var(--shelf-header-padding);
  color: var(--shelf-header-text);
  background: rgb(255 255 255 / 96%);
  border-bottom: 1px solid var(--shelf-header-border);
  font-family:
    "MiSans",
    system-ui,
    -apple-system,
    sans-serif;
  backdrop-filter: blur(14px);
}

.site-content {
  padding-top: var(--shelf-header-height);
}

/* PC-only left group: square logo, wordmark, and primary navigation. */
.shelf-header__desktop-left {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
}

.shelf-header__main-logo,
.shelf-header__wordmark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.shelf-header__main-logo img {
  display: block;
  width: 48px;
  height: 48px;
}

.shelf-header__wordmark img {
  display: block;
  width: 120px;
  height: 24px;
  object-fit: contain;
}

.shelf-header__navigation {
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.shelf-header__navigation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 32px;
  padding: 0 12px;
  color: var(--shelf-header-primary);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 28px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.shelf-header__navigation-link:hover {
  background: rgb(94 113 255 / 8%);
}

.shelf-header__navigation-link--active {
  font-weight: 700;
}

/* H5-only left group: square logo and the drawer trigger. */
.shelf-header__mobile-left {
  display: none;
}

.shelf-header__menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0;
  color: var(--shelf-header-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  line-height: 20px;
  text-transform: uppercase;
}

.shelf-header__menu-trigger img {
  display: block;
  width: 24px;
  height: 24px;
}

/* Search, account, and cart actions shared by PC and H5. */
.shelf-header__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
}

.shelf-header__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 40px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.shelf-header__action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}
.shelf-header__account-avatar {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

/* The drawer is only rendered visually in the H5 state. */
.shelf-menu-drawer,
.shelf-menu-backdrop {
  display: none;
}

/* H5 layout and drawer. */
@media (max-width: 767px) {
  :root {
    --shelf-header-height: 48px;
  }

  .shelf-header {
    min-height: var(--shelf-header-height);
    padding: 0 16px;
  }

  .shelf-header__desktop-left {
    display: none;
  }

  .shelf-header__mobile-left {
    display: block;
  }

  .shelf-header__actions {
    gap: 8px;
  }

  .shelf-header__action {
    width: 24px;
    height: 40px;
  }

  .shelf-header__action svg {
    width: 18px;
    height: 18px;
  }

  .shelf-menu-drawer[data-open="true"] {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    width: 280px;
    max-width: 85vw;
    overflow-y: auto;
    color: #000;
    background: #fff;
    box-shadow: 0 4px 20px rgb(0 0 0 / 15%);
  }

  .shelf-menu-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 16px;
    text-transform: uppercase;
  }

  .shelf-menu-drawer__header button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    font-size: 24px;
  }

  .shelf-menu-drawer nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
  }

  .shelf-menu-drawer nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    color: #374151;
    font-size: 16px;
    line-height: 24px;
    text-decoration: none;
    text-transform: uppercase;
  }

  .shelf-menu-drawer nav a.is-active {
    color: #171717;
    font-weight: 700;
  }

  .shelf-menu-drawer__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
  }

  .shelf-menu-drawer__icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
  }

  .shelf-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: block;
    visibility: hidden;
    background: rgb(0 0 0 / 40%);
    opacity: 0;
    transition:
      opacity 0.2s,
      visibility 0.2s;
  }

  .shelf-menu-drawer[data-open="true"] + .shelf-menu-backdrop {
    visibility: visible;
    opacity: 1;
  }
}
