/* ===========================================================================
   Gai iluna: lo común de TTS, Aditu, Elia y s2st (cabecera, footer, piezas de elh_shell.css y Bootstrap/MDB).
   El MISMO fichero en los cuatro proyectos; el original es el de TTS (copiar con scripts/elh_shell_sync.sh).
   Se carga después de elh_shell.css; lo propio de cada web, en su CSS (buscar "theme-dark").
   html.theme-dark: lo pone js/elh_theme.js (elegido con el botón de la cabecera, o el del sistema en modo "auto").
   Colores con contraste WCAG AA (texto normal ≥ 4,5:1 sobre su fondo), los mismos que las páginas públicas de s2st.
   =========================================================================== */

/* --- Botón de la cabecera (junto al idioma): solo el icono, discreto como el resto de la derecha --- */
#mainNav.elh-header .hdr-theme { justify-content: center; width: 28px; padding: 0; }
#mainNav.elh-header .hdr-theme i { width: 1em; font-size: .9rem; text-align: center; }
/* va en el mismo grupo que el idioma (sin separador entre los dos) */
#mainNav.elh-header .nav-account > li.hdr-group { gap: 0; }
#mainNav.elh-header .hdr-group .hdr-lang { padding-left: .4rem; }
/* con sesión, la cabecera de s2st y la de Elia van justas entre 1200 y 1520 px: la derecha, un poco más junta para que quepa el botón */
@media (min-width: 1200px) and (max-width: 1519.98px) {
	#mainNav.elh-header .nav-account > li { padding: 0 .2rem; }
}
@media (min-width: 1200px) and (max-width: 1359.98px) {
	#mainNav.elh-header .nav-account .hdr-pill:not(.hdr-login):not(.hdr-theme) { padding-left: .35rem; padding-right: .35rem; }
}

/* --- Colores ----------------------------------------------------------------- */
html.theme-dark {
	--dk-page: #10131c;      /* fondo de la página */
	--dk-surface: #1d2233;   /* cajas, tarjetas, menús */
	--dk-soft: #161a26;      /* zonas hundidas dentro de una caja */
	--dk-raised: #262d44;    /* botones secundarios, hover */
	--dk-input: #131724;     /* campos de formulario */
	--dk-fill: #3d5fe0;      /* fondo de los botones principales (texto blanco 5,1:1) */
	--dk-fill-dark: #2f4fcc;
	--dk-accent: #a9bcff;    /* azul de marca como texto */
	--dk-teal: #5fe0d5;      /* turquesa de marca como texto */
	/* las variables de elh_shell.css se usan sobre todo como color de texto: en oscuro, sus versiones claras */
	--elh-blue: var(--dk-accent);
	--elh-blue-dark: #c5d2ff;
	--elh-blue-soft: #26305a;
	--elh-blue-hover: #222a48;
	--elh-teal-dark: var(--dk-teal);
	--elh-ink: #eef1f8;
	--elh-muted: #b6bdd0;
	--elh-faint: #949cb3;
	--elh-line: #39415b;
	--elh-line-soft: #2c3347;
	--elh-danger: #ff8f9c;
	--elh-danger-bg: #3b1f26;
	--elh-surface: var(--dk-surface);
	--elh-bg: var(--dk-soft);
	color-scheme: dark;
}
/* !important: las hojas antiguas de TTS y Aditu ponen el fondo y el texto de html/body con !important.
   La trama de puntos del fondo (Aditu, Elia), apenas visible (soft-light) */
html.theme-dark, html.theme-dark body { background-color: var(--dk-page) !important; }
html.theme-dark body { background-blend-mode: soft-light; color: var(--elh-ink) !important; }
html.theme-dark ::placeholder { color: var(--elh-faint) !important; opacity: 1; }
/* enlaces sin clase (los de Bootstrap, azul oscuro): azul claro; los que tienen estilo propio, con el suyo */
html:where(.theme-dark) a:where(:not([class])) { color: var(--dk-accent); }
html.theme-dark hr { border-color: var(--elh-line); }

