/* ============================================================
   Test de Licencia — estilos (vanilla, sin dependencias)
   ============================================================ */
:root {
  /* Design system "Autority" (Figma) -------------------------------------- */
  --bg: #f3f7f4;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #d6ffea 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #e8fbfc 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #001943;            /* Tangaroa/500  */
  --ink-soft: #535862;       /* Neutral Grises/700 */
  --line: #e9eaeb;           /* Neutral Grises/200 */
  --primary: #00493e;        /* Primario/Verde-oscuro/500 */
  --primary-ink: #00382a;    /* Primario/Verde-oscuro/700 (hover) */
  --brand: #00bd00;          /* Primario/Autority/600 (acento vivo) */
  --brand-soft: #f1ffe6;     /* Primario/Autority/50 (selección) */
  --success: #039855;        /* Estados/Success/700 */
  --success-ink: #027a48;    /* Estados/Success/800 */
  --success-soft: #ecfdf3;   /* Estados/Success/100 */
  --danger: #d92d20;         /* Estados/Error/700 */
  --danger-ink: #b42318;     /* Estados/Error/800 */
  --danger-soft: #fef3f2;    /* Estados/Error/100 */
  --amber: #f79009;          /* Estados/Warning/600 */
  --focus: #66fc4c;          /* Primario/Autority/300 (anillo de foco) */

  --cat-senales: #254d7a;    /* Tangaroa/400 */
  --cat-reglas: #237a1f;     /* Esmeralda/800 */
  --cat-velocidad: #3c7c91;  /* Cielo/800 */
  --cat-mecanica: #b54708;   /* Warning/800 */

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(20, 33, 61, .18);
  --shadow-sm: 0 4px 14px -8px rgba(20, 33, 61, .25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; color: var(--primary); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.02rem; letter-spacing: -.01em; }
.brand-text span { font-size: .78rem; color: var(--ink-soft); }

main { max-width: 980px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 24px) 60px; }

/* ---------- Screens ---------- */
.screen { display: none; animation: fade .35s ease both; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; border-radius: 999px;
  padding: 11px 20px; transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 8px;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-ink); }
.btn-success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover { filter: brightness(.95); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-link { background: none; color: var(--primary-ink); padding: 8px; }
.btn-link:hover { text-decoration: underline; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Home ---------- */
#screen-home { display: none; gap: 28px; }
#screen-home.active { display: grid; grid-template-columns: 1.4fr 1fr; align-items: start; }
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 3vw, 36px); box-shadow: var(--shadow); }
.eyebrow { display: inline-block; font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-ink); background: var(--brand-soft); padding: 5px 12px; border-radius: 999px; }
.hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); line-height: 1.12; letter-spacing: -.02em; margin: 16px 0 12px; }
.lead { color: var(--ink-soft); font-size: 1.02rem; margin: 0 0 24px; max-width: 46ch; }
.dist-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 28px; padding-top: 22px; border-top: 1px dashed var(--line); }
.dist-item { display: flex; align-items: center; gap: 9px; font-size: .92rem; color: var(--ink-soft); }
.dist-item b { margin-left: auto; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 1px 9px; font-size: .85rem; }
.dist-item .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dist-item[data-cat="senales"] .dot { background: var(--cat-senales); }
.dist-item[data-cat="reglas"] .dot { background: var(--cat-reglas); }
.dist-item[data-cat="velocidad"] .dot { background: var(--cat-velocidad); }
.dist-item[data-cat="mecanica"] .dot { background: var(--cat-mecanica); }

