/* =========================
   VARIABLES
========================= */
:root {
  --bg: #0f172a;
  --bg-secondary: #1e1b4b;
  --card: #1f2937;
  --card-hover: #253347;
  --border: #334155;
  --border-hover: #4a5f7a;

  --primary: #60a5fa;
  --primary-dark: #2563eb;
  --primary-glow: rgba(96, 165, 250, 0.15);

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --code-bg: #0f1f35;
  --code-text: #7dd3fc;

  --radius-sm: 0.4rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;

  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(96, 165, 250, 0.12);

  --transition: 0.3s ease;
  --max-width: 1100px;
}

/* =========================
   RESET & BASE
========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-secondary) 100%);

  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
}

/* =========================
   TIPOGRAFÍA
========================= */
h1,
h2,
h3 {
  font-family: system-ui, "Segoe UI", sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 100%);
  background-clip: text;

  font-size: clamp(1.8rem, 5vw, 2.6rem);
  color: transparent;
}

h2 {
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;

  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--text);
}

h2::before {
  content: "";
  display: inline-block;

  width: 4px;
  height: 1em;
  margin-right: 0.6rem;
  background: var(--primary);

  border-radius: 2px;
  vertical-align: middle;
}

h3 {
  margin-bottom: 0.75rem;

  font-size: 1.05rem;
  color: var(--primary);
}

p {
  margin-bottom: 1rem;

  color: var(--text-muted);
}

p:last-child {
  margin-bottom: 0;
}

strong {
  color: var(--text);
  font-weight: 600;
}

code {
  padding: 0.15em 0.45em;
  background: var(--code-bg);

  font-family: "Courier New", "Consolas", monospace;
  font-size: 0.875em;
  color: var(--code-text);

  border-radius: var(--radius-sm);
  border: 1px solid rgba(96, 165, 250, 0.2);
}

/* =========================
   LAYOUT
========================= */
header,
main,
footer {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* =========================
   HEADER
========================= */
header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;

  padding: 2.5rem 1rem;

  text-align: center;
}

header::after {
  content: "";
  display: block;

  height: 2px;
  width: 100%;
  margin: 0.875rem auto 0;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);

  border-radius: 2px;
}

header p {
  margin: 0;

  font-size: clamp(1rem, 4vw, 1.05rem);
  color: var(--text-muted);
}

nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  min-height: 44px;
  padding: 0.4rem 0.9rem;

  text-decoration: none;
  font-family: system-ui, sans-serif;
  font-size: 0.875rem;
  color: var(--text-muted);

  border: 1px solid var(--border);
  border-radius: 999px;

  transition: var(--transition);
}

nav a:hover {
  background: var(--primary-glow);

  color: var(--primary);

  border-color: var(--primary);
}

/* =========================
   MAIN & SECTIONS
========================= */
main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 480px) {
  main {
    gap: 3rem;
    padding: 0 1rem;
  }
}

@media (min-width: 768px) {
  main {
    gap: 3.5rem;
    padding: 0 4rem;
  }
}

section {
  padding: 2rem 1rem;
  background: var(--card);

  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);

  transition:
    box-shadow var(--transition),
    border-color var(--transition);

  animation: fadeUp 0.5s ease both;
}

@media (min-width: 480px) {
  section {
    border-radius: var(--radius-lg);
  }
}

section:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

section#intro {
  padding: 2.5rem 2rem;
  background: linear-gradient(135deg, #1a2a45 0%, var(--card) 100%);

  text-align: center;

  border-color: rgba(96, 165, 250, 0.25);
}

@media (min-width: 480px) {
  section#intro {
    padding: 1.5rem 1.25rem;
  }
}

@media (min-width: 768px) {
  section#intro {
    padding: 2.5rem;
  }
}

section#intro h2 {
  border-bottom: none;
}

section#intro h2::before {
  display: none;
}

