/* TuAula.lat — app de estudio
   Concepto: el cuaderno cuadriculado (claro) y el tablero (oscuro), con resaltador aguamarina. */

:root {
  --paper: #f7f5ef;
  --paper-2: #efece3;
  --card: #ffffff;
  --ink: #0b2545;
  --ink-2: #3c4f6b;
  --ink-3: #6b7a90;
  --grid: rgba(11, 37, 69, 0.055);
  --line: rgba(11, 37, 69, 0.12);
  --teal: #0fa3a3;
  --teal-ink: #0a7c7c;
  --aqua: #5eead4;
  --mint: #b9f5e6;
  --green: #1e9e5a;
  --green-bg: #e3f6ea;
  --red: #d64545;
  --red-bg: #fde8e6;
  --gold: #f2a516;
  --shadow: 0 1px 0 rgba(11, 37, 69, 0.08), 0 8px 24px -12px rgba(11, 37, 69, 0.25);
  --radius: 16px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1a2c;
    --paper-2: #10233a;
    --card: #132a44;
    --ink: #eef4fa;
    --ink-2: #b9c7d8;
    --ink-3: #8597ad;
    --grid: rgba(255, 255, 255, 0.035);
    --line: rgba(255, 255, 255, 0.12);
    --teal: #2dd4bf;
    --teal-ink: #5eead4;
    --mint: rgba(45, 212, 191, 0.18);
    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.14);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.14);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.01em; }
p { margin: 0 0 .8em; }
a { color: var(--teal-ink); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--aqua); outline-offset: 2px; border-radius: 8px; }

.hl { background: linear-gradient(transparent 58%, var(--mint) 58%, var(--mint) 92%, transparent 92%); padding: 0 .1em; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--ink); letter-spacing: -0.02em; }
.logo b { color: var(--teal); font-weight: 700; }
.logo small { font-size: .7em; color: var(--ink-3); font-weight: 500; }
.chips { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-weight: 600; font-size: .85rem; font-family: var(--font-head);
}
.chip svg { width: 16px; height: 16px; }
.chip.flame { color: #e8590c; }
.chip.flame.off { color: var(--ink-3); }
.chip.xp { color: var(--teal-ink); }

/* ---------- Estructura ---------- */
main { max-width: 980px; margin: 0 auto; padding: 20px 16px 110px; }
.narrow { max-width: 560px; margin: 0 auto; }
.view-enter { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; text-decoration: none; color: var(--ink-3);
  font-size: .72rem; font-weight: 600;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--teal-ink); background: var(--mint); }
