/* Ruta B2 · IoTeXa — diseño oscuro comprometido */
:root {
  --bg: #0b1220;
  --bg2: #101a2e;
  --card: #16233c;
  --card2: #1c2c4a;
  --line: #263a5e;
  --text: #e8eefb;
  --muted: #93a5c4;
  --accent: #2dd4bf;       /* teal IoTeXa */
  --accent2: #38bdf8;      /* cian */
  --warn: #fbbf24;
  --ok: #34d399;
  --bad: #f87171;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.6; min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
.hidden { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-block; border: 0; border-radius: 10px;
  padding: .7rem 1.4rem; font-weight: 600; font-size: 1rem;
  transition: transform .12s, filter .12s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04121c; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; border-radius: 8px; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

/* ---------- Landing ---------- */
.landing header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem clamp(1rem, 5vw, 4rem); position: sticky; top: 0; z-index: 10;
  background: rgba(11,18,32,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04121c; font-weight: 900;
}
.brand small { color: var(--muted); font-weight: 500; }

.hero {
  padding: clamp(3rem, 9vw, 6.5rem) clamp(1rem, 5vw, 4rem) 3rem;
  max-width: 1100px; margin: 0 auto; text-align: center;
}
.hero .tag {
  display: inline-block; padding: .3rem .9rem; border-radius: 999px; font-size: .85rem;
  border: 1px solid var(--line); color: var(--accent); background: var(--bg2); margin-bottom: 1.2rem;
}
.hero h1 {
  font-size: clamp(2rem, 5.5vw, 3.4rem); line-height: 1.15; font-weight: 800; letter-spacing: -.02em;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { max-width: 640px; margin: 1.2rem auto 2rem; color: var(--muted); font-size: 1.12rem; }
.hero .cta { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }

.stats-row {
  display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;
  margin-top: 2.6rem;
}
.stat-pill {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.4rem; min-width: 140px;
}
.stat-pill b { display: block; font-size: 1.4rem; color: var(--accent); }
.stat-pill span { color: var(--muted); font-size: .85rem; }

.section { max-width: 1100px; margin: 0 auto; padding: 3rem clamp(1rem, 5vw, 4rem); }
.section h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin-bottom: .5rem; letter-spacing: -.01em; }
.section > p.sub { color: var(--muted); max-width: 640px; margin-bottom: 2rem; }

.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.1rem; }
.feature {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; transition: border-color .15s;
}
.feature:hover { border-color: var(--accent); }
.feature .ico { font-size: 1.7rem; margin-bottom: .6rem; }
.feature h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.feature p { color: var(--muted); font-size: .93rem; }

/* Timeline de fases en la landing */
.timeline { display: grid; gap: .8rem; }
.tl-item {
  display: grid; grid-template-columns: 90px 1fr; gap: 1rem; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem;
}
.tl-item .mes {
  font-weight: 800; color: var(--accent); font-size: .95rem; padding-top: .1rem;
}
.tl-item h4 { font-size: 1rem; }
.tl-item p { color: var(--muted); font-size: .9rem; }

.landing footer {
  border-top: 1px solid var(--line); padding: 2rem clamp(1rem, 5vw, 4rem);
  color: var(--muted); font-size: .9rem; text-align: center;
}

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow);
}
.auth-card h2 { margin-bottom: .3rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.4rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .9rem; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.form-error { color: var(--bad); font-size: .9rem; min-height: 1.3rem; margin-bottom: .5rem; }
.auth-switch { margin-top: 1.2rem; text-align: center; font-size: .9rem; color: var(--muted); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--line); padding: 1.2rem .9rem;
  display: flex; flex-direction: column; gap: .2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { margin-bottom: 1.4rem; padding: 0 .5rem; }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 10px;
  color: var(--muted); font-weight: 500; font-size: .95rem;
}
.nav-link:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--card2); color: var(--accent); }
.sidebar .spacer { flex: 1; }
.userbox { padding: .8rem; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.userbox b { color: var(--text); display: block; }

.main { padding: clamp(1.2rem, 3vw, 2.4rem); max-width: 980px; width: 100%; }
.main h1.page { font-size: 1.6rem; margin-bottom: .3rem; letter-spacing: -.01em; }
.main p.page-sub { color: var(--muted); margin-bottom: 1.6rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem; margin-bottom: 1.1rem;
}
.card h3 { margin-bottom: .6rem; font-size: 1.05rem; }
.card .muted, .muted { color: var(--muted); }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .card { flex: 1; min-width: 240px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.kpi b { display: block; font-size: 1.55rem; color: var(--accent); line-height: 1.2; }
.kpi span { color: var(--muted); font-size: .82rem; }

/* Checklist del día */
.blocks { display: grid; gap: .6rem; }
.block-item {
  display: flex; align-items: center; gap: .9rem; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; cursor: pointer;
  transition: border-color .12s;
  -webkit-user-select: none; user-select: none;
}
.block-item:hover { border-color: var(--accent); }
.block-item.done { border-color: var(--ok); background: rgba(52,211,153,.08); }
.block-item .chk {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: .9rem; flex-shrink: 0;
}
.block-item.done .chk { background: var(--ok); border-color: var(--ok); color: #04121c; }
.block-item .bi-name { font-weight: 600; }
.block-item .bi-min { margin-left: auto; color: var(--muted); font-size: .85rem; white-space: nowrap; }

.progressbar { height: 10px; border-radius: 999px; background: var(--bg2); overflow: hidden; margin: .6rem 0 .3rem; }
.progressbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; border-radius: 999px; }

/* Plan / meses */
.month-card { border-left: 4px solid var(--line); }
.month-card.current { border-left-color: var(--accent); }
.month-card.done-month { border-left-color: var(--ok); }
.month-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.month-head .phase-tag { font-size: .78rem; color: var(--accent); border: 1px solid var(--line); padding: .15rem .6rem; border-radius: 999px; }
.month-head .lvl { color: var(--muted); font-size: .85rem; margin-left: auto; }
.gate { display: flex; gap: .7rem; align-items: center; padding: .45rem 0; cursor: pointer; -webkit-user-select: none; user-select: none; }
.gate .chk { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .75rem; flex-shrink: 0; }
.gate.done .chk { background: var(--ok); border-color: var(--ok); color: #04121c; }
.gate.done span { color: var(--muted); text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
.chip { background: var(--bg2); border: 1px solid var(--line); color: var(--muted); font-size: .82rem; padding: .25rem .7rem; border-radius: 999px; }

/* Vocabulario / SRS */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.flashcard {
  background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.2rem 1.6rem; text-align: center; min-height: 220px;
  display: flex; flex-direction: column; justify-content: center; gap: .7rem;
}
.flashcard .word { font-size: 1.9rem; font-weight: 800; }
.flashcard .trans { color: var(--accent); font-size: 1.15rem; }
.flashcard .ex { color: var(--muted); font-style: italic; }
.srs-btns { display: flex; gap: .7rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.srs-btns .again { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.srs-btns .hard  { background: transparent; border: 1px solid var(--warn); color: var(--warn); }
.srs-btns .good  { background: transparent; border: 1px solid var(--ok); color: var(--ok); }
.speak-btn {
  background: var(--bg2); border: 1px solid var(--line); color: var(--accent2);
  border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; margin: 0 auto;
}

/* Listening / shadowing */
.sh-sentence {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem;
}
.sh-sentence button { flex-shrink: 0; }
.sh-sentence.playing { border-color: var(--accent); }

/* Recorder */
.rec-controls { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; }
.rec-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
audio { width: 100%; margin-top: .6rem; }

/* Writing */
.writing-area textarea { min-height: 220px; resize: vertical; line-height: 1.7; }
.wordcount { text-align: right; color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.saved-text { border-left: 3px solid var(--accent); padding-left: 1rem; margin-bottom: 1rem; }
.saved-text .meta { color: var(--muted); font-size: .82rem; }
.saved-text pre { white-space: pre-wrap; font-family: inherit; margin-top: .3rem; }

/* Ranking */
table.rank { width: 100%; border-collapse: collapse; }
table.rank th, table.rank td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
table.rank th { color: var(--muted); font-weight: 600; font-size: .85rem; }
table.rank tr.me { background: rgba(45,212,191,.08); }

/* Toast */
#toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--accent); color: var(--text);
  padding: .7rem 1.4rem; border-radius: 999px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100; font-size: .92rem;
}
#toast.show { opacity: 1; }

/* ---------- Efectos de la landing ---------- */
.hero { position: relative; overflow: visible; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .35;
  pointer-events: none; z-index: -1;
}
.orb-a { width: 380px; height: 380px; background: var(--accent);  top: -80px;  left: -120px; animation: float-a 11s ease-in-out infinite; }
.orb-b { width: 320px; height: 320px; background: var(--accent2); top: 40px;   right: -100px; animation: float-b 13s ease-in-out infinite; }
.orb-c { width: 240px; height: 240px; background: #8b5cf6;        bottom: -60px; left: 40%;  animation: float-c 15s ease-in-out infinite; opacity: .22; }
@keyframes float-a { 50% { transform: translate(50px, 40px) scale(1.12); } }
@keyframes float-b { 50% { transform: translate(-45px, 55px) scale(.9); } }
@keyframes float-c { 50% { transform: translate(30px, -45px) scale(1.15); } }
.landing { overflow-x: hidden; }

.shimmer {
  font-style: normal;
  background: linear-gradient(110deg, var(--accent) 20%, #fff 40%, var(--accent2) 60%, var(--accent) 80%);
  background-size: 250% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 4.5s linear infinite;
}
@keyframes shimmer { to { background-position: -250% center; } }

.btn-lg { padding: .9rem 1.9rem; font-size: 1.08rem; border-radius: 12px; }
.btn.glow { position: relative; box-shadow: 0 0 26px rgba(45,212,191,.45); overflow: hidden; }
.btn.glow:hover { box-shadow: 0 0 42px rgba(45,212,191,.65); }
.btn.glow::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%);
  transform: translateX(-120%);
  animation: shine 3.6s ease-in-out infinite;
}
@keyframes shine { 12% { transform: translateX(120%); } 100% { transform: translateX(120%); } }

/* aparición al hacer scroll (el JS agrega .in) */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .12s; }
.reveal.d2 { transition-delay: .24s; }
.reveal.d3 { transition-delay: .36s; }
.reveal.d4 { transition-delay: .48s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .orb, .shimmer, .btn.glow::after { animation: none; }
}

.feature, .tl-item, .stat-pill {
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, opacity .7s ease;
}
.feature:hover, .tl-item:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 32px rgba(45,212,191,.12); }
.stat-pill:hover { transform: translateY(-3px); border-color: var(--accent2); }
.stat-pill b { font-size: 1.7rem; }

.cta-final { padding-bottom: 4.5rem; }
.cta-card {
  text-align: center; background: linear-gradient(160deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: 22px; padding: 3rem 2rem; position: relative; overflow: hidden;
}
.cta-card::before {
  content: ''; position: absolute; inset: -2px; z-index: 0; pointer-events: none;
  background: radial-gradient(600px 200px at 50% 0%, rgba(45,212,191,.16), transparent 70%);
}
.cta-card > * { position: relative; z-index: 1; }

/* Móvil */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto;
    flex-direction: row; overflow-x: auto; border-right: 0; border-top: 1px solid var(--line);
    padding: .5rem; z-index: 20;
  }
  .sidebar .brand, .sidebar .spacer, .userbox { display: none; }
  .nav-link { flex-direction: column; gap: .15rem; font-size: .7rem; padding: .45rem .6rem; white-space: nowrap; }
  .main { padding-bottom: 6rem; }
  .tl-item { grid-template-columns: 1fr; gap: .3rem; }
}
