/* ==========================================================
   i18n del visor: tipografías por idioma, RTL, selector y ventanas de aviso.
   Se carga el último para poder acotar lo que dejan los demás CSS.
   ========================================================== */

/* Roboto (Google Fonts) no incluye árabe ni CJK: se usan fuentes del sistema, sin descargas extra. */
html:lang(ar) {
  --Myfont: "Roboto", "Noto Sans Arabic", "Segoe UI", "Geeza Pro", Tahoma, sans-serif;
}

html:lang(ja) {
  --Myfont: "Roboto", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, sans-serif;
}

html:lang(zh) {
  --Myfont: "Roboto", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

/* El espaciado entre letras rompe las ligaduras del árabe y apelmaza el CJK.
   El !important también neutraliza el letter-spacing animado del banner final. */
html:lang(ar) *,
html:lang(ja) *,
html:lang(zh) * {
  letter-spacing: 0 !important;
}

html:lang(ar) .txtEnd,
html:lang(ja) .txtEnd,
html:lang(zh) .txtEnd {
  font-style: normal;
  transform: none;
}

/* RTL solo en los textos: la tabla de pilotos conserva su orden de columnas y los números no se invierten. */
html[dir="rtl"] .table_header_grid,
html[dir="rtl"] #DriverList,
html[dir="rtl"] .race-stat-item .val {
  direction: ltr;
}

html[dir="rtl"] .race-stat-item .val {
  unicode-bidi: isolate;
}

/* Barra del selector sobre la cabecera de la carrera */
.lang-bar {
  display: flex;
  justify-content: flex-end;
  max-width: 90%;
  margin: 0 auto;
  padding: 8px 0 6px;
}

@media screen and (max-width: 1000px) {
  .lang-bar {
    max-width: 98%;
  }
}

/* Esquina de la ventana de espera */
.lang-corner {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 30;
}

.lang-sel {
  position: relative;
  display: inline-block;
}

/* La ventana de espera pinta todo en blanco: el selector fija sus propios colores */
.lang-sel .lang-sel__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font: 600 13px/1.2 var(--Myfont, Roboto, sans-serif);
  color: #333;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: var(--shadow-s, 0 1px 2px rgba(0, 0, 0, .06));
  cursor: pointer;
}

.lang-sel .lang-sel__btn:hover,
.lang-sel .lang-sel__btn:focus-visible {
  border-color: var(--NaranjaPixelcom, #ff6000);
  outline: none;
}

.lang-sel .lang-sel__flag {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
  flex: 0 0 auto;
}

.lang-sel .lang-sel__name {
  color: inherit;
  white-space: nowrap;
}

.lang-sel .lang-sel__caret {
  width: 0;
  height: 0;
  border-inline: 4px solid transparent;
  border-top: 5px solid #666;
}

.lang-sel .lang-sel__list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: var(--shadow-l, 0 10px 34px rgba(0, 0, 0, .10));
}

.lang-sel .lang-sel__list[hidden] {
  display: none;
}

.lang-sel .lang-sel__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font: 500 13px/1.2 var(--Myfont, Roboto, sans-serif);
  color: #333;
  cursor: pointer;
}

.lang-sel .lang-sel__item:hover,
.lang-sel .lang-sel__item:focus-visible {
  background: var(--DarkBackground2, #f0f0f0);
  outline: none;
}

.lang-sel .lang-sel__item[aria-selected="true"] {
  font-weight: 800;
  box-shadow: inset 3px 0 0 var(--NaranjaPixelcom, #ff6000);
}

html[dir="rtl"] .lang-sel .lang-sel__item[aria-selected="true"] {
  box-shadow: inset -3px 0 0 var(--NaranjaPixelcom, #ff6000);
}

/* Ventanas de aviso del modal (antes con estilos en línea dentro de un innerHTML) */
.containertxt .modal-title {
  font-weight: 700;
  font-size: 18px;
  color: #dc3545;
  margin-bottom: 12px;
}

.containertxt .modal-body > * {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  margin-bottom: 12px;
}

.containertxt .modal-body > *:last-child {
  margin-bottom: 0;
}

.containertxt .modal-body .modal-reason {
  font-style: italic;
}

.containertxt .modal-body strong {
  color: inherit;
}

.containertxt .modal-example {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--NaranjaPixelcom, #ff6000);
  background: #212529;
  border-radius: 4px;
  direction: ltr;
  unicode-bidi: isolate;
}
