/* Shared site header — mock editorial layout + production hooks
   Requires: css/design-tokens.css */

@import url("panel-close.css");

body.has-site-header {
  margin: 0;
  color: var(--lf-ink);
  font-family: var(--lf-font);
  line-height: var(--lf-body-line);
  padding-top: var(--lf-header-height);
  box-sizing: border-box;
}

body.has-site-header:not(.has-hero-header) {
  background: var(--lf-surface);
}

body.has-site-header.has-hero-header {
  padding-top: 0;
}

body.has-site-header.is-bag-open,
body.has-site-header.is-header-menu-open,
body.has-site-header.is-auth-open,
body.has-site-header.is-search-open {
  overflow: hidden;
}

body.has-site-header.account-space .account-space-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 60px);
  box-sizing: border-box;
}

body.has-site-header:not(.account-space):not(.has-hero-header) .page-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 60px) 80px;
  box-sizing: border-box;
}

/* —— Header shell —— */
.site-header-sticky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--lf-header-height);
  padding: 0;
  margin: 0;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  background: var(--lf-header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--lf-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
  transition:
    background var(--lf-header-ease),
    color var(--lf-header-ease),
    box-shadow var(--lf-header-ease);
}

body.has-site-header .site-header-sticky.is-scrolled {
  background: var(--lf-header-scrolled-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--lf-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
  border-bottom: none;
  padding: 0;
  min-height: 0;
}

/* TOP over hero: transparent until scrolled */
body.has-hero-header .site-header-sticky:not(.is-scrolled) {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  color: #fff;
}

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 var(--lf-header-pad-x);
  border-bottom: none;
  box-sizing: border-box;
  gap: 16px;
}

/* Logo — centered */
.site-header-sticky .logo,
.site-header-sticky .logo.brand-case {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  font-family: var(--lf-font-display);
  font-size: var(--lf-logo-size);
  font-weight: var(--lf-logo-weight);
  letter-spacing: var(--lf-logo-tracking);
  text-transform: none;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  transition: font-size var(--lf-header-ease), color var(--lf-ease);
}

.site-header-sticky.is-scrolled .logo,
.site-header-sticky.is-scrolled .logo.brand-case,
body.has-site-header .site-header-sticky.is-scrolled .logo,
body.has-site-header .site-header-sticky.is-scrolled .logo.brand-case {
  font-size: var(--lf-logo-size-scrolled);
  color: var(--lf-ink);
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .logo,
body.has-hero-header .site-header-sticky:not(.is-scrolled) .logo.brand-case {
  color: #fff;
}

/* Side slots — equal flex keeps absolute logo truly centered */
.header-start,
.header-end {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  z-index: 1;
  gap: var(--lf-tools-gap);
}

.header-start {
  justify-content: flex-start;
}

.header-end {
  justify-content: flex-end;
}

/* Left category nav (PC) */
.nav-left {
  display: flex;
  align-items: center;
  gap: var(--lf-nav-gap);
  min-width: 0;
}

.nav-left .nav-link {
  font-family: var(--lf-font);
  font-size: var(--lf-nav-size);
  letter-spacing: var(--lf-nav-tracking);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--lf-nav, #6a6560);
  position: relative;
  padding-bottom: 5px;
  transition: color var(--lf-ease);
  white-space: nowrap;
}

.nav-left .nav-link:hover {
  color: var(--lf-ink);
}

.nav-left .nav-link.active {
  color: var(--lf-ink);
}

.nav-left .nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--lf-ink);
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-left .nav-link {
  color: rgba(255, 255, 255, 0.9);
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-left .nav-link:hover,
body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-left .nav-link.active {
  color: #fff;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-left .nav-link.active::after {
  background: #fff;
}

.header-end .nav-actions {
  display: flex;
  align-items: center;
  gap: var(--lf-tools-gap);
}

/* Inline search (mock) */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
  width: var(--lf-search-width);
  height: var(--lf-search-height);
  padding: 0 12px;
  border-radius: var(--lf-radius-sharp);
  border: 1px solid var(--lf-search-border);
  background: var(--lf-search-bg);
  transition: border-color var(--lf-ease), background var(--lf-ease);
  box-sizing: border-box;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .header-search {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.header-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 8px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.header-search-btn:focus {
  outline: none;
}

.header-search-btn:focus-visible {
  opacity: 0.7;
}

.header-search .lf-icon,
.header-search-btn .lf-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

.header-search-input,
.header-search .quiet-search-input,
#searchInput {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  outline: none;
  font-family: var(--lf-font);
  font-size: 12px;
  color: var(--lf-ink);
}

.header-search-input::placeholder,
.header-search .quiet-search-input::placeholder,
#searchInput::placeholder {
  color: var(--lf-muted);
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .header-search-btn,
body.has-hero-header .site-header-sticky:not(.is-scrolled) #searchInput {
  color: #fff;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) #searchInput::placeholder {
  color: rgba(255, 255, 255, 0.9);
}

