/* Language switcher in the header (templates/partials/_lang_switch.php). */
.lang-switch { position: relative; flex: none; }
.lang-switch > summary { list-style: none; }
.lang-switch > summary::-webkit-details-marker { display: none; }
.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font: 700 var(--font-size-sm)/1 var(--font-body);
  letter-spacing: .02em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, color .15s, border-color .15s;
}
.lang-switch-btn:hover { background: var(--bg-hover); }
.lang-switch-btn:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
.lang-switch-icon { flex: none; }
body.site-shell > header .lang-switch-btn { color: #fff; border-color: rgba(255, 255, 255, .3); }
body.site-shell > header .lang-switch-btn:hover { background: rgba(255, 255, 255, .1); }
.lang-switch[open] > .lang-switch-btn,
body.site-shell > header .lang-switch[open] > .lang-switch-btn { background: var(--saffron); border-color: var(--saffron); color: var(--ink-deep); }

.lang-switch-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  z-index: 1200;
  width: 460px;
  max-width: calc(100vw - 24px);
  padding: .75rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.lang-switch-title {
  margin: 0 0 .4rem;
  padding: 0 .55rem;
  color: var(--text-muted);
  font: 650 var(--font-size-xs)/1.3 var(--font-body);
}
.lang-switch-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lang-switch-list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: .35rem .55rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.lang-switch-list a:hover { background: var(--bg-hover); color: var(--text-primary); }
.lang-switch-list a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-switch-list a[aria-current="true"] { background: var(--saffron-soft); color: var(--saffron-deep); }
.lang-switch-list a[aria-current="true"]::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin-inline-end: .45rem;
  border-radius: 50%;
  background: var(--saffron);
}

@media (max-width: 768px) {
  .lang-switch { position: static; }
  .lang-switch-btn { padding: 0 .55rem; gap: .3rem; }
  .lang-switch-panel {
    position: fixed;
    top: calc(var(--nav-height, 64px) + 6px);
    inset-inline: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - var(--nav-height, 64px) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .lang-switch-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .lang-switch-code { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .lang-switch[open] .lang-switch-panel { animation: lang-switch-in .16s var(--ease-out); }
}
@keyframes lang-switch-in { from { opacity: 0; transform: translateY(-4px); } }
