/* Cursos: a catalog to scan. Hero with a skippable 3-question quiz that ends in a lead form,
   a sticky filter bar, then programs first and courses grouped by level. Uses tokens from styles.css. */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* Hero */
.cat-hero {
  padding-block: clamp(48px, 8vw, 96px) clamp(36px, 5vw, 56px);
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px 64px; align-items: end;
}
.cat-hero h1 { font-size: var(--step-4); margin-top: 18px; max-width: 12ch; }
.cat-hero h1 em { font-style: italic; color: var(--accent); }
.cat-hero .hero-lead { margin-top: 24px; }
.cat-hero .hero-lead span { font-family: var(--f-data); color: var(--ink); font-weight: 500; }

.cat-hero { align-items: center; }

/* Quiz: the first thing on the page, skippable */
.quiz {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: clamp(22px, 3vw, 32px); box-shadow: var(--shadow); min-height: 340px; display: grid;
  transition: background-color .35s, border-color .35s;
}
.quiz::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(70% 60% at 100% 0%, color-mix(in srgb, var(--accent-soft) 35%, transparent), transparent 70%);
}
.quiz-pane { position: relative; display: flex; flex-direction: column; gap: 14px; animation: rise .35s ease both; }
.quiz-pane[hidden] { display: none; }
.quiz h2 { font-size: var(--step-2); }
.quiz p { color: var(--muted); line-height: 1.5; }
.quiz-bars { display: inline-flex; align-items: flex-end; gap: 6px; height: 46px; }
.quiz-bars i { width: 12px; border-radius: 6px; background: var(--brand); transform: skewX(-14deg); }
.quiz-bars i:nth-child(1) { height: 20px; opacity: .45; }
.quiz-bars i:nth-child(2) { height: 33px; opacity: .7; }
.quiz-bars i:nth-child(3) { height: 46px; }
.quiz-bars.is-done i { background: var(--teal); opacity: 1; }
.quiz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: auto; padding-top: 6px; }
.quiz-skip, .quiz-back {
  border: 0; background: none; padding: 4px 0; font: inherit; font-size: 0.92rem; color: var(--muted); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line);
}
.quiz-skip:hover, .quiz-back:hover { color: var(--ink); text-decoration-color: currentColor; }
.quiz-back { text-decoration: none; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-step { font-family: var(--f-data); font-size: 0.78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.quiz-progress { display: inline-flex; gap: 4px; }
.quiz-progress i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); transition: background-color .3s; }
.quiz-progress i.on, .quiz-progress.is-full i { background: var(--brand); }
.quiz fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.quiz legend { font-family: var(--f-display); font-weight: 600; font-size: var(--step-1); letter-spacing: -0.01em; padding: 0; margin-bottom: 14px; }
.quiz-options { display: grid; gap: 8px; }
.quiz-opt {
  display: grid; gap: 2px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  transition: border-color .2s, background-color .2s, transform .2s;
}
.quiz-opt strong { font-weight: 600; font-size: 0.98rem; }
.quiz-opt span { font-size: 0.85rem; color: var(--muted); }
.quiz-opt:hover { border-color: var(--accent); transform: translateX(3px); }
.quiz-opt[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 30%, var(--surface)); }

/* Forms */
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.field--full { grid-column: 1 / -1; }
.field em { font-style: normal; color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 0.98rem; color: var(--ink); background: var(--bg); width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field [aria-invalid="true"], .consent input[aria-invalid="true"] { border-color: #d64545; outline-color: #d64545; }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 0.85rem; color: var(--muted); line-height: 1.4; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.form-error, .quiz .form-error { color: #c23b3b; font-size: 0.88rem; font-weight: 500; }
:root[data-theme="dark"] .form-error, :root[data-theme="dark"] .quiz .form-error { color: #ff8a8a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .form-error, :root:not([data-theme="light"]) .quiz .form-error { color: #ff8a8a; } }
@media (max-width: 520px) { .field-grid { grid-template-columns: minmax(0, 1fr); } }

/* Recommendations */
.recos { display: grid; gap: 28px; padding-block: 8px clamp(48px, 6vw, 72px); scroll-margin-top: 90px; }
.recos[hidden] { display: none; }
.recos .group-head h2 { color: var(--accent); }
.recos .course-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 228px), 1fr)); }
.recos-lead {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px;
  padding: 18px 22px; border-radius: 16px; background: var(--sky); border: 1px solid var(--line);
}
.recos-lead[hidden] { display: none; }
.recos-lead p { color: var(--muted); max-width: 60ch; }
.recos-lead strong { color: var(--ink); }

