:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #5c6470;
  --line: #e6e1d5;
  --brand: #1a2a6c;
  --brand-2: #2f4bb5;
  --gold: #f5b301;
  --red: #c0392b;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(26, 42, 108, 0.10);
  --shadow-sm: 0 3px 12px rgba(26, 42, 108, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", "Roboto", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.tricolor {
  height: 6px;
  background: linear-gradient(90deg, #ffd100 0 33.33%, #0033a0 33.33% 66.66%, #ef3340 66.66% 100%);
}

header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 245, 239, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.brand .logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.brand .name { font-weight: 800; font-size: 17px; letter-spacing: -0.2px; }
.brand .name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
nav.links { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
nav.links button {
  border: none; background: transparent; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--muted);
  padding: 9px 14px; border-radius: 10px; transition: .15s;
}
nav.links button:hover { background: #ece7d8; color: var(--ink); }
nav.links button.active { background: var(--brand); color: #fff; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(245, 179, 1, 0.35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(239, 51, 64, 0.30), transparent 55%),
    linear-gradient(135deg, #14204f 0%, #1a2a6c 45%, #2f4bb5 100%);
  padding: 72px 20px 84px;
}
.hero-inner { max-width: 1080px; margin: 0 auto; }
.hero .badge {
  display: inline-block; background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.3px; margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.08; letter-spacing: -1px; max-width: 16ch; margin-bottom: 18px;
}
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p.lema { font-size: 18px; max-width: 58ch; color: #e8ecfb; margin-bottom: 30px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; font: inherit; font-weight: 700; font-size: 15px;
  padding: 13px 22px; border-radius: 12px; transition: .15s;
}
.btn-gold { background: var(--gold); color: #241c00; }
.btn-gold:hover { background: #ffc933; transform: translateY(-1px); }
.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.2); }

/* ---------- Sections ---------- */
section.block { max-width: 1180px; margin: 0 auto; padding: 56px 20px; }
.kicker {
  text-transform: uppercase; letter-spacing: 2px; font-size: 12px; font-weight: 700;
  color: var(--brand-2); margin-bottom: 10px;
}
h2.sec-title { font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -0.6px; margin-bottom: 10px; }
p.sec-sub { color: var(--muted); max-width: 70ch; margin-bottom: 28px; }

/* ---------- Cards grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: transparent; }
.card .icon { font-size: 30px; margin-bottom: 12px; }
.card h3 { font-size: 17px; margin-bottom: 6px; letter-spacing: -0.2px; }
.card p { font-size: 14px; color: var(--muted); }
.card .tag {
  display: inline-block; margin-top: 12px; font-size: 12px; font-weight: 700;
  color: var(--brand-2); background: #eef1fb; padding: 4px 10px; border-radius: 999px;
}
.card .accent {
  position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--c, var(--brand)), transparent);
}

/* nivel cards */
.nivel-card .grados { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.nivel-card .grado-chip {
  font-size: 12px; font-weight: 600; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px;
}

/* ---------- Materia / detail ---------- */
.materia-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 12px; cursor: pointer;
  display: flex; gap: 16px; align-items: flex-start; transition: .15s;
}
.materia-row:hover { border-color: var(--brand-2); box-shadow: var(--shadow-sm); }
.materia-row .icon { font-size: 26px; }
.materia-row h4 { font-size: 16px; margin-bottom: 4px; }
.materia-row p { font-size: 13.5px; color: var(--muted); }
.materia-row .temas { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.materia-row .tema {
  font-size: 11.5px; background: #f0eee6; color: #55503f; padding: 3px 8px; border-radius: 6px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px;
  transition: .15s;
}
.chip:hover { border-color: var(--brand-2); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 20, 40, 0.55);
  backdrop-filter: blur(4px); z-index: 100; display: none;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 20px; max-width: 780px; width: 100%;
  padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,0.3); position: relative;
}
.modal .close {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px;
  border-radius: 10px; border: none; background: var(--bg); cursor: pointer; font-size: 18px;
  color: var(--muted);
}
.modal h2 { font-size: 24px; letter-spacing: -0.5px; margin-bottom: 6px; }
.modal .muted { color: var(--muted); font-size: 14px; }
.modal h5 { margin: 22px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--brand-2); }
.modal ul { padding-left: 20px; }
.modal ul li { margin-bottom: 6px; font-size: 15px; }
.modal .panel7T {
  margin-top: 22px; background: #f3f7ff; border-left: 4px solid var(--brand-2);
  padding: 14px 16px; border-radius: 10px; font-size: 14px; color: #2a3a70;
}
.modal .panel7T b { color: var(--brand); }

/* ---------- Audiences ---------- */
.bloque {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; margin-bottom: 14px;
}
.bloque h4 { margin-bottom: 8px; font-size: 17px; color: var(--brand); }
.bloque p { font-size: 15px; color: #3a414d; }

/* ---------- Footer ---------- */
footer {
  background: #131a38; color: #cdd3ec; padding: 48px 20px 36px; margin-top: 30px;
}
.footer-inner { max-width: 1180px; margin: 0 auto; }
footer h4 { color: #fff; margin-bottom: 12px; font-size: 15px; }
footer p, footer li { font-size: 13.5px; color: #a7b0d4; }
footer ul { list-style: none; }
footer li { margin-bottom: 6px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; margin-bottom: 28px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
footer .legal { border-top: 1px solid #2a335c; padding-top: 20px; font-size: 12px; color: #7f89b8; }

.hidden { display: none !important; }
.back-link { margin-bottom: 18px; }
.back-link button { background: none; border: none; cursor: pointer; font: inherit; font-weight: 600; color: var(--brand-2); font-size: 14px; }

/* ---------- Unidades de estudio (acordeón por grado) ---------- */
#modalUnidades { margin-top: 8px; }
.grado-label {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--brand); margin: 20px 0 8px; padding-left: 2px;
}
details.unidad {
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px;
  background: var(--surface); overflow: hidden;
}
details.unidad > summary {
  cursor: pointer; padding: 14px 16px; font-weight: 700; font-size: 15px;
  list-style: none; display: flex; align-items: center; gap: 10px; user-select: none;
}
details.unidad > summary::-webkit-details-marker { display: none; }
details.unidad > summary::before { content: "▸"; color: var(--brand-2); transition: transform .15s; }
details.unidad[open] > summary::before { transform: rotate(90deg); }
details.unidad > summary:hover { background: #faf8f2; }
details.unidad .duracion {
  margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.unidad-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.unidad-body .intro { color: #3a414d; margin-bottom: 12px; font-size: 14.5px; }
.unidad-body h5 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--brand-2); }
.unidad-body h6 { font-size: 14.5px; margin: 14px 0 6px; color: var(--ink); }
.seccion p { font-size: 14.5px; color: #3a414d; margin-bottom: 8px; }
.ejemplos {
  background: #f6f3e8; border-left: 3px solid var(--gold); padding: 10px 14px;
  border-radius: 8px; margin: 10px 0; font-size: 14px;
}
.ejemplos ul { margin: 4px 0 0 18px; }
.ejemplos li { margin-bottom: 4px; }
ol.ejercicios { padding-left: 20px; }
ol.ejercicios li { margin-bottom: 10px; font-size: 14.5px; }
.ayuda { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.respuesta { display: block; font-size: 13px; color: #16a34a; font-weight: 600; margin-top: 3px; }
