/* Niveles y precios (#formatos). Arriba, el titular; debajo, las pestañas grandes (Titulado · Máster · Doctorado
   en Excon, fino y gris el que no está elegido, grueso y claro el elegido, con una raya verde encima de su nombre).
   Luego el precio en un panel (con «Con FUNDAE» en equipos) junto a «Qué incluye», y el itinerario que se ilumina.
   Fondo: lo pone base.css (data-tone="surface"). Todos los selectores empiezan por #formatos.
   Verde = lo que se consigue (sesiones incluidas, la bonificación); el rojo, solo en el botón. */

#formatos { --niv-node: 30px; --niv-gap: clamp(16px, 2vw, 28px); }

/* ---------- Cabecera ---------- */
#formatos .niv-head { display: grid; gap: clamp(10px, 1.4vw, 16px); }
#formatos .niv-title { max-width: 18ch; }
#formatos .niv-lead { max-width: 46ch; font-size: var(--fs-lead); line-height: 1.5; color: var(--text-2); text-wrap: pretty; }

/* ---------- Pestañas grandes ---------- */
#formatos .niv-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--niv-gap);
  margin: clamp(28px, 3.6vw, 48px) 0 0; padding: 0; min-inline-size: 0; border: 0;
}
#formatos .niv-tab {
  position: relative; display: grid; justify-items: start; gap: 8px; min-width: 0;
  padding: 18px 0 6px; border-top: 1px solid var(--line-2);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s var(--ease-out);
}
#formatos .niv-tab::before {
  content: ""; position: absolute; top: -1px; left: 0; width: 100%; height: 2px; border-radius: 1px;
  background: var(--human); transform: scaleX(0); transform-origin: 0 50%;
  transition: transform 0.45s var(--ease-out);
}
#formatos .niv-tab:active { transform: scale(0.98); }
#formatos .niv-tab:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 6px; border-radius: 6px; }
#formatos .niv-tab-n {
  font-family: var(--font-display); font-weight: 200;
  font-size: clamp(2rem, 0.6rem + 3.6vw, 4.5rem); line-height: 0.95; letter-spacing: -0.04em; white-space: nowrap;
  color: var(--text-3);
  transition: color 0.35s var(--ease-out), font-weight 0.45s var(--ease-out);
}
#formatos .niv-tab-k { font-size: 0.9375rem; font-weight: 500; line-height: 1.3; color: var(--text-2); transition: color 0.3s var(--ease-out); }
#formatos .niv-tab:has(input:checked) { cursor: default; }
#formatos .niv-tab:has(input:checked)::before { transform: scaleX(1); }
#formatos .niv-tab:has(input:checked) .niv-tab-n { font-weight: 800; color: var(--text); }
#formatos .niv-tab:has(input:checked) .niv-tab-k { color: var(--text); }

/* ---------- Cuerpo: panel del precio y qué incluye ---------- */
#formatos .niv-body { display: grid; gap: clamp(28px, 3.4vw, 48px); margin-top: clamp(28px, 3.4vw, 44px); }

#formatos .niv-panel {
  position: relative; align-self: start;
  padding: clamp(22px, 2.6vw, 34px);
  border-radius: var(--radius-lg); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
#formatos .niv-price { position: relative; }
/* El polvo del precio (lo pone formatos.js): sobresale del número y no coge clics. */
#formatos .niv-dust { position: absolute; inset: -40px -48px; width: calc(100% + 96px); height: calc(100% + 80px); pointer-events: none; z-index: 1; }
#formatos .niv-price-n {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(3.25rem, 1.9rem + 4.2vw, 5.75rem); line-height: 0.95; letter-spacing: -0.045em; white-space: nowrap;
  color: var(--text);
  transition: color 0.4s var(--ease-out);
}
/* Con FUNDAE, el precio es lo que os cuesta de verdad: en verde. */
#formatos .niv-panel.is-fundae .niv-price-n { color: var(--human); }
#formatos .niv-unit { margin-top: 12px; font-size: 1.0625rem; font-weight: 500; line-height: 1.4; color: var(--text); }
#formatos .niv-tax { margin-top: 2px; font-size: var(--fs-small); color: var(--text-2); }

/* Interruptor «Con FUNDAE» */
#formatos .niv-fundae { margin-top: clamp(20px, 2.4vw, 28px); padding-top: clamp(18px, 2vw, 24px); border-top: 1px solid var(--line); }
#formatos .niv-switch {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; text-align: left;
  border-radius: 12px; transition: transform 0.16s var(--ease-out);
}
#formatos .niv-switch:active { transform: scale(0.98); }
#formatos .niv-switch-track {
  position: relative; flex: none; width: 48px; height: 28px; border-radius: 999px;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
#formatos .niv-switch-knob {
  position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.3s var(--ease-out), background-color 0.25s var(--ease-out);
}
#formatos .niv-switch[aria-checked="true"] .niv-switch-track { background: var(--human); box-shadow: none; }
#formatos .niv-switch[aria-checked="true"] .niv-switch-knob { transform: translateX(20px); background: var(--human-ink); }
#formatos .niv-switch-text { display: grid; gap: 1px; }
#formatos .niv-switch-l { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; line-height: 1.2; letter-spacing: -0.01em; }
#formatos .niv-switch-hint { font-size: var(--fs-small); line-height: 1.35; color: var(--text-2); }