/* --- Cabecera ----------------------------------------------------------------- */
html.theme-dark #mainNav.elh-header { background: var(--dk-surface) !important; box-shadow: 0 1px 0 var(--elh-line) !important; }
html.theme-dark #mainNav.elh-header .elh-topbar__link:hover, html.theme-dark #mainNav.elh-header .elh-topbar__link:focus-visible { color: var(--dk-accent) !important; }   /* Bloga, Harremanetarako */
html.theme-dark #mainNav.elh-header a.hdr-pill:hover, html.theme-dark #mainNav.elh-header button.hdr-pill:hover,
html.theme-dark #mainNav.elh-header .show > .hdr-pill { background: var(--dk-raised); }
html.theme-dark #mainNav.elh-header .hdr-login, html.theme-dark .skip-link,
html.theme-dark #mainNav.elh-header .navbar-toggler { background: var(--dk-fill); border-color: var(--dk-fill); }
html.theme-dark #mainNav.elh-header a.hdr-login:hover { background: var(--dk-fill-dark); border-color: var(--dk-fill-dark); }
html.theme-dark #mainNav.elh-header .hdr-user.is-current .hdr-avatar { background: var(--dk-fill); color: #fff; }
html.theme-dark #mainNav.elh-header .hdr-credit__buy:hover { background: var(--dk-teal); color: var(--dk-page) !important; }
html.theme-dark #mainNav.elh-header .nav-badge--new { background: var(--elh-danger-bg); }
html.theme-dark #mainNav.elh-header .dropdown-menu { background: var(--dk-surface); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
html.theme-dark #mainNav.elh-header .hdr-menu__usage { background: var(--dk-soft); }
/* logos de las webs en la cabecera: cada web pone su versión para oscuro (*_dark-theme: el azul oscuro, en azul claro) con .theme-dark-only */
html.theme-dark .elh-wordmark__text strong { color: var(--dk-accent); }
html.theme-dark .elh-wordmark__text small { color: var(--dk-teal); }