/* Hide legacy popover shell when using inline input */
.header-search-popover {
  display: none !important;
}

/* Icon buttons */
.nav-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--lf-ease);
}

.nav-icon-btn:hover,
.nav-icon-btn:focus-visible {
  opacity: 0.7;
  color: inherit;
}

.nav-icon-btn .lf-icon {
  width: var(--lf-icon-size);
  height: var(--lf-icon-size);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* Lucide-style filled paths used in production icons */
.nav-icon-btn .lf-icon path,
.nav-icon-btn .lf-icon circle,
.nav-icon-btn .lf-icon line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Heart / bag paths that rely on fill in source SVGs */
.nav-icon-saved .lf-icon path,
.nav-icon-btn[data-bag-toggle] .lf-icon path,
button.nav-icon-btn .lf-icon path {
  fill: none;
}

.nav-icon-mark {
  position: relative;
  display: inline-flex;
}

.nav-icon-count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--lf-ink);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  line-height: 14px;
  text-align: center;
  text-shadow: none;
  box-sizing: border-box;
}

.nav-icon-count.is-zero {
  display: none;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-icon-btn {
  color: #fff;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .nav-icon-count {
  background: #fff;
  color: var(--lf-ink);
}

.edit-nav-state {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lf-ink);
  right: -2px;
  bottom: 0;
  display: none;
}

.edit-nav-state.is-active {
  display: block;
}

/* Menu button — mobile only (default hidden; shown ≤767px) */
.header-menu-btn {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.header-menu-btn .lf-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
}

body.has-hero-header .site-header-sticky:not(.is-scrolled) .header-menu-btn {
  color: #fff;
}

/* Mobile menu panel (i18n + support) */
.header-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--lf-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--lf-ease), visibility var(--lf-ease);
}

.header-menu-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.header-menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 111;
  width: min(320px, 88vw);
  height: 100%;
  background: var(--lf-surface);
  border-right: 1px solid var(--lf-line);
  transform: translateX(-100%);
  transition: transform var(--lf-ease);
  padding: 24px 20px 32px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.header-menu-panel.is-open {
  transform: translateX(0);
}

.header-menu-close {
  align-self: flex-end;
}

.header-menu-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header-menu-links a {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--lf-muted);
}

.header-menu-links a:hover {
  color: var(--lf-ink);
}

.header-menu-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header-menu-guide {
  font-size: 12px;
  color: var(--lf-muted);
  text-decoration: none;
}

.header-menu-guide:hover {
  color: var(--lf-ink);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--lf-line);
  border-radius: var(--lf-radius-sharp);
  overflow: hidden;
}

.lang-switch-btn {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--lf-muted);
  cursor: pointer;
}

.lang-switch-btn:hover {
  color: var(--lf-ink);
}

.lang-switch-btn.is-active {
  color: var(--lf-ink);
  background: rgba(21, 21, 21, 0.06);
}

/* Legacy structure hooks (nav wrapper unused but may remain briefly) */
.site-header > .nav {
  display: contents;
}

.header-leading {
  display: contents;
}

.nav-primary {
  display: none;
}

