/* ==========================================================================
   Eterniseed HTML port — Language switcher chrome (α.2 SD-3)
   --------------------------------------------------------------------------
   Visual treatment for the persistent header switcher. Mirrors the spec at
   Architect/Projects/LANGUAGE_SWITCHER_CHROME_SPEC_2026-05-04.md §1.1
   (selected-state Option A: 2px gold underline; light theme uses
   skin-accent-strong for WCAG AA compliance; dark theme uses skin-accent).
   --------------------------------------------------------------------------
   Two layout modes, switched via data-mode attribute on the host element:
     auth   — minimal-header inline row (8 anonymous auth surfaces + 404)
     chrome — slot inside existing logged-in chrome (right of wordmark
              cluster, left of ⇄/person icons)
   Mobile <768px collapses to chip + dropdown pattern in BOTH modes.
   ========================================================================== */

/* ── Container ──────────────────────────────────────────────────────────── */
.eterniseed-langswitch {
  display: inline-flex;
  align-items: center;
  position: relative;
  font-family: var(--skin-font-body);
}

/* ── Inline radiogroup row — RETIRED from display 2026-06-02 ─────────────────
   The collapsed chip (below) is now the universal presentation at ALL widths
   (Joe 2026-06-02: the inline pill took too much real estate as the language
   list grew past 6). The row markup is retained in the DOM for a11y/keyboard
   parity + easy revert, but hidden everywhere. */
.eterniseed-langswitch__row {
  display: none;
  align-items: center;
  gap: var(--space-1, 4px);
}

.eterniseed-langswitch__entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--skin-ink-secondary);
  font-family: inherit;
  font-size: var(--text-sm, 14px);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: color var(--motion-fast, 120ms) var(--easing, ease),
              background var(--motion-fast, 120ms) var(--easing, ease),
              border-color var(--motion-fast, 120ms) var(--easing, ease);
}

.eterniseed-langswitch__entry:hover {
  color: var(--skin-ink-primary);
  background: var(--skin-accent-tint-bg, rgba(217, 170, 82, 0.10));
}

.eterniseed-langswitch__entry:focus-visible {
  outline: 2px solid var(--skin-accent-strong, #A47A33);
  outline-offset: 2px;
}

.eterniseed-langswitch__entry[aria-checked="true"] {
  color: var(--skin-ink-primary);
  font-weight: 600;
  border-bottom-color: var(--skin-accent-strong, #A47A33);
}

.eterniseed-langswitch__flag {
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Inline SVG flag — sized + subtle border so flags read clean on every
   platform (Windows desktop has no native flag-emoji font; SVG bypasses
   the font-fallback path entirely). ZH stays as text glyph (CEO political-
   neutrality call) and inherits the parent font-size sizing. */
.eterniseed-langswitch__flag svg {
  display: block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15);
}

/* Mobile menu item flags read at slightly larger size to match menu typography. */
.eterniseed-langswitch__menu-item .eterniseed-langswitch__flag svg {
  width: 22px;
  height: 15px;
}

.eterniseed-langswitch__code {
  letter-spacing: 0.04em;
}

/* Inline separator (middle dot) between entries */
.eterniseed-langswitch__sep {
  color: var(--skin-ink-tertiary);
  font-size: 12px;
  user-select: none;
  opacity: 0.5;
}

/* Dark theme — accent (gold) reads richer against dark surface */
[data-theme="dark"] .eterniseed-langswitch__entry[aria-checked="true"] {
  border-bottom-color: var(--skin-accent, #D9AA52);
}
[data-theme="dark"] .eterniseed-langswitch__entry:focus-visible {
  outline-color: var(--skin-accent, #D9AA52);
}

/* ── Collapsed chip + dropdown — UNIVERSAL presentation (all widths) ─────── */
.eterniseed-langswitch__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 64px;
  min-height: 36px;
  padding: 6px 12px;
  background: var(--skin-surface, #FAF6F0);
  color: var(--skin-ink-primary);
  border: 1px solid var(--skin-border, rgba(44, 44, 44, 0.12));
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: var(--text-sm, 14px);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--motion-fast, 120ms) var(--easing, ease),
              background var(--motion-fast, 120ms) var(--easing, ease);
}

.eterniseed-langswitch__chip:hover {
  border-color: var(--skin-ink-secondary);
}

.eterniseed-langswitch__chip:focus-visible {
  outline: 2px solid var(--skin-accent-strong, #A47A33);
  outline-offset: 2px;
}

.eterniseed-langswitch__chip-caret {
  font-size: 10px;
  margin-left: 2px;
  transition: transform var(--motion-fast, 120ms) var(--easing, ease);
}

.eterniseed-langswitch[data-open="true"] .eterniseed-langswitch__chip-caret {
  transform: rotate(180deg);
}

/* Dropdown menu — opens below chip OR below row */
.eterniseed-langswitch__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--skin-surface-elevated, #FFFFFF);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--skin-shadow-float, 0 8px 24px rgba(0, 0, 0, 0.12));
  padding: 6px;
  z-index: var(--z-popover, 100);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.eterniseed-langswitch[data-open="true"] .eterniseed-langswitch__menu {
  display: flex;
}

.eterniseed-langswitch__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md, 8px);
  color: var(--skin-ink-primary);
  font-family: inherit;
  font-size: var(--text-md, 16px);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fast, 120ms) var(--easing, ease);
}

.eterniseed-langswitch__menu-item:hover {
  background: var(--skin-accent-tint-bg, rgba(217, 170, 82, 0.10));
}

.eterniseed-langswitch__menu-item:focus-visible {
  outline: 2px solid var(--skin-accent-strong, #A47A33);
  outline-offset: -2px;
}

.eterniseed-langswitch__menu-item[aria-checked="true"] {
  background: var(--skin-accent-tint-bg, rgba(217, 170, 82, 0.10));
  font-weight: 600;
}

.eterniseed-langswitch__menu-check {
  margin-left: auto;
  color: var(--skin-accent-strong, #A47A33);
}

/* Reduced-motion — disable transitions */
@media (prefers-reduced-motion: reduce) {
  .eterniseed-langswitch__entry,
  .eterniseed-langswitch__chip,
  .eterniseed-langswitch__chip-caret,
  .eterniseed-langswitch__menu-item {
    transition: none;
  }
}

/* Row/chip swap is now unconditional (chip universal) — see the base rules
   above. The former `@media (max-width: 767px)` breakpoint is retired. */

/* Auth-mode minimal header — sits at right of auth-topbar */
.eterniseed-langswitch[data-mode="auth"] {
  margin-left: auto;
}

/* Auth-floating — for auth surfaces without an existing auth-topbar.
   Pins to top-right of the viewport so anonymous users see it pre-form. */
.eterniseed-langswitch[data-mode="auth-floating"] {
  position: fixed;
  top: var(--space-5, 12px);
  right: var(--space-5, 12px);
  z-index: var(--z-fixed, 50);
  background: var(--skin-surface, #FAF6F0);
  border-radius: var(--radius-pill, 999px);
  padding: 4px 6px;
  box-shadow: var(--skin-shadow-card, 0 2px 8px rgba(0, 0, 0, 0.08));
}

/* Chrome-mode — sits inside logged-in header controls cluster */
.eterniseed-langswitch[data-mode="chrome"] {
  /* No special positioning; flex parent (header controls) handles layout */
}

/* aria-live region — visually hidden but readable by screen readers */
.eterniseed-langswitch__live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
