/* =========================================================
   Helix · Plantilla de las guías del blog (docs/plans/web-funciones, ticket 09)
   La pone docs/plans/web-funciones/herramientas/blog_plantilla.py (y gen_guia.py a través de ella): `hg-marco` en los
   contenedores, `div.hg-rejilla` (ámbito de todo lo del artículo), `nav.hg-indice` (índice «En esta guía»),
   `div.hg-faqs > div.hg-faq`, `aside.hg-rel` («Relacionado en Helix») y `div.tabla-wrap[data-hg-col]` (columna de
   Helix en las comparativas). En el índice del blog: `hg-blog-marco` y `div.hg-blog-rejilla`.
   `<main>`, `<h2 class="t-h2">` y `<table class="tabla">` quedan literales: otras herramientas y tests los buscan así.
   Solo tokens de helix-web.css. Oscuro en :root, claro con [data-theme="light"].
   - Desde 760 px el artículo es una hoja opaca (contenido = tarjeta opaca) y lo de dentro, tarjetas interiores.
   - Desde 1100 px el índice va a la derecha, en cristal (es navegación) y pegado al hacer scroll.
   - Por debajo de 760 px el texto flota sobre la pared, como el panel en el móvil, y el índice es un desplegable.
   ========================================================= */

:root {
  --hg-medida: 664px;                  /* texto: ~70 caracteres por línea con Geist a 17 px */
  --hg-pad: clamp(28px, 4.4vw, 60px);  /* margen interior de la hoja */
  --hg-hoja: calc(var(--hg-medida) + 2 * var(--hg-pad));
  --hg-lado: 236px;
  --hg-hueco: 36px;
  --hg-arriba: 92px;                   /* debajo de la cápsula de navegación */
  --hg-texto: color-mix(in srgb, var(--v5-t1) 58%, var(--v5-t2));
  /* Bloques dentro del artículo: tarjetas que flotan en móvil, interiores dentro de la hoja */
  --hg-bloque: var(--v5-card);
  --hg-bloque-sh: 0 0 0 .5px var(--v5-edge), inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent), var(--v5-sh1);
  --hg-sombra-lado: rgba(0, 0, 0, .5);
}
[data-theme="light"] {
  --hg-bloque-sh: 0 0 0 .5px rgba(60, 30, 20, .08), var(--v5-sh1);
  --hg-sombra-lado: rgba(60, 30, 20, .18);
}
@media (min-width: 760px) {
  :root { --hg-bloque: color-mix(in srgb, var(--v5-t1) 5%, var(--v5-card)); --hg-bloque-sh: inset 0 0 0 1px var(--v5-line); }
  [data-theme="light"] { --hg-bloque: #F6F2F0; --hg-bloque-sh: inset 0 0 0 1px var(--v5-line); }
}

/* ---------- Medida y columnas ---------- */
.hg-marco { max-width: calc(var(--hg-hoja) + 2 * var(--hx-margen)); }
.hw-section--tight:has(> .hg-marco) { padding-top: clamp(12px, 3vh, 32px); }
.hg-indice { margin-bottom: 16px; }
@media (min-width: 1100px) {
  .hg-marco { max-width: calc(var(--hg-hoja) + var(--hg-hueco) + var(--hg-lado) + 2 * var(--hx-margen)); }
  .hg-rejilla { display: grid; grid-template-columns: minmax(0, var(--hg-hoja)) var(--hg-lado); column-gap: var(--hg-hueco);
    align-items: start; }
  .hg-rejilla > article.post { grid-column: 1; grid-row: 1; }
  .hg-rejilla > .hg-indice { grid-column: 2; grid-row: 1; margin: 0; position: sticky; top: var(--hg-arriba); }
}

/* Cabecera de la guía: alineada con el texto de la hoja */
@media (min-width: 760px) {
  .hw-hero .hg-marco > * { padding-inline: var(--hg-pad); }
  .hw-hero .hg-marco > h1 { max-width: calc(var(--hg-hoja) + 40px); padding-right: 0; }
  .hw-hero .hg-marco > p { max-width: var(--hg-hoja); }
}

/* ---------- La hoja del artículo ---------- */
.hg-rejilla article.post { display: block; }
@media (min-width: 760px) {
  .hg-rejilla article.post {
    background: var(--v5-card); border-radius: var(--r-slab);
    padding: clamp(30px, 4vw, 52px) var(--hg-pad) clamp(32px, 4.4vw, 56px);
    box-shadow: 0 0 0 .5px var(--v5-edge), inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent), var(--v5-sh1);
  }
  [data-theme="light"] .hg-rejilla article.post { box-shadow: 0 0 0 .5px rgba(60, 30, 20, .08), var(--v5-sh1); }
}

