/* Frederick Institute — sistema de estilos. Mobile-first. Clases: docs/CONVENCIONES.md */
:root {
  --navy: #1b2a4a; --navy-2: #2a3d66; --red: #c8102e; --red-2: #a00d25;
  --gold: #e0a526; --cream: #f7f4ec; --teal: #2bb3a3; --yellow: #ffc93c;
  --ok: #1f8a4c; --ok-bg: #e5f5ec; --warn: #b26a00; --warn-bg: #fff3dc;
  --err: #b3261e; --err-bg: #fde8e6; --info: #1d5fa8; --info-bg: #e6f0fb;
  --text: #1d2433; --muted: #5d6677; --line: #dde1e8; --bg: #f4f6fa; --card: #fff;
  --radius: 12px; --shadow: 0 2px 10px rgba(27, 42, 74, .08);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--sans); color: var(--text); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
body.publico { background: #fff; }
main { flex: 1; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); } h2 { font-size: 1.4rem; } h3 { font-size: 1.12rem; }
a { color: var(--navy-2); }
a:hover { color: var(--red); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: .6rem 1rem; border-bottom: 4px solid var(--red); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.brand:hover { color: #fff; }
.nav-toggle { display: none; background: none; border: 2px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: .3rem .6rem; font-size: 1.1rem; cursor: pointer; }
.topbar nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .9rem; }
.topbar nav a { color: #fff; text-decoration: none; font-weight: 500; padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { border-bottom-color: var(--gold); color: #fff; }
.topbar nav a.btn { border: 0; padding: .4rem .9rem; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-block; }
  .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: .5rem 0; }
  .topbar nav.abierto { display: flex; }
  .topbar nav a, .topbar nav form { padding: .5rem 0; }
}

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1150px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; border: 1px solid var(--line); }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 460px; margin: 2rem auto; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 700px) and (max-width: 980px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.inline { display: inline; margin: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .text-right { text-align: right; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 2px dashed var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- Botones ---------- */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: var(--red); color: #fff; border: 0; border-radius: 999px; padding: .6rem 1.25rem; font: 600 1rem var(--sans); text-decoration: none; cursor: pointer; transition: background .15s, transform .1s; }
.btn:hover { background: var(--red-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .85rem; font-size: .875rem; }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.btn-ghost:hover { background: rgba(127,127,127,.12); color: inherit; }
.topbar .btn-ghost { color: #fff; }
.btn-danger { background: var(--err); } .btn-danger:hover { background: #8c1c16; }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #176b3a; }
.btn-navy { background: var(--navy); } .btn-navy:hover { background: var(--navy-2); }

/* ---------- Formularios ---------- */
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #c4cad6; border-radius: 8px; background: #fff; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--red); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); outline: 2px solid rgba(42,61,102,.2); }
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .93rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .9rem; }
.form legend { font-weight: 700; color: var(--navy); padding: 0 .4rem; }
.form-row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--cream); color: var(--navy); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table tbody tr:hover { background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.table-compact th, .table-compact td { padding: .4rem .55rem; }

/* ---------- Alertas y badges ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; margin: 0 0 1rem; border-left: 5px solid; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok); color: #124d2b; }
.alert-error { background: var(--err-bg); border-color: var(--err); color: #6e1712; }
.alert-info { background: var(--info-bg); border-color: var(--info); color: #133f70; }
.container > .alert:first-child, main > .alert { max-width: 1150px; margin: 1rem auto; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e8ebf1; color: var(--navy); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--err-bg); color: var(--err); }
.badge-ninos { background: #def6f3; color: #157468; }
.badge-adultos { background: #e6eaf4; color: var(--navy); }

/* ---------- Estadísticas / tabs ---------- */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: #fff; border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); border-top: 4px solid var(--navy); }
.stat:nth-child(2) { border-top-color: var(--red); } .stat:nth-child(3) { border-top-color: var(--gold); } .stat:nth-child(4) { border-top-color: var(--teal); }
.stat-num { display: block; font: 700 2rem/1.1 var(--serif); color: var(--navy); }
.stat-label { color: var(--muted); font-size: .9rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; border-bottom: 2px solid var(--line); margin-bottom: 1.2rem; }
.tabs a { padding: .55rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active, .tabs a:hover { color: var(--navy); border-bottom-color: var(--red); }

/* ---------- Footer ---------- */
.footer { background: var(--navy); color: #c9d1e3; text-align: center; padding: 1.2rem 1rem; font-size: .9rem; border-top: 4px solid var(--red); }
.footer p { margin: 0; }

/* ---------- Página pública ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; padding: clamp(2.5rem, 8vw, 5rem) 1rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; bottom: -60px; width: 260px; height: 260px; border-radius: 50%; border: 28px solid rgba(200,16,46,.35); }
.hero-inner { max-width: 1150px; margin: 0 auto; position: relative; z-index: 1; display: grid; gap: 2rem; align-items: center; }
@media (min-width: 820px) { .hero-inner { grid-template-columns: 1.4fr 1fr; } }
.hero h1 { color: #fff; font-size: clamp(2rem, 6vw, 3.2rem); margin-bottom: .3em; }
.hero .lema { font: italic 1.3rem var(--serif); color: var(--gold); margin: 0 0 1rem; }
.hero p { font-size: 1.1rem; color: #dfe5f2; max-width: 36em; }
.hero .row { margin-top: 1.5rem; }
.hero .btn-ghost { color: #fff; }
.hero-logo { justify-self: center; width: min(240px, 60vw); filter: drop-shadow(0 10px 25px rgba(0,0,0,.3)); }
.section { padding: clamp(2.5rem, 6vw, 4rem) 1rem; }
.section-inner { max-width: 1150px; margin: 0 auto; }
.section-alt { background: var(--cream); }
.section h2 { text-align: center; font-size: clamp(1.5rem, 4vw, 2rem); }
.section .intro { text-align: center; color: var(--muted); max-width: 40em; margin: 0 auto 2rem; }
.curso-card { border-top: 6px solid var(--navy); height: 100%; }
.curso-card.ninos { border-top-color: var(--teal); }
.curso-card.teens { border-top-color: var(--gold); }
.curso-card.adultos { border-top-color: var(--red); }
.curso-card .icono { font-size: 2.2rem; line-height: 1; margin-bottom: .5rem; }
.curso-card ul { padding-left: 1.1rem; margin: .5rem 0 0; color: var(--muted); }
.feature { text-align: center; padding: 1rem; }
.feature .icono { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 1.7rem; margin-bottom: .75rem; }
.feature:nth-child(2n) .icono { background: var(--red); }
.contacto-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; font-size: 1.05rem; }
.contacto-list li { display: flex; gap: .7rem; align-items: center; }
.cta { background: var(--red); color: #fff; text-align: center; }
.cta h2 { color: #fff; }

/* ---------- Login ---------- */
.login { margin-top: 3rem; border-top: 6px solid var(--red); }
.login h1 { text-align: center; }
.login .muted { text-align: center; }

/* ---------- Actividades / quiz ---------- */
.quiz { max-width: 820px; margin: 0 auto; }
.pregunta { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1rem; border-left: 5px solid var(--navy); }
.pregunta h3, .pregunta .enunciado { font-family: var(--sans); font-size: 1.08rem; color: var(--text); margin: 0 0 .8rem; }
.pregunta.ok { border-left-color: var(--ok); } .pregunta.mal { border-left-color: var(--err); }
.pregunta-num { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 .4rem; border-radius: 999px; background: var(--navy); color: #fff; font-weight: 700; margin-right: .5rem; font-size: .9rem; }
.opciones { display: grid; gap: .5rem; }
.opcion { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; font-weight: 500; }
.opcion:hover { border-color: var(--navy-2); }
.opcion:has(input:checked) { border-color: var(--navy); background: #eef1f8; }
.opcion.ok { border-color: var(--ok); background: var(--ok-bg); } .opcion.mal { border-color: var(--err); background: var(--err-bg); }
.hueco { display: inline-block; width: auto; min-width: 8ch; max-width: 100%; padding: .25rem .5rem; border: 0; border-bottom: 3px solid var(--navy); border-radius: 4px 4px 0 0; background: var(--cream); font-weight: 600; text-align: center; }

/* Unir pares */
.pares { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; }
.col-izq, .col-der { display: grid; gap: .5rem; align-content: start; }
.pares .item { width: 100%; padding: .7rem .8rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; font: 600 1rem var(--sans); cursor: pointer; text-align: center; transition: all .15s; }
.pares .item:hover { border-color: var(--navy-2); }
.pares .item.sel { border-color: var(--gold); background: #fff6df; box-shadow: 0 0 0 3px rgba(224,165,38,.3); }
.pares .item.ok { border-color: var(--ok); background: var(--ok-bg); }
.pares .item.mal { border-color: var(--err); background: var(--err-bg); }
.pares .item[data-par] { border-color: var(--navy-2); background: #eef1f8; }

/* Ordenar palabras */
.palabras { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 3rem; }
.chip { padding: .5rem .95rem; border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy); font: 600 1rem var(--sans); cursor: pointer; transition: transform .1s, background .15s; }
.chip:hover { background: #eef1f8; } .chip:active { transform: scale(.96); }
.chip:disabled, .chip.usada { opacity: .3; cursor: default; }
.oracion-armada { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 3.4rem; padding: .6rem; margin-bottom: .8rem; border: 2px dashed #b9c1d1; border-radius: 12px; background: var(--cream); align-items: center; }
.oracion-armada .chip { background: var(--navy); color: #fff; }

/* Memotest */
.memotest { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .6rem; perspective: 800px; }
.carta { position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; cursor: pointer; transform-style: preserve-3d; transition: transform .4s; font: 700 1rem var(--sans); }
.carta::before, .carta .frente, .carta .dorso { position: absolute; inset: 0; border-radius: 12px; display: grid; place-items: center; backface-visibility: hidden; padding: .4rem; text-align: center; }
.carta::before { content: "F"; font: 700 2.2rem var(--serif); color: #fff; background: var(--navy); border: 3px solid var(--gold); background-image: repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.05) 10px 20px); }
.carta .frente, .carta > span { position: absolute; inset: 0; border-radius: 12px; display: grid; place-items: center; padding: .4rem; background: #fff; border: 3px solid var(--navy); color: var(--navy); transform: rotateY(180deg); backface-visibility: hidden; word-break: break-word; }
.carta.volteada, .carta.encontrada { transform: rotateY(180deg); }
.carta.encontrada { cursor: default; }
.carta.encontrada .frente, .carta.encontrada > span { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }

/* Resultados */
.resultado-box { text-align: center; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem 1rem; margin-bottom: 1.25rem; }
.puntaje { display: inline-block; font: 700 3.2rem/1 var(--serif); color: var(--navy); }
.puntaje.puntaje-sm, .table .puntaje { font-size: 1rem; }
.puntaje-alto { color: var(--ok); } .puntaje-medio { color: var(--warn); } .puntaje-bajo { color: var(--err); }
.progress { height: 12px; background: #e3e7ef; border-radius: 999px; overflow: hidden; margin: .6rem 0 1rem; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--navy-2)); border-radius: 999px; transition: width .3s; }

/* Editor de actividades */
.editor { display: grid; gap: 1rem; }
.editor-pregunta { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--gold); border-radius: var(--radius); padding: 1rem; display: grid; gap: .7rem; }
.editor-pregunta .form-row { align-items: start; }
.editor-tools { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.editor-tools .spacer { flex: 1; }

/* ---------- Panel del alumno: más colorido ---------- */
body.rol-alumno { background: #f0f7fb; }
body.rol-alumno .topbar { background: linear-gradient(90deg, var(--navy), #22507a); }
body.rol-alumno .btn { padding: .75rem 1.5rem; font-size: 1.05rem; }
body.rol-alumno .btn-sm { padding: .45rem 1rem; font-size: .95rem; }
body.rol-alumno .card { border-radius: 18px; }
body.rol-alumno .card:nth-of-type(4n+1) { border-top: 5px solid var(--teal); }
body.rol-alumno .card:nth-of-type(4n+2) { border-top: 5px solid var(--yellow); }
body.rol-alumno .card:nth-of-type(4n+3) { border-top: 5px solid var(--red); }
body.rol-alumno .card:nth-of-type(4n+4) { border-top: 5px solid var(--navy-2); }
body.rol-alumno .pregunta { border-radius: 18px; border-left-color: var(--teal); }
body.rol-alumno .pregunta-num { background: var(--teal); }

/* ---------- Impresión ---------- */
@media print {
  .topbar, .footer, .btn, form, .tabs, .nav-toggle { display: none !important; }
  body, .card, .table-wrap { background: #fff; box-shadow: none; border: 0; }
  .table th { background: #eee; color: #000; }
  .container { max-width: none; padding: 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
