/* ===========================================================
   Cartas de ciberseguridad con JEV
   Diseño oscuro con acento dorado, guiño a las cartas de cromos.
   =========================================================== */

:root {
  --bg: #0b0f1a;
  --bg-2: #121829;
  --bg-3: #1a2236;
  --line: #27314a;
  --line-soft: #1e2739;
  --ink: #e8edf7;
  --ink-2: #a5b0c7;
  --ink-3: #6c7894;
  --gold: #e8c15a;
  --gold-2: #b8912f;
  --accent: #4da3ff;
  --ok: #3ec98a;
  --warn: #f0a63c;
  --bad: #f2647a;

  --off: #f2647a;
  --def: #4da3ff;
  --int: #b98cf5;
  --grc: #f0a63c;
  --eng: #3ec98a;
  --for: #56d4d4;

  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 4rem;
  background:
    radial-gradient(1100px 600px at 12% -8%, #1b2540 0%, transparent 60%),
    radial-gradient(900px 500px at 92% 4%, #1d2035 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
a { color: var(--accent); }
p { margin: 0 0 .75rem; }

/* ---------- Avisos ---------- */
.banner {
  padding: .7rem 1.2rem;
  font-size: .9rem;
  text-align: center;
  border-bottom: 1px solid transparent;
}
.banner--warn {
  background: #3a2410;
  color: #ffd9a6;
  border-bottom-color: #6b4415;
}

/* ---------- Cabecera ---------- */
/* Cabecera y contador van juntos: dos elementos sticky con top:0 se pisan,
   y el contador de coste tiene que verse SIEMPRE, que es medio argumento
   de la demo. */
.stickyhead { position: sticky; top: 0; z-index: 30; }

.top {
  border-bottom: 1px solid var(--line);
  background: rgba(11,15,26,.92);
  backdrop-filter: blur(10px);
}
.top__inner {
  max-width: 1180px; margin: 0 auto; padding: 1rem 1.2rem .4rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start;
  justify-content: space-between;
}
.top__brand { display: flex; gap: .8rem; align-items: center; }
.top__logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 11px; font-size: 1.1rem;
  background: linear-gradient(145deg, var(--gold), var(--gold-2));
  color: #1a1405;
}
.top h1 { font-size: 1.12rem; letter-spacing: -.01em; }
.top__sub { margin: 0; font-size: .85rem; color: var(--ink-2); }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.tab {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-2); font: inherit; font-size: .9rem;
  padding: .6rem .85rem; border-radius: 9px 9px 0 0;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); background: var(--bg-2); }
.tab.is-active { color: var(--gold); border-bottom-color: var(--gold); }

/* ---------- Barra de consumo ---------- */
.meter {
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}

/* En pantallas estrechas la cabecera se compacta en vez de soltarse: un sticky
   dentro de un contenedor que se va de pantalla se va con el, asi que la unica
   forma de mantener el contador visible es que el bloque entero siga anclado. */
@media (max-width: 720px) {
  .top__inner { padding: .6rem .9rem .2rem; gap: .4rem; }
  .top__sub { display: none; }
  .top__logo { width: 30px; height: 30px; flex-basis: 30px; font-size: .9rem; border-radius: 8px; }
  .top h1 { font-size: 1rem; }
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; width: 100%;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: .45rem .6rem; font-size: .84rem; white-space: nowrap; }
  .meter__inner { padding: .4rem .9rem; gap: .7rem; font-size: .76rem; }
  .meter__label { display: none; }
}
.meter__inner {
  max-width: 1180px; margin: 0 auto; padding: .5rem 1.2rem;
  display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap;
  font-size: .82rem; color: var(--ink-2);
}
.meter__label { color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; font-size: .7rem; }
.meter__item b { color: var(--ink); font-variant-numeric: tabular-nums; font-family: var(--mono); }
.meter__item--cost b { color: var(--gold); }
.meter__info {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink-2);
  cursor: pointer; font-size: .75rem; line-height: 1;
}
.meter__info:hover { color: var(--gold); border-color: var(--gold-2); }