/* ---------- Texto ---------- */
.hg-rejilla article.post > * + * { margin-top: 18px; }
.hg-rejilla article.post .t-body { font-size: 16.5px; line-height: 1.68; color: var(--hg-texto); max-width: none; }
.hg-rejilla article.post > p:first-child { font-size: clamp(17.5px, 1.5vw, 19px); line-height: 1.6; color: var(--v5-t1);
  letter-spacing: -0.012em; }
@media (min-width: 760px) {
  .hg-rejilla article.post .t-body { font-size: 17px; line-height: 1.72; }
  .hg-rejilla article.post > * + * { margin-top: 20px; }
}
.hg-rejilla article.post > h2 { margin-top: 52px; font-size: clamp(23px, 2.3vw, 28px); line-height: 1.18; letter-spacing: -0.03em;
  color: var(--v5-t1); scroll-margin-top: 96px; }
.hg-rejilla article.post > h2 + * { margin-top: 12px; }
.hg-rejilla article.post > h3 { margin-top: 30px; }
.hg-rejilla article.post strong { color: var(--v5-t1); font-weight: 620; }
.hg-rejilla article.post a:not(.hw-btn):not(.hg-rel-tarjeta) { text-decoration-color: color-mix(in srgb, var(--hx-link) 45%, transparent);
  transition: text-decoration-color var(--hx-d-hover) var(--v5-eo), color var(--hx-d-hover) var(--v5-eo); }
.hg-rejilla article.post a:not(.hw-btn):not(.hg-rel-tarjeta):hover { text-decoration-color: currentColor; }

/* Listas: viñeta coral (con ::marker, para no perder la semántica de lista) */
.hg-rejilla article.post > ul, .hg-rejilla article.post > ol { padding-left: 24px; gap: 10px; }
.hg-rejilla article.post > ul > li { padding-left: 4px; }
.hg-rejilla article.post > ul > li::marker { color: var(--v5-acc); font-size: 1.05em; }
.hg-rejilla article.post > ol > li { padding-left: 6px; }
.hg-rejilla article.post > ol > li::marker { color: var(--hx-acc-text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Cita: la frase que se queda (p.aparte) */
.hg-rejilla article.post p.aparte { position: relative; border-left: 0; margin-block: 30px; padding: 2px 0 2px 24px;
  font-size: clamp(18.5px, 1.75vw, 21px); line-height: 1.48; font-weight: 560; letter-spacing: -0.016em; color: var(--v5-t1); }
.hg-rejilla article.post p.aparte::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--v5-acc-2), var(--v5-acc));
  box-shadow: 0 0 14px color-mix(in srgb, var(--v5-acc) 55%, transparent); }

/* Figuras */
.hg-rejilla article.post figure img { border-radius: 16px; box-shadow: 0 0 0 .5px var(--v5-edge), 0 18px 40px -24px rgba(0, 0, 0, .55); }
[data-theme="light"] .hg-rejilla article.post figure img { box-shadow: 0 0 0 .5px rgba(60, 30, 20, .1), 0 16px 32px -22px rgba(80, 30, 15, .3); }

