/* Controls shared by the public SSR pages and the SPA shell: the skip link,
   the language switcher, the menu toggle and the screen-reader helper. Each
   surface keeps only its own sizing, spacing and colour next to its markup. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The first stop for keyboard users: hidden until it receives focus, then
   shown above the page (WCAG 2.4.1). */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-raised);
}

.skip-link:not(:focus) {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The public pages' language switcher: a disclosure button over a list of
   links, so choosing a language is a deliberate activation rather than a
   side effect of moving through a select (WCAG 3.2.2). Without JavaScript the
   list is simply shown and the button stays hidden. nav.js drives it. */
.language-switcher {
  position: relative;
  flex: 0 0 auto;
}

.language-switcher__toggle {
  display: none;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  padding: 0 var(--space-3) 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
}

.js .language-switcher__toggle { display: inline-flex; }
.language-switcher__toggle:hover { border-color: var(--border-strong); background: var(--surface-subtle); }

.language-switcher__toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-switcher__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.js .language-switcher__list {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  min-width: 10rem;
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.js .language-switcher.is-open .language-switcher__list { display: flex; }

.language-switcher__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.language-switcher__list a:hover { background: var(--surface-subtle); }
.language-switcher__list a[aria-current] { color: var(--primary); font-weight: 800; }

.language-switcher__list a[aria-current]::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

/* The SPA keeps a select: switching its language rewrites the interface in
   place without leaving the page. */
.language-select {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* The select drops its own outline; the wrapper carries the ring instead. */
.language-select:focus-within { border-color: var(--focus); outline: 3px solid var(--focus); outline-offset: 2px; }

.language-select svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-select select {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.language-select select:disabled { cursor: wait; opacity: 0.6; }

.menu-toggle {
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}

.menu-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.menu-toggle__line {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 180ms ease, opacity 120ms ease;
}

.menu-toggle.is-open .menu-toggle__line--top { transform: translateY(5px) rotate(45deg); }
.menu-toggle.is-open .menu-toggle__line--middle { opacity: 0; }
.menu-toggle.is-open .menu-toggle__line--bottom { transform: translateY(-5px) rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
  .menu-toggle__line { transition: none; }
}

@media (forced-colors: active) {
  [aria-current] { outline: 2px solid Highlight; outline-offset: 2px; }
}
