/**
 * @file
 * MVSD Core — Mobile translate panel.
 *
 * Mobile-only companion to the desktop `.nav-translate` panel (layout.css),
 * which is display:none at <=900px — leaving phone users with no way to
 * translate the site at all. Adds a brand-colored globe button beside the
 * hamburger that opens a left slide-out panel mirroring #mobile-menu.
 *
 * The language rows are CLONED from the desktop `.translate-menu` at runtime
 * (js/mobile-translate.js) so the list can never drift from the desktop one.
 * Clones keep their `.translate-menu__link` / `.translate-menu__restore`
 * classes, so the base link styling in layout.css still applies — the rules
 * here only add the mobile sizing/layout on top.
 *
 * Nothing in this file touches the desktop translate system.
 */

/* ── Toggle button (sits beside the hamburger on the mobile bar) ─────────── */
/*
 * Hidden until JS has cloned the language list and added .is-ready, so a JS
 * failure leaves no dead button (the whole translate system is JS-driven).
 * A class is used rather than the [hidden] attribute because the UA's
 * [hidden]{display:none} loses to the display:flex rule below.
 */
.mobile-translate-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  /* Per-site brand color — every subtheme sets its own --color-brand. */
  background: var(--color-brand);
  /* Same square-bordered shape/size as .mobile-nav-toggle (nav.css) so the
     two buttons read as a pair; only the fill differs. */
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: var(--color-on-primary);
  border-radius: var(--radius-sm);
  /* 24px icon + 8px padding + 2px border each side = exactly 44x44, matching
     the hamburger's rendered box so the pair reads as one control group. */
  padding: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

@media (max-width: 900px) {
  .mobile-translate-toggle.is-ready {
    display: flex;
  }
}

.mobile-translate-toggle:hover {
  border-color: var(--color-on-primary);
}

.mobile-translate-toggle:focus-visible {
  outline: 3px solid var(--color-focus-ring-on-dark);
  outline-offset: 2px;
}

.mobile-translate-toggle svg {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
}

/* ── Slide-out panel ──────────────────────────────────────────────────────
 * Geometry, motion, overlay and stacking all mirror .mobile-menu (layout.css)
 * so the two panels behave identically. They are mutually exclusive (the JS
 * closes one when the other opens), so sharing --z-drawer is safe.
 */
.mobile-translate {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 80vw;
  height: 100dvh;
  background: var(--color-primary);
  color: var(--color-on-primary);
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform var(--transition-slow);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.mobile-translate.is-open {
  transform: translateX(0);
}

.mobile-translate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-drawer) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.mobile-translate-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

/* Reduced motion: appear/disappear without the slide. */
@media (prefers-reduced-motion: reduce) {
  .mobile-translate,
  .mobile-translate-overlay {
    transition: none;
  }
}

/* ── Panel header ─────────────────────────────────────────── */
.mobile-translate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
  flex-shrink: 0;
}

.mobile-translate-title {
  margin: 0;
  /* base.css sets h1-h6 { color: var(--color-primary) }, which on this
     primary-colored panel renders the title invisible. */
  color: var(--color-on-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--ls-snug);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.mobile-translate-title svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* Matches .mobile-menu-close (layout.css). */
.mobile-translate-close {
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: var(--color-on-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-width: 2.75rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--font-size-xl);
  line-height: 1;
  flex-shrink: 0;
  transition: border-color var(--transition-fast);
}

.mobile-translate-close:hover {
  border-color: var(--color-on-primary);
}

.mobile-translate-close:focus-visible {
  outline: 3px solid var(--color-focus-ring-on-dark);
}

.mobile-translate-intro {
  margin: 0;
  padding: var(--space-3) var(--space-4) 0;
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

/* ── Language list (rows cloned from the desktop menu) ────── */
.mobile-translate-list {
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
  border-top: 3px solid var(--color-accent);
}

.mobile-translate-list li {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* The rule above outranks the UA's [hidden]{display:none}, which would leave
   the "Show original (English)" row visible when nothing is translated. */
.mobile-translate-list li[hidden] {
  display: none;
}

/* Full-width, 44px-minimum touch rows. The color/hover treatment is inherited
   from .translate-menu__link in layout.css (the clones keep that class). */
.mobile-translate-list .translate-menu__link,
.mobile-translate-list .translate-menu__restore {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  white-space: normal;
}

/* ── "More languages…" → Google's full picker ─────────────── */
.mobile-translate-more {
  padding: var(--space-4);
  flex-shrink: 0;
}

.mobile-translate-more[hidden] {
  display: none;
}

.mobile-translate-select {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-base);
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-on-primary);
}

.mobile-translate-select:focus-visible {
  outline: 3px solid var(--color-focus-ring-on-dark);
}

/* Native option lists render in the OS palette — keep the text legible. */
.mobile-translate-select option {
  color: #000;
  background: #fff;
}
