/* ==========================================================
   Apuntes SMR · Redes Locales · IES San Alberto Magno
   Solo HTML5 + CSS. Paleta tomada del logo de Informática.
   ========================================================== */

:root {
  --navy:   #123f6e;   /* azul oscuro del logo */
  --navy-2: #0c2d52;
  --blue:   #2f7fd0;   /* azul de la red/wifi */
  --sky:    #dff0f7;   /* azul glaciar */
  --sky-2:  #eef7fb;
  --green:  #3f8a2c;   /* verde del rótulo "Informática" */
  --green-2:#e8f3e2;
  --ink:    #17283b;
  --muted:  #5a6b7c;
  --line:   #d3e2ec;
  --paper:  #f6fafc;
  --white:  #ffffff;
  --warn:   #fff6df;
  --warn-b: #e2b43c;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(18, 63, 110, .08);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--navy); color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- Cabecera ---------- */
.site-header {
  background:
    radial-gradient(circle at 12% 120%, rgba(144,200,224,.35) 0 18%, transparent 19%),
    radial-gradient(circle at 92% -20%, rgba(63,138,44,.35) 0 14%, transparent 15%),
    linear-gradient(135deg, var(--navy-2), var(--navy) 55%, #1c5a97);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.site-header::before {            /* rejilla tipo circuito */
  content: ""; position: absolute; inset: 0; opacity: .08;
  background-image:
    linear-gradient(#fff 1px, transparent 1px),
    linear-gradient(90deg, #fff 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
}
.header-inner {
  position: relative;
  max-width: 1120px; margin: 0 auto;
  padding: 1.1rem 1rem 1.2rem;
  display: flex; align-items: center; gap: 1.1rem;
}
.brand { display: flex; align-items: center; gap: 1rem; color: inherit; text-decoration: none; }
.brand img {
  width: 76px; height: 76px; flex: none;
  background: #fff; border-radius: 50%; padding: 3px;
  box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}
.brand-text small {
  display: block; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: #bfe0f0;
}
.brand-text strong { display: block; font-size: 1.35rem; line-height: 1.2; }

.main-nav { margin-left: auto; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.main-nav a {
  display: block; padding: .5rem .95rem; border-radius: 999px;
  color: #fff; text-decoration: none; font-weight: 600; font-size: .95rem;
  border: 1px solid rgba(255,255,255,.28);
}
.main-nav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.main-nav a[aria-current="page"] { background: #fff; color: var(--navy); border-color: #fff; }

/* ---------- Estructura ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }

.page-title { padding: 2rem 0 .5rem; }
.eyebrow {
  display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--green);
}
.page-title h1 { margin: .15rem 0 .4rem; font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.15; color: var(--navy); }
.page-title p { margin: 0; color: var(--muted); max-width: 60ch; }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2rem; align-items: start; padding: 1.5rem 0 3rem; }

/* ---------- Índice lateral ---------- */
.toc {
  position: sticky; top: 1rem;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
  max-height: calc(100vh - 2rem); overflow: auto;
  font-size: .94rem;
}
.toc h2 { margin: 0 0 .5rem; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: t; }
.toc > ol > li { counter-increment: t; margin: .15rem 0; }
.toc a { display: block; padding: .28rem .5rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.toc a:hover { background: var(--sky); color: var(--navy); }
.toc > ol > li > a { font-weight: 700; color: var(--navy); }
.toc > ol > li > a::before { content: counter(t) ". "; color: var(--green); }
.toc ol ol { padding-left: .9rem; border-left: 2px solid var(--line); margin: .1rem 0 .4rem .5rem; }
.toc ol ol a { font-size: .9rem; }

/* ---------- Contenido ---------- */
.content > section {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.6rem 1.8rem; margin: 0 0 1.6rem;
}
.content h2 {
  margin: 0 0 1rem; font-size: 1.55rem; line-height: 1.2; color: var(--navy);
  padding-bottom: .6rem; border-bottom: 3px solid var(--sky);
  display: flex; align-items: center; gap: .7rem;
}
.content h2 .num {
  flex: none; display: inline-grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 1rem;
}
.content h3 { margin: 1.8rem 0 .5rem; font-size: 1.2rem; color: var(--navy); }
.content h3::before { content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .5rem; background: var(--blue); border-radius: 2px; transform: translateY(-1px); }
.content h4 { margin: 1.2rem 0 .3rem; font-size: 1.02rem; color: var(--green); }
.content p { margin: .6rem 0; }
.content ul, .content ol { padding-left: 1.3rem; }
.content li { margin: .3rem 0; }
.content li::marker { color: var(--blue); }

dl.glosario { margin: .8rem 0; }
dl.glosario dt { font-weight: 700; color: var(--navy); margin-top: .8rem; }
dl.glosario dd { margin: .15rem 0 0 0; padding-left: 1rem; border-left: 3px solid var(--sky); }

/* ---------- Figuras ---------- */
figure { margin: 1.2rem 0; text-align: center; }
figure img { margin: 0 auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
figcaption { margin-top: .4rem; font-size: .87rem; color: var(--muted); }

.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; align-items: center; margin: 1.2rem 0; }
.fig-row figure { margin: 0; }
.fig-row img { max-height: 230px; width: auto; }

.fig-row.duo { grid-template-columns: 1fr 1fr; gap: .6rem; }
.fig-row.duo img { max-height: 150px; }
.split { display: grid; grid-template-columns: minmax(0,1fr) minmax(0, 320px); gap: 1.6rem; align-items: start; }
.split.wide { grid-template-columns: minmax(0,1fr) minmax(0, 400px); }
.split figure { margin: .6rem 0; }

/* ---------- Cajas ---------- */
.nota, .definicion, .dato {
  margin: 1.1rem 0; padding: .9rem 1.1rem; border-radius: 10px; border-left: 5px solid;
}
.nota       { background: var(--sky-2); border-color: var(--blue); }
.definicion { background: var(--green-2); border-color: var(--green); }
.dato       { background: var(--warn); border-color: var(--warn-b); }
.nota > :first-child, .definicion > :first-child, .dato > :first-child { margin-top: 0; }
.nota > :last-child, .definicion > :last-child, .dato > :last-child { margin-bottom: 0; }
.caja-titulo { display: block; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .2rem; }
.nota .caja-titulo { color: var(--blue); }
.definicion .caja-titulo { color: var(--green); }
.dato .caja-titulo { color: #9a6d00; }

.formula {
  margin: 1rem 0; padding: .9rem 1rem; text-align: center;
  background: var(--navy); color: #fff; border-radius: 10px;
  font-family: var(--mono); font-size: 1.05rem; overflow-x: auto;
}

/* ---------- Actividades ---------- */
details.actividad {
  margin: 1.2rem 0; border: 2px dashed var(--green); border-radius: 12px;
  background: var(--green-2); padding: 0;
}
details.actividad > summary {
  cursor: pointer; list-style: none; padding: .8rem 1.1rem; font-weight: 700; color: var(--green);
  display: flex; align-items: center; gap: .6rem;
}
details.actividad > summary::-webkit-details-marker { display: none; }
details.actividad > summary::before { content: "✎"; font-size: 1.2rem; }
details.actividad > summary::after { content: "▾"; margin-left: auto; transition: transform .2s; }
details.actividad[open] > summary::after { transform: rotate(180deg); }
details.actividad > .actividad-cuerpo { padding: 0 1.1rem 1rem; }
details.actividad .actividad-cuerpo > :first-child { margin-top: 0; }
details.solucion { margin-top: .8rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
details.solucion > summary { cursor: pointer; padding: .55rem .9rem; font-weight: 600; color: var(--navy); }
details.solucion > div { padding: 0 .9rem .9rem; }

/* ---------- Tablas ---------- */
.tabla-scroll { overflow-x: auto; margin: 1rem 0; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .96rem; background: #fff; }
caption { text-align: left; font-weight: 700; color: var(--navy); padding: .6rem .9rem; caption-side: top; background: var(--sky-2); }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--navy); color: #fff; font-weight: 600; white-space: nowrap; }
tbody th { background: var(--sky-2); color: var(--navy); }
tbody tr:nth-child(even) td { background: #f8fcfe; }
table.rellenar td { height: 3.2rem; background: repeating-linear-gradient(0deg, #fff 0 1.5rem, #eef3f6 1.5rem calc(1.5rem + 1px)); }

/* ---------- Tarjetas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1rem 0; }
.cards.dos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 680px) { .cards.dos { grid-template-columns: 1fr; } }
.card {
  background: var(--sky-2); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem;
  border-top: 4px solid var(--blue);
}
.card.verde { border-top-color: var(--green); background: var(--green-2); }
.card h4 { margin: 0 0 .3rem; color: var(--navy); }
.card p { margin: .3rem 0; font-size: .96rem; }
.card ul { margin: .3rem 0; padding-left: 1.1rem; font-size: .96rem; }
.etiqueta {
  display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--navy); color: #fff; vertical-align: middle;
}
.etiqueta.verde { background: var(--green); }

/* ---------- Niveles / pasos ---------- */
ol.pasos { list-style: none; padding: 0; counter-reset: p; }
ol.pasos > li {
  counter-increment: p; position: relative; margin: .8rem 0; padding: .9rem 1rem .9rem 3.4rem;
  background: var(--sky-2); border: 1px solid var(--line); border-radius: 12px;
}
ol.pasos > li::before {
  content: counter(p); position: absolute; left: .9rem; top: .85rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
}
ol.pasos > li strong:first-child { color: var(--navy); }
ol.pasos ul { margin: .4rem 0 0; }

/* ---------- Enlaces de recursos ---------- */
ul.recursos { list-style: none; padding: 0; }
ul.recursos li { margin: .5rem 0; padding: .6rem .9rem; background: var(--sky-2); border-radius: 10px; border: 1px solid var(--line); word-break: break-word; }
ul.recursos li::before { content: "↗ "; color: var(--green); font-weight: 700; }

/* ---------- Portada ---------- */
.hero { padding: 2.5rem 0 1rem; }
.hero h1 { margin: 0 0 .6rem; font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.1; color: var(--navy); }
.hero p { max-width: 62ch; font-size: 1.15rem; color: var(--muted); margin: 0; }
.unidades { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; margin: 2rem 0 1rem; }
.unidad {
  display: flex; flex-direction: column;
  background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
  text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s;
}
.unidad:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(18,63,110,.16); color: inherit; }
.unidad-img { height: 220px; overflow: hidden; background: var(--sky); }
.unidad-img img { width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; }
.unidad-img.contain img { object-fit: contain; padding: .6rem; background: #fff; }
.unidad-body { padding: 1.2rem 1.3rem 1.4rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.unidad h2 { margin: 0; font-size: 1.35rem; color: var(--navy); line-height: 1.2; }
.unidad p { margin: 0; color: var(--muted); font-size: .98rem; }
.unidad ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .93rem; color: var(--ink); }
.unidad .ir { margin-top: auto; padding-top: .6rem; font-weight: 700; color: var(--green); }

/* ---------- Navegación entre páginas y pie ---------- */
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0 0 2rem; }
.pager a {
  padding: .7rem 1.2rem; border-radius: 999px; background: var(--navy); color: #fff; text-decoration: none; font-weight: 600;
}
.pager a:hover { background: var(--green); color: #fff; }
.arriba { text-align: right; margin: -.6rem 0 1.6rem; font-size: .9rem; }

.site-footer { background: var(--navy-2); color: #bfd6e8; padding: 1.6rem 1rem; font-size: .92rem; }
.site-footer .wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: 0; }
.site-footer img { width: 44px; height: 44px; background: #fff; border-radius: 50%; padding: 2px; }
.site-footer p { margin: 0; }
.site-footer .f-brand { display: flex; gap: .8rem; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .toc { position: static; max-height: none; }
  .split, .split.wide { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  body { font-size: 1rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .main-nav { margin-left: 0; }
  .main-nav ul { justify-content: flex-start; }
  .brand img { width: 62px; height: 62px; }
  .content > section { padding: 1.2rem 1rem; }
  .content h2 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .unidad { transition: none; }
}

/* ---------- Impresión ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .site-header, .toc, .pager, .arriba, .site-footer, .skip { display: none; }
  .layout { display: block; padding: 0; }
  .content > section { box-shadow: none; border: 0; padding: 0; break-inside: auto; }
  details.actividad > .actividad-cuerpo, details.solucion > div { display: block; }
  figure, .card, table { break-inside: avoid; }
}