/* ---------- Tablas ---------- */
.hg-rejilla article.post > .tabla-wrap { margin-block: 26px; }
.hg-rejilla .tabla-wrap { border-radius: 18px; box-shadow: var(--hg-bloque-sh);
  /* Sombras de desplazamiento: aparecen en el lado por el que queda tabla (solo si no cabe) */
  background:
    linear-gradient(to right, var(--hg-bloque) 30%, transparent) left / 44px 100% no-repeat local,
    linear-gradient(to left, var(--hg-bloque) 30%, transparent) right / 44px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--hg-sombra-lado), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--hg-sombra-lado), transparent) right / 14px 100% no-repeat scroll,
    var(--hg-bloque); }
.hg-rejilla .tabla { font-size: 14.5px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.hg-rejilla .tabla th, .hg-rejilla .tabla td { padding: 13px 16px; border-bottom: 0; }
.hg-rejilla .tabla thead th { font-size: 13px; font-weight: 620; color: var(--v5-t1); letter-spacing: -0.005em;
  background: color-mix(in srgb, var(--v5-t1) 5%, transparent); }
.hg-rejilla .tabla thead th:first-child { border-top-left-radius: 18px; }
.hg-rejilla .tabla thead th:last-child { border-top-right-radius: 18px; }
.hg-rejilla .tabla tbody tr + tr td { border-top: 1px solid var(--v5-line); }
.hg-rejilla .tabla td { color: var(--hg-texto); }
.hg-rejilla .tabla td:first-child { color: var(--v5-t1); }
/* Comparativas: la columna de Helix, con un tinte coral */
.hg-rejilla .tabla-wrap[data-hg-col="2"] :is(th, td):nth-child(2), .hg-rejilla .tabla-wrap[data-hg-col="3"] :is(th, td):nth-child(3),
.hg-rejilla .tabla-wrap[data-hg-col="4"] :is(th, td):nth-child(4), .hg-rejilla .tabla-wrap[data-hg-col="5"] :is(th, td):nth-child(5) {
  background: color-mix(in srgb, var(--v5-acc) 8%, transparent); color: var(--v5-t1); }
.hg-rejilla .tabla-wrap[data-hg-col="2"] th:nth-child(2), .hg-rejilla .tabla-wrap[data-hg-col="3"] th:nth-child(3),
.hg-rejilla .tabla-wrap[data-hg-col="4"] th:nth-child(4), .hg-rejilla .tabla-wrap[data-hg-col="5"] th:nth-child(5) {
  color: var(--hx-acc-text); background: color-mix(in srgb, var(--v5-acc) 14%, transparent); }

/* ---------- Llamadas a probar (las de la guía, con el tono de la hoja) ---------- */
.hg-rejilla article.post > .hx-cta-guia { margin-block: 30px; padding: 18px 20px; border-radius: 20px; }
.hg-rejilla article.post > .hx-cta-guia .t-body-s { font-size: 14.5px; line-height: 1.5; }
.hg-rejilla article.post > .hx-cta-guia-fin { margin-top: 18px; background: var(--hx-panel-marca); border-radius: var(--hx-r-destacada); }

/* ---------- Preguntas frecuentes: una tarjeta por pregunta ---------- */
.hg-rejilla article.post > .hg-faqs { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.hg-faq { background: var(--hg-bloque); box-shadow: var(--hg-bloque-sh); border-radius: 18px; padding: 18px 20px 19px; }
.hg-rejilla article.post .hg-faq > h3 { margin: 0; font-size: 16.5px; line-height: 1.35; font-weight: 620; letter-spacing: -0.012em;
  color: var(--v5-t1); }
.hg-rejilla article.post .hg-faq > :not(h3) { margin-top: 7px; }
.hg-rejilla article.post .hg-faq > .t-body { font-size: 15.5px; line-height: 1.62; }

/* ---------- Relacionado en Helix ---------- */
.hg-rejilla article.post > .hg-rel { margin-top: 40px; }
.hg-rejilla article.post a.hg-rel-tarjeta { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 22px;
  color: inherit; text-decoration: none; background: var(--hg-bloque); box-shadow: var(--hg-bloque-sh);
  transition: transform .25s var(--v5-eo), box-shadow .35s var(--v5-eo); }
.hg-rel-ic { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--hx-acc-bg); color: var(--hx-acc-text); }
.hg-rel-ic .icon { width: 22px; height: 22px; stroke-width: 1.7; }
.hg-rel-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.hg-rel-eti { font-size: 12.5px; font-weight: 550; color: var(--hx-t3-aa); }
.hg-rel-nombre { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; color: var(--v5-t1); }
.hg-rel-linea { font-size: 14.5px; line-height: 1.4; color: var(--v5-t2); }
.hg-rel-ir { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center;
  color: var(--hx-acc-text); background: var(--hx-acc-bg); transition: transform .3s var(--v5-eo); }
.hg-rel-ir .icon { width: 17px; height: 17px; stroke-width: 2.1; }
.hg-rejilla article.post a.hg-rel-tarjeta:hover { transform: translateY(-2px); }
.hg-rejilla article.post a.hg-rel-tarjeta:hover .hg-rel-ir, .hg-rejilla article.post a.hg-rel-tarjeta:focus-visible .hg-rel-ir { transform: translateX(3px); }
@media (max-width: 420px) { .hg-rejilla article.post a.hg-rel-tarjeta { gap: 13px; padding: 16px; } .hg-rel-ir { display: none; } }

/* ---------- Sigue leyendo (tarjeta interior) ---------- */
.hg-rejilla article.post > .sigue-leyendo { margin-top: 14px; background: var(--hg-bloque); box-shadow: var(--hg-bloque-sh); }
.hg-rejilla article.post .sigue-leyendo .t-body { font-size: 15.5px; line-height: 1.55; }

/* ---------- Índice «En esta guía» ---------- */
.hg-indice-caja { border-radius: 18px; background: var(--v5-card);
  box-shadow: 0 0 0 .5px var(--v5-edge), inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent), var(--v5-sh1); }
