@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --paper: #f4f7fa;
  --ink: #0e2238;
  --navy: #004a8d;
  --navy-deep: #00305e;
  --sky: #5fc0ff;
  --slate: #4f6275;
  --line: #d9e2ea;
  --white: #ffffff;
  --measure: 66ch;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
}

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

.wrap { width: min(1140px, 100% - 3rem); margin-inline: auto; }

/* ---------- Cabecera + hero (bloque azul de marca) ---------- */
.top {
  background:
    radial-gradient(1200px 500px at 85% 40%, rgba(95,192,255,.16), transparent 60%),
    var(--navy-deep);
  color: var(--white);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 5rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand img { height: 58px; width: auto; }
.site-header nav a {
  color: #c4d7ea; text-decoration: none; font-size: .95rem; margin-left: 1.6rem;
}
.site-header nav a:hover { color: var(--white); }

.hero { padding-block: clamp(3rem, 7vw, 5.5rem) clamp(3.5rem, 7vw, 6rem); }
.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.hero h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.25rem, 4.4vw, 3.5rem);
  line-height: 1.05;
  font-weight: 720;
  font-stretch: 110%;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.hero .lede { margin: 0 0 2rem; max-width: 36ch; font-size: 1.18rem; color: #c9dcf0; }
.hero .note { margin: 1rem 0 0; font-size: .92rem; color: #a9c3dd; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .95rem 1.7rem; border-radius: 6px;
  font: inherit; font-weight: 640; font-stretch: 106%;
  text-decoration: none;
  transition: background-color .15s ease;
}
.btn-sky { background: var(--sky); color: var(--ink); }
.btn-sky:hover { background: #8dd3ff; color: var(--ink); }
.btn-white { background: var(--white); color: var(--navy-deep); }
.btn-white:hover { background: #e3edf6; color: var(--navy-deep); }

/* Curva de Bragg sobre fondo azul */
.bragg { margin: 0; }
.bragg svg { width: 100%; height: auto; display: block; }
.bragg figcaption { margin-top: .4rem; font-size: .88rem; color: #a9c3dd; }
.bragg .gridline { stroke: rgba(255,255,255,.12); stroke-width: 1; }
.bragg .axis { stroke: rgba(255,255,255,.55); stroke-width: 1.25; }
.bragg .ticklabel { fill: #a9c3dd; font-size: 12px; font-family: "Archivo", sans-serif; }
.bragg .axislabel { fill: #dbe8f5; font-size: 13px; font-family: "Archivo", sans-serif; font-weight: 560; }
.bragg .curve {
  fill: none; stroke: var(--sky); stroke-width: 3;
  stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 1000; stroke-dashoffset: 1000;
  filter: drop-shadow(0 0 6px rgba(95,192,255,.55));
  animation: trace 2.2s cubic-bezier(.55,.05,.35,1) .3s forwards;
}
.bragg .area { fill: var(--sky); fill-opacity: .12; opacity: 0; animation: fade-in .8s ease 2.3s forwards; }
.bragg .peak { opacity: 0; animation: fade-in .5s ease 2.4s forwards; }
.bragg .peak line { stroke: rgba(255,255,255,.6); stroke-dasharray: 3 4; }
.bragg .peak text { fill: var(--white); font-size: 13px; font-family: "Archivo", sans-serif; font-weight: 600; }
@keyframes trace { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .bragg .curve { animation: none; stroke-dashoffset: 0; }
  .bragg .area, .bragg .peak { animation: none; opacity: 1; }
}

/* ---------- Secciones ---------- */
.section { padding-block: clamp(3rem, 6vw, 4.75rem); }
.section + .section { border-top: 1px solid var(--line); }
.section h2 {
  margin: 0 0 .75rem;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  line-height: 1.15; font-weight: 690; font-stretch: 110%; letter-spacing: -0.015em;
}
.section .intro { margin: 0 0 2.5rem; max-width: var(--measure); color: var(--slate); }

/* Matriz de ejercicios: 2 haces x 2 tareas */
.matrix {
  display: grid;
  grid-template-columns: minmax(150px, .8fr) 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--white);
}
.matrix > * { padding: 1.4rem 1.5rem; border-top: 1px solid var(--line); }
.matrix > .corner, .matrix > .colhead { border-top: 0; }
.matrix .colhead, .matrix .rowhead { background: #eaf2f9; }
.matrix .colhead { border-left: 1px solid var(--line); }
.matrix .cell { border-left: 1px solid var(--line); }
.matrix .colhead, .matrix .rowhead {
  display: flex; flex-direction: column; gap: .6rem;
  justify-content: center; align-items: center; text-align: center;
}
.matrix img { width: 92px; }
.matrix .rowhead img { width: 104px; }
.matrix h3 { margin: 0; font-size: 1.08rem; font-weight: 660; font-stretch: 106%; color: var(--navy-deep); }
.matrix .sub { margin: 0; font-size: .9rem; color: var(--slate); }
.matrix .cell p { margin: 0; color: var(--ink); }
.matrix .corner { background: #eaf2f9; }
.standard { margin: 1.25rem 0 0; font-size: .95rem; color: var(--slate); }

/* Pasos de una sesión (secuencia real) */
.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  counter-reset: paso;
}
.steps li { counter-increment: paso; padding: 2.75rem 1.5rem 0 0; position: relative; }
.steps li::before {
  content: counter(paso);
  position: absolute; top: 0; left: 0; z-index: 1;
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--navy); color: var(--white);
  font-weight: 700; font-size: .9rem;
}
.steps li::after {
  content: ""; position: absolute; top: .95rem; left: 1.9rem; right: 0;
  height: 2px; background: var(--line);
}
.steps li:last-child::after { display: none; }
.steps h3 { margin: 0 0 .4rem; font-size: 1.1rem; font-weight: 650; font-stretch: 106%; }
.steps p { margin: 0; color: var(--slate); font-size: .98rem; }

/* Detectores */
.detectors { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.detectors ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.detectors li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid var(--line);
}
.detectors li span:first-child { font-weight: 600; }
.detectors li span:last-child { color: var(--slate); }

/* Requisitos + licencias */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(2rem, 5vw, 4.5rem); }
.checklist { margin: 0; padding-left: 1.2rem; }
.checklist li { margin-bottom: .6rem; }
.checklist li::marker { color: var(--navy); }
.licence {
  background: var(--navy-deep); color: #e8eef2;
  border-radius: 12px; padding: clamp(1.75rem, 3vw, 2.5rem);
}
.licence h2 { color: var(--white); }
.licence p { color: #c4d7ea; margin: 0 0 1.5rem; }

/* ---------- Pie ---------- */
.site-footer { background: var(--white); border-top: 1px solid var(--line); padding-block: 2.5rem; font-size: .92rem; color: var(--slate); }
.credits { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem 2.5rem; margin-bottom: 2rem; }
.credits figure { margin: 0; display: flex; align-items: center; gap: 1rem; }
.credits figcaption { max-width: 14ch; line-height: 1.35; }
.credits .svg-logo { height: 64px; width: auto; }
.credits .usc-logo { height: 56px; width: auto; }
.legal-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.legal-row p { margin: 0; }
.legal-row nav a { color: var(--slate); margin-right: 1.25rem; }
.legal-row nav a:last-child { margin-right: 0; }

/* ---------- Páginas legales ---------- */
.top.compact .site-header .wrap { border-bottom: 0; }
.legal { padding-block: clamp(2.5rem, 6vw, 4rem); }
.legal .wrap { max-width: 760px; }
.legal h1 { font-size: clamp(2rem, 4vw, 2.6rem); font-weight: 700; font-stretch: 112%; letter-spacing: -0.02em; margin: 0 0 .5rem; }
.legal .updated { color: var(--slate); margin: 0 0 2.5rem; }
.legal h2 { font-size: 1.25rem; font-weight: 650; margin: 2.25rem 0 .5rem; }
.legal p, .legal li { max-width: var(--measure); }
.legal .fill { background: #fff3c4; padding: 0 .25em; border-radius: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero .wrap, .two-col, .detectors { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 2rem; }
  .steps li:nth-child(2)::after { display: none; }
}
@media (max-width: 680px) {
  .matrix { grid-template-columns: 1fr; }
  .matrix .corner, .matrix .colhead { display: none; }
  .matrix .cell { border-left: 0; }
  .matrix .cell::before { content: attr(data-task); display: block; font-weight: 650; color: var(--navy-deep); margin-bottom: .25rem; }
}
@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .steps li::after { display: none; }
  .site-header nav { display: none; }
  .brand img { height: 36px; }
}
