/*
 * New components on top of the live theme (mobile-first; desktop from 1201px,
 * the theme's drawer/desktop breakpoint). Loaded after site.css + site-fixes.css.
 */

/* ===================================================================
 * Language picker (src/components/wp/LanguagePicker.astro)
 * Toggle at the bottom of the mobile drawer / far right of the desktop
 * header; panel = native popover: full-screen sheet on mobile (scrollable
 * list), column grid dropdown on desktop. Scales to dozens of languages.
 * =================================================================== */
.header nav .lang-picker {
  margin-top: auto; /* bottom of the drawer */
  width: 100%;
  max-width: 33rem;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.header .lang-picker__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 4px;
  background: none;
  border: 0;
  color: #fff;
  font: 600 17px/1.2 Montserrat, sans-serif;
  cursor: pointer;
  text-align: left;
}
.header .lang-picker__name { flex: 1; }
.header .lang-picker__code { display: none; }
.header .lang-picker__chevron { transform: rotate(-90deg); } /* "›" on mobile: opens a sheet */
.header .lang-picker__toggle:focus-visible { outline: 2px solid #F5A623; outline-offset: 2px; border-radius: 6px; }

/* panel: hidden unless open (native popover, or .is-open fallback set by lang-picker.js) */
.lang-panel { display: none; }
.lang-panel:popover-open { display: flex; }
.lang-panel.is-open { display: flex; }

/* mobile: full-screen sheet */
.lang-panel {
  position: fixed;
  inset: 0;
  z-index: 3000;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  background: #2D063C;
  color: #fff;
  font-family: Montserrat, sans-serif;
  animation: lang-panel-in 0.2s ease-out;
}
@keyframes lang-panel-in { from { opacity: 0; transform: translateY(16px); } }
.lang-panel::backdrop { background: rgba(20, 4, 28, 0.45); }
.lang-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.lang-panel__title { font-size: 18px; font-weight: 600; }
.lang-panel__close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.header .lang-panel .lang-panel__list {
  display: block;
  margin: 0;
  padding: 8px 12px 32px;
  list-style: none;
  max-width: none;
}
.header .lang-panel .lang-panel__item { display: block; margin: 0; padding: 0; width: auto; }
.header .lang-panel .lang-panel__item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px;
  border-radius: 10px;
  color: #fff !important;
  font: 400 17px/1.3 Montserrat, sans-serif !important;
  text-decoration: none;
}
.header .lang-panel .lang-panel__item a::after { display: none; } /* theme nav underline */
.header .lang-panel .lang-panel__item a:hover,
.header .lang-panel .lang-panel__item a:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.header .lang-panel .lang-panel__item a[aria-current] { font-weight: 600 !important; color: #F5A623 !important; }
.lang-panel__badge { font-size: 12px; letter-spacing: 0.06em; opacity: 0.6; }
.lang-panel a[aria-current] .lang-panel__badge::before { content: "✓ "; }

/* desktop: compact toggle in the header row, dropdown panel with columns */
@media (min-width: 1201px) {
  .header nav.nav { flex-direction: row; align-items: center; }
  .header nav .lang-picker {
    margin: 0 0 0 28px;
    width: auto;
    max-width: none;
    padding: 0;
    border: 0;
  }
  .header .lang-picker__toggle { width: auto; padding: 8px 4px; gap: 6px; font-size: 14px; font-weight: 700; }
  .header .lang-picker__name { display: none; }
  .header .lang-picker__code { display: inline; }
  .header .lang-picker__chevron { transform: none; }

  .lang-panel {
    inset: auto;
    top: 84px;
    right: 24px;
    width: min(560px, calc(100vw - 48px));
    height: auto;
    max-height: min(70vh, 560px);
    border-radius: 14px;
    background: #fff;
    color: #2D063C;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  }
  .lang-panel::backdrop { background: transparent; }
  .lang-panel__head { padding: 14px 14px 14px 20px; border-bottom: 1px solid #EEE7F2; }
  .lang-panel__title { font-size: 15px; }
  .lang-panel__close { width: 32px; height: 32px; font-size: 22px; background: #F4EEF8; }
  .header .lang-panel .lang-panel__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px;
    padding: 12px;
  }
  .header .lang-panel .lang-panel__item a { min-height: 40px; padding: 9px 12px; color: #2D063C !important; font-size: 15px !important; }
  .header .lang-panel .lang-panel__item a:hover,
  .header .lang-panel .lang-panel__item a:focus-visible { background: #F4EEF8; }
  .header .lang-panel .lang-panel__item a[aria-current] { color: #5C2483 !important; }
}
/* anchor the desktop dropdown to its button where CSS anchor positioning exists */
@supports (position-anchor: --lang-toggle) {
  @media (min-width: 1201px) {
    .header .lang-picker__toggle { anchor-name: --lang-toggle; }
    .lang-panel { position-anchor: --lang-toggle; top: anchor(bottom); right: anchor(right); margin-top: 14px; }
  }
}
