/* ============================================================
   styles.css — Física Básica desde 0
   ============================================================ */
:root {
  --bg: #0f1220;
  --bg-2: #161a2e;
  --surface: #1c2138;
  --surface-2: #232a47;
  --text: #e8ebf7;
  --muted: #9aa3c4;
  --line: #2c3357;
  --primary: #6c8cff;
  --primary-2: #8b5cff;
  --accent: #2ee6c5;
  --ok: #2ecc71;
  --bad: #ff5a6e;
  --warn: #ffb84d;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --maxw: 1140px;

  /* colores de tema */
  --c-azul: #5b8cff;
  --c-rojo: #ff6b81;
  --c-verde: #2ee6a5;
  --c-cyan: #29c7e6;
  --c-naranja: #ff9a52;
  --c-amarillo: #ffce4f;
}
[data-theme="light"] {
  --bg: #f4f6fc;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1fb;
  --text: #1a1f3a;
  --muted: #5b6486;
  --line: #e1e6f5;
  --shadow: 0 12px 36px rgba(60, 80, 160, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s, color .3s;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.grad {
  background: linear-gradient(90deg, var(--primary), var(--primary-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- HEADER ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 800; color: var(--text); }
.logo b { color: var(--primary); }
.nav { display: flex; gap: 22px; margin-left: auto; }
.nav a { color: var(--muted); font-weight: 600; font-size: .95rem; transition: color .2s; }
.nav a:hover { color: var(--text); }
.theme-btn, .burger {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 1.1rem;
}
.burger { display: none; }
.theme-btn { margin-left: 8px; }

/* ---------- HERO ---------- */
.hero { padding: 56px 0 40px; overflow: hidden; }
.hero-inner { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; }
.badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: .8rem; font-weight: 600; color: var(--accent); margin-bottom: 16px;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 850; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 540px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin: 24px 0; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px;
  border-radius: 12px; font-weight: 700; cursor: pointer; border: none; font-size: 1rem;
  transition: transform .15s, box-shadow .2s; text-align: center;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 8px 24px rgba(108,140,255,.4); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.stats { display: flex; gap: 28px; margin-top: 10px; }
.stats .s b { font-size: 1.7rem; display: block; color: var(--text); }
.stats .s span { color: var(--muted); font-size: .85rem; }

.hero-card { position: relative; height: 320px; }
.float-card {
  position: absolute; padding: 14px 20px; border-radius: 14px; font-weight: 800;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-family: "Cambria Math", Georgia, serif; font-size: 1.2rem;
  animation: float 6s ease-in-out infinite;
}
.f1 { top: 10%; left: 8%; color: var(--c-azul); }
.f2 { top: 30%; right: 6%; color: var(--c-verde); animation-delay: .8s; }
.f3 { bottom: 22%; left: 4%; color: var(--c-cyan); animation-delay: 1.6s; }
.f4 { bottom: 6%; right: 16%; color: var(--c-amarillo); animation-delay: 2.4s; }
.orbit {
  position: absolute; inset: 0; margin: auto; width: 130px; height: 130px;
  display: grid; place-items: center; font-size: 3.6rem;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 30%, transparent), transparent 70%);
  border-radius: 50%; animation: spin 18s linear infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- CONSTANTES STRIP ---------- */
.constantes { padding: 8px 0 32px; }
.const-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.const-strip .const {
  flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; min-width: 180px;
}
.const small { display: block; color: var(--muted); font-size: .75rem; }
.const b { color: var(--accent); font-family: "Cambria Math", Georgia, serif; }

/* ---------- SECTIONS ---------- */
.section { padding: 64px 0; }
.section.alt { background: var(--bg-2); }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 36px; }
.section-head h2 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
.section-head p { color: var(--muted); }

/* ---------- CONTROLS ---------- */
.controls { margin-bottom: 28px; }
#buscador {
  width: 100%; padding: 14px 18px; border-radius: 12px; font-size: 1rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); margin-bottom: 16px;
}
#buscador:focus { outline: 2px solid var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .85rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); transition: all .2s;
}
.chip:hover { color: var(--text); }
.chip.active { background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

/* ---------- CARDS ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s; animation: rise .4s ease both;
}
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--tc, var(--primary)); }
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--tc, var(--primary)); }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-icon { font-size: 1.8rem; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); }
.card-num { font-size: .75rem; color: var(--muted); font-weight: 700; }
.card h3 { font-size: 1.1rem; margin: 0; }
.card p { color: var(--muted); font-size: .92rem; margin: 0 0 14px; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tags span { font-size: .72rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.card-more { margin-top: 14px; font-size: .85rem; font-weight: 700; color: var(--tc, var(--primary)); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px;
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: pop .25s ease; position: relative;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.modal-head { padding: 26px 28px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); display: flex; gap: 14px; align-items: center; }
.modal-head .card-icon { font-size: 2rem; }
.modal-head h3 { font-size: 1.35rem; margin: 0; }
.modal-close {
  position: absolute; top: 18px; right: 18px; width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 1.1rem;
}
.modal-body { padding: 22px 28px 30px; }
.modal-body h4 { margin: 22px 0 10px; font-size: 1rem; display: flex; align-items: center; gap: 8px; color: var(--text); }
.modal-body h4:first-child { margin-top: 0; }
.modal-body ul { margin: 0; padding-left: 18px; color: var(--muted); }
.modal-body li { margin-bottom: 6px; }
.formula-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 10px; background: var(--surface); margin-bottom: 8px;
  border: 1px solid var(--line); cursor: pointer; transition: border-color .15s, transform .12s; text-align: left; width: 100%;
}
.formula-row:hover { border-color: var(--accent); transform: translateX(3px); }
.formula-row .desc { color: var(--muted); font-size: .85rem; text-align: right; display: flex; align-items: center; gap: 6px; }
.formula-row .desc::after { content: "🔍"; font-size: .8rem; opacity: .5; }
.pill-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-tags span { font-size: .8rem; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.example {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 16px 18px;
}
.example .enun { font-weight: 600; margin-bottom: 12px; }
.example .pasos { background: var(--bg); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.example .pasos > div { padding: 4px 0; }
.example .resp { color: var(--ok); font-weight: 700; }

/* ---------- FORMULAS GRID ---------- */
.formulas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.f-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.f-card h4 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; font-size: 1.02rem; }
.f-card .frow { padding: 9px 10px; border-bottom: 1px dashed var(--line); cursor: pointer; border-radius: 8px; transition: background .15s; position: relative; }
.f-card .frow:last-child { border-bottom: none; }
.f-card .frow:hover { background: var(--surface-2); }
.f-card .frow small { display: block; color: var(--muted); font-size: .76rem; margin-top: 2px; }
.f-card .frow::after { content: "🔍"; position: absolute; top: 9px; right: 8px; font-size: .72rem; opacity: 0; transition: opacity .15s; }
.f-card .frow:hover::after { opacity: .6; }

