/* Aula — kit visual para lecciones y exámenes (solo modo claro). */
/* Tema: cuaderno de clase — hoja cuadriculada, tinta azul, resaltador amarillo, bolígrafo rojo. */
@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #f9fbfe;            /* papel */
  --grid: #e4ebf6;          /* cuadrícula */
  --margin-line: #f2b8b8;   /* margen rojo del cuaderno */
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --ink: #172036;           /* tinta */
  --muted: #56617a;
  --line: #d9e1ee;
  --accent: #1f4fd8;        /* bolígrafo azul */
  --accent-soft: #e6edfd;
  --sun: #ffe14d;           /* resaltador */
  --sun-soft: #fff6c2;
  --ok: #13804f;
  --ok-soft: #e1f4ea;
  --warn: #b26b00;
  --warn-soft: #fff0d4;
  --bad: #d22f2f;           /* bolígrafo rojo */
  --bad-soft: #fde6e6;
  --code-bg: #182033;
  --code-ink: #e6ebf5;
  --radius: 8px;
  --shadow: 0 1px 0 #d6deeb, 0 14px 28px -20px rgba(23, 32, 54, .45);
  --font-head: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  color: var(--ink);
  font: 17px/1.6 var(--font-body);
}
::selection { background: var(--sun); color: var(--ink); }
/* Marca de resaltador reutilizable */
.mark-hl {
  background: linear-gradient(transparent 52%, var(--sun) 52%, var(--sun) 90%, transparent 90%);
  padding: 0 .1em;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; letter-spacing: -.01em; }
a { color: var(--accent); }
code, kbd, pre { font-family: var(--font-code); }
:not(pre) > code {
  background: var(--accent-soft);
  color: #1d3f94;
  padding: .08em .38em;
  border-radius: 6px;
  font-size: .9em;
}

