/* TheoLab: base compartida por la agencia y el portal.
   Cada espacio define sus variables en agencia.css o portal.css. */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
  background: var(--fondo);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-texto);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.tl-principal { flex: 1 0 auto; }
.tl-principal:focus { outline: none; }

img, svg, video { display: block; max-width: 100%; height: auto; }
svg { overflow: visible; }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-family: var(--fuente-titulos); }
p, ul, ol, figure, blockquote { margin: 0; }
ul[class], ol[class], nav ul { list-style: none; padding: 0; margin: 0; }
[hidden] { display: none !important; }

a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Foco visible y consistente */
:focus-visible {
  outline: 3px solid var(--foco);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.tl-saltar {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--acento);
  color: var(--acento-texto);
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
}
.tl-saltar:focus { top: 1rem; }

.tl-contenedor {
  width: 100%;
  max-width: var(--ancho-max, 1240px);
  margin-inline: auto;
  padding-inline: var(--margen, clamp(1rem, 4vw, 2.5rem));
}

.tl-icono { width: 1.25em; height: 1.25em; flex: none; }

/* Botones */
.tl-boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  min-height: 48px;
  padding: .75rem 1.4rem;
  border: 2px solid transparent;
  border-radius: var(--radio-boton, 10px);
  font-family: var(--fuente-titulos);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.tl-boton[disabled] { opacity: .45; cursor: not-allowed; }
.tl-boton__flecha { width: 1.2em; height: 1.2em; transition: transform .18s ease; }
.tl-boton:hover .tl-boton__flecha,
.tl-boton:focus-visible .tl-boton__flecha { transform: translateX(3px); }

/* Texto largo editable desde Markdown */
.tl-texto { max-width: var(--ancho-texto, 68ch); }
.tl-texto > * + * { margin-top: 1em; }
.tl-texto h2 { font-size: 1.5rem; margin-top: 1.8em; }
.tl-texto h3 { font-size: 1.2rem; margin-top: 1.5em; }
.tl-texto ul, .tl-texto ol { padding-left: 1.3em; }
.tl-texto li + li { margin-top: .4em; }
.tl-texto a { color: var(--enlace); }
.tl-texto strong { color: var(--texto-fuerte, inherit); }
.tl-texto img { border-radius: var(--radio, 12px); }

/* Formularios (plugin Form) */
.tl-form { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
.tl-campo { display: grid; gap: .4rem; }
.tl-campo__etiqueta, .tl-campo label { font-weight: 600; font-size: .95rem; }
.tl-campo .required { color: var(--acento-suave, var(--acento)); margin-left: .15em; }
.tl-campo__control,
.tl-form input[type="text"],
.tl-form input[type="email"],
.tl-form input[type="tel"],
.tl-form select,
.tl-form textarea {
  width: 100%;
  min-height: 48px;
  padding: .7rem .9rem;
  background: var(--campo-fondo);
  color: var(--texto);
  border: 1.5px solid var(--campo-borde);
  border-radius: var(--radio-campo, 8px);
  font-size: 1rem;
  line-height: 1.4;
}
.tl-form textarea { min-height: 150px; resize: vertical; }
.tl-form select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--texto-suave) 50%), linear-gradient(135deg, var(--texto-suave) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}
.tl-form select option { background: var(--superficie); color: var(--texto); }
.tl-form ::placeholder { color: var(--texto-suave); opacity: .8; }
.tl-form input:focus-visible,
.tl-form select:focus-visible,
.tl-form textarea:focus-visible { outline: 3px solid var(--foco); outline-offset: 1px; border-color: transparent; }
.tl-form .form-input-wrapper, .tl-form .form-select-wrapper, .tl-form .form-textarea-wrapper { display: block; }
.tl-campo.has-errors .tl-campo__control,
.tl-form .has-errors input,
.tl-form .has-errors select,
.tl-form .has-errors textarea { border-color: var(--error); }
.tl-form .form-errors, .tl-form__errores, .tl-form .form-error { color: var(--error); font-size: .92rem; font-weight: 600; }
.tl-form .form-errors p, .tl-form .form-errors ul { margin: .25rem 0 0; padding: 0; list-style: none; }
.tl-form .form-description, .tl-form .hint { color: var(--texto-suave); font-size: .9rem; }
.tl-form__acciones, .tl-form .buttons { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .25rem; }
.tl-form .form-honeybear, .tl-form .form-honeypot, .tl-form [name="data[honeypot]"] { display: none !important; }

/* Avisos del formulario: éxito y error */
.notices { margin: 1.25rem 0; padding: 1rem 1.1rem; border-radius: var(--radio-campo, 8px); border: 1.5px solid; font-weight: 600; }
.notices p { margin: 0; }
.notices.green, .notices.success { border-color: var(--exito); background: color-mix(in srgb, var(--exito) 12%, transparent); color: var(--texto); }
.notices.red, .notices.error { border-color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--texto); }
.notices.yellow, .notices.info, .notices.blue { border-color: var(--linea-fuerte); }

/* Error 404 */
.tl-error { padding-block: clamp(3rem, 10vh, 6rem); }
.tl-error p { margin-top: 1rem; color: var(--texto-suave); max-width: 50ch; }
.tl-error__acciones { display: flex; flex-wrap: wrap; gap: .75rem; }

/* Volver al comienzo (cada espacio le da su aspecto en agencia.css y portal.css) */
#arriba:focus { outline: none; }
.tl-arriba {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + var(--subir, 0px));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  text-decoration: none;
  transition: opacity .22s ease, visibility .22s, transform .22s ease, background-color .16s ease, color .16s ease, border-color .16s ease;
}
.tl-arriba > * { grid-area: 1 / 1; }
.tl-arriba .tl-icono { width: 1.3rem; height: 1.3rem; transition: transform .2s ease; }
.tl-arriba:hover .tl-icono { transform: translateY(-2px); }
.tl-arriba[data-oculto] { opacity: 0; visibility: hidden; transform: translateY(.75rem); }
.menu-abierto .tl-arriba { visibility: hidden; }
@media print { .tl-arriba { display: none; } }

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