/* ---------- Estructura ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 1.8rem 1.2rem 0; }
.panel { display: none; }
.panel.is-active { display: block; }

.intro { max-width: 680px; margin-bottom: 1.4rem; }
.intro h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.intro p { color: var(--ink-2); }
.note {
  font-size: .85rem; color: var(--warn);
  border-left: 2px solid var(--warn); padding-left: .7rem;
}

/* ---------- Carga ---------- */
.uploader {
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--bg-2); padding: 1.3rem; margin-bottom: 1.4rem;
}
.uploader.is-over { border-color: var(--gold); background: #1a1d2c; }
.uploader__cta { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.uploader__or { color: var(--ink-3); font-size: .87rem; }
textarea {
  width: 100%; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem; font: inherit; font-size: .9rem; margin-bottom: .8rem;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  font: inherit; font-size: .9rem; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn--primary {
  background: linear-gradient(145deg, var(--gold), var(--gold-2));
  border-color: var(--gold-2); color: #1a1405; font-weight: 600;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.samples { margin-top: 1rem; }
.samples summary { cursor: pointer; color: var(--ink-2); font-size: .88rem; }
.samples summary:hover { color: var(--gold); }
.samples__group h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); margin: 1rem 0 .5rem;
}
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  font: inherit; font-size: .82rem; cursor: pointer;
  padding: .38rem .7rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink-2);
}
.chip:hover { border-color: var(--gold-2); color: var(--gold); }
.chip--neg:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- Progreso ---------- */
.progress { margin-bottom: 1.4rem; }
.progress__bar {
  height: 4px; background: var(--bg-3); border-radius: 999px; overflow: hidden;
}
.progress__bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  transition: width .35s ease;
}
.progress p { margin: .5rem 0 0; font-size: .85rem; color: var(--ink-2); }