/* --- Footer: el mismo degradado, más oscuro ---------------------------------- */
html.theme-dark footer.site-footer { background: linear-gradient(to right, #142a7a, #006664); }

/* --- Portada -------------------------------------------------------------- */
html.theme-dark .lp-subnav { background: rgba(29, 34, 51, .97); }
html.theme-dark .lp-subnav__link i { color: var(--dk-accent); }
html.theme-dark header.masthead.lp-hero--light { background-color: var(--dk-page) !important; }
html.theme-dark .lp-hero--light .lp-cta__alt { color: var(--dk-accent) !important; border-color: var(--dk-accent); }
html.theme-dark .lp-hero__service:hover .lp-hero__service-icon, html.theme-dark .lp-hero__service:focus .lp-hero__service-icon { color: #1A3AAB; }

/* --- Información de una sección, inicio de sesión, registro, errores, precios ---- */
html.theme-dark .feature-info, html.theme-dark .auth-card, html.theme-dark .auth-done, html.theme-dark .error-page,
html.theme-dark .pricing-card { background: var(--dk-surface); border-color: var(--elh-line); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
html.theme-dark .fi-card, html.theme-dark .auth-type { background: var(--dk-soft); border-color: var(--elh-line-soft); }
html.theme-dark .feature-help { border-color: var(--elh-line); color: var(--dk-teal); }   /* "?" y su ventana (feature_info_help.html / _dialog.html) */
html.theme-dark .feature-help:hover { background: var(--dk-raised); }
html.theme-dark .feature-help-dialog { background: var(--dk-surface); color: var(--elh-ink); }
html.theme-dark .feature-help-dialog::backdrop { background: rgba(0, 0, 0, .65); }
html.theme-dark .feature-help-dialog .feature-info__hero { background: linear-gradient(120deg, #142a7a, #006664); }
html.theme-dark .feature-help-dialog .fi-card { background: var(--dk-soft); }
html.theme-dark .feature-help-dialog .fi-card i { background: var(--dk-raised); color: var(--dk-teal); box-shadow: none; }
html.theme-dark .feature-help-dialog__foot { background: var(--dk-surface); border-top-color: var(--elh-line); }
html.theme-dark .feature-help-dialog__done { background: var(--dk-fill); }
html.theme-dark .feature-help-dialog__done:hover { background: var(--dk-fill-dark); }
html.theme-dark .feature-info__icon, html.theme-dark .auth-done__icon { background: #17363a; color: var(--dk-teal); }
html.theme-dark .feature-info section.feature-info__cta, html.theme-dark .auth-card__side { background: linear-gradient(150deg, #142a7a, #006664); }
html.theme-dark .feature-info__actions .fi-btn-main { background: #fff !important; color: #1A3AAB !important; }
html.theme-dark .auth-card__context { background: var(--elh-blue-soft); }
html.theme-dark .auth-field .form-control, html.theme-dark .auth-captcha__refresh { background: var(--dk-input); border-color: var(--elh-line) !important; color: var(--elh-ink); }
html.theme-dark .auth-type__opt.is-active { background: var(--dk-raised); }
html.theme-dark .auth-submit { background-color: #00807e !important; }
html.theme-dark .auth-submit:hover, html.theme-dark .auth-submit:focus { background-color: #006d6b !important; }
html.theme-dark .auth-register:hover, html.theme-dark .auth-register:focus { background: var(--elh-blue-hover) !important; }
html.theme-dark .error-page__code { color: #36407a; }
html.theme-dark .pricing-card li .fa-check, html.theme-dark .pricing-card li.is-yes > i { color: #74e6ac !important; }
html.theme-dark .price-plan__amount, html.theme-dark .price-plan__alt strong { color: #fff; }
html.theme-dark .pricing-card p.price-plan__terms { color: #74e6ac; }
html.theme-dark .price-tabs .nav-link.active { background: var(--dk-surface) !important; color: var(--dk-accent) !important; border-color: var(--dk-surface) !important; }

/* --- Bootstrap / MDB: lo que usan las páginas de las tres webs antiguas ---------- */
html.theme-dark .card, html.theme-dark .modal-content, html.theme-dark .dropdown-menu, html.theme-dark .popover,
html.theme-dark .list-group-item, html.theme-dark .toast, html.theme-dark .jumbotron {
	background-color: var(--dk-surface); border-color: var(--elh-line); color: var(--elh-ink);
}
html.theme-dark .card-header, html.theme-dark .card-footer, html.theme-dark .modal-header, html.theme-dark .modal-footer { background-color: transparent; border-color: var(--elh-line); }
html.theme-dark .card-title, html.theme-dark .modal-title { color: var(--elh-ink); }
html.theme-dark .dropdown-item { color: var(--elh-ink); }
html.theme-dark .dropdown-item:hover, html.theme-dark .dropdown-item:focus { background-color: var(--dk-raised); color: var(--elh-ink); }
html.theme-dark .dropdown-divider { border-color: var(--elh-line); }
html.theme-dark .close { color: var(--elh-ink); text-shadow: none; opacity: .75; }
html.theme-dark .bg-white, html.theme-dark .bg-light { background-color: var(--dk-surface) !important; }
html.theme-dark .text-dark, html.theme-dark .black-text { color: var(--elh-ink) !important; }
html.theme-dark .text-muted, html.theme-dark .grey-text, html.theme-dark .text-secondary { color: var(--elh-muted) !important; }
html.theme-dark .text-primary { color: var(--dk-accent) !important; }
html.theme-dark .border, html.theme-dark .border-top, html.theme-dark .border-bottom, html.theme-dark .border-left, html.theme-dark .border-right { border-color: var(--elh-line) !important; }
html.theme-dark .form-control, html.theme-dark .custom-select, html.theme-dark .custom-file-label, html.theme-dark .input-group-text,
html.theme-dark select, html.theme-dark textarea, html.theme-dark input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=submit]):not([type=button]):not([type=color]) {
	background-color: var(--dk-input); border-color: var(--elh-line); color: var(--elh-ink);
}
html.theme-dark .form-control:disabled, html.theme-dark .form-control[readonly] { background-color: var(--dk-soft); }
html.theme-dark .md-form label, html.theme-dark .form-text, html.theme-dark label { color: inherit; }
html.theme-dark .md-form .form-control, html.theme-dark .md-form input { background-color: transparent; }
html.theme-dark .table { color: var(--elh-ink); }
html.theme-dark .table th, html.theme-dark .table td, html.theme-dark .table thead th { border-color: var(--elh-line); }
html.theme-dark .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(255, 255, 255, .03); }
html.theme-dark .table-hover tbody tr:hover { background-color: var(--dk-raised); color: var(--elh-ink); }
html.theme-dark .thead-light th, html.theme-dark .table-light, html.theme-dark .table-light > td, html.theme-dark .table-light > th { background-color: var(--dk-soft); color: var(--elh-ink); border-color: var(--elh-line); }
html.theme-dark .nav-tabs { border-color: var(--elh-line); }
html.theme-dark .nav-tabs .nav-link.active, html.theme-dark .nav-tabs .nav-item.show .nav-link { background-color: var(--dk-surface); border-color: var(--elh-line) var(--elh-line) var(--dk-surface); color: var(--elh-ink); }
html.theme-dark .page-link { background-color: var(--dk-surface); border-color: var(--elh-line); color: var(--dk-accent); }
html.theme-dark .page-item.active .page-link { background-color: var(--dk-fill); border-color: var(--dk-fill); color: #fff; }
html.theme-dark .page-item.disabled .page-link { background-color: var(--dk-soft); border-color: var(--elh-line); color: var(--elh-faint); }
html.theme-dark .btn-light, html.theme-dark .btn-white, html.theme-dark .btn-outline-secondary, html.theme-dark .btn-secondary:not(.btn-elhuyar) {
	background-color: var(--dk-raised) !important; border-color: var(--elh-line) !important; color: var(--elh-ink) !important;
}
html.theme-dark .btn-outline-primary { border-color: var(--dk-accent) !important; color: var(--dk-accent) !important; }
html.theme-dark .alert-info, html.theme-dark .alert-primary { background-color: #1f2a4d; border-color: #2f3d6b; color: #c9d5ff; }
html.theme-dark .alert-success { background-color: #153a29; border-color: #1f5a3e; color: #9df0c3; }
html.theme-dark .alert-warning { background-color: #3a3220; border-color: #5a4a26; color: #f3d58c; }
html.theme-dark .alert-danger { background-color: #3b1f26; border-color: #5c2b34; color: #ffb9c1; }
html.theme-dark .alert-secondary, html.theme-dark .alert-light { background-color: var(--dk-raised); border-color: var(--elh-line); color: var(--elh-ink); }
html.theme-dark .badge-light { background-color: var(--dk-raised); color: var(--elh-ink); }
html.theme-dark .progress { background-color: var(--dk-raised); }
html.theme-dark .tooltip-inner { background-color: #eef1f8; color: #10131c; }
html.theme-dark .modal-backdrop.show { opacity: .7; }
/* desplegables con buscador (elhuyar_select, multiselect, select2) */
html.theme-dark .select2-container--default .select2-selection, html.theme-dark .select2-dropdown { background-color: var(--dk-input); border-color: var(--elh-line); color: var(--elh-ink); }
html.theme-dark .select2-container--default .select2-selection__rendered { color: var(--elh-ink); }
html.theme-dark .select2-results__option[aria-selected=true] { background-color: var(--dk-raised); }

/* --- Selectores de idioma propios (elhuyar_select.css: .elhuyar-select en Elia, .language_selector en TTS y Aditu) --- */
html.theme-dark .elhuyar-select, html.theme-dark .language_selector { border-bottom-color: var(--elh-line); }
html.theme-dark .elhuyar-select .selected_option, html.theme-dark .language_selector .selected_option,
html.theme-dark .elhuyar-select .selected_option .label, html.theme-dark .language_selector .selected_option .label { color: var(--elh-muted); }
html.theme-dark .elhuyar-select .selected_option .label.active, html.theme-dark .language_selector .selected_option .label.active { color: var(--dk-teal); }
html.theme-dark .elhuyar-select .selected_option .option_text, html.theme-dark .language_selector .selected_option .option_text,
html.theme-dark .elhuyar-select .caret, html.theme-dark .elhuyar-select .option_info, html.theme-dark .language_selector .option_info { color: var(--dk-accent) !important; }
html.theme-dark .language_selector .caret { color: var(--dk-teal) !important; }
html.theme-dark .elhuyar-select .options_view ul, html.theme-dark .language_selector .options_view ul { background-color: var(--dk-surface); color: var(--elh-ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
html.theme-dark .elhuyar-select .options_view ul li:hover:not(.selected), html.theme-dark .language_selector .options_view ul li:hover:not(.selected) { background-color: var(--dk-raised); }
html.theme-dark .elhuyar-select .options_view ul li.selected { background-color: var(--dk-fill); }
html.theme-dark .elhuyar-select li.selected .option_info, html.theme-dark .language_selector li.selected .option_info { color: #fff !important; }

/* --- Clases de marca de las tres webs antiguas (custom_styles.css, asr_web.css, base.css) --- */
html.theme-dark .text-elhuyar-dark { color: var(--dk-accent) !important; }
html.theme-dark .btn-elhuyar-dark, html.theme-dark .btn-primary { background-color: var(--dk-fill) !important; border-color: var(--dk-fill) !important; color: #fff !important; }
html.theme-dark .btn-elhuyar-min { color: var(--elh-ink) !important; border-color: var(--elh-line) !important; }
html.theme-dark .bg-elhuyar-light { background-color: var(--dk-page) !important; }
/* fondos con trama de puntos: la trama, apenas visible sobre el fondo oscuro */
html.theme-dark .bg-trama-elhuyar, html.theme-dark .bg-trama-elhuyar-green, html.theme-dark #services.bg-trama-elhuyar-green {
	background-color: var(--dk-page) !important; background-blend-mode: soft-light;
}

/* --- Portada: demostración animada (elh_demo.css) --- */
html.theme-dark .elh-demo { background: var(--dk-soft); }
html.theme-dark .elh-demo__stage { background: var(--dk-surface); border-color: var(--elh-line); box-shadow: 0 14px 40px rgba(0, 0, 0, .35); }
html.theme-dark .elh-demo__steps li::before, html.theme-dark .elh-demo__toggle { background: var(--dk-surface); }
html.theme-dark .elh-demo__steps li.is-active::before { background: #00807e; border-color: #00807e; }
html.theme-dark .elh-demo__pill.is-active, html.theme-dark .elh-demo__speaker--a { background: var(--dk-fill); border-color: var(--dk-fill); }
html.theme-dark .elh-demo__speaker--b, html.theme-dark .elh-demo__word.is-current { background: #00807e; box-shadow: 0 0 0 3px #00807e; }
html.theme-dark .elh-demo__speaker--b { box-shadow: none; }
html.theme-dark .elh-demo__bar { background: #3a4570; }
html.theme-dark .elh-demo__bar.is-played { background: var(--dk-accent); }

/* --- Blog (elh_blog.css: TTS, Aditu y s2st) --- */
html.theme-dark .elh-blog { color: #d5dbe8; }
html.theme-dark .elh-blog__sheet { background: var(--dk-surface); border-color: var(--elh-line); box-shadow: none; }
html.theme-dark .elh-blog__featured-body h2, html.theme-dark .elh-blog__section-title, html.theme-dark .elh-blog__card h3,
html.theme-dark .elh-blog__article h2, html.theme-dark .elh-blog__article h3, html.theme-dark .elh-blog__article strong,
html.theme-dark .elh-blog__article b, html.theme-dark .elh-blog__article blockquote { color: var(--elh-ink); }
html.theme-dark .elh-blog__media { background: var(--dk-soft); }
html.theme-dark .elh-blog__media-empty { background: linear-gradient(135deg, #142a7a 0%, #006664 100%); }
html.theme-dark .elh-blog__btn { background: var(--dk-raised); color: var(--elh-ink) !important; }


/* --- Imágenes con versión para cada tema (iconos negros sobre transparente: macOS, iOS...) ---
   <img src="x.webp" class="theme-light-only"> <img src="x_dark-theme.webp" class="theme-dark-only" loading="lazy">
   (con loading="lazy", la que está oculta no se descarga) */
html:not(.theme-dark) .theme-dark-only, html.theme-dark .theme-light-only { display: none !important; }

/* --- Botones turquesa con texto blanco: en oscuro, el turquesa oscuro de la marca (contraste 4,8:1 en vez de 2,8:1).
   :is(#page_top, body) para ganar a "#page_top .btn-elhuyar { ... !important }" de la portada de TTS --- */
html.theme-dark :is(#page_top, body) .btn-elhuyar:not(.btn-elhuyar-dark):not(.btn-elhuyar-white):not(.btn-elhuyar-min) { background-color: #00807e !important; }
html.theme-dark :is(#page_top, body) .btn-elhuyar:not(.btn-elhuyar-dark):not(.btn-elhuyar-white):not(.btn-elhuyar-min):hover { background-color: #006d6b !important; }

/* Animación "Así funciona", escena de documentos (Elia): traído de la copia de Elia */
html.theme-dark .elh-doc__drop { border-color: var(--elh-line); background: var(--dk-soft); }
html.theme-dark .elh-doc__chip { background: var(--dk-raised); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
html.theme-dark .elh-doc__progress { background: #3a4570; }
html.theme-dark .elh-doc__chip.is-ok .elh-doc__bar, html.theme-dark .elh-doc__ok { background: none; color: #74e6ac; }
html.theme-dark .elh-doc__chip.is-ok .elh-doc__bar { background: #74e6ac; }
html.theme-dark .elh-doc__paper { background: var(--dk-soft); box-shadow: 0 6px 16px rgba(0, 0, 0, .3); }
html.theme-dark .elh-doc__text.is-pending { background: #2c3347; }
html.theme-dark .elh-art__sky { fill: #26304a; }
html.theme-dark .elh-art__track { stroke: #2c3347; }
html.theme-dark .elh-art__far, html.theme-dark .elh-art__near, html.theme-dark .elh-art__slice--a { filter: brightness(1.6) saturate(.85); }
html.theme-dark .elh-doc__block--meta { filter: brightness(1.7) saturate(.85); }
html.theme-dark .elh-doc__block--h { color: var(--elh-ink); }
html.theme-dark .elh-doc__chip > .fas:first-child { filter: brightness(1.7) saturate(.85); }
html.theme-dark .elh-doc__engine.is-working, html.theme-dark .elh-doc__download.is-ready .elh-doc__button { background: #00807e; }

/* Animación "Así funciona": escenas "voices" (TTS) y "media" (Aditu) */
html.theme-dark .elh-voc__source, html.theme-dark .elh-med__chip { background: var(--dk-raised); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
html.theme-dark .elh-voc__box, html.theme-dark .elh-voc__paper, html.theme-dark .elh-voc__browser, html.theme-dark .elh-voc__slide { background: var(--dk-soft); box-shadow: 0 6px 16px rgba(0, 0, 0, .3); }
html.theme-dark .elh-voc__chrome { background: var(--dk-raised); border-bottom-color: var(--elh-line); }
html.theme-dark .elh-voc__url { background: var(--dk-soft); }
html.theme-dark .elh-voc__junk--menu { background: repeating-linear-gradient(#2c3347 0 .5rem, transparent .5rem 1.1rem); }
html.theme-dark .elh-voc__junk--ad { background: linear-gradient(135deg, #4a3a2a, #4a2a35); }
html.theme-dark .elh-voc__block--h, html.theme-dark .elh-voc__word.is-read { color: var(--dk-accent); }
html.theme-dark .elh-voc__tool, html.theme-dark .elh-voc__source > .fas:first-child, html.theme-dark .elh-voc__output > .fas:first-child, html.theme-dark .elh-med__chip > .fas:first-child { filter: brightness(1.7) saturate(.85); }
html.theme-dark .elh-voc__player, html.theme-dark .elh-med__result { background: var(--dk-raised); }
html.theme-dark .elh-voc__play { background: var(--dk-fill); }
html.theme-dark .elh-voc__voice.is-set { color: var(--dk-teal); }
html.theme-dark .elh-med__lang { background: var(--dk-raised); color: var(--dk-accent); }
html.theme-dark .elh-med__label { color: var(--dk-accent); }
html.theme-dark .elh-voc__output .elh-doc__button { background: #00807e; }
html.theme-dark #mainNav.elh-header.is-scrolled { box-shadow: 0 1px 0 var(--elh-line), 0 6px 18px rgba(0, 0, 0, .35) !important; }   /* cabecera fija, desplazada */