/* Desglose (solo con FUNDAE) */
#formatos .niv-bd { overflow: hidden; }
#formatos .niv-bd-list { margin-top: 18px; }
#formatos .niv-bd-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-top: 1px solid var(--line-soft);
}
#formatos .niv-bd-row:first-child { border-top: 0; }
#formatos .niv-bd-row dt { display: grid; gap: 2px; font-size: 0.9688rem; color: var(--text-2); }
#formatos .niv-bd-calc { font-size: 0.8125rem; color: var(--text-3); }
#formatos .niv-bd-row dd { font-weight: 700; white-space: nowrap; }
#formatos .niv-bd-row.is-total { border-top: 1px solid var(--line-2); }
#formatos .niv-bd-row.is-total dt { color: var(--text); font-weight: 700; }
#formatos .niv-bd-row.is-total dd { font-family: var(--font-display); font-size: 1.375rem; color: var(--human); }
#formatos .niv-bd-note { margin-top: 10px; font-size: 0.875rem; line-height: 1.5; color: var(--text-2); text-wrap: pretty; }
#formatos .niv-steps { margin-top: 18px; }
#formatos .niv-steps-k { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
#formatos .niv-steps-list { display: grid; gap: 10px; margin-top: 10px; counter-reset: none; }
#formatos .niv-steps-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; font-size: 0.9375rem; line-height: 1.45; color: var(--text-2); }
#formatos .niv-steps-i {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 0.75rem; font-weight: 700; color: var(--human); box-shadow: inset 0 0 0 1.5px var(--human);
}

/* Qué incluye */
#formatos .niv-detail { display: grid; align-content: start; }
#formatos .niv-inc-t { font-size: clamp(1.375rem, 1.15rem + 0.6vw, 1.75rem); font-weight: 600; letter-spacing: -0.02em; }
#formatos .niv-inc-n { color: var(--human); }
#formatos .niv-inc-h {
  margin-top: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 600; font-size: 1.125rem; color: var(--text);
}
#formatos .niv-inc li {
  position: relative; padding: 11px 0 11px 30px; border-bottom: 1px solid var(--line-soft);
  font-size: 1rem; line-height: 1.45; color: var(--text); text-wrap: pretty;
}
#formatos .niv-inc li::before {
  content: ""; position: absolute; left: 2px; top: 15px; width: 14px; height: 8px;
  border-left: 2px solid var(--human); border-bottom: 2px solid var(--human);
  transform: rotate(-45deg); border-radius: 1px;
}
#formatos .niv-sop { margin-top: 12px; font-size: 0.8438rem; line-height: 1.5; color: var(--text-2); text-wrap: pretty; }
#formatos .niv-cta { display: grid; gap: 12px; margin-top: 24px; }
#formatos .niv-cta-btn { justify-self: start; white-space: normal; text-align: left; line-height: 1.25; padding-block: 12px; }
#formatos .niv-note { max-width: 52ch; font-size: 0.9375rem; line-height: 1.5; color: var(--text-2); text-wrap: pretty; }

/* ---------- Itinerario: las sesiones en un recorrido; las incluidas, encendidas ----------
   Cada paso pinta su tramo hasta el siguiente (::before el raíl gris, ::after el tramo verde, que crece si los dos
   pasos están encendidos: .is-link). --d: retraso de cada paso al encenderse o apagarse (lo pone formatos.js). */
#formatos .niv-route { margin-top: clamp(40px, 5vw, 72px); }
#formatos .niv-route-t { font-size: clamp(1.375rem, 1.15rem + 0.6vw, 1.75rem); font-weight: 600; letter-spacing: -0.02em; }
#formatos .niv-route-h { margin-left: 8px; font-family: var(--font-text); font-size: 1rem; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
#formatos .niv-it { display: grid; margin-top: 22px; }
#formatos .niv-it-step { position: relative; display: grid; align-content: start; gap: 6px; }
#formatos .niv-it-step::before,
#formatos .niv-it-step::after { content: ""; position: absolute; border-radius: 2px; pointer-events: none; }
#formatos .niv-it-step:last-child::before,
#formatos .niv-it-step:last-child::after { display: none; }
#formatos .niv-it-step::before { background: var(--line-2); }
#formatos .niv-it-step::after { background: var(--human); transition: transform 0.35s var(--ease-out) var(--d, 0ms); }
#formatos .niv-it-node {
  position: relative; z-index: 1;
  display: grid; place-items: center; width: var(--niv-node); height: var(--niv-node); border-radius: 50%;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line-2);
  font-size: 0.8125rem; font-weight: 700; color: var(--text-3);
  transition: background-color 0.3s var(--ease-out) var(--d, 0ms), color 0.3s var(--ease-out) var(--d, 0ms), box-shadow 0.3s var(--ease-out) var(--d, 0ms);
}
#formatos .niv-it-t {
  font-family: var(--font-display); font-weight: 600; font-size: 1.125rem; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--text-3); transition: color 0.3s var(--ease-out) var(--d, 0ms);
}
#formatos .niv-it-d { font-size: 0.9375rem; line-height: 1.45; color: var(--text-3); text-wrap: pretty; transition: color 0.3s var(--ease-out) var(--d, 0ms); }
#formatos .niv-it-step.is-on .niv-it-node { background: var(--human); color: var(--human-ink); box-shadow: 0 0 0 5px var(--human-soft); }
#formatos .niv-it-step.is-on .niv-it-t { color: var(--text); }
#formatos .niv-it-step.is-on .niv-it-d { color: var(--text-2); }
/* Antes de asomar (con JS), el recorrido espera apagado; al llegar se enciende (formatos.js pone .is-lit). */
.js #formatos:not(.is-lit) .niv-it-step .niv-it-node { background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.js #formatos:not(.is-lit) .niv-it-step::after { transform: scale(0, 0) !important; }

