/* ==========================================================================
   Mobile bottom navigation (thxsilk-style tab bar)
   Visible below 990px only. Sits under drawers/modals (z 150) and above the
   sticky header (z 100). Body gets bottom clearance so the last section is
   never covered, including iOS safe-area insets.
   ========================================================================== */

.mobile-bar{ display: none; }

@media (max-width: 989px){

  body{ padding-bottom: calc(5.8rem + env(safe-area-inset-bottom, 0px)); }

  .mobile-bar{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: stretch;
    padding: 0 .2rem env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, .97);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--color-border, #E8E4DE);
    box-shadow: 0 -6px 18px rgba(31, 58, 46, .06);
    transform: translateY(0);
    transition: transform .3s ease;
  }

  /* Drawer / search / modal open: step out of the way */
  body.menu-open .mobile-bar,
  body.search-open .mobile-bar,
  body.cart-open .mobile-bar,
  body.market-open .mobile-bar,
  body.no-mobile-bar .mobile-bar{
    transform: translateY(110%);
    pointer-events: none;
  }

  /* app.min.js pins the consent bar to bottom:0 with z-index 260 and flags
     <body class="has-cookie">. Stacking two bars wastes 170px of a phone
     screen, so the tab bar waits underneath until consent is given. */
  body.has-cookie .mobile-bar{
    transform: translateY(110%);
    pointer-events: none;
  }

  /* PDP owns the bottom strip while its sticky buy bar is on screen —
     two stacked bars would bury the add-to-cart button. */
  .mobile-bar.is-suppressed,
  body:has(.pdpv2-stickybar.is-on) .mobile-bar{
    transform: translateY(110%);
    pointer-events: none;
  }

  .mobile-bar__item{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .28rem;
    height: 5.8rem;
    padding: .6rem .1rem .4rem;
    color: var(--color-muted, #8A8178);
    font-family: var(--font-heading-family, inherit);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: .01rem;
    line-height: 1;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s ease;
  }

  .mobile-bar__item svg{
    width: 2.1rem;
    height: 2.1rem;
    flex: none;
  }

  /* Five tabs on a 390px screen leave ~70px of label width. Long words such as
     "Boutique" stay on one line by shrinking slightly instead of wrapping. */
  @media (max-width: 420px){
    .mobile-bar__item{ font-size: 1.05rem; letter-spacing: 0; }
    .mobile-bar__item svg{ width: 2.05rem; height: 2.05rem; }
  }
  @media (max-width: 350px){
    .mobile-bar__item{ font-size: .95rem; }
  }

  .mobile-bar__item span{
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bar__item:active{ color: var(--color-primary, #1F3A2E); }

  .mobile-bar__item.is-active{
    color: var(--color-primary, #1F3A2E);
  }

  .mobile-bar__item.is-active::before{
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2.4rem;
    height: .2rem;
    margin-left: -1.2rem;
    background: var(--color-accent, #C9A96E);
    border-radius: 0 0 .2rem .2rem;
  }

  .mobile-bar__item .badge{
    position: absolute;
    top: .5rem;
    left: 50%;
    margin-left: .5rem;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 .35rem;
    border-radius: 999px;
    background: var(--color-primary, #1F3A2E);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.6rem;
    text-align: center;
  }

  /* RTL (Arabic): keep the visual rhythm, flip the badge offset */
  html[dir="rtl"] .mobile-bar__item .badge{
    left: auto;
    right: 50%;
    margin-left: 0;
    margin-right: .5rem;
  }

  /* ------------------------------------------------------------------
     Header market trigger — flag + language + currency, left of the
     magnifier. Gathers the same sheet as before.
     ------------------------------------------------------------------ */
  .header-market{
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    height: 4rem;
    padding: 0 .6rem;
    background: none;
    border: 0;
    border-radius: .6rem;
    color: var(--color-muted, #8A8178);
    font-family: var(--font-heading-family, inherit);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .header-market:active{ background: rgba(31, 58, 46, .06); }

  .header-market__lang{ color: var(--color-heading, #1F3A2E); }

  /* Second slot now carries the ship-to country name, which is longer than a
     three-letter currency code — clamp it so the trigger never pushes the
     magnifier off a 320px header. */
  .header-market__cur{
    max-width: 8.5rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-market__flag{
    display: inline-flex;
    flex: none;
    width: 1.7rem;
    height: 1.15rem;
    overflow: hidden;
    border-radius: .15rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .08);
  }

  .mobile-market__flag svg{ width: 100%; height: 100%; display: block; }

  /* ------------------------------------------------------------------
     Market sheet — language + currency picker (bottom sheet)
     ------------------------------------------------------------------ */
  .market-sheet{
    position: fixed;
    inset: 0;
    z-index: 210;
    display: none;
  }

  .market-sheet.is-open{ display: block; }

  .market-sheet__backdrop{
    position: absolute;
    inset: 0;
    background: rgba(31, 58, 46, .42);
    opacity: 0;
    transition: opacity .28s ease;
  }

  .market-sheet.is-open .market-sheet__backdrop{ opacity: 1; }

  .market-sheet__panel{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 84vh;
    overflow-y: auto;
    padding: 1.4rem 1.8rem calc(1.8rem + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface, #fff);
    border-radius: 1.8rem 1.8rem 0 0;
    box-shadow: 0 -18px 40px rgba(31, 58, 46, .18);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.22, .61, .36, 1);
  }

  .market-sheet.is-open .market-sheet__panel{ transform: translateY(0); }

  .market-sheet__head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
  }

  .market-sheet__title{
    margin: 0;
    font-family: var(--font-heading-family, inherit);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-heading, #1F3A2E);
  }

  .market-sheet__close{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.6rem;
    height: 3.6rem;
    border: 0;
    border-radius: 50%;
    background: var(--color-surface-alt, #F3EFE8);
    color: var(--color-heading, #1F3A2E);
    cursor: pointer;
  }

  .market-sheet__close svg{ width: 1.7rem; height: 1.7rem; }

  /* Language and ship-to sit side by side, each with its own scroll area —
     the country list is every opened market (50+ rows) and would otherwise
     bury the language column. */
  .market-sheet__cols{
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 1rem;
    align-items: start;
  }

  .market-sheet__col--lang{
    padding-inline-end: 1rem;
    border-inline-end: 1px solid var(--color-border, #E8E4DE);
  }

  .market-sheet__list{
    max-height: 52vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .market-sheet__label{
    margin: 0 0 .6rem;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--color-muted, #8A8178);
  }

  .market-opt{
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .8rem .5rem;
    background: none;
    border: 0;
    border-radius: .8rem;
    color: var(--color-heading, #1F3A2E);
    font-family: inherit;
    font-size: 1.3rem;
    text-align: start;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .market-opt:hover{ background: rgba(31, 58, 46, .05); }

  .market-opt.is-active{
    background: rgba(31, 58, 46, .07);
    font-weight: 700;
  }

  .market-opt.is-active::after{
    content: "\2713";
    margin-inline-start: auto;
    color: var(--color-primary, #1F3A2E);
    font-size: 1.4rem;
  }

  /* Real flag image per country row (the API sends /assets/flags/xx.svg) */
  .market-opt__flag{
    flex: none;
    width: 2.2rem;
    height: 1.5rem;
    object-fit: cover;
    border-radius: .15rem;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
  }

  .market-opt .mobile-market__flag{ width: 2.4rem; height: 1.6rem; border-radius: .2rem; }

  .market-opt__sign{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 2.4rem;
    height: 1.6rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-accent, #C9A96E);
  }

  .market-opt__name{ min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .market-opt__code{
    flex: none;
    margin-inline-start: auto;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-muted, #8A8178);
  }

  .market-opt.is-active .market-opt__code{ margin-inline-end: .4rem; }
}

/* Never show on desktop, even if a page forgets the media query context */
@media (min-width: 990px){
  .mobile-bar{ display: none !important; }
  .header-market{ display: none !important; }
  .market-sheet{ display: none !important; }
}

/* Header "ship to" select: country names run much longer than a currency
   code, so cap the width and let the browser truncate instead of shoving the
   search icon off the header. */
.locale-switch__select--country{
  max-width: 12rem;
  text-overflow: ellipsis;
}

/* Current country flag beside the header select (options themselves are native
   <option>s, which cannot carry images). */
.locale-switch__field{
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
}

.locale-switch__flag{
  flex: none;
  width: 1.8rem;
  height: 1.2rem;
  object-fit: cover;
  border-radius: .15rem;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
}

/* ---------- Desktop country picker (custom listbox) ----------
   Native <option> cannot render an image, so the desktop dropdown is a real
   popup: every row shows its flag, country name and dial code. */
.locale-switch__country{ position: relative; }

.locale-switch__trigger{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  max-width: 20rem;
}

@media (max-width: 1439px){
  /* 窄桌面把目的地控件收窄，给导航让出空间 */
  .locale-switch__trigger{ max-width: 14rem; }
}

.locale-switch__ctry{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locale-switch__chev{ width: 1.4rem; height: 1.4rem; flex: none; opacity: .55; }

.locale-switch__menu{
  position: absolute;
  top: calc(100% + .5rem);
  /* The picker sits near the right edge of the header, so the panel grows
     leftwards — anchored left it would run off the viewport. */
  inset-inline-end: 0;
  z-index: 240;
  display: none;
  width: 22rem;
  max-width: calc(100vw - 2rem);
  max-height: 46vh;
  overflow-y: auto;
  padding: .5rem;
  background: #fff;
  border: 1px solid var(--color-border, #E4E4E4);
  border-radius: .8rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .14);
  overscroll-behavior: contain;
}

.locale-switch__country.is-open .locale-switch__menu{ display: block; }

.locale-switch__opt{
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .6rem .7rem;
  background: none;
  border: 0;
  border-radius: .5rem;
  color: var(--color-heading, #1F3A2E);
  font-family: inherit;
  font-size: 1.3rem;
  text-align: start;
  cursor: pointer;
  white-space: nowrap;
}

.locale-switch__opt:hover{ background: rgba(31, 58, 46, .06); }

.locale-switch__opt.is-active{
  background: rgba(31, 58, 46, .08);
  font-weight: 700;
}

.locale-switch__opt .locale-switch__flag{ width: 2rem; height: 1.35rem; }

.locale-switch__flag--blank{ background: rgba(0, 0, 0, .06); box-shadow: none; }

.locale-switch__opt-name{ min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.locale-switch__opt-dial{
  margin-inline-start: auto;
  padding-inline-start: .6rem;
  font-size: 1.2rem;
  color: var(--color-muted, #8A8178);
}

@media (max-width: 989px){
  /* Inside the drawer both selects share the row, so the cap is lifted. */
  .site-header__drawer .locale-switch__select--country{ max-width: none; }
  .site-header__drawer .locale-switch__field{ flex: 1 1 0; min-width: 0; }
  .site-header__drawer .locale-switch__field .locale-switch__select{ width: 100%; }
}