/*
  Breakpoint: 767px / 768px
  ≤767 mobile header | ≥768 PC/tablet header
*/
@media (max-width: 767px) {
  /* Search sits in header-end in the DOM (tab order: logo → search → icons).
     Flatten header-end so the icon stays left of the logo cluster, next to Menu. */
  .header-end {
    display: contents;
  }

  .header-start {
    flex: 0 0 auto;
  }

  .header-end .nav-actions {
    margin-left: auto;
    padding-right: 6px;
  }

  /* Remove PC-only chrome from the mobile header composition */
  .header-pc-only {
    display: none !important;
  }

  .header-menu-btn {
    display: inline-flex;
  }

  /*
    UI微調整（レイアウト構成は変えず）
    - 左グループを中央へ +6px
    - 右端余白 +6px（Account–Bag 間隔は維持）
  */
  .header-start {
    padding-left: 6px;
  }

  /* ロゴ: 22px → 24px（存在感をわずかに） */
  .site-header-sticky .logo,
  .site-header-sticky .logo.brand-case,
  .site-header-sticky.is-scrolled .logo,
  .site-header-sticky.is-scrolled .logo.brand-case {
    font-size: 24px;
  }

  /* Search: icon only — 全状態で枠・塗りなし（TOP scrolled 上書きも含む） */
  .header-search,
  body.has-hero-header .site-header-sticky:not(.is-scrolled) .header-search,
  body.has-hero-header .site-header-sticky.is-scrolled .header-search,
  .site-header-sticky.is-scrolled .header-search,
  body.page-top .header-search,
  body.page-top .site-header-sticky.is-scrolled .header-search,
  body.page-top .site-header-sticky:not(.is-scrolled) .header-search {
    width: auto;
    min-width: 0;
    height: auto;
    padding: 0;
    border: none !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
  }

  .header-search:hover,
  .header-search:focus,
  .header-search:focus-within,
  .header-search:active,
  body.page-top .header-search:hover,
  body.page-top .header-search:focus,
  body.page-top .header-search:focus-within,
  body.page-top .header-search:active,
  body.page-top .site-header-sticky.is-scrolled .header-search:hover,
  body.page-top .site-header-sticky.is-scrolled .header-search:focus-within {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
  }

  .header-search-input,
  .header-search .quiet-search-input,
  #searchInput {
    display: none;
  }

  .header-search-btn {
    position: relative;
    margin: 0;
    width: 36px;
    height: 36px;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
    border-radius: 50%;
  }

  .header-search-btn:hover,
  .header-search-btn:active {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    opacity: 0.7;
  }

  /* a11y: 四角枠ではなく薄い円形ハイライト */
  .header-search-btn:focus {
    outline: none;
  }

  .header-search-btn:focus-visible {
    outline: none;
    background: rgba(21, 21, 21, 0.08) !important;
    box-shadow: none !important;
  }

  body.has-hero-header .site-header-sticky:not(.is-scrolled) .header-search-btn:focus-visible,
  body.page-top .site-header-sticky:not(.is-scrolled) .header-search-btn:focus-visible {
    background: rgba(255, 255, 255, 0.18) !important;
  }

  .header-search .lf-icon,
  .header-search-btn .lf-icon {
    width: 18px;
    height: 18px;
  }

  .nav-icon-account {
    display: inline-flex !important;
  }

  /* タップ領域 44×44（見た目・アイコンサイズは維持） */
  .header-menu-btn::before,
  .header-search-btn::before,
  body.page-detail .header-collection-back::before,
  .header-end .nav-icon-btn::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  .header-menu-footer {
    display: none;
  }

  /*
    Detail mobile: keep .header-start in-flow width ≈ TOP (Menu only).
    Collection-back must be out of flex flow; otherwise Search sits under the
    absolute centered logo (logo z-index:2) and appears "missing".
    Position against .site-header (position:relative), not via display:contents.
  */
  body.page-detail .header-collection-back {
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
  }
}

@media (min-width: 768px) {
  /* PC/tablet: flatten start so Search sits on the right with icons */
  .header-menu-btn {
    display: none !important;
  }

  .header-start {
    display: contents;
  }

  .nav-left {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
  }

  .header-end {
    order: 4;
    flex: 0 0 auto;
  }

  body.page-detail .header-collection-back {
    order: 0;
  }
}

/* Detail — collection back in header (← chevron, all breakpoints) */
body.page-detail .header-collection-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--lf-text-subtle, #6a6560);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

/* Desktop/tablet: participate in flex order (mobile uses absolute above). */
@media (min-width: 768px) {
  body.page-detail .header-collection-back {
    position: relative;
  }
}

body.page-detail .header-collection-back .lf-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.page-detail .header-collection-back:hover,
body.page-detail .header-collection-back:focus-visible {
  color: var(--lf-ink);
  outline: none;
}
