/* Puente · estilo "cuaderno de comunicaciones" */
@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=Patrick+Hand&display=swap");

:root {
  --papel: #fbf7ee;
  --hoja: #fffdf8;
  --renglon: #dfe8ef;
  --margen: #e6a5a0;
  --pizarron: #2f4a3e;
  --pizarron-2: #263d33;
  --tiza: #f4f1e8;
  --madera: #8b5e3c;
  --tinta: #23364f;
  --lapiz: #f2b632;
  --ok: #3e7d4f;
  --warn: #c98200;
  --warn-txt: #8a5a00; /* el ámbar como texto necesita más contraste */
  --bad: #b5442e;
  --gris: #5d6168; /* AA (≥4.5:1) también sobre las pestañas y fondos crema */
  --borde: #e6dfcf;
  --mano: "Patrick Hand", "Comic Sans MS", cursive;
  --texto: "Atkinson Hyperlegible", system-ui, sans-serif;
  /* Escala de espacios y foco común */
  --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e5: 24px; --e6: 32px;
  --toque: 44px;
  --foco: 0 0 0 3px var(--hoja), 0 0 0 6px var(--tinta);
  --radio: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--texto); font-size: 16px; line-height: 1.5; color: var(--tinta);
  background-color: var(--papel);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--renglon) 31px 32px);
}