section#intro p {
  text-align: center;
  font-size: 1.05rem;
}

section:nth-child(1) {
  animation-delay: 0.05s;
}
section:nth-child(2) {
  animation-delay: 0.1s;
}
section:nth-child(3) {
  animation-delay: 0.15s;
}
section:nth-child(4) {
  animation-delay: 0.2s;
}
section:nth-child(5) {
  animation-delay: 0.25s;
}
section:nth-child(6) {
  animation-delay: 0.3s;
}
section:nth-child(7) {
  animation-delay: 0.35s;
}

section p {
  text-align: justify;
}

/* =========================
   FIGURES & MEDIA
========================= */
figure {
  margin: 1.5rem 0;
  background: var(--card);

  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);

  overflow: hidden;
}

figure img,
figure video,
figure iframe {
  display: block;

  width: 100%;
  height: auto;
}

figure video,
figure iframe {
  aspect-ratio: 16 / 9;
}

figure audio {
  display: block;

  height: 88px;
  width: 100%;
  padding: 1.25rem 1rem;
  background: var(--bg);
}

figcaption {
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.03);

  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);

  border-top: 1px solid var(--border);
}

/* =========================
   BUENAS PRÁCTICAS
========================= */
#buenas-practicas {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 480px) {
  #buenas-practicas {
    gap: 3rem;
  }
}

#buenas-practicas h2 {
  margin-bottom: 0;
  padding-bottom: 0;
}

article {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  overflow: hidden;
}

@media (min-width: 768px) {
  article {
    align-self: center;
  }
}

article h3 {
  margin: 0;
  padding: 0.75rem 1.25rem;
  background: rgba(96, 165, 250, 0.08);

  font-size: 0.95rem;
  letter-spacing: 0.01em;

  border-bottom: 1px solid var(--border);
}

/* =========================
   TABLAS
========================= */
table {
  display: block;

  font-family: system-ui, sans-serif;
  font-size: 0.875rem;

  overflow-x: auto;
  border-collapse: collapse;
  -webkit-overflow-scrolling: touch;
}

thead {
  background: rgba(96, 165, 250, 0.08);
}

th {
  padding: 0.5rem 0.65rem;

  font-size: clamp(0.8rem, 3vw, 1rem);
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);

  border-bottom: 2px solid var(--border);
}

@media (min-width: 480px) {
  th {
    padding: 0.65rem 1rem;
  }
}

td {
  padding: 0.5rem 0.65rem;

  font-size: clamp(0.8rem, 3vw, 1rem);

  color: var(--text-muted);

  border-bottom: 1px solid rgba(51, 65, 85, 0.5);

  vertical-align: top;
}

@media (min-width: 480px) {
  td {
    padding: 0.6rem 1rem;
  }
}

td:first-child {
  font-weight: 500;
  color: var(--text);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(96, 165, 250, 0.05);
}

/* =========================
   ENLACE VOLVER ARRIBA
========================= */
main > a[href="#top"] {
  align-self: center;

  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  min-height: 44px;
  padding: 0.5rem 1rem;

  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-muted);

  border: 1px solid var(--border);
  border-radius: 999px;

  transition: var(--transition);
}

main > a[href="#top"]:hover {
  background: var(--primary-glow);

  color: var(--primary);

  border-color: var(--primary);

  transform: translateY(-2px);
}

/* =========================
   FOOTER
========================= */
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;

  padding: 1.5rem 1rem;

  text-align: center;
}

hr {
  width: 100%;
  margin-bottom: 0.5rem;

  border: none;
  border-top: 1px solid var(--border);
}

footer a {
  display: inline-flex;
  align-items: center;

  min-height: 44px;

  font-family: system-ui, sans-serif;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--text-muted);

  transition: color var(--transition);
}

footer a:hover {
  color: var(--primary);
}

footer p {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* =========================
   ANIMACIONES
========================= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   ACCESIBILIDAD
========================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