[data-theme="light"] .hg-indice-caja { box-shadow: 0 0 0 .5px rgba(60, 30, 20, .08), var(--v5-sh1); }
.hg-indice-tit { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 18px;
  cursor: pointer; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--v5-t1); border-radius: 18px;
  -webkit-tap-highlight-color: transparent; }
.hg-indice-tit::-webkit-details-marker { display: none; }
.hg-indice-ic { width: 18px; height: 18px; color: var(--hx-acc-text); }
.hg-indice-chev { margin-left: auto; width: 18px; height: 18px; color: var(--hx-t3-aa); transition: transform var(--hx-d-hover) var(--v5-eo); }
.hg-indice-caja[open] .hg-indice-chev { transform: rotate(180deg); }
.hg-indice-lista { list-style: none; margin: 0; padding: 0 8px 10px; position: relative; }
.hg-indice-lista li + li { margin-top: 1px; }
/* .hg-rejilla delante: helix-web.css pinta y subraya todo `main li a` como enlace de texto */
.hg-rejilla .hg-indice-lista a { position: relative; display: block; padding: 11px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.35;
  color: var(--v5-t2); text-decoration: none; transition: color var(--hx-d-hover) var(--v5-eo), background var(--hx-d-hover) var(--v5-eo); }
.hg-rejilla .hg-indice-lista a:hover { color: var(--v5-t1); background: color-mix(in srgb, var(--v5-t1) 6%, transparent); }
.hg-indice-lista a:active { transform: scale(.985); }