/* Pizarrón */
header {
  position: relative; color: var(--tiza); padding: 18px 20px 16px;
  background: radial-gradient(120% 140% at 20% 0%, #3a5a4c 0%, var(--pizarron) 45%, var(--pizarron-2) 100%);
  border-bottom: 8px solid var(--madera);
  box-shadow: inset 0 -2px 0 #6f4a2e, 0 2px 0 #00000014;
}
header h1 { font-family: var(--mano); font-weight: 400; font-size: 34px; line-height: 1; margin: 0; letter-spacing: .5px; text-shadow: 0 0 1px #fff6, 0 0 6px #ffffff22; }
header .bajada { font-family: var(--mano); font-size: 18px; opacity: .85; margin-top: 4px; }
header .tiza { position: absolute; right: 18px; bottom: -6px; width: 46px; height: 9px; border-radius: 3px; background: #f7f4ec; box-shadow: 54px 1px 0 -1px #f2b6b0, 0 1px 1px #0003; }

/* Pestañas de carpeta */
nav { display: flex; gap: 6px; padding: 14px 12px 0; max-width: 820px; margin: 0 auto; overflow-x: auto; }
nav button {
  flex: 1; min-width: 92px; padding: 10px 12px 9px; border: 1px solid var(--borde); border-bottom: 0;
  border-radius: 10px 10px 0 0; background: #f3ecdc; color: var(--gris);
  font-family: var(--texto); font-size: 15px; font-weight: 700; cursor: pointer; position: relative; top: 1px;
  box-shadow: inset 0 4px 0 var(--tab, var(--lapiz));
}
nav button[data-s="docente"] { --tab: var(--lapiz); }
nav button[data-s="alumno"] { --tab: #7fb3d5; }
nav button[data-s="familia"] { --tab: #e8998d; }
nav button[data-s="progreso"] { --tab: #8fbf8a; }
nav button.on { background: var(--hoja); color: var(--tinta); z-index: 2; padding-top: 12px; top: 1px; }

main { max-width: 820px; margin: 0 auto; padding: 0 12px 24px; }
.pagina { background: var(--hoja); border: 1px solid var(--borde); border-radius: 0 0 14px 14px; padding: 18px 16px 8px 34px; position: relative; min-height: 60vh; box-shadow: 0 1px 2px #0000000d, 0 8px 24px -16px #5a4a2a40; }
.pagina::before { content: ""; position: absolute; left: 18px; top: 0; bottom: 0; width: 2px; background: var(--margen); opacity: .75; }
section { display: none; } section.on { display: block; }

h2, .titulo { font-family: var(--mano); font-weight: 400; font-size: 26px; line-height: 1.15; margin: 4px 0 10px; color: var(--tinta); }
h3 { font-size: 17px; margin: 0 0 8px; }
label { display: block; font-weight: 700; font-size: 14px; margin: 10px 0 4px; }

.card { background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card > b:first-child, .card .rotulo { display: block; font-family: var(--mano); font-size: 22px; font-weight: 400; margin-bottom: 6px; }
.cinta { position: relative; }
.cinta::before { content: ""; position: absolute; top: -10px; left: 50%; width: 96px; height: 20px; transform: translateX(-50%) rotate(-2deg); background: #f2e3a8cc; border-left: 2px dotted #0001; border-right: 2px dotted #0001; }

select, textarea, input {
  width: 100%; font-family: var(--texto); font-size: 16px; color: var(--tinta);
  padding: 10px 12px; border: 1.5px solid #d6cdb8; border-radius: 10px; background: #fffef9;
}
select:focus, textarea:focus, input:focus { outline: 3px solid #f2b63266; border-color: var(--lapiz); }
textarea { min-height: 120px; line-height: 32px; background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--renglon) 31px 32px); background-attachment: local; padding-top: 4px; }

.big {
  display: block; width: 100%; padding: 14px; margin-top: 10px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--pizarron); color: var(--tiza); font-family: var(--texto); font-size: 17px; font-weight: 700;
  box-shadow: 0 3px 0 var(--pizarron-2);
}
.big:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--pizarron-2); }
.big:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.big.alt { background: #fff; color: var(--tinta); border: 1.5px solid var(--tinta); box-shadow: 0 3px 0 #23364f33; }
.big.chico { font-size: 14px; padding: 10px; }
.big.rec { background: var(--bad); color: #fff; box-shadow: 0 3px 0 #7d2e1f; animation: pulso 1.2s infinite; }
.fila { display: flex; gap: 8px; } .fila .big { flex: 1; }
@keyframes pulso { 50% { opacity: .75; } }

/* Tarjetas de pictogramas */
.tira { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.picto {
  background: #fff; border: 2px solid #e2dccd; border-bottom-width: 8px; border-radius: 12px;
  padding: 10px 8px 8px; text-align: center; cursor: pointer; transition: transform .12s;
}
.picto:hover { transform: translateY(-2px) rotate(-.4deg); }
.picto img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.picto .t { font-weight: 700; font-size: 16px; margin-top: 6px; text-transform: uppercase; letter-spacing: .5px; }
.picto .h { color: var(--gris); font-size: 13px; }
.bien { border-bottom-color: var(--ok); } .regular { border-bottom-color: var(--warn); } .dificil { border-bottom-color: var(--bad); }
.picto.apoyo { border-style: dashed; border-color: var(--pizarron); border-bottom-style: solid; background: #f4f8f3; }
.picto.apoyo::before { content: "apoyo nuevo"; display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--pizarron); background: #dfeadb; padding: 1px 8px; border-radius: 10px; margin-bottom: 4px; }
.vacio { color: var(--gris); font-family: var(--mano); font-size: 20px; }

/* Notas */
.alerta, .logro, .hallazgo { padding: 10px 12px; border-radius: 8px; margin: 8px 0; border-left: 5px solid; }
.alerta { background: #fbefe9; border-color: var(--bad); }
.logro { background: #eef5ec; border-color: var(--ok); }
.hallazgo { background: #fdf6e1; border-color: var(--lapiz); }
.muted { color: var(--gris); font-size: 14px; }
pre { white-space: pre-wrap; font-family: var(--texto); background: #fdf9ef; border: 1px dashed #d6cdb8; padding: 12px; border-radius: 8px; font-size: 15px; }
.animo { display: flex; align-items: center; gap: 12px; }
.animo img { width: 64px; height: 64px; }
.animo b { font-family: var(--mano); font-size: 24px; font-weight: 400; text-transform: capitalize; }

/* Sellos de estado */
.sello { display: inline-block; padding: 1px 10px; border: 2px solid currentColor; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; transform: rotate(-2deg); color: var(--gris); }
.sello.avanzando { color: var(--ok); } .sello.estancado, .sello.retroceso { color: var(--bad); } .sello.estable { color: var(--warn-txt); }
.ppi { padding: 10px 0; border-bottom: 1px dashed var(--borde); }
.ppi:last-child { border-bottom: 0; }
.estr { padding: 12px; border: 1px solid var(--borde); border-radius: 10px; margin: 8px 0; background: #fffef9; }
.estr a { font-size: 13px; color: var(--tinta); }
.titular { font-family: var(--mano); font-size: 26px; line-height: 1.2; }

/* Traza del agente */
.traza { font-size: 14px; }
.paso { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--renglon); animation: entra .35s ease; }
.paso .n { width: 22px; height: 22px; border-radius: 50%; background: var(--pizarron); color: var(--tiza); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.paso b { color: var(--tinta); } .paso .r { color: var(--gris); word-break: break-word; font-size: 13px; }
@keyframes entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--borde); border-top-color: var(--pizarron); border-radius: 50%; animation: gira .8s linear infinite; vertical-align: -2px; }
@keyframes gira { to { transform: rotate(360deg); } }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; float: right; color: var(--gris); font-weight: 700; }
details[open] summary::after { content: "\2212"; }
.hist { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--renglon); cursor: pointer; }
.hist img { width: 28px; height: 28px; }
.etiqueta { font-size: 12px; font-weight: 700; color: var(--bad); }

footer { text-align: center; font-size: 12px; color: var(--gris); padding: 18px; }
footer a { color: var(--gris); }

/* Celular */
@media (max-width: 520px) {
  header { padding: 14px 16px 12px; }
  header h1 { font-size: 30px; }
  header .bajada { font-size: 16px; }
  nav { gap: 4px; padding: 10px 8px 0; }
  nav button { min-width: 0; padding: 9px 4px 8px; font-size: 14px; }
  nav button.on { padding-top: 11px; }
  main { padding: 0 8px 20px; }
  .pagina { padding: 14px 10px 6px 24px; }
  .pagina::before { left: 12px; }
  .card { padding: 14px 12px; }
  .tira { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .picto .t { font-size: 14px; }
  .fila { flex-direction: column; gap: 0; }
  .m { max-width: 92%; }
  .sug button { padding: 8px 12px; }
  .titular { font-size: 22px; }
}

/* Pantalla de PIN */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: #2f4a3ef2; }
.gate[hidden] { display: none; }
/* El atributo hidden tiene que ganarle a .big, .fila, .cuenta-n… (si no, se ven botones ocultos como «Borrar alumno»). */
[hidden] { display: none !important; }
.gate .card { width: 100%; max-width: 380px; }
.gate form { display: flex; gap: 8px; } .gate form .big { width: auto; margin: 0; padding: 0 18px; }

/* Autocompletar de escuelas (escuelas.js) */
.ac { position: relative; }
.ac-lista { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; max-height: 320px; overflow-y: auto;
  background: #fff; border: 1.5px solid var(--lapiz); border-radius: 10px; box-shadow: 0 10px 24px -12px #5a4a2a66; }
.ac-lista li { padding: 8px 12px; cursor: pointer; line-height: 1.3; border-bottom: 1px solid var(--renglon); }
.ac-lista li:last-child { border-bottom: 0; }
.ac-lista li[aria-selected="true"], .ac-lista li:hover { background: #fdf6e1; }
.ac-lista li[aria-selected="true"] { outline: 2px solid var(--lapiz); outline-offset: -2px; }
.ac-nombre { font-weight: 700; }
.ac-det { display: block; font-size: 13px; color: var(--gris); }
.ac-esp { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--pizarron); background: #dfeadb; padding: 0 8px; border-radius: 10px; }
.ac-estado { font-size: 13px; color: var(--gris); min-height: 0; margin-top: 2px; }
.ac-estado:empty { display: none; }
.ac-elegida { font-size: 13px; color: var(--ok); margin-top: 4px; }
.ac-elegida .enlace { background: none; border: 0; padding: 0; color: var(--tinta); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; margin-left: 4px; }

/* ---------- Pie común (pie.js): BETA, legales, ARASAAC, comentarios y donaciones ---------- */
.pie-puente { margin-top: 10px; font-size: 13px; }
.pie-puente p { margin: 6px 0; }
.pie-puente .beta { display: inline-block; background: var(--lapiz); color: var(--tinta); font-weight: 700; font-size: 11px; letter-spacing: .5px; padding: 1px 7px; border-radius: 10px; margin-right: 4px; }
.pie-puente .pie-arasaac { color: var(--gris); }
.pie-fb-form { max-width: 520px; margin: 8px auto; text-align: left; }
.pie-fb-form textarea { min-height: 70px; }
.pie-don { margin: 10px auto 4px; max-width: 620px; }
.pie-don-txt { color: var(--gris); }
.pie-don-botones { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: center; align-items: flex-start; }
.pie-don-item { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 260px; }
.pie-don-en { color: var(--gris); font-size: 12px; }
.boton-don { display: inline-block; border: 1.5px solid var(--tinta); color: var(--tinta); background: #fff; border-radius: 20px; padding: 4px 14px; font-weight: 700; text-decoration: none; font-size: 13px; }
.boton-don:hover, .boton-don:focus-visible { background: var(--tinta); color: var(--tiza); }
table.tabla { border-collapse: collapse; width: 100%; font-size: 13px; }
table.tabla th, table.tabla td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px dashed var(--borde); vertical-align: top; }
/* Páginas legales */
.legal { max-width: 760px; }
.legal h3 { font-family: var(--mano); font-weight: 400; font-size: 22px; margin: 18px 0 4px; }
.borrador { background: #fff4d6; border: 1.5px dashed var(--warn); border-radius: 10px; padding: 10px 12px; margin: 8px 0 14px; }
.pie-puente .enlace { background: none; border: 0; padding: 0; color: var(--tinta); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
body.modo-familia .pie-don { display: none !important; }

/* ---------- Pulido general (consistencia, estados, foco, táctil, movimiento) ---------- */
html { scroll-padding-top: 12px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
a { color: var(--tinta); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h3 { line-height: 1.3; }
.muted a, .chiquito a { color: var(--tinta); }
img { max-width: 100%; }

/* Saltar al contenido (teclado / lector de pantalla) */
.saltar { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--lapiz); color: var(--tinta); font-weight: 700; padding: 10px 14px; border-radius: 0 0 10px 10px; text-decoration: none; }
.saltar:focus { top: 0; }

/* Foco visible y consistente en todo lo que se puede tocar con teclado */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--tinta); outline-offset: 2px; box-shadow: 0 0 0 6px #f2b63299; }
select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--tinta); outline-offset: 1px; box-shadow: none; }
header :focus-visible, .gate :focus-visible { outline-color: var(--lapiz); }
select:focus, textarea:focus, input:focus { border-color: var(--tinta); }
input::placeholder, textarea::placeholder { color: #767a80; }

/* Formularios: errores visibles, campos inválidos marcados después de tocarlos */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"],
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--bad); background-color: #fff8f5; }
.error { color: var(--bad); font-weight: 700; }
.error:not(:empty)::before { content: "⚠ "; }
.ok { color: var(--ok); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--pizarron); flex: none; margin: 0; }
.check { min-height: var(--toque); cursor: pointer; }
textarea.corto { min-height: 64px; }
input:disabled, select:disabled, textarea:disabled { background: #f3efe5; color: var(--gris); cursor: not-allowed; }

/* Botones: tamaño táctil, hover, presionado, deshabilitado y cargando */
.big { min-height: var(--toque); line-height: 1.25; text-align: center; text-decoration: none; position: relative;
  transition: background-color .15s, box-shadow .15s, transform .1s, filter .15s; -webkit-tap-highlight-color: transparent; }
a.big { display: flex; align-items: center; justify-content: center; }
.big:hover:not(:disabled) { filter: brightness(1.12); }
.big.alt:hover:not(:disabled) { filter: none; background: #f4f7f5; }
.big.alt:disabled { background: #fff; }
.big:disabled { opacity: .55; filter: grayscale(.3); box-shadow: none; }
.big.chico { min-height: var(--toque); }
.big.auto { width: auto; margin: 0; padding: 0 16px; }
.big.peligro, .big.alt.peligro { color: var(--bad); border-color: var(--bad); }
.big.alt.peligro:hover:not(:disabled) { background: #fbefe9; }
.big[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.big[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: var(--tiza) var(--tiza) transparent transparent; animation: gira .8s linear infinite; }
.big.alt[aria-busy="true"]::after { border-color: var(--tinta) var(--tinta) transparent transparent; }
.enlace { min-height: 32px; border-radius: 4px; }
.quitar { min-width: 36px; min-height: 36px; border-radius: 8px; }
.quitar:hover { background: #fbefe9; }
.quitar.txt { font-size: 14px; font-weight: 700; }
.boton-don { min-height: 40px; display: inline-flex; align-items: center; }
nav button { min-height: var(--toque); transition: background-color .15s, color .15s; }
nav button:hover:not(.on) { background: #f8f2e4; color: var(--tinta); }
.picto { transition: transform .12s, box-shadow .12s; }
.picto:active { transform: scale(.98); }
.ac-lista li { min-height: var(--toque); }
details > summary { min-height: 32px; }

/* Pestañas: en celular no se aprietan, se deslizan */
@media (max-width: 520px) {
  nav { scroll-snap-type: x proximity; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 1 0 auto; min-width: 0; padding: 9px 10px 8px; scroll-snap-align: start; }
  .big.auto { padding: 0 14px; }
  h2, .titulo { font-size: 24px; }
  .card > b:first-child, .card .rotulo { font-size: 21px; }
}
/* Pantallas muy angostas (360px) */
@media (max-width: 380px) {
  header h1 { font-size: 28px; }
  .pagina { padding-left: 20px; }
  .pagina::before { left: 10px; }
  .gate form { flex-direction: column; } .gate form .big { padding: 0 18px; }
}
/* Desktop ancho: un poco más de aire */
@media (min-width: 900px) {
  .pagina { padding: 24px 28px 14px 44px; }
  .pagina::before { left: 24px; }
}

/* Movimiento reducido: sin animaciones ni transiciones (el spinner queda, más lento) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spin, .big[aria-busy="true"]::after { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
  .picto:hover { transform: none; }
}
/* Alto contraste del sistema */
@media (forced-colors: active) { .big, nav button, .picto { border: 1px solid ButtonText; } }
main[tabindex="-1"]:focus, main[tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }
