/* ============================================================
 * theme.css — TEMA de la guía de TABLA PERIÓDICA (capa LIBRE).
 * SOLO estilos del tema (prefijo tp-): tabla periódica interactiva,
 * panel de datos, leyenda de categorías, modo tendencias.
 * Andamiaje en assets/guia-components.css; variables --guia-*.
 * Pisos de letra: lectura ≥17px · apoyo ≥15px · etiquetas MAYÚSCULAS ≥13px.
 * Tap targets ≥44px. Sin overflow horizontal a 360px. Light-mode fijo.
 * ============================================================ */

/* ===== Paleta del tema (alias locales con fallback a vars compartidas) ===== */
.tp-widget, .tp-legend, .tp-visual, .tp-panel {
  --tp-alcalino:       #E63946;
  --tp-alcalinotérreo: #E07C00;
  --tp-transicion:     #C8A600;
  --tp-trans-int:      #2A9D8F;
  --tp-metaloide:      #2D6A4F;
  --tp-no-metal:       #3A5A8C;
  --tp-halogeno:       #7B2D8B;
  --tp-gas-noble:      #A8174B;
  --tp-otro:           #6B7280;
  --tp-ink: var(--guia-ink, #181B22);
  --tp-line: var(--guia-line, #D7D2C8);
  --tp-cream: var(--guia-cream, #F9F7F3);
  --tp-orange: var(--guia-orange, #C75D08);
  --tp-navy: var(--guia-navy, #283891);
  --tp-green: var(--guia-green-deep, #1C7A3A);
  --tp-muted: var(--guia-muted, #6B7280);
}

/* ===== Leyenda de categorías ===== */
.tp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1.5px solid var(--guia-line, #D7D2C8);
  border-radius: 12px;
  margin: 4px 0;
}
.tp-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tp-ink);
  line-height: 1.3;
}
.tp-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
  border: 1.5px solid rgba(0,0,0,0.18);
}

/* ===== Visual SVG estático ===== */
.tp-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}
.tp-visual .vcap {
  font-size: 15px;
  font-weight: 700;
  color: var(--tp-muted);
  text-align: center;
}
.tp-svg {
  width: 100%;
  max-width: 360px;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}

/* ===== Widget contenedor ===== */
.tp-widget {
  border: 2px solid var(--tp-ink);
  border-radius: 14px;
  background: var(--tp-cream);
  padding: 14px 12px 12px;
  margin: 2px 0;
  display: grid;
  gap: 10px;
}

/* ===== Encabezado del widget ===== */
.tp-widget-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tp-flag {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
  background: var(--tp-orange);
  border: 2px solid var(--tp-ink);
  border-radius: 999px;
  padding: 3px 11px;
  flex: 0 0 auto;
}
.tp-inst {
  font-size: 15px;
  font-weight: 700;
  color: var(--tp-navy);
  line-height: 1.4;
}

/* ===== Controles de modo tendencias ===== */
.tp-trend-ctrl {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.tp-trend-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--tp-muted);
}
.tp-trend-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 13px;
  min-height: 36px;
  border: 2px solid var(--tp-ink);
  border-radius: 8px;
  background: #fff;
  color: var(--tp-ink);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.tp-trend-btn:hover {
  background: #f0ede8;
}
.tp-trend-btn.active {
  background: var(--tp-navy);
  color: #fff;
  border-color: var(--tp-navy);
}
.tp-trend-btn.active-eneg {
  background: var(--tp-alcalino);
  color: #fff;
  border-color: var(--tp-alcalino);
}

/* ===== Hint de scroll móvil ===== */
.tp-scroll-hint {
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  color: var(--tp-ink, #1f2733);
  background: var(--tp-hint-bg, #fff3e7);
  border: 1.5px solid var(--tp-accent, #f5821f);
  border-radius: 12px;
  padding: 9px 12px;
  margin: 4px auto 10px;
  max-width: 92%;
  display: none;
}
.tp-scroll-hint::before { content: "\2194\00a0"; }
@media (max-width: 540px) {
  .tp-scroll-hint { display: block; }
}

/* ===== Tabla periódica: wrapper con scroll horizontal ===== */
.tp-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Evita que el documento desborde; solo el wrapper hace scroll */
  max-width: 100%;
}

/* ===== Grid de la tabla ===== */
.tp-table {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: 2px;
  /* Ancho mínimo para que 18 columnas quepan con celdas legibles */
  min-width: 540px;
  padding: 2px;
}

/* ===== Celda individual ===== */
.tp-cell {
  position: relative;
  border: 1.5px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  background: #e0e0e0;
  cursor: pointer;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1px;
  transition: transform .1s, box-shadow .1s, filter .1s;
  min-width: 28px;
  min-height: 28px;
  /* tap target helper */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tp-cell:hover,
.tp-cell:focus-visible {
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 10;
  outline: 2px solid var(--tp-ink);
}
.tp-cell.selected {
  box-shadow: 0 0 0 2.5px var(--tp-ink), 0 2px 10px rgba(0,0,0,0.3);
  z-index: 11;
  transform: scale(1.15);
}
.tp-cell-empty {
  background: transparent !important;
  border-color: transparent !important;
  cursor: default;
  pointer-events: none;
}
.tp-cell-z {
  font-size: 8px;
  font-weight: 700;
  color: rgba(0,0,0,0.55);
  line-height: 1;
  align-self: flex-start;
  padding-left: 2px;
  width: 100%;
}
.tp-cell-sym {
  font-size: 13px;
  font-weight: 900;
  color: rgba(0,0,0,0.85);
  line-height: 1;
  text-align: center;
}
/* Responsive: celdas más pequeñas en móvil */
@media (max-width: 480px) {
  .tp-table { min-width: 480px; }
  .tp-cell { min-width: 24px; min-height: 24px; }
  .tp-cell-sym { font-size: 11px; }
  .tp-cell-z { font-size: 7px; }
}

/* ===== Fila separadora lantánidos/actínidos ===== */
.tp-separator {
  grid-column: 1 / -1;
  height: 6px;
}

/* ===== Panel de datos del elemento seleccionado ===== */
.tp-panel {
  background: #fff;
  border: 2px solid var(--tp-ink);
  border-radius: 12px;
  padding: 14px 16px;
  display: none;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: start;
}
.tp-panel.visible { display: grid; }

.tp-panel-badge {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 2.5px solid var(--tp-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 4px;
}
.tp-panel-badge-z {
  font-size: 11px;
  font-weight: 800;
  color: rgba(0,0,0,0.55);
  line-height: 1;
  width: 100%;
  text-align: left;
}
.tp-panel-badge-sym {
  font-size: 30px;
  font-weight: 900;
  color: #111;
  line-height: 1;
}
.tp-panel-badge-mass {
  font-size: 10px;
  font-weight: 700;
  color: rgba(0,0,0,0.55);
  line-height: 1;
  margin-top: 2px;
}

.tp-panel-info { display: grid; gap: 4px; }
.tp-panel-name {
  font-size: 19px;
  font-weight: 900;
  color: var(--tp-ink);
  line-height: 1.1;
  margin-bottom: 2px;
}
.tp-panel-cat {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  display: inline-block;
  width: fit-content;
}
.tp-panel-meta {
  font-size: 14px;
  color: #444;
  line-height: 1.5;
}
.tp-panel-meta strong { color: var(--tp-ink); }
.tp-panel-fun {
  font-size: 14px;
  font-weight: 600;
  color: var(--tp-navy);
  background: #EEF2FF;
  border-radius: 8px;
  padding: 6px 10px;
  line-height: 1.4;
  grid-column: 1 / -1;
  margin-top: 2px;
}
.tp-panel-trend {
  font-size: 13px;
  color: var(--tp-muted);
  grid-column: 1 / -1;
}

/* Responsive panel */
@media (max-width: 400px) {
  .tp-panel { grid-template-columns: 1fr; }
  .tp-panel-badge { width: 56px; height: 56px; }
  .tp-panel-badge-sym { font-size: 26px; }
}

/* ===== Leyenda de tendencias ===== */
.tp-trend-legend {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tp-muted);
  margin-top: 2px;
  flex-wrap: wrap;
}
.tp-trend-legend.visible { display: flex; }
.tp-trend-grad {
  width: 80px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  background: linear-gradient(to right, #4361EE, #E63946);
  flex: 0 0 auto;
}

/* ===== Botón "categorías" para volver ===== */
.tp-cat-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 13px;
  min-height: 36px;
  border: 2px solid var(--tp-ink);
  border-radius: 8px;
  background: #fff;
  color: var(--tp-ink);
  cursor: pointer;
}
.tp-cat-btn:hover { background: #f0ede8; }

/* ===== SVG visual de átomo ===== */
.tp-atomo-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}

/* ===== SVG visual de celda ===== */
.tp-celda-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}

/* ===== SVG propiedades metales ===== */
.tp-props-svg {
  width: 100%;
  max-width: 360px;
  height: auto;
  display: block;
  margin: 0 auto;
  overflow: visible;
}
