/* ============================================================
   Portafolio TFI — Modelos y Simulación (UNNOBA)
   Tema: panel de estado de un SOC (dark dashboard).
   HTML + CSS + JS plano, sin dependencias externas.
   ============================================================ */

:root {
  /* Superficies */
  --bg:         #0a0e14;
  --surface:    #111823;
  --surface-2:  #17202e;
  --border:     #232e3f;
  /* Texto */
  --text:       #e6edf3;
  --text-muted: #8b99ab;
  /* Acento */
  --accent:     #56c7e6;
  /* Severidad (estado de cada escenario) */
  --ok:         #2dd4a7;
  --warn:       #f2b134;
  --crit:       #ff5c57;

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --maxw: 1080px;
  --radius: 10px;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.65;
  font-size: 16px;
  /* Textura sutil de "grilla de monitoreo" en el fondo */
  background-image:
    linear-gradient(var(--surface) 1px, transparent 1px),
    linear-gradient(90deg, var(--surface) 1px, transparent 1px);
  background-size: 46px 46px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }  .warn { color: var(--warn); }  .crit { color: var(--crit); }

.hl-ok   { color: var(--ok); }
.hl-crit { color: var(--crit); }

code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .05em .4em;
  color: var(--accent);
}

a { color: var(--accent); }
a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.todo {
  color: var(--warn);
  font-style: italic;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-radius: 4px;
  padding: 0 .35em;
}

/* ===================== NAV ===================== */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav__brand {
  font-family: var(--mono); font-weight: 700; letter-spacing: .5px;
  color: var(--text); text-decoration: none; font-size: 1.02rem;
}
.blink { color: var(--ok); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }
.nav__links { display: flex; gap: clamp(.6rem, 2vw, 1.4rem); flex-wrap: wrap; }
.nav__links a {
  font-family: var(--mono); font-size: .86rem; text-decoration: none;
  color: var(--text-muted); padding: .2rem 0; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.nav__links a:hover { color: var(--text); }
.nav__links a.is-active { color: var(--accent); border-color: var(--accent); }

/* ===================== LAYOUT ===================== */
main { display: block; }
.section, .portada {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2.6rem, 7vw, 4.5rem) clamp(1rem, 4vw, 2rem);
  scroll-margin-top: 70px;
}
.section { border-top: 1px solid var(--border); }

.section__num {
  color: var(--accent); font-size: .8rem; letter-spacing: 2px;
  margin: 0 0 .4rem;
}
.section__title { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 1.4rem; line-height: 1.2; }
h3 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.4rem, 4vw, 2.8rem); }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

/* ===================== PORTADA ===================== */
.portada {
  min-height: 82vh; display: flex; align-items: center;
  padding-top: clamp(3rem, 10vw, 6rem);
}
.tag { color: var(--accent); letter-spacing: 2px; font-size: .82rem; margin: 0 0 1rem; }
.portada__title {
  font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.12; margin: 0 0 1.1rem;
  letter-spacing: -.5px;
}
.portada__sub { font-size: clamp(1rem, 2.4vw, 1.2rem); color: var(--text-muted); max-width: 60ch; margin: 0 0 2.2rem; }