/* Lead modal */
.lead-modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); overflow: auto;
}
.lead-modal[open] { animation: pop .25s ease; }
.lead-modal::backdrop { background: rgba(8, 21, 33, 0.62); backdrop-filter: blur(3px); }
.lead-modal form { display: grid; }
.lead-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 22px 0 26px; }
.lead-head h2 { font-size: var(--step-2); margin-top: 8px; }
.lead-body { display: grid; gap: 14px; padding: 18px 26px 26px; }
.lead-body[hidden], .lead-done[hidden] { display: none; }
.lead-course { font-size: 0.9rem; color: var(--muted); padding: 10px 14px; border-radius: 10px; background: var(--sky); }
.lead-course strong { color: var(--ink); }
.lead-submit { justify-content: center; padding-block: 12px; font-size: 1rem; cursor: pointer; }
.lead-submit:disabled { opacity: .7; cursor: progress; }
.lead-done { display: grid; gap: 12px; justify-items: start; padding: 18px 26px 28px; }
.lead-done p { color: var(--muted); }
.lead-form.is-done .lead-head > div { visibility: hidden; }
.lead-form.is-done .lead-done { padding-top: 0; margin-top: -40px; }
.btn { cursor: pointer; font-family: inherit; }

/* Filters */
.filters {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 75px); z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-block: 1px solid transparent; transition: border-color .3s, background-color .35s;
}
.filters.stuck { border-bottom-color: var(--line); }
.filters-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-block: 14px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--sky); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.9rem; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; transition: background-color .2s, color .2s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 42, 67, .14); }
.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 300px;
  padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 17px; height: 17px; flex: none; }
