/* ===================================================
   China Passage - Language Switcher Component
   =================================================== */

.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-family: 'Source Sans 3', -apple-system, sans-serif;
  font-size: 0.875rem;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: inherit;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lang-btn:hover,
.lang-btn:focus-visible {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Light background adapt */
.editorial-site:not(.home-page) .site-header .lang-btn,
.site-header.is-scrolled .lang-btn {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.15);
  color: #0f172a;
}

.editorial-site:not(.home-page) .site-header .lang-btn:hover,
.site-header.is-scrolled .lang-btn:hover {
  background: rgba(15, 23, 42, 0.12);
  border-color: rgba(15, 23, 42, 0.25);
}

.lang-btn svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 1.6;
}

.lang-btn .chevron {
  width: 0.75rem;
  height: 0.75rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.lang-switcher.is-open .lang-btn .chevron {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: #ffffff;
  color: #0f172a;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  min-width: 150px;
  padding: 0.35rem;
  z-index: 1000;
  display: none;
  animation: langFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-switcher.is-open .lang-dropdown-menu {
  display: block;
}

@keyframes langFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  color: #334155;
  text-decoration: none;
  font-size: 0.825rem;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  text-align: left;
}

.lang-option:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.lang-option.is-active {
  background: #fff7ed;
  color: #c2410c;
  font-weight: 600;
}

.lang-option .lang-code {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.lang-option.is-active .lang-code {
  color: #ea580c;
}

/* Mobile drawer language bar */
.menu-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 1.5rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.menu-lang-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, 0.03);
  color: #334155;
  font-size: 0.8125rem;
  text-decoration: none;
}

.menu-lang-link.is-active {
  background: #ea580c;
  color: #ffffff;
  font-weight: 600;
}

/* ===================================================
   Smart Browser Language Suggestion Banner
   =================================================== */

.lang-suggest-banner {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  padding: 0.65rem 1.25rem;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.875rem;
  animation: bannerSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

@keyframes bannerSlideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.lang-suggest-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.lang-suggest-text {
  font-weight: 500;
  color: #e2e8f0;
}

.lang-suggest-btn {
  background: #ea580c;
  color: #ffffff;
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.8125rem;
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(234, 88, 12, 0.3);
}

.lang-suggest-btn:hover {
  background: #c2410c;
  transform: translateY(-1px);
}

.lang-suggest-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.15s ease;
}

.lang-suggest-close:hover {
  color: #ffffff;
}

/* ===================================================
   Native HTML5 <details class="language-switcher">
   Reference: https://localchinatours.com/
   =================================================== */
.language-switcher {
  position: relative;
  flex-shrink: 0;
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  display: inline-flex;
  align-items: center;
}
.language-switcher summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: 38px;
  white-space: nowrap;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: inherit;
  transition: all 0.2s ease;
  user-select: none;
}
.editorial-site:not(.home-page) .site-header .language-switcher summary,
.site-header.is-scrolled .language-switcher summary {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.15);
  color: #0f172a;
}
.language-switcher summary::-webkit-details-marker {
  display: none;
}
.language-switcher summary::marker {
  display: none;
}
.language-switcher summary > span:first-child {
  font-size: 16px;
  opacity: 0.85;
}
.language-switcher summary .language-label {
  font-size: 13px;
  font-weight: 600;
}
.language-switcher[open] summary {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.45);
}
.language-switcher:not([open]) nav {
  display: none !important;
}
.language-switcher[open] nav {
  position: absolute;
  z-index: 500;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  min-width: 270px;
  padding: 12px !important;
  gap: 4px 12px !important;
  background: #ffffff;
  color: #172334;
  border: 1px solid #ddd9d0;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  max-height: 70vh;
  overflow: auto;
  animation: langFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.language-switcher a {
  display: block;
  padding: 8px 10px;
  color: #172334 !important;
  text-decoration: none;
  font-size: 13.5px !important;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.language-switcher a:hover {
  background: #f4eee6;
  color: #8c1a28 !important;
}
.language-switcher a[aria-current="page"] {
  background: #f4eee6;
  color: #8c1a28 !important;
  font-weight: 700;
}
.language-switcher summary:focus-visible,
.language-switcher a:focus-visible {
  outline: 2px solid #8c1a28;
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .language-switcher .language-label {
    display: none !important;
  }
  .language-switcher summary {
    padding: 6px 10px;
    gap: 0;
  }
  .language-switcher nav {
    min-width: 250px;
  }
}

@media (max-width: 480px) {
  .language-switcher {
    display: none !important;
  }
}