.stats-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stats-card h2 { font-size: 1.05rem; margin: 0 0 14px; }
.stats-card h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 18px 0 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.stat-num { display: block; font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.stat-label { font-size: .74rem; color: var(--ink-soft); }
.history-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history-list li { display: flex; align-items: center; justify-content: space-between; font-size: .88rem; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.history-list .pill { font-weight: 700; font-size: .76rem; padding: 2px 9px; border-radius: 999px; }
.pill.pass { background: var(--success-soft); color: var(--success-ink); }
.pill.fail { background: var(--danger-soft); color: var(--danger-ink); }
.history-list .when { color: var(--ink-soft); }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.progress { flex: 1; }
.progress-bar { height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 5%; border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--brand)); transition: width .35s ease; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
#q-counter { font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.cat-badge { font-size: .76rem; font-weight: 700; color: #fff; padding: 3px 11px; border-radius: 999px; background: var(--cat-senales); }
.cat-badge[data-cat="senales"] { background: var(--cat-senales); }
.cat-badge[data-cat="reglas"] { background: var(--cat-reglas); }
.cat-badge[data-cat="velocidad"] { background: var(--cat-velocidad); }
.cat-badge[data-cat="mecanica"] { background: var(--cat-mecanica); }

.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 3vw, 32px); display: grid; grid-template-columns: 1fr 230px; gap: 28px; align-items: start; }
.question-card.no-media { grid-template-columns: 1fr; }
.question-text { font-size: clamp(1.15rem, 2.2vw, 1.4rem); line-height: 1.35; letter-spacing: -.01em; margin: 0 0 22px; }
.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 15px 18px; font: inherit; cursor: pointer; color: var(--ink);
  transition: border-color .15s, background .15s, transform .08s;
}
.option:hover { border-color: #a6d9b0; background: #fff; }
.option:active { transform: scale(.995); }
.option .marker { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #cfd0d0;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem; color: var(--ink-soft); transition: .15s; }
.option.selected { border-color: var(--primary); background: var(--brand-soft); }
.option.selected .marker { background: var(--primary); border-color: var(--primary); color: #fff; }
.option:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.question-media { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; position: sticky; top: 86px; }
.question-media img { width: 100%; height: auto; border-radius: 8px; display: block; }

.quiz-hint { text-align: center; color: var(--ink-soft); font-size: .9rem; margin: 20px 0 0; }
.option.just-picked { border-color: var(--primary); background: var(--brand-soft); }

/* ---------- Results ---------- */
.result-banner { display: flex; align-items: center; gap: 26px; border-radius: var(--radius); padding: clamp(22px, 3vw, 34px); color: #fff; box-shadow: var(--shadow); margin-bottom: 24px; }
.result-banner.pass { background: linear-gradient(135deg, #12b76a, var(--success)); }
.result-banner.fail { background: linear-gradient(135deg, #f04438, var(--danger)); }
.result-score { display: flex; align-items: baseline; gap: 4px; }
.score-big { font-size: clamp(3rem, 9vw, 4.6rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.score-den { font-size: 1.3rem; opacity: .85; }
.result-verdict h2 { margin: 0 0 4px; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.result-verdict p { margin: 0; opacity: .92; }

.result-breakdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.bd-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow-sm); }
.bd-card .bd-cat { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 7px; color: var(--ink-soft); }
.bd-card .bd-cat .dot { width: 9px; height: 9px; border-radius: 50%; }
.bd-card .bd-score { font-size: 1.5rem; font-weight: 800; margin-top: 6px; }
.bd-card .bd-bar { height: 6px; background: var(--line); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.bd-card .bd-bar span { display: block; height: 100%; border-radius: inherit; }

.result-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.result-actions .btn-link { margin-left: auto; }

/* ---------- Review ---------- */
.review-title { margin: 30px 0 4px; font-size: 1.05rem; }
.review { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.rev-item { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--success); border-radius: var(--radius-sm); padding: 18px; box-shadow: var(--shadow-sm); }
.rev-item.wrong { border-left-color: var(--danger); }
.rev-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.rev-num { font-weight: 800; color: var(--ink-soft); }
.rev-q { font-weight: 600; }
.rev-media { float: right; width: 130px; margin: 0 0 10px 16px; border-radius: 10px; border: 1px solid var(--line); }
.rev-opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; clear: none; }
.rev-opts li { padding: 9px 13px; border-radius: 10px; font-size: .93rem; border: 1px solid var(--line); background: var(--surface-2); }
.rev-opts li.correct { background: var(--success-soft); border-color: #a6f4c5; color: var(--success-ink); font-weight: 600; }
.rev-opts li.chosen-wrong { background: var(--danger-soft); border-color: #fecdca; color: var(--danger-ink); font-weight: 600; }
.rev-opts li .tag { font-size: .72rem; font-weight: 700; margin-left: 8px; opacity: .8; }

.footnote { text-align: center; color: var(--ink-soft); font-size: .8rem; padding: 24px 16px 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  #screen-home.active { grid-template-columns: 1fr; }
  .question-card { grid-template-columns: 1fr; }
  .question-media { order: -1; position: static; max-width: 260px; }
  .result-breakdown { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .dist-legend { grid-template-columns: 1fr; }
  .result-banner { flex-direction: column; text-align: center; gap: 12px; }
  .quiz-nav { flex-wrap: wrap; }
  .quiz-nav .dots { order: 3; width: 100%; }
  .rev-media { float: none; display: block; width: 160px; margin: 0 0 12px; }
}
