/* arbol.css — Menú lateral «Categorías» (Fase 2.9b, includes/arbol_categorias.php + assets/js/arbol.js).
   Escritorio (≥ 900 px): columna de 300 px fija al hacer scroll. Móvil: botón «Categorías» junto al buscador y panel deslizante.
   Contraste AA: tinta #1e1a18, gris #5f5853 y naranja de texto #9a4f04 sobre blanco y crema. */

:root {
  --ac-ink: #1e1a18; --ac-gris: #5f5853; --ac-linea: #ebe1d2; --ac-nar: #f7921e; --ac-nar-t: #9a4f04;
  --ac-crema: #fff8ee; --ac-hover: #faf5ec; --ac-foco: #1F8A85; --ac-chip: #f4efe7;
}

/* ---------- Dos columnas (antes en sidebar.css) ---------- */
.layout { display: block; width: 100%; box-sizing: border-box; }
.layout__sidebar { display: none; }
.layout__content { min-width: 0; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; padding: 16px 16px 32px; }
  .layout__sidebar { display: block; position: sticky; top: 16px; align-self: start; }
}

/* ---------- El menú ---------- */
.ac {
  box-sizing: border-box; display: flex; flex-direction: column; background: #fff; border-radius: 18px;
  box-shadow: 0 8px 24px rgba(30, 26, 24, .07); padding: 14px 10px 10px; color: var(--ac-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; text-align: left;
}
.layout__sidebar .ac { max-height: calc(100vh - 32px); }
.ac *, .ac *::before, .ac *::after { box-sizing: border-box; }
.ac[hidden], .ac [hidden] { display: none !important; }
.ac-oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; margin: 0; padding: 0; }

.ac-cab { display: flex; align-items: center; gap: 8px; padding: 2px 6px 10px; }
.ac-titulo { flex: 1; margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ac-nar-t); }
.ac-contraer { white-space: nowrap; border: 0; background: none; padding: 6px 4px; color: var(--ac-gris); font: 600 12px/1.2 inherit; font-family: inherit; cursor: pointer; border-radius: 6px; }
.ac-contraer:hover { color: var(--ac-nar-t); text-decoration: underline; }
.ac-cerrar { display: none; }