.search input { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 0.95rem; width: 100%; min-width: 0; outline: none; }
.filter-status { flex: none; display: flex; align-items: center; gap: 14px; font-family: var(--f-data); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-status .link-btn { font-family: var(--f-body); font-size: 0.9rem; }
@media (max-width: 860px) {
  .cat-hero { grid-template-columns: minmax(0, 1fr); }
  .filters { position: relative; top: 0; }
  .search { margin-left: 0; flex: 1 1 100%; }
  .seg { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { flex: none; }
}

/* Level meter: three rising bars, like the logo */
.lvl { display: inline-flex; align-items: center; gap: 7px; font-family: var(--f-data); font-size: 0.78rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.lvl-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.lvl-bars i { width: 4px; border-radius: 2px; background: var(--line); transform: skewX(-14deg); }
.lvl-bars i:nth-child(1) { height: 6px; }
.lvl-bars i:nth-child(2) { height: 9.5px; }
.lvl-bars i:nth-child(3) { height: 13px; }
.lvl[data-n="1"] i:nth-child(-n+1), .lvl[data-n="2"] i:nth-child(-n+2), .lvl[data-n="3"] i { background: var(--brand); }

/* Catalog */
.catalog-wrap { padding-block: clamp(32px, 5vw, 56px) clamp(48px, 7vw, 96px); }
#catalogo { display: grid; gap: clamp(56px, 8vw, 96px); }
.cat-group { display: grid; gap: 28px; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 32px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.group-head h2 { font-size: var(--step-2); }
.group-head h2 .lvl { font-family: var(--f-display); font-size: var(--step-2); font-weight: 600; gap: 14px; letter-spacing: -0.02em; }
.group-head h2 .lvl-bars { height: 26px; gap: 4px; }
.group-head h2 .lvl-bars i { width: 8px; border-radius: 4px; }
.group-head h2 .lvl-bars i:nth-child(1) { height: 12px; }
.group-head h2 .lvl-bars i:nth-child(2) { height: 19px; }
.group-head h2 .lvl-bars i:nth-child(3) { height: 26px; }
.group-head p { color: var(--muted); max-width: 52ch; }

.course-grid, .program-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 24px; }
.course-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.program-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); }
.course, .program-card { display: flex; animation: rise .45s ease both; }
@keyframes rise { from { transform: translateY(10px); opacity: .35; } }

.course-link {
  display: flex; flex-direction: column; width: 100%; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s, background-color .35s;
}
.course-link:hover, .course-link:focus-within { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.course-media { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--sky); }
.course-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.course-link:hover .course-media img { transform: scale(1.05); }
.media-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 18px;
  background:
    radial-gradient(90% 80% at 100% 100%, color-mix(in srgb, var(--teal) 22%, transparent), transparent 70%),
    linear-gradient(160deg, var(--sky), color-mix(in srgb, var(--accent-soft) 45%, var(--sky)));
}
.fb-bars { display: inline-flex; align-items: flex-end; gap: 6px; height: 46px; }
.fb-bars i { width: 12px; border-radius: 6px; background: var(--brand); transform: skewX(-14deg); }
.fb-bars i:nth-child(1) { height: 22px; opacity: .45; }
.fb-bars i:nth-child(2) { height: 34px; opacity: .7; }
.fb-bars i:nth-child(3) { height: 46px; }
.fb-area { font-family: var(--f-data); font-size: 0.8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.course-body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 18px; flex: 1; }
.course-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.course-area { font-size: 0.78rem; color: var(--muted); padding: 2px 10px; border-radius: 999px; background: var(--sky); }
.course-title { font-family: var(--f-display); font-weight: 600; font-size: 1.22rem; line-height: 1.15; letter-spacing: -0.015em; text-wrap: balance; flex: 1; }
.course-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-top: 4px; }
.course-lead {
  font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--brand); background: var(--brand); color: var(--on-accent); transition: transform .2s, filter .2s;
}
.course-lead:hover { transform: translateY(-1px); filter: brightness(1.08); }
.course-more { font-weight: 600; font-size: 0.88rem; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.course-more:hover { text-decoration: underline; text-underline-offset: 3px; }

.program-card .course-link { flex-direction: row; }
.program-card .course-media { aspect-ratio: auto; width: 44%; flex: none; min-height: 200px; }
.program-card .course-body { padding: 20px 22px; gap: 12px; }
.program-card .course-title { font-size: var(--step-1); flex: 0; }
.program-card .course-meta { justify-content: flex-start; }
.program-card .course-actions { margin-top: auto; justify-content: flex-start; }
.program-type { font-family: var(--f-data); font-size: 0.75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
@media (max-width: 520px) {
  .program-card .course-link { flex-direction: column; }
  .program-card .course-media { width: 100%; aspect-ratio: 16 / 10; min-height: 0; }
}

.empty { display: grid; gap: 10px; justify-items: start; padding: 40px; border: 1px dashed var(--faint); border-radius: 18px; }
.empty-title { font-family: var(--f-display); font-size: var(--step-2); font-weight: 600; }
.empty p { color: var(--muted); }
.empty .hero-actions { margin-top: 10px; }

.cat-cta {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px 40px;
  padding-block: clamp(48px, 7vw, 88px); border-top: 1px solid var(--line);
}
.cat-cta h2 { font-size: var(--step-3); margin-top: 12px; max-width: 18ch; }

@media (prefers-reduced-motion: reduce) {
  .course, .program-card { animation: none; }
}

/* Ajustes de la revisión: botones más fáciles de tocar y aviso de que el filtro sigue a la derecha */
.quiz-skip, .quiz-back { padding-block: 10px; }
@media (max-width: 760px) {
  .seg button { min-height: 44px; }
  .seg { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}

/* Mapa de cursos (PROTOTIPO): cada punto es una propuesta, por área (horizontal) y nivel (vertical) */
.cat-hero { grid-template-areas: "texto quiz" "mapa quiz"; align-items: start; }
.cat-hero-text { grid-area: texto; }
.cat-hero .quiz { grid-area: quiz; position: sticky; top: 96px; }
.mapa { grid-area: mapa; margin: 0; display: grid; gap: 10px; position: relative; }
.mapa-cap { font-size: 0.98rem; color: var(--muted); min-height: 1.6em; }
.mapa-cap strong { font-family: var(--f-data); font-size: 1.5rem; color: var(--accent); margin-right: 4px; font-variant-numeric: tabular-nums; }
.mapa-plot { position: relative; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); padding: 10px 8px 4px; }
.mapa-plot svg { width: 100%; height: auto; display: block; overflow: visible; }
.m-band { opacity: .07; }
.m-axis { font-family: var(--f-data); font-size: 12px; fill: var(--muted); }
.m-macro { font-family: var(--f-display); font-weight: 600; font-size: 12.5px; }
.m-grid { stroke: var(--line); stroke-dasharray: 3 5; }
.m-dot { cursor: pointer; outline: none; transition: opacity .55s var(--aw-ease, ease), transform 1s var(--aw-ease, ease); transition-delay: 0s, var(--d, 0ms); }
.m-dot circle { transition: r .4s var(--aw-ease, ease), fill .4s, stroke-width .3s; }
.m-dot .m-ring { fill: none; stroke-width: 2; }
.m-dot .m-halo { fill: none; stroke-width: 2; opacity: 0; }
.m-dot:hover .m-core, .m-dot:focus-visible .m-core { r: 11; }
.m-dot:focus-visible .m-halo { opacity: .6; }
.m-dot.is-off { opacity: .14; }
.m-dot.is-mid { opacity: .45; }
.m-dot.is-top .m-halo { opacity: .7; animation: m-pulso 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.m-dot .m-num { font-family: var(--f-data); font-weight: 700; font-size: 11px; fill: #fff; pointer-events: none; }
.m-dot.is-top .m-core { r: 10; }
.m-dot.is-hl .m-core { r: 12.5; }
.m-dot.is-hl .m-halo { opacity: 1; }
.mapa-ley { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.mapa-ley button { all: unset; cursor: pointer; display: flex; gap: 10px; align-items: baseline; font-size: 0.92rem; color: var(--ink); padding: 4px 0; }
.mapa-ley button:hover, .mapa-ley button:focus-visible { color: var(--accent); text-decoration: underline; }
.mapa-ley b { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--surface); font-family: var(--f-data); font-size: 0.75rem; }
@keyframes m-pulso { 50% { transform: scale(1.35); opacity: .15; } }
.mapa:not(.in) .m-dot { opacity: 0; transform: translate(var(--fx), var(--fy)); }
.mapa-tip { font-size: 0.9rem; color: var(--ink); min-height: 1.4em; }
.mapa-tip:empty::before { content: "Tocá un punto para ver el curso."; color: var(--muted); }
@media (max-width: 860px) {
  .cat-hero { grid-template-areas: "texto" "quiz" "mapa"; }
  .cat-hero .quiz { position: relative; top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mapa:not(.in) .m-dot { opacity: 1; transform: none; }
  .m-dot, .m-dot circle { transition: none; }
  .m-dot.is-top .m-halo { animation: none; }
}
:root[data-theme="dark"] { --mapa-ia: #a9c7dd; --mapa-ia-num: #0b2236; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --mapa-ia: #a9c7dd; --mapa-ia-num: #0b2236; } }

/* El mapa no adelanta la recomendación: mientras responde "procesa" y en el paso de los datos queda borroso */
.mapa-cap strong:empty { display: none; }
.mapa[data-fase="pensando"] .m-dot { animation: m-procesa 1.6s ease-in-out infinite; animation-delay: var(--d, 0ms); }
@keyframes m-procesa { 50% { opacity: .35; } }
.mapa-plot svg { transition: filter .8s var(--aw-ease, ease); }
.mapa[data-fase="datos"] .mapa-plot svg { filter: blur(7px) saturate(.8); }
.mapa-velo { position: absolute; left: 0; right: 0; top: 40px; bottom: 30px; margin: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .4s; }
.mapa-velo span { padding: 10px 18px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(11, 34, 54, .12); font-weight: 600; color: var(--ink); font-size: 0.95rem; text-align: center; max-width: 85%; }
.mapa[data-fase="datos"] .mapa-velo { opacity: 1; }
.mapa[data-fase="datos"] .mapa-tip, .mapa[data-fase="datos"] .m-dot { pointer-events: none; }
.mapa[data-fase="datos"] .mapa-tip { visibility: hidden; }
/* Al revelar, los recomendados aparecen después de que se apagan los demás */
.mapa[data-fase="listo"] .m-dot.is-top { animation: m-revela .9s var(--aw-ease, ease) .35s both; }
@keyframes m-revela { from { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .mapa[data-fase="pensando"] .m-dot, .mapa[data-fase="listo"] .m-dot.is-top { animation: none; }
  .mapa-plot svg { transition: none; }
}

/* Al filtrar, la transición la maneja cursos.js (las tarjetas se deslizan y las nuevas llegan en cascada) */
.cat-flip .course, .cat-flip .program-card { animation: none; }