/* «en Doctorado»: elige el nivel que trae esa sesión. Zona de toque de 44 px sin cambiar el aspecto. */
#formatos .niv-it-need {
  position: relative; justify-self: start; min-height: 26px; margin-top: 4px; padding: 0 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 500; line-height: 26px; color: var(--text); white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: box-shadow 0.25s var(--ease-out), transform 0.16s var(--ease-out);
}
#formatos .niv-it-need::after { content: ""; position: absolute; inset: -9px -6px; }
#formatos .niv-it-need:active { transform: scale(0.97); }
#formatos .niv-it-step.is-on .niv-it-need { display: none; }

/* En horizontal (escritorio): una columna por sesión, raíl a la altura de los nodos. */
@media (min-width: 1024px) {
  #formatos .niv-it { grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 0 var(--niv-gap); }
  #formatos .niv-it-step { gap: 8px; padding-right: 4px; }
  #formatos .niv-it-node { margin-bottom: 6px; }
  #formatos .niv-it-step::before,
  #formatos .niv-it-step::after {
    top: calc(var(--niv-node) / 2 - 1px); left: calc(var(--niv-node) / 2); height: 2px; width: calc(100% + var(--niv-gap));
  }
  #formatos .niv-it-step::after { transform: scaleX(0); transform-origin: 0 50%; }
  #formatos .niv-it-step.is-link::after { transform: scaleX(1); }
}
/* En vertical (tableta y móvil): nodo a la izquierda, raíl hacia abajo. */
@media (max-width: 1023px) {
  #formatos .niv-it-step { grid-template-columns: var(--niv-node) minmax(0, 1fr); column-gap: 16px; row-gap: 4px; padding-bottom: 22px; }
  #formatos .niv-it-step:last-child { padding-bottom: 0; }
  #formatos .niv-it-node { grid-row: 1 / span 3; }
  #formatos .niv-it-t { grid-column: 2; padding-top: 5px; }
  #formatos .niv-it-d, #formatos .niv-it-need { grid-column: 2; }
  #formatos .niv-it-step::before,
  #formatos .niv-it-step::after {
    left: calc(var(--niv-node) / 2 - 1px); top: calc(var(--niv-node) / 2); width: 2px; height: 100%;
  }
  #formatos .niv-it-step::after { transform: scaleY(0); transform-origin: 50% 0; }
  #formatos .niv-it-step.is-link::after { transform: scaleY(1); }
}

/* ---------- Solo con ratón ---------- */
@media (hover: hover) and (pointer: fine) {
  #formatos .niv-tab:not(:has(input:checked)):hover .niv-tab-n,
  #formatos .niv-tab:not(:has(input:checked)):hover .niv-tab-k { color: var(--text); }
  #formatos .niv-switch:hover .niv-switch-track { box-shadow: inset 0 0 0 1px var(--text-3); }
  #formatos .niv-switch[aria-checked="true"]:hover .niv-switch-track { box-shadow: none; background: #92e39e; }
  #formatos .niv-it-need:hover { box-shadow: inset 0 0 0 1px var(--text-2); }
}

/* ---------- Escritorio: precio (5/12) y qué incluye (7/12) ---------- */
@media (min-width: 1024px) {
  #formatos .niv-body { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: clamp(32px, 4vw, 64px); }
}

/* ---------- Tableta ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  #formatos .niv-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
  #formatos .niv-price-n { font-size: clamp(3rem, 6.4vw, 4rem); }
}

/* ---------- Móvil: pestañas en filas (nombre a la izquierda, sesiones a la derecha) ---------- */
@media (max-width: 599px) {
  #formatos .niv-tabs { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #formatos .niv-tab {
    grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 12px;
    padding: 14px 0 12px;
  }
  #formatos .niv-tab:last-child { border-bottom: 1px solid var(--line-2); }
  #formatos .niv-tab-n { font-size: 2.125rem; }
  #formatos .niv-tab-k { font-size: 0.875rem; text-align: right; }
  #formatos .niv-cta-btn { justify-self: stretch; text-align: center; }
  #formatos .niv-panel { padding: 22px 18px; }
  #formatos .niv-dust { inset: -32px -18px; width: calc(100% + 36px); height: calc(100% + 64px); }
}