.tabbar .badge { position: absolute; transform: translate(12px, -4px); background: var(--red); color: #fff; border-radius: 999px; font-size: .62rem; padding: 0 5px; }
.tabbar a { position: relative; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 14px; border: 0;
  font-family: var(--font-head); font-weight: 600; font-size: 1rem;
  background: var(--ink); color: var(--paper);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
  text-decoration: none; transition: transform .08s ease, filter .15s ease;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn.primary { background: var(--teal); color: #fff; box-shadow: 0 3px 0 #087575; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn.small { padding: 8px 12px; font-size: .88rem; border-radius: 10px; }
.linkbtn { background: none; border: 0; color: var(--teal-ink); font-weight: 600; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.muted { color: var(--ink-3); }
.eyebrow { font-family: var(--font-head); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-ink); font-weight: 600; }

/* ---------- Inicio ---------- */
.hello { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 26px; }
.hello h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.goal { display: flex; align-items: center; gap: 14px; }
.goal .ring { width: 58px; height: 58px; flex: none; }
.continue { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-left: 6px solid var(--teal); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 12px; }
.section-title h2 { font-size: 1.25rem; }

.subjects { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.subject {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  text-decoration: none; color: var(--ink); padding: 16px; min-height: 170px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease; overflow: hidden;
}
.subject:hover { transform: translateY(-3px) rotate(-.3deg); }
.subject .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.subject .ico svg { width: 24px; height: 24px; }
.subject h3 { font-size: 1.08rem; margin: 4px 0 0; }
.subject .meta { font-size: .8rem; color: var(--ink-3); margin-top: auto; }
.bar { height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 99px; transition: width .4s ease; }
.subject.soon { opacity: .8; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); font-family: var(--font-head); letter-spacing: .02em; }
.tag.free { background: var(--green-bg); color: var(--green); }
.tag.pro { background: #fff4d6; color: #9a6400; }
@media (prefers-color-scheme: dark) { .tag.pro { background: rgba(242, 165, 22, .15); color: var(--gold); } }

/* ---------- Materia ---------- */
.subject-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.subject-head .ico { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; color: #fff; flex: none; }
.subject-head .ico svg { width: 34px; height: 34px; }
.unit { margin-bottom: 18px; }
.unit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.unit-head h3 { font-size: 1.05rem; margin: 0; }
.lessons { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lesson-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  text-decoration: none; color: var(--ink);
}
.lesson-row:hover { border-color: var(--teal); }
.lesson-row .dot { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid var(--line); font-family: var(--font-head); font-weight: 700; font-size: .85rem; }
.lesson-row.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.lesson-row.locked { opacity: .65; }
.lesson-row .t { flex: 1; }
.lesson-row .t small { display: block; color: var(--ink-3); }
.lesson-row svg { width: 18px; height: 18px; }

/* ---------- Lección ---------- */
.player { max-width: 600px; margin: 0 auto; }
.player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.player-top .bar { flex: 1; height: 12px; }
.player-top .bar > i { background: linear-gradient(90deg, var(--teal), var(--aqua)); }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.iconbtn svg { width: 18px; height: 18px; }

.concept { padding: 26px 22px; border-top: 6px solid var(--teal); }
.concept h2 { font-size: 1.5rem; }
.concept p { font-size: 1.08rem; color: var(--ink-2); }
.concept .counter { font-family: var(--font-head); color: var(--ink-3); font-size: .85rem; }

.q-type { font-family: var(--font-head); font-size: .78rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-ink); }
.q-prompt { font-size: 1.3rem; margin: 6px 0 14px; }
.q-context { background: var(--paper-2); border-left: 4px solid var(--aqua); padding: 12px 14px; border-radius: 0 12px 12px 0; margin-bottom: 14px; color: var(--ink-2); }

.options { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 14px 16px; border-radius: 14px;
  background: var(--card); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line);
  font-size: 1rem; transition: border-color .12s ease, background .12s ease;
}
.opt:hover:not(:disabled) { border-color: var(--teal); }
.opt.sel { border-color: var(--teal); background: var(--mint); }
.opt.ok { border-color: var(--green); background: var(--green-bg); }
.opt.bad { border-color: var(--red); background: var(--red-bg); }
.opt:disabled { cursor: default; }
.tf { grid-template-columns: 1fr 1fr; }
.tf .opt { text-align: center; font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; padding: 22px 10px; }

.sentence { font-size: 1.2rem; line-height: 2.2; margin-bottom: 18px; }
.slot { display: inline-block; min-width: 110px; border-bottom: 3px dashed var(--teal); text-align: center; padding: 0 8px; font-weight: 600; color: var(--teal-ink); }
.bank { display: flex; flex-wrap: wrap; gap: 10px; }
.word { padding: 10px 14px; border-radius: 12px; background: var(--card); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line); font-weight: 500; }
.word.used { visibility: hidden; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.match .opt { font-size: .92rem; padding: 12px; min-height: 56px; }
.match .opt.lock { border-color: var(--green); background: var(--green-bg); opacity: .75; }
.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.order-answer { min-height: 70px; border: 2px dashed var(--line); border-radius: 14px; padding: 10px; display: grid; gap: 8px; margin-bottom: 14px; counter-reset: step; }
.order-answer .word { text-align: left; counter-increment: step; display: flex; gap: 10px; }
.order-answer .word::before { content: counter(step); font-family: var(--font-head); font-weight: 700; color: var(--teal-ink); }
.order-pool { display: grid; gap: 8px; }
.order-pool .word { text-align: left; }

.flash { perspective: 1000px; cursor: pointer; margin-bottom: 16px; }
.flash-inner { position: relative; min-height: 220px; transition: transform .5s ease; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--card); }
.flash-face.front h2 { font-size: 1.7rem; }
.flash-face.back { transform: rotateY(180deg); background: var(--ink); color: var(--paper); font-size: 1.1rem; }
.flash-hint { font-size: .8rem; color: var(--ink-3); margin-top: 8px; }

.actions { position: sticky; bottom: 0; padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--paper) 30%); margin-top: 18px; }

.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border-top: 3px solid; animation: up .25s ease both;
}
.feedback .inner { max-width: 600px; margin: 0 auto; }
.feedback.ok { background: var(--green-bg); border-color: var(--green); }
.feedback.bad { background: var(--red-bg); border-color: var(--red); }
.feedback h3 { font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.feedback.ok h3 { color: var(--green); }
.feedback.bad h3 { color: var(--red); }
.feedback .explain { color: var(--ink); margin-bottom: 10px; }
.feedback .tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.feedback .tutor { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; max-height: 32vh; overflow: auto; }
.feedback .tutor .who { font-family: var(--font-head); font-weight: 700; font-size: .8rem; color: var(--teal-ink); display: flex; gap: 6px; align-items: center; }
.feedback, .feedback .btn { color-scheme: inherit; }
body.has-feedback main { padding-bottom: 320px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }

.result { text-align: center; padding: 30px 20px; }
.result .big { font-family: var(--font-head); font-size: 3.4rem; font-weight: 700; line-height: 1; color: var(--teal); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.stat { background: var(--paper-2); border-radius: 14px; padding: 12px 6px; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.4rem; }
.stat span { font-size: .78rem; color: var(--ink-3); }

/* ---------- Formularios ---------- */
.auth { max-width: 420px; margin: 4vh auto 0; }
.auth h1 { font-size: 1.9rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--mint); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .88rem; color: var(--ink-2); }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--teal); }
.error { color: var(--red); font-weight: 600; font-size: .9rem; min-height: 1.4em; margin: 10px 0; }

/* ---------- Premium ---------- */
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 18px 0; }
.plan { position: relative; display: flex; flex-direction: column; gap: 6px; }
.plan .price { font-family: var(--font-head); font-size: 2rem; font-weight: 700; }
.plan .price small { font-size: .9rem; color: var(--ink-3); font-weight: 500; }
.plan.featured { border: 2px solid var(--teal); }
.plan .ribbon { position: absolute; top: -12px; right: 14px; background: var(--teal); color: #fff; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; font-family: var(--font-head); }
.perks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.perks li { display: flex; gap: 10px; align-items: flex-start; }
.perks svg { width: 20px; height: 20px; color: var(--green); flex: none; margin-top: 2px; }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: rise .25s ease both; max-width: 90vw; }

.empty { text-align: center; padding: 40px 16px; }
.empty svg { width: 64px; height: 64px; color: var(--teal); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--teal); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  .hello { grid-template-columns: 1.4fr 1fr; align-items: end; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
