/* ═══════════════════════════════════════════════════════════════
   styles.css  —  Tablas de Frecuencia · Probabilidad & Estadística
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #21262d;
  --muted:     #8b949e;
  --text:      #e6edf3;
  --accent1:   #58a6ff;   /* azul  — ejemplo 1 */
  --accent2:   #3fb950;   /* verde — ejemplo 2 */
  --accent3:   #d29922;   /* ámbar — ejemplo 3 */
  --head1:     #1f3d5c;
  --head2:     #1a3d29;
  --head3:     #4a3500;
  --row-alt:   rgba(255,255,255,.03);
  --radius:    12px;
  --radius-sm: 6px;
}

/* ── Reset / Base ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 64px 24px 48px;
  background: linear-gradient(160deg, #0d1117 0%, #131b27 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 50%, rgba(88,166,255,.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 30%, rgba(63,185,80,.06) 0%, transparent 70%);
  pointer-events: none;
}
header .label {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent1);
  border: 1px solid var(--accent1);
  padding: 3px 12px;
  border-radius: 99px;
  margin-bottom: 20px;
}
header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 1.15;
  max-width: 720px;
  margin: 0 auto 16px;
}
header p {
  color: var(--muted);
  max-width: 580px;
  margin: 0 auto;
  font-size: 1rem;
}

/* ── Nav pills ───────────────────────────────────────────────── */
.nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 28px 24px;
  flex-wrap: wrap;
}
.nav a {
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  padding: 6px 18px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all .2s;
}
.nav a:hover      { color: var(--text); border-color: var(--muted); }
.nav a.e1         { border-color: var(--accent1); color: var(--accent1); }
.nav a.e2         { border-color: var(--accent2); color: var(--accent2); }
.nav a.e3         { border-color: var(--accent3); color: var(--accent3); }

/* ── Main layout ─────────────────────────────────────────────── */
main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 64px;
}

/* ── Section card ────────────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp .55s both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section:nth-child(2) { animation-delay: .1s; }
.section:nth-child(3) { animation-delay: .2s; }

/* ── Section header ──────────────────────────────────────────── */
.sec-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 28px 32px;
  border-bottom: 1px solid var(--border);
}
.badge {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
}
.e1 .badge { background: rgba(88,166,255,.15); color: var(--accent1); border: 2px solid var(--accent1); }
.e2 .badge { background: rgba(63,185,80,.15);  color: var(--accent2); border: 2px solid var(--accent2); }
.e3 .badge { background: rgba(210,153,34,.15); color: var(--accent3); border: 2px solid var(--accent3); }

.sec-header-text h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  margin-bottom: 4px;
}
.type-tag {
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.e1 .type-tag { background: rgba(88,166,255,.15); color: var(--accent1); }
.e2 .type-tag { background: rgba(63,185,80,.15);  color: var(--accent2); }
.e3 .type-tag { background: rgba(210,153,34,.15); color: var(--accent3); }

/* ── Context block ───────────────────────────────────────────── */
.context {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  color: #c9d1d9;
  font-size: .97rem;
}
.context strong { color: var(--text); }

/* ── Dataset display ─────────────────────────────────────────── */
.dataset-block {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}
.dataset-block h3 {
  font-size: .78rem;
  font-family: 'DM Mono', monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.data-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.data-chip {
  font-family: 'DM Mono', monospace;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  border: 1px solid var(--border);
}
.e1 .data-chip { border-color: rgba(88,166,255,.2); }
.e2 .data-chip { border-color: rgba(63,185,80,.2);  }
.e3 .data-chip { border-color: rgba(210,153,34,.2); }

/* ── Table section ───────────────────────────────────────────── */
.table-wrap {
  padding: 24px 32px 32px;
}
.table-wrap h3 {
  font-size: .78rem;
  font-family: 'DM Mono', monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
thead tr {
  border-bottom: 2px solid;
}
.e1 thead tr { border-color: var(--accent1); }
.e2 thead tr { border-color: var(--accent2); }
.e3 thead tr { border-color: var(--accent3); }

th {
  padding: 10px 16px;
  text-align: center;
  font-weight: 600;
  font-size: .83rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.e1 th { color: var(--accent1); background: var(--head1); }
.e2 th { color: var(--accent2); background: var(--head2); }
.e3 th { color: var(--accent3); background: var(--head3); }

td {
  padding: 9px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td  { border-bottom: none; }
tbody tr:nth-child(even){ background: var(--row-alt); }
tbody tr:hover          { background: rgba(255,255,255,.06); transition: background .15s; }

/* Total row */
.total-row td {
  font-weight: 600;
  border-top: 2px solid var(--border);
}
.e1 .total-row td { color: var(--accent1); }
.e2 .total-row td { color: var(--accent2); }
.e3 .total-row td { color: var(--accent3); }

/* ═══════════════════════════════════════════════════════════════
   SECCIÓN DE GRÁFICOS ESTADÍSTICOS
   ═══════════════════════════════════════════════════════════════ */

.charts-wrap {
  padding: 28px 32px 36px;
  border-bottom: 1px solid var(--border);
}
.charts-wrap h3 {
  font-size: .78rem;
  font-family: 'DM Mono', monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

/* Grid 2+3 para 5 gráficos: fila 1 → 2 grandes, fila 2 → 3 medianos */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto auto;
  gap: 16px;
  grid-template-areas:
    "ch1 ch2"
    "ch3 ch4"
    "chp chp";
}
.chart-card:nth-child(1) { grid-area: ch1; }
.chart-card:nth-child(2) { grid-area: ch2; }
.chart-card:nth-child(3) { grid-area: ch3; }
.chart-card:nth-child(4) { grid-area: ch4; }
.chart-card:nth-child(5) { grid-area: chp; }

/* ── Tarjeta de gráfico ──────────────────────────────────── */
.chart-card {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease;
  display: flex;
  flex-direction: column;
}
.chart-card:hover { transform: translateY(-3px); }

.e1 .chart-card:hover { box-shadow: 0 10px 28px rgba(88,166,255,.2); }
.e2 .chart-card:hover { box-shadow: 0 10px 28px rgba(63,185,80,.2);  }
.e3 .chart-card:hover { box-shadow: 0 10px 28px rgba(210,153,34,.2); }

/* Etiqueta de tipo de gráfico */
.chart-card .chart-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.e1 .chart-label { color: var(--accent1); }
.e2 .chart-label { color: var(--accent2); }
.e3 .chart-label { color: var(--accent3); }

.chart-label .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.e1 .dot { background: var(--accent1); }
.e2 .dot { background: var(--accent2); }
.e3 .dot { background: var(--accent3); }

/* Imagen del gráfico */
.chart-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  background: #0d1117;
  /* El pastel ocupa la mitad del ancho centrado */
}
/* El pastel (5.º) se centra horizontalmente */
.chart-card:nth-child(5) img {
  max-width: 460px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .charts-wrap { padding-left: 20px; padding-right: 20px; }
  .charts-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "ch1" "ch2" "ch3" "ch4" "chp";
  }
}

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sec-header, .context, .dataset-block, .table-wrap {
    padding-left: 20px;
    padding-right: 20px;
  }
  th, td { padding: 8px 10px; font-size: .82rem; }
}