.meta {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
@media (max-width: 560px) { .meta { grid-template-columns: 1fr; } }
.meta > div { background: var(--surface); padding: .85rem 1.1rem; }
.meta dt { color: var(--text-muted); font-size: .72rem; letter-spacing: 1px; text-transform: uppercase; }
.meta dd { margin: .15rem 0 0; font-size: 1.02rem; }

/* ===================== TEXTO ===================== */
.obj { padding-left: 1.1rem; }
.obj li { margin-bottom: .7rem; }
.pregunta {
  margin-top: 1.6rem; padding: 1.1rem 1.3rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.pregunta p:last-child { margin: .4rem 0 0; }

/* ===================== TABLAS ===================== */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; margin: .6rem 0 1rem;
  font-size: .93rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
table.data th, table.data td { text-align: left; padding: .58rem .8rem; border-bottom: 1px solid var(--border); }
table.data thead th {
  background: var(--surface-2); font-family: var(--mono); font-weight: 600;
  font-size: .78rem; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted);
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tfoot td { font-family: var(--mono); color: var(--text-muted); background: var(--surface-2); }
table.data td:first-child { font-variant-numeric: tabular-nums; }
.data--map td:first-child { color: var(--accent); width: 40%; }
.data--results td, .data--matrix td { vertical-align: middle; }

/* ===================== LISTAS DE STATS ===================== */
.stat-list { list-style: none; padding: 0; margin: .4rem 0 1rem; display: grid; gap: .7rem; }
.stat-list li { display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: baseline; }
.stat-num {
  font-family: var(--mono); font-weight: 700; font-size: 1.25rem;
  white-space: nowrap; min-width: 3.6em; text-align: right;
}
.src { color: var(--text-muted); font-style: normal; font-size: .82rem; display: block; }

.fuentes { margin-top: 1.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.fuentes summary { cursor: pointer; padding: .8rem 1rem; color: var(--accent); font-size: .86rem; }
.fuentes ul { margin: 0; padding: 0 1.4rem 1rem 2.2rem; color: var(--text-muted); font-size: .9rem; }
.fuentes li { margin: .25rem 0; }

/* ===================== FÓRMULAS ===================== */
.formula {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}
.formula pre { margin: 0; padding: 1rem 1.2rem; font-size: .85rem; line-height: 1.7; color: var(--text); }
.formula pre .c { color: var(--text-muted); }

/* ===================== ρ BOARD ===================== */
.board__heading { margin-top: 2.6rem; }
.board__lead { margin-top: -.2rem; max-width: 70ch; }
.board {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem clamp(1rem, 3vw, 1.8rem);
  display: grid; gap: 1.25rem;
}
.bar__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; }
.bar__name { font-size: .95rem; font-weight: 600; }
.bar__track {
  position: relative; height: 22px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
/* Línea de saturación (ρ = 1) sobre cada barra. Escala: ancho total = ρ 1,8 → ρ=1 en 55,5% */
.bar__track::before {
  content: ""; position: absolute; left: 55.5%; top: 0; bottom: 0;
  border-left: 2px dashed color-mix(in srgb, var(--text-muted) 70%, transparent);
  z-index: 2;
}
.bar__fill {
  height: 100%; width: calc(var(--rho) * 55.5%);
  border-radius: 5px 0 0 5px;
  transition: width .9s cubic-bezier(.2,.7,.2,1);
}
.bar[data-state="ok"]   .bar__fill { background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 55%, #000), var(--ok)); }
.bar[data-state="warn"] .bar__fill { background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 55%, #000), var(--warn)); }
.bar[data-state="crit"] .bar__fill {
  background: repeating-linear-gradient(45deg, var(--crit) 0 10px, color-mix(in srgb, var(--crit) 72%, #000) 10px 20px);
  box-shadow: 0 0 14px color-mix(in srgb, var(--crit) 50%, transparent);
}
.bar__val { font-size: .8rem; color: var(--text-muted); margin-top: .4rem; }
.board__satline { font-size: .72rem; color: var(--text-muted); letter-spacing: 1px; text-align: right; }

/* Chips de estado (texto + color, nunca color solo → accesible) */
.chip {
  font-family: var(--mono); font-size: .68rem; font-weight: 700; letter-spacing: .8px;
  padding: .18rem .5rem; border-radius: 5px; white-space: nowrap; text-transform: uppercase;
  border: 1px solid currentColor;
}
.chip--ok   { color: var(--ok);   background: color-mix(in srgb, var(--ok) 12%, transparent); }
.chip--warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip--crit { color: var(--crit); background: color-mix(in srgb, var(--crit) 14%, transparent); }

.data--results .crit { font-weight: 700; }

/* ===================== LIMITACIONES ===================== */
.lims { padding-left: 1.1rem; }
.lims li { margin: .45rem 0; }

/* ===================== LOG DE PROMPTS ===================== */
.log { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: 1rem; }
.log__item {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
}
.log__item h3 { margin: .3rem 0 .5rem; }
.log__meta { display: flex; gap: .6rem; font-size: .74rem; }
.log__stage { color: var(--accent); font-weight: 700; letter-spacing: 1px; }
.log__tool {
  color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 .45em; background: var(--surface-2);
}
.log__prompt { margin: .3rem 0 .6rem; color: var(--text-muted); font-size: .92rem; }
.log__reflex { margin: 0; font-size: .93rem; }

/* ===================== GALERÍA ===================== */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; margin-top: 1rem; }
@media (max-width: 760px) { .gallery { grid-template-columns: 1fr; } }
.gallery figure {
  margin: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.gallery img { display: block; width: 100%; height: auto; background: #fff; }
.gallery figcaption { padding: .8rem 1rem; font-size: .86rem; color: var(--text-muted); border-top: 1px solid var(--border); }
.gallery figcaption strong { color: var(--text); }

/* ===================== CONSOLA (evidencia) ===================== */
.console {
  background: #06090e; border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto; margin: .6rem 0 1rem;
}
.console pre { margin: 0; padding: 1rem 1.2rem; font-size: .82rem; line-height: 1.7; color: var(--text); }
.console__p { color: var(--ok); user-select: none; }
.console__c { color: var(--accent); }

/* ===================== CONCLUSIONES ===================== */
.conc__lead { font-size: 1.15rem; }
.conc p { max-width: 72ch; }
.reflex-open {
  margin-top: 2rem; padding: 1.2rem 1.4rem;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.reflex-open .section__num { color: var(--ok); }

/* ===================== FOOTER ===================== */
.foot {
  max-width: var(--maxw); margin: 0 auto;
  padding: 1.6rem clamp(1rem, 4vw, 2rem) 3rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  font-size: .8rem; color: var(--text-muted);
}