/* ---------- Veredicto del filtro ---------- */
.gate {
  border-radius: var(--radius); padding: 1.2rem;
  margin-bottom: 1.4rem; border: 1px solid var(--line); background: var(--bg-2);
}
.gate--pass { border-color: #1e5c40; background: #10261c; }
.gate--fail { border-color: #6b2333; background: #2a1119; }
.gate__head { display: flex; gap: .7rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .9rem; }
.gate__verdict { font-size: 1.05rem; font-weight: 650; }
.gate--pass .gate__verdict { color: var(--ok); }
.gate--fail .gate__verdict { color: var(--bad); }
.gate__reason { color: var(--ink-2); font-size: .92rem; }
.gate__probs { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.prob__label { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .3rem; }
.prob__label span:last-child { font-family: var(--mono); color: var(--ink); }
.prob__track { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.prob__fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.prob__fill--ok { background: var(--ok); }
.prob__fill--bad { background: var(--bad); }
.gate__saved {
  margin-top: .9rem; font-size: .85rem; color: var(--warn);
  border-top: 1px solid rgba(255,255,255,.08); padding-top: .8rem;
}

/* ---------- Carta ---------- */
.result { display: grid; gap: 1.4rem; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .result { grid-template-columns: 1fr; } }

.card {
  position: relative; border-radius: 20px; padding: 1.4rem;
  background: linear-gradient(160deg, #33302a 0%, #1c2033 45%, #141829 100%);
  border: 1px solid var(--gold-2); box-shadow: var(--shadow);
  overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(232,193,90,.14), transparent 45%);
  pointer-events: none;
}
.card__top { display: flex; gap: 1rem; align-items: flex-start; position: relative; }
.card__rating { text-align: center; flex: 0 0 auto; }
.card__overall {
  font-size: 3.4rem; font-weight: 800; line-height: .95;
  color: var(--gold); letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  background: none; border: 0; cursor: pointer; font-family: inherit; padding: 0;
}
.card__overall:hover { filter: brightness(1.15); }
.card__position {
  font-size: .9rem; font-weight: 700; letter-spacing: .1em;
  color: var(--ink); margin-top: .1rem;
}
.card__ident { min-width: 0; padding-top: .3rem; }
.card__name {
  font-size: 1.05rem; font-weight: 650; margin: 0 0 .15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__role { font-size: .82rem; color: var(--ink-2); }
.card__divider { height: 1px; background: linear-gradient(90deg, var(--gold-2), transparent); margin: 1rem 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .9rem; position: relative; }
.stat {
  display: flex; align-items: center; gap: .55rem;
  background: none; border: 0; padding: .28rem .3rem; border-radius: 7px;
  cursor: pointer; font: inherit; color: var(--ink); text-align: left; width: 100%;
}
.stat:hover { background: rgba(255,255,255,.06); }
.stat__value {
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  min-width: 2.1ch; text-align: right; font-variant-numeric: tabular-nums;
}
.stat__code { font-size: .74rem; letter-spacing: .09em; color: var(--ink-2); min-width: 3.2ch; }
.stat__bar { flex: 1; height: 5px; background: rgba(0,0,0,.35); border-radius: 999px; overflow: hidden; }
.stat__fill { display: block; height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.3,1); }

.card__badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; position: relative; }
.badge {
  font-size: .73rem; padding: .3rem .6rem; border-radius: 7px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.1);
  color: var(--ink-2); cursor: help;
}
.badge b { color: var(--ink); font-weight: 600; }
.badge--warn { border-color: var(--warn); color: #ffd9a6; }

.traits { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .32rem; position: relative; }
.trait {
  font-size: .71rem; padding: .22rem .5rem; border-radius: 999px;
  background: rgba(232,193,90,.12); border: 1px solid rgba(232,193,90,.3);
  color: var(--gold); cursor: help;
}

/* ---------- Radar ---------- */
.radar { display: block; width: 100%; height: auto; }
.radar__grid { fill: none; stroke: var(--line); stroke-width: 1; }
.radar__axis { stroke: var(--line-soft); stroke-width: 1; }
.radar__shape { fill: rgba(232,193,90,.18); stroke: var(--gold); stroke-width: 2; transition: all .6s cubic-bezier(.2,.8,.3,1); }
.radar__dot { fill: var(--gold); }
.radar__label { fill: var(--ink-2); font-size: 10px; font-family: system-ui, sans-serif; }
.radar__value { fill: var(--ink); font-size: 10px; font-weight: 700; font-family: var(--mono); }

/* ---------- Lateral ---------- */
.side { display: grid; gap: 1.1rem; }
.box {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2); padding: 1.1rem;
}
.box h3 { font-size: .95rem; margin-bottom: .7rem; }
.box__lead { font-size: .82rem; color: var(--ink-3); margin-bottom: .8rem; }
.reading p { font-size: .92rem; color: var(--ink-2); }
.reading p:last-child { margin-bottom: 0; }
.reading__by {
  font-size: .75rem; color: var(--ink-3); margin-top: .9rem;
  border-top: 1px solid var(--line-soft); padding-top: .7rem;
}
.cautions { list-style: none; padding: 0; margin: .9rem 0 0; display: grid; gap: .5rem; }
.cautions li {
  font-size: .84rem; color: #ffd9a6; background: rgba(240,166,60,.08);
  border-left: 2px solid var(--warn); padding: .5rem .7rem; border-radius: 0 7px 7px 0;
}

/* ---------- Distribuciones ---------- */
.dist { display: grid; gap: .45rem; }
.dist__row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: .6rem; align-items: center; font-size: .82rem; }
.dist__name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist__track { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.dist__fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.dist__pct { font-family: var(--mono); color: var(--ink); font-size: .78rem; min-width: 4ch; text-align: right; }
.dist__row--top .dist__name { color: var(--ink); font-weight: 600; }
.dist__row--top .dist__fill { background: var(--gold); }

/* ---------- Paneles "qué acaba de pasar" ---------- */
.passes { margin: 2rem 0 3rem; }
.passes__title { font-size: 1.15rem; }
.passes__lead { color: var(--ink-2); max-width: 680px; font-size: .92rem; }
.pass {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2); margin-bottom: .7rem; overflow: hidden;
}
.pass summary {
  cursor: pointer; padding: .85rem 1rem; display: flex;
  gap: .8rem; align-items: center; flex-wrap: wrap; list-style: none;
}
.pass summary::-webkit-details-marker { display: none; }
.pass summary:hover { background: var(--bg-3); }
.pass__name { font-weight: 600; font-size: .93rem; flex: 1; min-width: 200px; }
.pass__meta { font-size: .76rem; color: var(--ink-3); font-family: var(--mono); display: flex; gap: .8rem; flex-wrap: wrap; }
.pass__body { padding: 0 1rem 1rem; border-top: 1px solid var(--line-soft); }
.pass__explain {
  font-size: .89rem; color: var(--ink-2); margin: .9rem 0 1.1rem;
  background: var(--bg-3); padding: .8rem .9rem; border-radius: 9px;
  border-left: 2px solid var(--accent);
}
.q { border-top: 1px solid var(--line-soft); padding: .9rem 0; }
.q:first-of-type { border-top: 0; }
.q__head { display: flex; gap: .6rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.q__id { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.q__type {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
  padding: .12rem .4rem; border-radius: 4px; border: 1px solid var(--line);
  color: var(--ink-2);
}
.q__type--noul { border-color: #3a5c8a; color: #8fc0ff; }
.q__type--choice { border-color: #6b4a8a; color: #cba8f5; }
.q__type--score { border-color: #2e6b52; color: #7fdcb0; }
.q__text { font-size: .88rem; color: var(--ink); margin: .45rem 0 .6rem; }
.q__levels { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .25rem; counter-reset: lvl -1; }
.q__levels li {
  font-size: .79rem; color: var(--ink-3); padding-left: 1.7rem; position: relative;
}
.q__levels li::before {
  counter-increment: lvl; content: counter(lvl);
  position: absolute; left: 0; top: 0; width: 1.2rem; text-align: center;
  font-family: var(--mono); color: var(--ink-3);
}
.q__levels li.is-picked { color: var(--ink); }
.q__levels li.is-picked::before { color: var(--gold); font-weight: 700; }
.q__answer { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.q__conf { font-size: .76rem; color: var(--ink-3); }
.q__conf b { color: var(--ink-2); }
.q__json { margin-top: .7rem; }
.q__json summary { font-size: .76rem; color: var(--ink-3); cursor: pointer; padding: 0; }
.q__json pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem; overflow-x: auto; font-size: .74rem; color: var(--ink-2); margin: .5rem 0 0;
}

/* ---------- Tabla de candidatos ---------- */
.cands { width: 100%; border-collapse: collapse; font-size: .88rem; }
.cands th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); padding: .5rem .6rem; border-bottom: 1px solid var(--line); font-weight: 600;
}
.cands td { padding: .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.cands tr { transition: background .4s; }
.cands tr.is-new { background: rgba(232,193,90,.09); }
.cands tr.is-out td { opacity: .45; }
.cands__score { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.cands__move { font-size: .72rem; font-family: var(--mono); }
.cands__move--up { color: var(--ok); }
.cands__move--down { color: var(--bad); }
.pos-pill {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  padding: .15rem .4rem; border-radius: 5px; background: var(--bg-3);
  border: 1px solid var(--line); color: var(--ink-2);
}
.table-wrap { overflow-x: auto; }

/* ---------- Glosario ---------- */
.learn { max-width: 780px; margin: 0 auto; }
.learn h2 { font-size: 1.5rem; margin-top: 2rem; }
.learn h2:first-child { margin-top: 0; }
.learn h3 { font-size: 1.02rem; margin-top: 1.5rem; }
.learn p, .learn li { color: var(--ink-2); }
.learn .box { margin: 1rem 0; }
.learn table { width: 100%; border-collapse: collapse; font-size: .87rem; margin: 1rem 0; }
.learn th { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.learn td { padding: .5rem; border-bottom: 1px solid var(--line-soft); }
.learn code {
  font-family: var(--mono); font-size: .85em; background: var(--bg-3);
  padding: .1rem .35rem; border-radius: 4px; color: var(--gold);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3,6,14,.78); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 1.2rem;
}
.modal__box {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  max-width: 620px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 1.5rem; position: relative; box-shadow: var(--shadow);
}
.modal__close {
  position: absolute; top: .7rem; right: .8rem;
  background: none; border: 0; color: var(--ink-3); font-size: 1.5rem;
  cursor: pointer; line-height: 1;
}
.modal__close:hover { color: var(--ink); }
.modal h3 { font-size: 1.15rem; }
.modal p, .modal li { color: var(--ink-2); font-size: .92rem; }

/* ---------- Traza ---------- */
.trace { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .8rem 0; }
.trace th { text-align: left; padding: .45rem .5rem; color: var(--ink-3); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); }
.trace td { padding: .45rem .5rem; border-bottom: 1px solid var(--line-soft); }
.trace td:not(:first-child) { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.trace tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 700; color: var(--gold); }
.trace .is-missing { color: var(--ink-3); font-style: italic; }
.formula {
  font-family: var(--mono); font-size: .8rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .7rem;
  overflow-x: auto; color: var(--ink-2); white-space: pre-wrap;
}

.foot {
  max-width: 1180px; margin: 3rem auto 0; padding: 1.5rem 1.2rem;
  border-top: 1px solid var(--line); font-size: .82rem; color: var(--ink-3);
}
.foot a { color: var(--ink-2); }

.empty { color: var(--ink-3); font-size: .88rem; padding: 1rem 0; }
[hidden] { display: none !important; }
