@import url('https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,300;0,400;0,600;0,700;0,800;1,400&display=swap');

/* =========================
   Reset + variables
========================= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --bg:        #F2F5F7;
  --surface:   #ffffff;
  --border:    #e6ebf0;
  --text:      #002138;
  --muted:     #587385;

  --primary:     #f43737;
  --primary-700: #c42020;
  --ink:         #002138;

  --ring:        rgba(244, 55, 55, .28);
  --radius:      8px;
  --shadow:      0 4px 24px rgba(0, 33, 56, .10);
  --shadow-soft: 0 2px 10px rgba(0, 33, 56, .07);
}

/* =========================
   Base
========================= */
body {
  font-family: "Overpass", system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-weight: 400;
}

.container {
  max-width: 980px;
  margin: clamp(16px, 4vw, 40px) auto;
  padding: 0 16px 56px;
}

.container::before {
  content: "";
  display: block;
  height: 4px;
  border-radius: 999px;
  margin: 20px 0 28px;
  background: linear-gradient(90deg, var(--primary) 0%, rgba(244,55,55,.30) 100%);
}

/* =========================
   Título
========================= */
h1 {
  font-size: clamp(1.55rem, 2.6vw, 2rem);
  font-weight: 800;
  margin: 8px 0 6px;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -.4px;
}

h1::after {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--primary);
}

h3 {
  font-size: .92rem;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 32px 0 10px;
  padding-left: 12px;
  position: relative;
}
h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 14px;
  background: var(--primary);
  border-radius: 999px;
}

p {
  color: var(--muted);
  font-size: .96rem;
  margin: 0 0 20px;
  max-width: 68ch;
}

h1 + p {
  margin-top: 20px;
}

/* =========================
   Acordeones
========================= */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin: 10px 0;
  overflow: hidden;
  transition: border-color .2s ease, box-shadow .2s ease;
}

details:hover {
  border-color: rgba(0, 33, 56, .30);
  box-shadow: var(--shadow);
}

details:focus-within { outline: none; }

summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-weight: 700;
  font-size: .93rem;
  background: var(--ink);
  color: #fff;
  user-select: none;
  transition: background-color .15s ease;
}

summary::-webkit-details-marker { display: none; }

summary::before {
  content: "▸";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: .85rem;
  flex-shrink: 0;
  transition: transform .2s ease, background-color .15s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
  background: var(--primary);
  color: #fff;
}

summary:hover {
  background: #003256;
}

details[open] summary:hover {
  background: #003256;
}

summary:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: -3px;
}

/* =========================
   Contenido interno
========================= */
details > ul {
  list-style: none;
  margin: 0;
  padding: 6px 18px 14px 18px;
}

li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 6px;
  flex-wrap: wrap;
}

li:hover {
  background: rgba(0, 33, 56, .03);
}

li span {
  flex: 1;
  min-width: 220px;
  color: var(--text);
  font-size: .92rem;
}

/* =========================
   Enlaces
========================= */
a {
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(var(--primary), var(--primary)) 0 100% / 0% 2px no-repeat;
  transition: color .15s ease, background-size .2s ease;
  border-radius: 4px;
  padding: 2px;
}

a:hover {
  color: var(--primary);
  background-size: 100% 2px;
}

a:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* =========================
   Badges DER / CRL / PEM
========================= */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .2px;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform .06s ease, background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
  background: none;
}
.badge:active { transform: translateY(1px); }
.badge:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* DER (azul) */
.badge.der {
  background: rgba(0, 80, 200, .08);
  color: #0050c8;
  border-color: rgba(0, 80, 200, .20);
}
.badge.der:hover {
  background: #0050c8;
  color: #fff;
  border-color: #0050c8;
  box-shadow: 0 4px 14px rgba(0,80,200,.20);
}

/* CRL (ámbar) */
.badge.crl {
  background: rgba(180, 90, 0, .10);
  color: #7a4000;
  border-color: rgba(180, 90, 0, .20);
}
.badge.crl:hover {
  background: #b45a00;
  color: #fff;
  border-color: #b45a00;
  box-shadow: 0 4px 14px rgba(180,90,0,.18);
}

/* PEM (verde) */
.badge.pem {
  background: rgba(0, 130, 70, .10);
  color: #006038;
  border-color: rgba(0, 130, 70, .20);
}
.badge.pem:hover {
  background: #008246;
  color: #fff;
  border-color: #008246;
  box-shadow: 0 4px 14px rgba(0,130,70,.18);
}

/* Primary (rojo corporativo) */
.badge.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
  margin-left: 10px;
}
.badge.primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
  box-shadow: 0 4px 14px rgba(244,55,55,.30);
}

/* Botón de vuelta al menú */
.menu-back {
  margin-top: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.menu-back .badge.primary { margin-left: 0; }

/* =========================
   Header
========================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 33, 56, .07);
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 4px 6px;
  border-radius: 6px;
}
.header-logo:hover {
  color: var(--primary);
  background: none;
}
.header-logo img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.header-nav a {
  background: none;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease;
}
.header-nav a:hover {
  color: #fff;
  background: var(--ink);
}
.header-nav a.active {
  color: #fff;
  background: var(--ink);
}

/* =========================
   Footer
========================= */
.site-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  margin-top: 8px;
}

.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--muted);
}

.footer-inner a {
  background: none;
  color: var(--muted);
}
.footer-inner a:hover {
  color: var(--primary);
  background: none;
}

.footer-brand {
  font-weight: 700;
  color: var(--ink);
  font-size: .88rem;
}

/* =========================
   Página de imágenes SVG
========================= */
.page-jerarquias .container {
  max-width: 1240px;
}

.svg-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 16px;
}

.svg-card {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.svg-card figcaption {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: .92rem;
  color: var(--ink);
}

.jerarquia-img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  max-width: 980px;
  background: #fff;
}

.jerarquia-img.sm { max-width: 500px; }
.jerarquia-img.lg { max-width: 1200px; }

/* =========================
   Responsive
========================= */
@media (max-width: 560px) {
  summary { padding: 13px 14px; }
  details > ul { padding: 6px 14px 12px; }
  li span { min-width: 0; }
  a { display: inline-block; }
  .svg-card { padding: 12px; }
  .jerarquia-img,
  .jerarquia-img.sm,
  .jerarquia-img.lg { max-width: 100%; }
  .header-inner { height: 60px; }
  .header-logo img { height: 30px; }
  .header-nav a { padding: 5px 7px; font-size: .8rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}