/* ---------- Barra superior de la actividad ---------- */
.aula-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.aula-bar a.back { text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.aula-bar a.back:hover { color: var(--accent); }
.aula-bar .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aula-bar .score { font-family: var(--font-head); font-weight: 800; font-size: 17px; white-space: nowrap; color: var(--accent); }
.aula-bar .score small { font-weight: 500; color: var(--muted); font-size: 14px; }
.aula-bar .due { color: var(--muted); white-space: nowrap; }
.aula-bar .due.late { color: var(--bad); font-weight: 700; }
@media (max-width: 760px) { .aula-bar .due { display: none; } }
@media (max-width: 520px) { .aula-bar .squares { display: none; } .aula-bar .title { font-size: 14px; } }

/* Cuadritos: un cuadro por ejercicio, se rellena con resaltador al completarlo. */
.squares { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }
.squares i {
  width: 12px; height: 12px; border: 1.5px solid #9fb0cc; border-radius: 2px; background: #fff;
  transition: background .3s ease, border-color .3s ease;
}
.squares i.half { background: linear-gradient(135deg, var(--sun) 50%, #fff 50%); border-color: #c9a800; }
.squares i.full { background: var(--sun); border-color: #c9a800; }
.squares.big i { width: 18px; height: 18px; border-radius: 3px; }

/* ---------- Ejercicio de código ---------- */
.aula-code, .aula-quiz, .aula-answer {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 4px 4px 0 var(--ink);
  margin: 32px 0;
  overflow: hidden;
}
.ax-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--surface-2);
}
.ax-head .ax-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; flex: 1; min-width: 180px; }
.ax-pill {
  font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: #eef0f4; color: var(--muted); white-space: nowrap;
}
.ax-pill.pts { background: var(--sun-soft); color: #7a5d00; }
.ax-pill.done { background: var(--ok-soft); color: var(--ok); }
.ax-pill.partial { background: var(--warn-soft); color: var(--warn); }
.ax-pill.practice { background: var(--accent-soft); color: var(--accent); }
.ax-body { padding: 14px 16px 16px; }
.ax-body > .ax-prompt { margin: 0 0 12px; }
.ax-body > .ax-prompt > :first-child { margin-top: 0; }
.ax-body > .ax-prompt > :last-child { margin-bottom: 0; }

.ax-editor { border-radius: 10px; overflow: hidden; border: 1px solid #2b3347; }
.ax-editor textarea.ax-plain {
  width: 100%; min-height: 140px; border: 0; resize: vertical; display: block;
  background: var(--code-bg); color: var(--code-ink);
  font: 15px/1.55 var(--font-code); padding: 12px 14px; tab-size: 4;
}
.ax-editor .CodeMirror { height: auto; min-height: 120px; font: 15px/1.55 var(--font-code); padding: 6px 0; }
.ax-editor .CodeMirror-scroll { min-height: 120px; max-height: 480px; }

.ax-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.ax-btn {
  font: 600 15px var(--font-body);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 16px; border-radius: 10px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.ax-btn:hover { background: #f3f1ec; }
.ax-btn:active { transform: translateY(1px); }
.ax-btn:disabled { opacity: .55; cursor: progress; }
.ax-btn.run { background: var(--ink); color: #fff; border-color: var(--ink); }
.ax-btn { border-radius: 6px; border-width: 1.5px; }
.ax-btn.run:hover { background: #2b3550; }
.ax-btn.submit { background: var(--accent); color: #fff; border-color: var(--ink); }
.ax-btn.submit:hover { background: #2350ba; }
.ax-hint { color: var(--muted); font-size: 13px; margin-left: auto; }
@media (max-width: 640px), (pointer: coarse) { .ax-hint { display: none; } }

.ax-console {
  margin-top: 12px; border-radius: 10px;
  background: #11151f; color: #dfe6f3;
  font: 14px/1.5 var(--font-code);
  padding: 10px 14px; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto;
}
.ax-console:empty { display: none; }
.ax-console .err { color: #ff9b9b; }
.ax-console .sys { color: #8b96ad; font-style: italic; }

.ax-feedback {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid; white-space: pre-wrap; font-size: 15px;
}
.ax-feedback:empty { display: none; }
.ax-feedback.ok { background: var(--ok-soft); border-color: #b5e2cb; color: #135e3b; }
.ax-feedback.partial { background: var(--warn-soft); border-color: #f0d49a; color: #7a4c00; }
.ax-feedback.bad { background: var(--bad-soft); border-color: #f3b9b9; color: #8c2424; }
.ax-feedback.info { background: var(--accent-soft); border-color: #c5d4f7; color: #1d3f94; }

/* ---------- Pregunta de opción ---------- */
.ax-options { display: grid; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.ax-option {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  font: 500 16px/1.45 var(--font-body); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.ax-option:hover { border-color: #b9c6ea; background: #f8faff; }
.ax-option .mark {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font: 700 13px var(--font-head);
  background: #eef0f4; color: var(--muted);
}
.ax-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ax-option[aria-pressed="true"] .mark { background: var(--accent); color: #fff; }
.ax-option.right { border-color: var(--ok); background: var(--ok-soft); }
.ax-option.wrong { border-color: var(--bad); background: var(--bad-soft); }

.ax-input {
  width: 100%; font: 16px var(--font-body); padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.ax-input:focus, .ax-option:focus-visible, .ax-btn:focus-visible { outline: 3px solid #b9cbf5; outline-offset: 1px; }

/* ---------- Toast y confeti ---------- */
.aula-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-weight: 600; box-shadow: var(--shadow); opacity: 0; transition: all .25s ease; z-index: 100;
  max-width: calc(100vw - 32px);
}
.aula-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.aula-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; }

/* ---------- Lección por partes ---------- */
/* Mientras carga el JS solo se ve la primera parte; luego manda el atributo hidden. */
body:not(.aula-stepped) .aula-step ~ .aula-step { display: none; }
.aula-step[hidden] { display: none !important; }
.aula-step { scroll-margin-top: 120px; }

.aula-stephead {
  position: sticky; top: 49px; z-index: 40;
  background: rgba(249, 251, 254, .96); backdrop-filter: blur(6px);
  border-bottom: 1.5px solid var(--ink); padding: 8px 18px 10px;
}
.aula-stephead .sh-row { display: flex; align-items: baseline; gap: 10px; max-width: 1100px; margin: 0 auto; }
.aula-stephead .sh-count { font: 800 15px var(--font-head); color: var(--accent); white-space: nowrap; }
.aula-stephead .sh-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aula-stephead .sh-segs { display: flex; gap: 3px; max-width: 1100px; margin: 8px auto 0; }
.aula-stephead .seg {
  flex: 1; height: 9px; min-width: 6px; padding: 0; border: 1.5px solid #9fb0cc; border-radius: 2px;
  background: #fff; cursor: pointer;
}
.aula-stephead .seg.done { background: var(--sun); border-color: #c9a800; }
.aula-stephead .seg.current { background: var(--accent); border-color: var(--accent); }
.aula-stephead .seg.locked { background: #eef1f6; border-color: #d3dae6; cursor: not-allowed; }
.sh-menu { position: relative; }
.sh-menu summary {
  list-style: none; cursor: pointer; font: 700 14px var(--font-body); white-space: nowrap;
  border: 1.5px solid var(--ink); border-radius: 6px; padding: 4px 10px; background: var(--surface);
}
.sh-menu summary::-webkit-details-marker { display: none; }
.sh-menu[open] summary { background: var(--sun-soft); }
.sh-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; margin: 0; padding: 6px;
  list-style: none; width: min(360px, 88vw); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1.5px solid var(--ink); border-radius: 6px; box-shadow: 4px 4px 0 var(--ink);
}
.sh-item {
  display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: left; padding: 7px 8px;
  border: 0; background: none; border-radius: 4px; font: 15px var(--font-body); color: var(--ink); cursor: pointer;
}
.sh-item:hover:not(:disabled) { background: var(--accent-soft); }
.sh-item .ic { width: 18px; flex: none; text-align: center; }
.sh-item .n { color: var(--muted); width: 26px; flex: none; }
.sh-item.done .ic { color: var(--ok); font-weight: 700; }
.sh-item.current { background: var(--sun-soft); font-weight: 700; }
.sh-item.current .ic { color: var(--accent); }
.sh-item.locked { color: #9aa4b6; cursor: not-allowed; }

.aula-stepnav {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 36px 0 8px; padding-top: 18px; border-top: 1.5px dashed #b9c6dc;
}
.aula-stepnav .grow { flex: 1; }
.aula-stepnav .next {
  display: inline-grid; text-align: left; padding: 10px 18px; font-size: 16px; box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none; max-width: 100%;
}
.aula-stepnav .next small { font-weight: 400; font-size: 13px; opacity: .85; }
.aula-stepnav .next:active { transform: translate(3px, 3px); box-shadow: none; }
@media (max-width: 560px) {
  .aula-stephead { top: 45px; padding: 6px 12px 8px; }
  .aula-stepnav .next { width: 100%; }
  .aula-stepnav .prev { order: 3; }
}

.aula-finish {
  max-width: 760px; margin: 40px auto; background: var(--surface); border: 1.5px solid var(--ink);
  border-radius: 4px; box-shadow: 6px 6px 0 var(--ink); padding: 28px 30px;
}
.aula-finish h2 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 40px); }
.aula-finish .big { font-size: 19px; }
.aula-finish ul { padding-left: 20px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: 700 16px var(--font-body); text-decoration: underline; cursor: pointer; }
