/* ryannegri.com English / Spanish toggle. One copy per site folder; see docs/ryannegri-i18n/README.md. */

/* Inline pairs: English shows unless the visitor chose Spanish. */
html:not([data-lang="es"]) [lang="es"]:not(html):not(.lang-btn):not(.lang-keep) { display: none !important; }
html[data-lang="es"] [lang="en"]:not(html):not(.lang-btn):not(.lang-keep) { display: none !important; }
/* The shown span makes no box of its own, so layout is exactly what it was
   before the pairs (flex and grid parents included). */
html:not([data-lang="es"]) span[lang="en"]:not(.lang-btn),
html[data-lang="es"] span[lang="es"]:not(.lang-btn) { display: contents; }

/* Dictionary pages hold the first paint until the Spanish text is in place. */
html.rn-i18n-pending body { visibility: hidden; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  margin: 0;
  padding: 0;
}

.lang-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 44px;
  margin: 0;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: none;
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--ink-soft, #45514a);
  cursor: pointer;
}

/* The underline sits on the letters. Its 2px is always there, so the active
   state changes color only and nothing moves. */
.lang-code {
  display: block;
  padding: 4px 0 3px 0.08em;
  border-bottom: 2px solid transparent;
}

.lang-btn:hover { color: var(--ink, #16231e); }

html:not([data-lang="es"]) .lang-btn[data-set-lang="en"],
html[data-lang="es"] .lang-btn[data-set-lang="es"] { color: var(--ink, #16231e); }

html:not([data-lang="es"]) .lang-btn[data-set-lang="en"] .lang-code,
html[data-lang="es"] .lang-btn[data-set-lang="es"] .lang-code { border-bottom-color: var(--dusk, #c0863c); }

.lang-btn:focus-visible {
  outline: 2px solid var(--dusk, #c0863c);
  outline-offset: 3px;
  border-radius: 4px;
}

.lang-sep {
  display: block;
  width: 1px;
  height: 14px;
  background: rgba(22, 35, 30, 0.12);
}

/* Same roles on a dark band. */
.lang-toggle.is-dark .lang-btn { color: rgba(246, 244, 238, 0.72); }
.lang-toggle.is-dark .lang-btn:hover,
html:not([data-lang="es"]) .lang-toggle.is-dark .lang-btn[data-set-lang="en"],
html[data-lang="es"] .lang-toggle.is-dark .lang-btn[data-set-lang="es"] { color: var(--paper-warm, #f6f4ee); }
html:not([data-lang="es"]) .lang-toggle.is-dark .lang-btn[data-set-lang="en"] .lang-code,
html[data-lang="es"] .lang-toggle.is-dark .lang-btn[data-set-lang="es"] .lang-code { border-bottom-color: var(--dusk-soft, #d7a869); }
.lang-toggle.is-dark .lang-sep { background: rgba(255, 255, 255, 0.14); }

/* The copy inside the phone menu: first item, set off by a hairline. */
.lang-toggle.in-menu {
  display: flex;
  padding: 0 0 4px;
  margin: 0 0 4px;
  border-bottom: 1px solid rgba(22, 35, 30, 0.12);
}
.lang-toggle.in-menu .lang-btn { padding: 0 12px; }
.lang-toggle.in-menu .lang-btn + .lang-sep + .lang-btn { padding-left: 12px; }

/* Portfolio pages: the menu copy lives in .nav-links, which is the inline
   desktop nav above 940px, so it only shows once that becomes the phone menu. */
.nav-links > .lang-toggle.in-menu { display: none; }
@media (max-width: 940px) {
  .nav-links > .lang-toggle.in-menu { display: flex; align-self: stretch; }
}
/* Their menu links have no side padding, so the first letter lines up with them. */
.nav-links > .lang-toggle.in-menu .lang-btn:first-child { padding-left: 0; }

@media (prefers-reduced-motion: reduce) {
  .lang-btn, .lang-code { transition: none !important; }
}