@media (min-width: 1100px) {
  /* Navegación: cápsula de cristal, abierta siempre, con un carril que marca el apartado que se lee */
  .hg-indice-caja { border-radius: 22px; padding: 16px 0 12px;
    background: var(--v5-glass); backdrop-filter: var(--hx-blur-capsula); -webkit-backdrop-filter: var(--hx-blur-capsula);
    box-shadow: 0 0 0 .5px var(--v5-edge), inset 0 1px 0 var(--v5-hl), 0 18px 40px -22px rgba(0, 0, 0, .6); }
  [data-theme="light"] .hg-indice-caja { box-shadow: 0 0 0 .5px var(--v5-edge), inset 0 1px 0 var(--v5-hl), 0 16px 36px -22px rgba(80, 30, 15, .28); }
  .hg-indice-caja::details-content { content-visibility: visible; }  /* abierto antes de que llegue el JS */
  .hg-indice-tit { min-height: 0; padding: 0 20px 10px; cursor: default; font-size: 13px; color: var(--v5-t2); }
  .hg-indice-ic { width: 15px; height: 15px; }
  .hg-indice-chev { display: none; }
  .hg-indice-lista { max-height: calc(100vh - var(--hg-arriba) - 96px); overflow-y: auto; overscroll-behavior: contain;
    padding: 2px 12px 2px 20px; scrollbar-width: thin; }
  .hg-indice-lista::before { content: ''; position: absolute; left: 20px; top: 4px; bottom: 4px; width: 1.5px; border-radius: 2px;
    background: var(--v5-track); }
  .hg-indice-lista li + li { margin-top: 0; }
  .hg-rejilla .hg-indice-lista a { padding: 7px 8px 7px 15px; font-size: 13.5px; line-height: 1.38; border-radius: 0 10px 10px 0; }
  .hg-rejilla .hg-indice-lista a:hover { background: transparent; }
  .hg-indice-lista a::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px;
    background: var(--v5-acc); box-shadow: 0 0 8px var(--v5-acc); opacity: 0; transform: scaleY(.4);
    transition: opacity var(--hx-d-hover) var(--v5-eo), transform .35s var(--v5-eo); }
  .hg-rejilla .hg-indice-lista a[aria-current] { color: var(--v5-t1); font-weight: 560; }
  .hg-indice-lista a[aria-current]::before { opacity: 1; transform: none; }
}

/* ---------- Barra de lectura: mide el artículo, no la página entera (la pone helix-web.js) ---------- */
@supports (timeline-scope: --a) and (animation-timeline: view()) {
  html:has(.hg-rejilla) { timeline-scope: --hg-lectura; }
  .hg-rejilla article.post { view-timeline: --hg-lectura block; }
  html:has(.hg-rejilla) .hx-progreso { animation-timeline: --hg-lectura; animation-range: contain 0% contain 100%; }
}

/* =========================================================
   Índice del blog: las guías en una rejilla de tarjetas
   ========================================================= */
.hg-blog-marco { max-width: var(--hx-ancho); }
.hg-blog-rejilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.hg-blog-marco .hx-guia { margin: 0; display: flex; flex-direction: column; padding: 26px 28px 24px; border-radius: 22px; }
.hg-blog-marco .hx-guia .t-h2 { font-size: clamp(19px, 1.65vw, 22px); line-height: 1.24; letter-spacing: -0.024em; }
.hg-blog-marco .hx-guia .t-body { font-size: 15px; line-height: 1.55; }
.hg-blog-marco .hx-guia .hx-leer { margin-top: auto; padding-top: 4px; transition: color var(--hx-d-hover) var(--v5-eo), gap .3s var(--v5-eo); }
.hg-blog-marco .hx-guia:hover .hx-leer { gap: 10px; }
.hg-blog-marco > .t-caption, .hg-blog-marco > .hx-cta-guia-fin { max-width: 780px; margin-inline: auto; }
.hg-blog-marco > .hx-cta-guia-fin { margin-top: 20px; }
@media (max-width: 860px) {
  .hg-blog-rejilla { grid-template-columns: 1fr; gap: 12px; }
  .hg-blog-marco .hx-guia { padding: 22px 20px 20px; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .hg-rejilla article.post a.hg-rel-tarjeta, .hg-rel-ir, .hg-indice-chev, .hg-indice-lista a, .hg-indice-lista a::before, .hg-blog-marco .hx-guia .hx-leer { transition: none; }
  .hg-rejilla article.post a.hg-rel-tarjeta:hover, .hg-rejilla article.post a.hg-rel-tarjeta:hover .hg-rel-ir { transform: none; }
  .hg-indice-lista a:active { transform: none; }
}