.ac-filtro { position: relative; margin: 0 4px 10px; }
.ac-filtro svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ac-nar-t); pointer-events: none; }
.ac-filtro-campo {
  width: 100%; height: 38px; padding: 0 10px 0 32px; border: 1.5px solid var(--ac-linea); border-radius: 10px; background: var(--ac-crema);
  color: var(--ac-ink); font: 400 13.5px/1 inherit; font-family: inherit; outline: none; -webkit-appearance: none; appearance: none;
}
.ac-filtro-campo::placeholder { color: #857d77; }
.ac-filtro-campo:focus { border-color: var(--ac-nar); background: #fff; }

/* 2.9c: position relative para que los textos ocultos (.ac-oculto, absolute) de las filas que no se ven queden DENTRO del scroll del árbol.
   Sin esto se salían por debajo y alargaban la página (el hueco gris debajo del pie en las páginas cortas). */
.ac-arbol { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 4px 0; scrollbar-width: thin; }
.ac-lista { list-style: none; margin: 0; padding: 0; }
.ac-hijas { margin-left: 15px; padding-left: 6px; border-left: 1.5px solid var(--ac-linea); }
.ac-raiz { margin-bottom: 2px; }
.ac-sep { border-top: 1px solid var(--ac-linea); margin: 8px 6px; }

.ac-fila { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.ac-fila:hover { background: var(--ac-hover); }
.ac-flecha, .ac-hueco { flex: none; width: 26px; height: 32px; }
.ac-flecha {
  display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--ac-gris); cursor: pointer;
}
.ac-chev { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin-left: -2px; transition: transform .2s ease; }
.ac-flecha[aria-expanded="true"] { color: var(--ac-nar-t); }
.ac-flecha[aria-expanded="true"] .ac-chev { transform: rotate(45deg); margin: -3px 0 0; }
.ac-flecha:hover { background: #f3ebde; }
.ac-flecha.ac-cargando .ac-chev { opacity: .35; }
.ac-enlace {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 2px; border-radius: 8px;
  color: #2c2725; text-decoration: none; font-size: 13.5px; line-height: 1.25;
}
.ac-nombre { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ac-raiz > .ac-fila .ac-enlace { font-weight: 800; font-size: 13px; letter-spacing: .04em; }
.ac-camino > .ac-fila .ac-nombre { font-weight: 700; }
.ac-actual { background: var(--ac-crema); box-shadow: inset 3px 0 0 var(--ac-nar); }
.ac-actual:hover { background: var(--ac-crema); }
.ac-actual .ac-enlace { color: var(--ac-nar-t); font-weight: 700; }
.ac-cont {
  flex: none; padding: 2px 7px; border-radius: 999px; background: var(--ac-chip); color: var(--ac-gris);
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.ac-punto { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ac-nar); }
.ac-nombre mark { background: #ffe2b8; color: inherit; border-radius: 3px; padding: 0 1px; }
.ac-vacio { padding: 10px 10px; color: var(--ac-gris); font-size: 13px; }

.ac a:focus-visible, .ac button:focus-visible, .ac-boton:focus-visible { outline: 3px solid var(--ac-foco); outline-offset: 1px; }
.ac-filtro-campo:focus-visible { outline: 3px solid var(--ac-foco); outline-offset: 1px; }

/* ---------- Botón «Categorías» (junto al buscador) ---------- */
.ac-boton {
  flex: none; display: none; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 14px;
  border: 1.5px solid var(--ac-linea); border-radius: 12px; background: #fff; color: var(--ac-ink);
  font: 700 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; cursor: pointer; white-space: nowrap;
}
.ac-boton:hover { border-color: var(--ac-nar); }
.catalogo-busqueda.ac-con-boton { display: flex; align-items: center; justify-content: center; gap: 10px; }
.catalogo-busqueda.ac-con-boton > .busqueda-box, .catalogo-busqueda.ac-con-boton > form { flex: 1 1 auto; min-width: 0; }
/* Solo en escritorio y en las páginas sin columna lateral (búsqueda, ficha). En el móvil (2.9c) las categorías están en el menú ☰ de la
   cabecera (entrada «CATEGORÍAS» que añade arbol.js) y el buscador ocupa todo el ancho. */
.ac-sin-lateral .ac-boton { display: inline-flex; }
@media (max-width: 899.98px) { .ac-sin-lateral .ac-boton { display: none; } }

/* ---------- 2.9c: entrada «CATEGORÍAS» en el menú ☰ de la cabecera (solo móvil) ---------- */
.catalogo-header nav .ac-menu-entrada { display: none; }
@media (max-width: 899.98px) { .catalogo-header nav.open .ac-menu-entrada { display: block; } }

/* ---------- 2.9c: el pie, siempre abajo (body ya es flex en catalogo.css; la ficha le ponía un margen fijo) ---------- */
body > footer { margin-top: auto !important; }
body .df.detalle-main { margin-bottom: 48px; } /* el hueco que daba el margen del pie (detalle.css, que se carga después: de ahí «body») */
@media (max-width: 640px) { body .df.detalle-main { margin-bottom: 32px; } }

/* ---------- Panel deslizante ---------- */
.ac-panel { position: fixed; inset: 0; z-index: 10050; }
.ac-panel[hidden] { display: none; }
.ac-panel-fondo { position: absolute; inset: 0; background: rgba(20, 16, 14, .45); opacity: 0; transition: opacity .2s ease; }
.ac-panel-caja {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(90vw, 380px); display: flex; flex-direction: column;
  background: #fff; box-shadow: 8px 0 30px rgba(0, 0, 0, .2); transform: translateX(-100%); transition: transform .22s ease;
}
.ac-panel.ac-abierto .ac-panel-fondo { opacity: 1; }
.ac-panel.ac-abierto .ac-panel-caja { transform: none; }
.ac-panel .ac { flex: 1; min-height: 0; border-radius: 0; box-shadow: none; padding: 14px 10px 10px; }
.ac-panel .ac-titulo { font-size: 15px; letter-spacing: .08em; }
.ac-panel .ac-cerrar {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: #f6f1ea;
  color: var(--ac-ink); cursor: pointer;
}
.ac-panel .ac-contraer { min-height: 44px; }
.ac-panel .ac-filtro-campo { height: 44px; font-size: 16px; }
.ac-panel .ac-flecha, .ac-panel .ac-hueco { width: 34px; height: 44px; }
.ac-panel .ac-enlace { min-height: 44px; font-size: 14.5px; }
.ac-panel .ac-raiz > .ac-fila .ac-enlace { font-size: 14px; }
html.ac-bloqueo, html.ac-bloqueo body { overflow: hidden; }
@media (max-width: 360px) { .ac-panel .ac-titulo { font-size: 14px; letter-spacing: .05em; } .ac-panel .ac-cab { gap: 4px; padding-right: 0; } }

@media (prefers-reduced-motion: reduce) {
  .ac-chev, .ac-panel-fondo, .ac-panel-caja { transition: none; }
}