/* ---------- FORMULA POPUP ---------- */
.fmodal-overlay {
  position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.62);
  backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; animation: fade .2s;
}
.fmodal {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px;
  max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: pop .22s ease; position: relative; padding: 26px 26px 28px;
}
.fmodal-close {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 1rem;
}
.fmodal .f-tema { font-size: .75rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.fmodal .f-big {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 18px; text-align: center; font-size: 1.15rem; margin: 10px 0 6px;
}
.fmodal .f-name { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }
.fmodal h5 { margin: 16px 0 10px; font-size: .95rem; display: flex; align-items: center; gap: 7px; }
.var-list { display: grid; gap: 8px; }
.var-item { display: flex; gap: 12px; align-items: baseline; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.var-item .sym { flex: 0 0 auto; min-width: 42px; text-align: center; color: var(--primary); font-weight: 700; }
.var-item .vd { color: var(--muted); font-size: .9rem; }
.f-ej { background: var(--surface-2); border-radius: 10px; padding: 13px 15px; font-size: .92rem; line-height: 1.7; }

/* ---------- QUIZ ---------- */
.quiz-setup {
  display: flex; gap: 18px; align-items: flex-end; justify-content: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
}
.quiz-field { display: flex; flex-direction: column; gap: 6px; }
.quiz-field label { font-weight: 600; font-size: .85rem; color: var(--muted); }
#quizTema, #quizNivel { padding: 11px 16px; border-radius: 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); font-size: 1rem; }
#quizTema { min-width: 240px; }
#quizNivel { min-width: 180px; }

/* badge de nivel */
.nivel-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.nivel-Básico { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.nivel-Intermedio { background: color-mix(in srgb, var(--warn) 24%, transparent); color: var(--warn); }
.nivel-Avanzado { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }
.quiz-box { max-width: 720px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.quiz-top { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.quiz-progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.quiz-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }
.quiz-counter { font-size: .85rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.quiz-q { font-size: 1.18rem; font-weight: 700; margin-bottom: 6px; }
.quiz-tema-tag { font-size: .75rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.quiz-options { display: grid; gap: 12px; margin: 20px 0; }
.quiz-opt {
  text-align: left; padding: 14px 18px; border-radius: 12px; cursor: pointer; font-size: 1rem;
  background: var(--bg); border: 2px solid var(--line); color: var(--text); transition: all .15s; display: flex; gap: 12px; align-items: center;
}
.quiz-opt .letter { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .85rem; }
.quiz-opt:hover:not(:disabled) { border-color: var(--primary); }
.quiz-opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--bg)); }
.quiz-opt.correct .letter { background: var(--ok); color: #fff; }
.quiz-opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--bg)); }
.quiz-opt.wrong .letter { background: var(--bad); color: #fff; }
.quiz-opt:disabled { cursor: default; }
.quiz-exp {
  border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; font-size: .95rem;
  background: var(--surface-2); border-left: 4px solid var(--accent); animation: rise .3s ease;
}
.quiz-exp b { color: var(--accent); }
.quiz-nav { display: flex; justify-content: flex-end; }

/* resultado */
.quiz-result { max-width: 560px; margin: 0 auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 30px; }
.score-ring { width: 150px; height: 150px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.score-ring span { font-size: 2.4rem; font-weight: 850; }
.score-ring small { color: var(--muted); }
.result-msg { font-size: 1.15rem; font-weight: 700; margin: 8px 0 20px; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- GUIA / STEPS ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 40px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 18px 20px; position: relative; color: var(--muted); }
.step span { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(90deg,var(--primary),var(--primary-2)); color: #fff; font-weight: 800; margin-bottom: 10px; }
.step b { color: var(--text); }
.identify { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; overflow-x: auto; }
.identify h3 { margin-top: 0; }
.identify table { width: 100%; border-collapse: collapse; min-width: 460px; }
.identify th, .identify td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.identify th { color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; }
.identify td:last-child { color: var(--primary); font-weight: 600; }

/* ---------- FOOTER ---------- */
.site-footer { padding: 40px 0; text-align: center; border-top: 1px solid var(--line); background: var(--bg-2); }
.site-footer p { margin: 4px 0; }

/* ---------- TOP BTN ---------- */
.top-btn {
  position: fixed; bottom: 24px; right: 24px; width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; border: none;
  font-size: 1.3rem; cursor: pointer; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .3s, transform .2s; z-index: 40;
}
.top-btn.show { opacity: 1; pointer-events: auto; }
.top-btn:hover { transform: translateY(-3px); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 860px) {
  .nav { position: fixed; top: 64px; right: 0; left: 0; background: var(--bg-2); flex-direction: column; padding: 16px 20px; gap: 14px; border-bottom: 1px solid var(--line); transform: translateY(-150%); transition: transform .3s; margin: 0; }
  .nav.open { transform: translateY(0); }
  .burger { display: block; margin-left: auto; }
  .theme-btn { order: 3; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-card { height: 240px; order: -1; }
  .stats { gap: 18px; }
}
@media (max-width: 520px) {
  .quiz-setup { flex-direction: column; align-items: stretch; }
  .quiz-field { width: 100%; }
  #quizTema, #quizNivel { min-width: 0; width: 100%; }
  .stats .s b { font-size: 1.4rem; }
  .modal-body, .modal-head { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
