/* ============================================================
   Test de Temperamentos — Tema "Lámina antigua / aguada sepia"
   Inspirado en grabados de tratado del XVII–XVIII: pergamino
   envejecido con foxing, tinta sepia, filetes finos y versalitas.
   Niño = ocre cálido, Ahora = oliva/verdigrís (distinguibles por
   tono y luminosidad). Solo fuentes del sistema (CSP estricta).
   ============================================================ */
:root {
  /* Lienzo / superficies (pergamino) */
  --bg: #e8dcc0;            /* fondo: pergamino cálido envejecido */
  --surface: #f4ecd9;       /* tarjetas: papel marfil más claro */
  --surface-2: #ecdfc3;     /* paneles / zebra de filas */
  /* Tinta / texto */
  --ink: #3b2c1c;           /* tinta sepia oscura (texto, ~10:1) */
  --ink-soft: #5b462f;      /* texto secundario */
  --muted: #8a7355;         /* atenuado, pies, metadatos */
  /* Acento principal (tinta canela) */
  --primary: #7c4a21;       /* sepia-canela: acentos, enlaces, foco */
  --primary-dark: #5c3415;
  --primary-soft: #efe2c8;
  /* Colores de columna: Niño = ocre cálido, Adulto = oliva frío */
  --adult: #4f6b57;         /* "Ahora" / adulto: oliva-verdigrís */
  --adult-soft: #dde4dc;
  --child: #9a6b2f;         /* "De niño/a": ocre/ámbar cálido */
  --child-soft: #f0e2c8;
  --neutral: #b8a784;       /* estado por defecto / divisor terroso */
  --line: #d8c7a3;          /* filete fino */
  --line-strong: #b39b72;   /* filete de grabado, definido */
  --ok: #5f6b34; --err: #9b3526; --wa: #4f7a52;
  /* Avisos (banda y caja) */
  --warn-bg: #f1e3bf; --warn-bd: #cda94f; --warn-bar: #9c7611;
  /* Faltantes: terracota lavada (resaltado suave) */
  --miss-bd: #c98a6b; --miss-bg: #f0ddca;
  /* Cuatro temperamentos (tintas terrosas) */
  --sang: #b06a2c; --coler: #9c3b22; --flem: #7a6a4f; --melan: #5b5230;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(59,44,28,.10), 0 4px 14px rgba(59,44,28,.07);
  /* Tipografía serif clásica (solo fuentes del sistema) */
  --serif-display: 'Palatino Linotype', 'Book Antiqua', Palatino, 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --serif-body: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Cambria, Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); line-height: 1.62; font-size: 17px;
  font-family: var(--serif-body);
  background-color: var(--bg);
  background-image:
    /* foxing: manchas de óxido dispersas (puntos de gradiente, sin filtros caros) */
    radial-gradient(rgba(150,96,40,.06) 1.4px, transparent 2.2px),
    radial-gradient(rgba(120,70,28,.05) 1.1px, transparent 2px),
    /* iluminación cálida de pergamino */
    radial-gradient(120% 90% at 18% 8%, #f6efda 0%, rgba(246,239,218,0) 55%),
    radial-gradient(120% 120% at 85% 95%, #e0d0aa 0%, rgba(224,208,170,0) 60%);
  background-repeat: repeat, repeat, no-repeat, no-repeat;
  background-size: 170px 170px, 240px 240px, 100% 100%, 100% 100%;
  background-position: 0 0, 80px 110px, 0 0, 0 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Encabezado: banda de pergamino con doble filete (sabor de lámina) */
.topbar {
  background: linear-gradient(180deg, #f4ecd9 0%, #e9dbbd 100%);
  color: var(--ink); padding: 14px 18px;
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 #f7f0db inset, 0 2px 0 var(--line);
}
.brand {
  color: var(--primary-dark); text-decoration: none; font-weight: 600;
  font-family: var(--serif-display); font-size: 22px;
  font-variant-caps: small-caps; letter-spacing: .06em;
}
main { max-width: 880px; margin: 0 auto; padding: 24px 18px; }

/* Tipografía */
h1, h2, h3, h4 { font-family: var(--serif-display); color: var(--ink); line-height: 1.22; }
h1 { font-size: 36px; font-weight: 700; margin: .15em 0; letter-spacing: .005em; }
h2 { font-size: 27px; font-weight: 700; margin: .1em 0 .5em; font-variant-caps: small-caps; letter-spacing: .03em; }
h3 { font-size: 20px; font-weight: 600; margin: 0 0 .5em; }
h4 { margin: .3em 0; color: var(--ink-soft); font-weight: 600; font-size: 16px; }
.muted { color: var(--muted); }
.lead { font-size: 19px; color: var(--ink-soft); }
.back { display: inline-block; margin-bottom: 12px; color: var(--primary); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--primary-dark); text-decoration: underline; }

/* Tarjetas: papel con doble filete interior */
.card {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 20px 22px; margin: 16px 0; position: relative;
  box-shadow: 0 0 0 1px rgba(255,253,245,.5) inset, var(--shadow);
}
.card > h3:first-child { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px;
  font-variant-caps: small-caps; letter-spacing: .03em; color: var(--ink); }

/* Formularios */
label { display: block; margin: 12px 0; font-weight: 600; color: var(--ink-soft); font-size: 15px; }
input, textarea, select {
  width: 100%; padding: 11px 12px; font-size: 15px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); margin-top: 5px; font-family: var(--serif-body);
  background: #fffdf6; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,74,33,.18); }
textarea { resize: vertical; word-break: break-all; }

/* Botones */
.btn {
  display: inline-block; padding: 10px 18px; font-size: 15px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #f6eed9, #e9dbbb); border-radius: var(--radius); cursor: pointer; font-weight: 600;
  color: var(--ink); font-family: var(--serif-display); font-variant-caps: small-caps; letter-spacing: .04em; transition: all .12s;
}
.btn:hover { border-color: var(--primary); background: linear-gradient(180deg, #f9f2e0, #e4d4b0); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #f6efda; border-color: var(--primary-dark);
  text-shadow: 0 1px 0 rgba(0,0,0,.22); }
.btn.primary:hover { background: linear-gradient(180deg, #8a5527, var(--primary-dark)); }
.btn.ghost { background: var(--surface-2); color: var(--ink-soft); }
.btn.whatsapp { background: var(--wa); color: #fff; border-color: #3c6341; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--err); cursor: pointer; font-size: 13px; font-family: var(--serif-body); }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.msg { margin-top: 8px; font-weight: 600; min-height: 1.2em; font-size: 15px; }
.msg.ok { color: var(--ok); } .msg.error { color: var(--err); } .msg.warn { color: var(--warn-bar); }
.ok { color: var(--ok); } .error { color: var(--err); }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-bd); border-left: 4px solid var(--warn-bar);
  padding: 10px 14px; border-radius: var(--radius); color: var(--ink-soft); font-size: 14px; margin-top: 10px; }

/* Inicio */
.hero { text-align: center; padding: 10px 0 4px; }
.hero h1 { font-size: 44px; font-variant-caps: small-caps; letter-spacing: .02em; }
/* filete con ornamento central (sabor de grabado) */
.hero h1::after {
  content: ""; display: block; height: 12px; width: 200px; margin: 14px auto 20px;
  background:
    radial-gradient(var(--primary) 38%, transparent 42%) center/11px 11px no-repeat,
    linear-gradient(var(--bg), var(--bg)) center/24px 12px no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) center/100% 1px no-repeat;
}
.role-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 26px; }
.role-card {
  display: block; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-top: 3px solid var(--primary); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s; text-align: left;
}
.role-card:hover { transform: translateY(-3px); border-top-color: var(--primary-dark); box-shadow: 0 7px 18px rgba(59,44,28,.14); }
.role-card h3 { color: var(--primary-dark); margin-top: 10px; }
.role-ic { color: var(--primary); display: inline-block; }
.role-ic svg { width: 30px; height: 30px; display: block; }

/* Test */
.form-meta label { font-weight: 600; }
.cols-head { display: grid; grid-template-columns: 1fr 100px 100px; gap: 8px; font-weight: 700;
  padding: 8px 4px; position: sticky; top: 0; font-size: 14px; font-variant-caps: small-caps; letter-spacing: .05em;
  background: var(--bg); z-index: 2; border-bottom: 2px solid var(--line-strong); }
.ch-q { color: var(--ink-soft); }
.ch-c { text-align: center; }
.ch-child { color: var(--child); }
.ch-adult { color: var(--adult); }
.qlist { margin-top: 6px; }
.qrow { display: grid; grid-template-columns: 1fr 100px 100px; gap: 8px; align-items: center;
  padding: 13px 4px; border-bottom: 1px solid var(--line); border-radius: var(--radius);
  border-left: 3px solid transparent; transition: background .12s; }
.qrow:nth-child(even) { background: var(--surface-2); }
.qtext { font-size: 16px; } .qn { color: var(--neutral); font-weight: 700; }
.qcol { display: flex; gap: 6px; justify-content: center; padding: 3px; border-radius: var(--radius); }
/* divisor neutro entre la columna de niño y la de adulto */
.qcol[data-group="adulto"], .cols-head .ch-adult { border-left: 1px solid var(--line); }
.opt { flex: 1; padding: 10px 0; border: 1px solid var(--line-strong); background: #fffdf6; border-radius: var(--radius);
  cursor: pointer; font-weight: 700; font-size: 13px; color: var(--neutral); font-family: var(--serif-display); }
.opt:hover { border-color: var(--primary); }
/* selección con color propio por columna (texto marfil sobre tinta) */
.qcol[data-group="ninez"] .opt.sel { background: var(--child); color: #fbf4e2; border-color: var(--child); }
.qcol[data-group="adulto"] .opt.sel { background: var(--adult); color: #fbf4e2; border-color: var(--adult); }
/* fila con respuesta faltante: contorno terracota lavado */
.qrow.missing { border-left-color: var(--miss-bd); background: var(--miss-bg); }
.qcol.col-missing { box-shadow: 0 0 0 2px var(--miss-bd); }
.progress { margin: 18px 0 10px; font-weight: 700; color: var(--primary-dark); font-size: 17px; font-variant-caps: small-caps; letter-spacing: .03em; }
.chk { font-weight: 500; display: flex; gap: 8px; align-items: center; color: var(--ink-soft); }
.chk input { width: auto; }
.chk.inline { display: inline-flex; margin: 4px 14px 4px 0; }

/* Resultados */
.cards-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.profile .temp-badge { display: inline-block; padding: 6px 16px; border-radius: 999px; font-weight: 700;
  color: #fbf4e2; margin-bottom: 12px; letter-spacing: .03em; font-size: 15px; font-variant-caps: small-caps; }
.temp-flemático { background: var(--flem); } .temp-sanguíneo { background: var(--sang); }
.temp-colérico { background: var(--coler); } .temp-melancólico { background: var(--melan); }
/* tarjeta de niño vs adulto: acento de borde superior según corresponda */
.profile.is-child { border-top: 3px solid var(--child); }
.profile.is-adult { border-top: 3px solid var(--adult); }
.stats { list-style: none; padding: 0; margin: 0; }
.stats li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap;
  justify-content: space-between; gap: 4px; }
.stats li span:first-child { color: var(--muted); }
.stats b { font-weight: 700; }

/* KPIs */
.kpi-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.kpi-val { font-size: 23px; font-weight: 700; color: var(--primary-dark); }
.kpi-label { font-weight: 700; font-size: 13px; margin-top: 3px; color: var(--ink-soft); font-variant-caps: small-caps; letter-spacing: .03em; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* Gráficos */
.chart-eysenck { width: 100%; height: auto; max-width: 460px; display: block; margin: 0 auto; }
.q-label { font-size: 12px; font-weight: 700; fill: rgba(59,44,28,.5); letter-spacing: .4px; font-family: var(--serif-display); }
.axis-label { font-size: 11px; font-weight: 700; fill: var(--muted); }
.pt-tag { font-size: 11px; font-weight: 700; }
.bars h4 { margin-bottom: 6px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 64px; gap: 8px; align-items: center; margin: 6px 0; }
.bar-track { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { display: block; height: 100%; }
.bar-val { font-size: 13px; text-align: right; color: var(--muted); }

/* Dashboard */
.case-list { list-style: none; padding: 0; } .case-list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.case-list a { color: var(--primary); font-weight: 600; text-decoration: none; }
.link-row { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 12px 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.link-row .ll { font-weight: 700; color: var(--ink-soft); font-size: 14px; }
.toggles { margin: 8px 0 16px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 5px; vertical-align: middle; }
/* divisor entre la tabla de niño y la de ahora */
.dash-cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
.dash-cols > div { border-top: 3px solid var(--neutral); padding-top: 6px; }
.dash-cols > #dash-niño { border-top-color: var(--child); }
.dash-cols > #dash-ahora { border-top-color: var(--adult); }
.foot { max-width: 880px; margin: 24px auto; padding: 18px; color: var(--muted); font-size: 13px; text-align: center;
  border-top: 1px solid var(--line); }
.foot a { color: var(--primary); }

/* Datos curiosos (sección tipo blog) */
.facts { margin-top: 34px; }
.facts > h2 { text-align: center; }
.facts > .lead-sub { text-align: center; color: var(--muted); margin-top: -6px; margin-bottom: 18px; font-style: italic; }
.fact { background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 16px 20px; margin: 14px 0; box-shadow: var(--shadow); }
.fact h3 { color: var(--primary-dark); font-size: 19px; margin-bottom: 6px; }
.fact p { margin: 0; color: var(--ink-soft); }
.fact .era { font-size: 13px; color: var(--muted); font-style: italic; }
/* capitular (drop cap) en el primer dato curioso */
.facts .fact:first-of-type > p:last-of-type::first-letter {
  float: left; font-family: var(--serif-display); font-size: 3.2em; line-height: .82;
  padding: .04em .12em 0 0; color: var(--primary); font-weight: 700;
}
.sources { font-size: 13px; color: var(--muted); margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.sources b { color: var(--ink-soft); }
.sources a { color: var(--primary); }

/* Selección de tipo de test (reutiliza .role-card) */
.test-sub { color: var(--muted); font-size: 14px; margin: -2px 0 0; font-style: italic; }
.role-card.soon { opacity: .6; border-top-color: var(--neutral); cursor: default; pointer-events: none; }
.tag-soon { display: inline-block; font-size: 12px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 10px; margin-top: 10px; font-variant-caps: small-caps; }
.test-banner { display: inline-block; font-size: 13px; font-weight: 700; color: var(--primary-dark);
  background: var(--primary-soft); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 12px; margin-bottom: 8px;
  font-variant-caps: small-caps; letter-spacing: .03em; }

/* Lámina de los cuatro temperamentos (cuadro de portada, sabor de grabado) */
.plate { margin: 22px auto 10px; max-width: 100%; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line-strong), var(--shadow); padding: 18px 16px; }
.plate-cap { text-align: center; font-family: var(--serif-display); font-variant-caps: small-caps;
  letter-spacing: .06em; font-size: 19px; color: var(--ink); margin-bottom: 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.plate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-strong);
  border: 1px solid var(--line-strong); }
.plate-cell { background: var(--surface-2); padding: 16px 12px; margin: 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; }
.plate-fig { max-height: 230px; max-width: 100%; height: auto; object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(59,44,28,.18)); }
.plate-fig.is-missing { display: none; }
.plate-info { display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 100%; position: relative; padding-top: 12px; margin-top: 2px; }
/* filete fino y difuminado bajo la figura, sobre el nombre */
.plate-info::before { content: ""; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
.plate-name { font-family: var(--serif-display); font-weight: 700; font-variant-caps: small-caps;
  letter-spacing: .04em; font-size: 19px; line-height: 1.1; }
.plate-humor { font-size: 13px; color: var(--ink-soft); font-style: italic; }
.plate-elem { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  font-variant-caps: small-caps; letter-spacing: .05em; font-weight: 600; }
.emblema { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linejoin: round; stroke-linecap: round; vertical-align: middle; }
/* nombre y símbolo del elemento en el color del temperamento */
.t-sang .plate-name, .t-sang .plate-elem { color: var(--sang); }
.t-coler .plate-name, .t-coler .plate-elem { color: var(--coler); }
.t-melan .plate-name, .t-melan .plate-elem { color: var(--melan); }
.t-flem .plate-name, .t-flem .plate-elem { color: var(--flem); }

/* Acción principal (portada) */
.cta-card { text-align: center; }
.cta-card .row-btns { justify-content: center; }

/* Línea de tiempo: regla proporcional, puntos alternados con su año */
.timeline { position: relative; height: 124px; margin: 24px 14px 14px; }
.tl-axis { position: absolute; left: 0; right: 0; top: 62px; height: 2px; background: var(--line-strong); }
/* marcas de referencia (1000, 2000 d.C.) para leerla como una regla */
.tl-tick { position: absolute; top: 56px; height: 14px; border-left: 1px solid var(--neutral); }
.tl-tick span { position: absolute; top: 15px; left: 50%; transform: translateX(-50%); font-size: 11px;
  color: var(--muted); white-space: nowrap; }
/* marcador del nacimiento de Cristo (año 0) */
.tl-christ { position: absolute; top: 18px; bottom: 30px; width: 0; border-left: 2px dashed var(--primary); }
.tl-christ-lbl { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 11px;
  color: var(--primary); white-space: nowrap; font-variant-caps: small-caps; letter-spacing: .04em; }
/* puntos: mitad arriba y mitad abajo del eje para que no se monten */
.tl-dot { position: absolute; width: 15px; height: 15px; margin-left: -7.5px; border-radius: 50%;
  background: #2b211a; border: 2px solid var(--surface); cursor: pointer; padding: 0; z-index: 3;
  transition: background .12s, transform .12s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tl-dot.tl-up { top: 48px; }
.tl-dot.tl-down { top: 63px; }
.tl-dot:hover, .tl-dot.active { background: var(--err); transform: scale(1.35); z-index: 4; }
.tl-dot:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.tl-yr { position: absolute; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted);
  white-space: nowrap; font-variant-caps: small-caps; letter-spacing: .02em; pointer-events: none; }
.tl-up .tl-yr { bottom: 19px; }
.tl-down .tl-yr { top: 19px; }
.tl-detail { background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--err);
  border-radius: var(--radius); padding: 14px 18px; min-height: 92px; box-shadow: var(--shadow); }
.tl-detail h3 { color: var(--primary-dark); margin-bottom: 4px; }
.tl-detail .era { font-size: 13px; color: var(--muted); font-style: italic; margin: 0 0 6px; }
.tl-detail p { color: var(--ink-soft); }
.tl-detail .src { font-size: 13px; color: var(--muted); margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.tl-detail .src a { color: var(--primary); }

/* QR e informe imprimible (PDF) */
.qr { display: block; margin: 10px auto; width: 184px; height: 184px; image-rendering: pixelated;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px; }
.qr-wrap { text-align: center; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.print-only { display: none; }
.print-brand { font-variant-caps: small-caps; letter-spacing: .05em; color: var(--primary-dark); font-weight: 700; }

@media print {
  .topbar, .foot, .back, .no-print, .row-btns, .qr-wrap { display: none !important; }
  body { background: #fff !important; background-image: none !important; color: #000; }
  main { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .print-only { display: block; }
}

@media (min-width: 720px) {
  .role-grid { grid-template-columns: 1fr 1fr 1fr; }
  .cards-2 { grid-template-columns: 1fr 1fr; }
  .dash-cols { grid-template-columns: 1fr 1fr; }
  .link-row { grid-template-columns: 190px 1fr auto auto auto; align-items: center; }
  .plate-grid { grid-template-columns: repeat(4, 1fr); }  /* 4 temperamentos en una fila */
}
