/* Atlas de estructuras – capa de estilo moderna.
   Se carga en todas las páginas y respeta el HTML original
   (tablas y controles JSmol). */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --ink: #1a2633;
  --muted: #5a6977;
  --line: #dbe2e9;
  --accent: #1d6a8c;
  --accent-strong: #134e69;
  --accent-soft: #e3eff5;
  --title: #13324a;
  --nav-bg: #12202c;
  --nav-ink: #c3d0dc;
  --nav-muted: #7f93a5;
  --nav-hover: #1c3142;
  --nav-accent: #7cc4e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 32, 44, .06), 0 4px 14px rgba(18, 32, 44, .06);
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }

body {
  box-sizing: border-box;
  margin: 0;
  padding: 24px 28px 40px;
  background: var(--bg) !important;
  color: var(--ink) !important;
  font-family: var(--font) !important;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Las etiquetas <font> heredan la tipografía nueva */
font { font-family: inherit !important; }
font[size="-1"] { font-size: .92em; }
font[size="+1"] { font-size: 1.15em; }

/* Títulos antiguos (FONT SIZE=+2/+3, colores morado/azul) */
font[size="+2"], font[size="+3"], font[size="5"] {
  display: inline-block;
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 4px 0 14px;
}
font[color="#6633CC" i], font[color="#3333CC" i], font[color="#990033" i] {
  color: var(--title) !important;
}

b, strong { font-weight: 600; }
i, em { font-style: italic; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

img { max-width: 100%; height: auto; }
/* JSmol 16 inserts a 0x0 helper image (src=".") inside each viewer; keep it invisible */
[id$="_appletdiv"] > img[width="0"][height="0"] { width: 0 !important; height: 0 !important; visibility: hidden; }

/* Mensaje de depuración de JSmol */
#_Loader-status { display: none !important; }

/* Página del ribosoma (maquetación propia con columnas) */
#col-der { border-left-color: var(--line) !important; padding-left: 18px !important; }
#pie {
  box-sizing: border-box;
  background: var(--surface-soft) !important;
  border-top: 1px solid var(--line) !important;
  border-radius: var(--radius);
  padding: 10px !important;
  margin-top: 12px;
}

/* ---------- Tablas ---------- */
table { border-collapse: separate; }
td { vertical-align: top; }

table[border="1"], table[border="2"] {
  border: 0;
  border-collapse: separate;
  border-spacing: 8px;
}
table[border="1"] > tbody > tr > td,
table[border="1"] > tr > td,
table[border="2"] > tbody > tr > td {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}

/* Tablas de datos (comparativas) */
table[border="1"][cellspacing="2"] {
  border-collapse: collapse;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table[border="1"][cellspacing="2"] > tbody > tr > td,
table[border="1"][cellspacing="2"] > tbody > tr > th {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 8px 14px;
}
table[border="1"][cellspacing="2"] > tbody > tr:first-child > * {
  background: var(--surface-soft);
  font-weight: 600;
}
table[border="1"][cellspacing="2"] > tbody > tr:last-child > * { border-bottom: 0; }

/* Fondos amarillos/crema heredados → superficies suaves */
[bgcolor="#FFF8DC" i], [bgcolor="#FFFFCC" i] { background-color: var(--surface-soft) !important; }

/* ---------- Visores JSmol ---------- */
div[id$="_appletinfotablediv"] {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #f0f8ff;
}

/* ---------- Controles JSmol (botones, menús, casillas) ---------- */
input[type="button"], button {
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--accent-strong);
  background: var(--surface);
  border: 1px solid #c4d3df;
  border-radius: 999px;
  padding: 6px 14px;
  margin: 3px 4px 3px 0;
  cursor: pointer;
  white-space: pre-line;
  max-width: 100%;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
input[type="button"]:hover, button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
input[type="button"]:active, button:active { background: #d2e6f0; }
input[type="button"]:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background-color: var(--surface);
  border: 1px solid #c4d3df;
  border-radius: 8px;
  padding: 7px 10px;
  max-width: 100%;
  cursor: pointer;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
optgroup { font-style: normal; font-weight: 600; color: var(--muted); }
option { color: var(--ink); font-weight: 400; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  vertical-align: -3px;
  margin-right: 6px;
  cursor: pointer;
}
label { cursor: pointer; }

/* Viñetas: el antiguo redball.gif se muestra como un punto de acento */
img[src$="redball.gif"] {
  width: 7px !important;
  height: 7px !important;
  border-radius: 50%;
  background: var(--accent);
  object-fit: none;
  object-position: -200px -200px;
  vertical-align: middle;
  margin-right: 4px;
}
ul { padding-left: 1.3em; text-align: left; list-style-image: none !important; }
li { margin: 3px 0; }
li::marker { color: var(--accent); }

/* Leyendas en colores muy claros: se muestran sobre una pastilla oscura
   para que se lean sobre fondo claro (coinciden con los colores del visor). */
font[color="#FFFF00" i], font[color="#FFCCFF" i], font[color="#33CCFF" i],
font[color="#00FF99" i], font[color="#33FFFF" i], font[color="#66FF00" i],
font[color="#00FF00" i], font[color="#FFFFFF" i], font[color="#CCCCFF" i] {
  background: #1a2633;
  padding: 0 5px;
  border-radius: 4px;
}
[bgcolor="#000099" i] font[color] { background: transparent; padding: 0; }

/* ======================================================
   Índice lateral (indice.htm)
   ====================================================== */
.nav-lateral {
  background: var(--nav-bg) !important;
  color: var(--nav-ink) !important;
  padding: 12px 8px 16px;
  font-size: 14px;
  line-height: 1.2;
  overflow-x: hidden;
}
.nav-lateral img[src*="LogoUva"] {
  display: block;
  width: 64px !important;
  height: auto;
  margin: 0 8px 10px;
  border-radius: 6px;
}
.nav-lateral ul { list-style: none; margin: 0; padding: 0; }

/* Nivel 1: los nueve apartados principales, todos con el mismo estilo */
.nav-lateral .nivel1 > li { margin: 0 0 1px; }
.nav-lateral .nivel1 > li > a,
.nav-lateral .cat {
  display: block;
  padding: 3px 8px;
  border-radius: 6px;
  color: #eef4f9;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.nav-lateral .cat { cursor: default; }

/* Nivel 2: contenido de cada apartado */
.nav-lateral .nivel2 {
  margin: 0 0 4px 8px;
  padding-left: 4px;
  border-left: 1px solid #2a4052;
}
.nav-lateral .nivel2 a {
  display: block;
  padding: 1px 8px;
  border-radius: 6px;
  color: var(--nav-ink);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
}

/* Grupos dentro de Proteínas (Estructura Secundaria, etc.) */
.nav-lateral .grupo {
  display: block;
  padding: 4px 8px 0;
  color: var(--nav-muted);
  font-size: 12px;
  font-weight: 500;
}
.nav-lateral .nivel2 > li:first-child > .grupo { padding-top: 0; }
.nav-lateral .nivel3 { margin-left: 6px; }

.nav-lateral a { transition: background .15s ease, color .15s ease; }
.nav-lateral a:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav-lateral a.activo,
.nav-lateral .nivel1 > li > a.activo { background: var(--nav-hover); color: var(--nav-accent); }

/* ======================================================
   Submenús en marco superior (glúcidos, globinas, inmuno)
   ====================================================== */
.nav-superior {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--line);
  padding: 6px 24px;
  font-size: 13.5px;
  line-height: 1.35;
}
.nav-superior table { width: auto !important; border-spacing: 0; }
.nav-superior td { padding: 2px 18px 2px 0; white-space: nowrap; }
.nav-superior a {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
}
.nav-superior a:hover { background: var(--accent-soft); text-decoration: none; }
.nav-superior a.activo { background: var(--accent); color: #fff; }

/* ======================================================
   Portada (atlas.htm)
   ====================================================== */
body.portada img[src*="jr.foto"] {
  width: 97px !important;
  height: 120px !important;
  object-fit: cover;
  border-radius: 0;
  margin: 0 18px 8px 0;
  box-shadow: var(--shadow);
}
body.portada img[src*="JSmol_logo"] { margin-top: 10px; opacity: .9; }
body.portada > font > table > tbody > tr:first-child > td {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px !important;
  font-size: 15.5px;
}
body.portada table { border-spacing: 0 18px; max-width: 900px; }

@media (max-width: 640px) {
  body { padding: 16px 14px 32px; font-size: 14.5px; }
  font[size="+2"], font[size="+3"], font[size="5"] { font-size: 1.35rem; }
}

/* ======================================================
   Versión sin marcos (js/marco.js): índice fijo y submenú
   ====================================================== */
html.con-marco body { padding-left: 228px !important; }
.marco-lateral {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 200px;
  box-sizing: border-box;
  overflow-y: auto;
  z-index: 50;
}
.marco-lateral a.marco-logo, .marco-lateral a.marco-logo:hover { display: block; background: none; padding: 0; }
.marco-superior {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: -24px -28px 22px -28px;
  padding: 8px 24px;
  box-shadow: 0 1px 0 var(--line);
}
.marco-superior ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.marco-superior li { margin: 0; }
.marco-superior a { padding: 3px 11px; }
.marco-boton { display: none; }

@media (max-width: 760px) {
  html.con-marco body { padding-left: 14px !important; }
  .marco-boton {
    display: block;
    box-sizing: border-box;
    width: 100vw;
    max-width: none;
    margin: -16px -14px 0;
    border-radius: 0;
    border: 0;
    background: var(--nav-bg);
    color: #eef4f9;
    text-align: left;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
  }
  .marco-boton::after { content: "  ▾"; color: var(--nav-accent); }
  .marco-boton[aria-expanded="true"]::after { content: "  ▴"; }
  .marco-boton:hover { background: var(--nav-hover); }
  .marco-lateral {
    display: none;
    position: static;
    width: auto;
    margin: 0 -14px 16px;
    max-height: none;
  }
  .marco-lateral.abierto { display: block; }
  .marco-lateral table, .marco-lateral td { display: block; }
  .marco-superior { position: static; margin: 0 -14px 16px; }
  .marco-lateral img[src*="LogoUva"] { width: 56px !important; }
}

/* Texto descriptivo al pie de las páginas con poco texto propio */
.descripcion-pagina { max-width: 760px; margin: 24px 0 8px; font-size: .95em; line-height: 1.5; color: var(--muted); }

/* ---------- Ayuda del ratón (botón creado por js/marco.js) ----------
   En pantalla ancha va junto al escudo, en la cabecera del índice;
   en pantalla estrecha, a la derecha de la barra «Índice». */
.marco-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 8px 10px 0;
}
.nav-lateral .marco-cabecera img[src*="LogoUva"] { margin-bottom: 0; }
.raton-boton {
  flex: none;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--nav-accent);
  background: transparent;
  color: var(--nav-accent);
  box-shadow: none;
  cursor: pointer;
}
.raton-boton:hover { background: var(--nav-hover); color: #fff; }
.raton-boton[aria-expanded="true"] { background: var(--nav-accent); border-color: var(--nav-accent); color: var(--nav-bg); }
.raton-ayuda {
  position: fixed;
  left: 212px;
  top: 12px;
  z-index: 9800;
  box-sizing: border-box;
  width: 340px;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 14px 16px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(18, 32, 44, .18);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
}
.raton-ayuda[hidden] { display: none; }
.raton-ayuda-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--title);
  font-size: 14.5px;
}
.raton-cerrar {
  margin: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  border-color: transparent;
}
.raton-ayuda dl { margin: 0; }
.raton-ayuda dt { font-weight: 600; color: var(--accent-strong); margin-top: 8px; }
.raton-ayuda dd { margin: 2px 0 0; color: var(--ink); }
.raton-nota {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}
@media (max-width: 760px) {
  /* El botón se sitúa sobre el extremo derecho de la barra «Índice» */
  .raton-boton {
    position: absolute;
    top: 5px;
    right: 10px;
    z-index: 60;
    width: 36px;
    height: 36px;
  }
  .raton-ayuda {
    position: fixed;
    left: 10px;
    right: auto;
    top: 52px;
    max-width: none;
    max-height: calc(100vh - 64px);
  }
}
@media print { .raton-boton, .raton-ayuda { display: none !important; } }
