/* ============================================================
   hoja.css (UX-05, PARIDAD-2026-10) -- <x-app.hoja>: hoja inferior en < 1024 px, inspector lateral sin velo en
   >= 1024 px (o modal centrado con :modal="true"). Comportamiento en public/js/hoja.js; guia en
   docs/kb/ux-2026-09/hoja.md. Mismos tokens de editorial.css (--ink, --rule-soft, --olive...): no cambia colores.
   El movimiento lo hace hoja.js con la Web Animations API (resorte muestreado, en el compositor); aqui solo hay
   posiciones de reposo. Sin transiciones CSS: se interrumpe leyendo la posicion en pantalla.
   ============================================================ */
.app-hoja {
  position: fixed; inset: 0; z-index: 45; width: auto; height: auto; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink);
  /* clip y no hidden: con hidden el <dialog> es contenedor de scroll y el foco inicial de showModal() lo desplaza
     para "ver" el panel que todavia esta fuera de la pantalla (la hoja quedaba 240 px arriba) */
  overflow: clip;
  overscroll-behavior: contain;
}
.app-hoja:not([open]) { display: none; }
.app-hoja::backdrop { background: transparent; }
/* dim-to-focus: el velo es nuestro (no ::backdrop) para atar su opacidad al arrastre */
.app-hoja-velo { position: absolute; inset: 0; background: var(--app-velo); opacity: 0; touch-action: none; }

/* ---------- hoja inferior (< 1024 px) ---------- */
.app-hoja-panel {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  max-height: calc(100dvh - env(safe-area-inset-top) - 12px);
  /* superficie grande = material mas grueso (/apple 12) */
  background: var(--app-material-hoja); /* DARK-01: token (claro = rgba(255,255,255,.94) de siempre) */
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04), 0 -12px 40px rgba(30, 25, 60, 0.16);
  transform: translateY(110%); will-change: transform;
  padding-bottom: env(safe-area-inset-bottom); outline: none;
}
/* al estirar hacia arriba (rubber-band) no se asoma la pagina por debajo */
.app-hoja-panel::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 240px; background: inherit; }
@media (min-width: 700px) { .app-hoja-panel { left: max(16px, calc((100% - 640px) / 2)); right: max(16px, calc((100% - 640px) / 2)); } }

.app-hoja-tirador {
  display: grid; place-items: center; flex: none; width: 100%; height: 22px; padding: 0; margin: 0;
  border: 0; background: none; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
}
.app-hoja-tirador::before { content: ""; width: 36px; height: 5px; border-radius: 999px; background: var(--ink-faint); }
.app-hoja-tirador:focus-visible { outline: none; }
.app-hoja-tirador:focus-visible::before { box-shadow: 0 0 0 3px var(--olive-dk); }

.app-hoja-cabeza { display: flex; align-items: flex-start; gap: 12px; padding: 4px 16px 12px; flex: none; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.app-hoja-cabeza > div { min-width: 0; flex: 1; }
.app-hoja-titulo {
  margin: 0; font-size: 1.25rem; line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; color: var(--ink);
  outline: none; overflow-wrap: anywhere; text-wrap: balance;
}
.app-hoja-sub { margin: 3px 0 0; color: var(--ink-soft); font-size: 0.875rem; line-height: 1.35; }
.app-hoja-sub:empty { display: none; }
.app-hoja-x {
  position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 999px; background: var(--app-relleno); color: var(--ink-soft); cursor: pointer;
  transition: transform var(--dur-press, 100ms) var(--ease-out);
}
.app-hoja-x::before { content: ""; position: absolute; inset: -6px; } /* 44 px de objetivo */
.app-hoja-x .material-symbols-outlined { font-size: 1.15rem; }
@media (hover: hover) { .app-hoja-x:hover { background: var(--app-relleno-fuerte); color: var(--ink); } }
.app-hoja-x:active { transform: scale(0.94); }
.app-hoja-x:focus-visible { outline: 2px solid var(--olive-dk); outline-offset: 2px; }

.app-hoja-cuerpo { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: 0 16px 12px; overscroll-behavior: contain; touch-action: pan-y; }
.app-hoja-panel.es-completo .app-hoja-cuerpo, .app-hoja--inspector .app-hoja-cuerpo, .app-hoja--centro .app-hoja-cuerpo { overflow-y: auto; }
/* acciones: en el detente medio hoja.js las sube para que siempre se vean */
.app-hoja-acciones {
  position: relative; z-index: 1; flex: none; display: flex; gap: 10px; padding: 10px 16px 14px;
  background: var(--app-material-barra); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--rule-soft);
}
.app-hoja-acciones > * { flex: 1 1 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin: 0; }
/* DARK-01: la regla de arriba le ganaba al atributo hidden (Puertas se veia sin liga en la computadora) */
.app-hoja-acciones > [hidden] { display: none; }

/* ---------- piezas de contenido reutilizables (ficha: datos clave/valor, nota, avatar, cargando) ---------- */
.app-hoja-avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--olive) 14%, var(--card-bg)); color: var(--olive-dk); font-weight: 600; font-size: 0.95rem;
}
.app-hoja-aviso { margin: 0 0 4px; display: flex; gap: 6px; align-items: center; font-size: 0.85rem; color: var(--ink-soft); }
.app-hoja-aviso .material-symbols-outlined { font-size: 1rem; }
.app-hoja-datos { margin: 0; }
.app-hoja-datos > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--rule-soft); }
.app-hoja-datos > div:last-child { border-bottom: 0; }
.app-hoja-datos dt { color: var(--ink-soft); font-weight: 400; font-size: 0.9rem; }
.app-hoja-datos dd { margin: 0; text-align: right; font-weight: 500; font-size: 0.95rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.app-hoja-punto { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.app-hoja-punto.es-aviso { background: var(--warn); }
.app-hoja-llave { display: inline-flex; align-items: center; gap: 6px; }
.app-hoja-llave .material-symbols-outlined { font-size: 1.05rem; color: var(--ink-soft); }
.app-hoja-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; }
.app-hoja-suave { color: var(--ink-soft); font-weight: 400; }
.app-hoja-nota { margin: 10px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--card-bg); box-shadow: 0 0 0 1px var(--rule-soft); }
.app-hoja-nota h3 { margin: 0 0 4px; font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.app-hoja-nota p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.app-hoja-ancho { width: 100%; margin-top: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.app-hoja [data-cargando] { display: inline-block; width: 88px; height: 0.95em; border-radius: 6px; background: var(--rule-soft); vertical-align: -2px; }
@media (prefers-reduced-motion: no-preference) {
  .app-hoja [data-cargando] { animation: app-hoja-latido 1.2s ease-in-out infinite; }
}
@keyframes app-hoja-latido { 50% { opacity: 0.55; } }

/* ---------- escritorio: inspector lateral SIN velo (tarea paralela, el Gantt sigue vivo) ---------- */
.app-hoja--inspector { pointer-events: none; }
.app-hoja--inspector .app-hoja-velo, .app-hoja--inspector .app-hoja-tirador { display: none; }
.app-hoja--inspector .app-hoja-panel {
  pointer-events: auto; left: auto; right: 16px; top: 80px; bottom: auto; width: 380px;
  max-height: calc(100dvh - 96px); border-radius: 18px; padding-bottom: 0;
  box-shadow: var(--app-sombra-inspector);
  transform: translateX(calc(100% + 32px));
}
.app-hoja--inspector .app-hoja-panel::after { display: none; }
.app-hoja--inspector .app-hoja-cabeza, .app-hoja--centro .app-hoja-cabeza { padding-top: 16px; cursor: auto; touch-action: auto; }
.app-hoja--inspector .app-hoja-acciones { border-radius: 0 0 18px 18px; }

/* ---------- modal centrado (:modal="true" en >= 1024 px): nace del disparador ---------- */
.app-hoja--centro .app-hoja-tirador { display: none; }
.app-hoja--centro .app-hoja-panel {
  left: 50%; top: 50%; right: auto; bottom: auto; width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 64px);
  translate: -50% -50%; border-radius: 18px; padding-bottom: 0; transform: scale(0.92); opacity: 0;
  box-shadow: var(--app-sombra-modal);
}
.app-hoja--centro .app-hoja-panel::after { display: none; }
.app-hoja--centro .app-hoja-acciones { border-radius: 0 0 18px 18px; }

html.app-hoja-bloqueo { overflow: hidden; }

@media (prefers-reduced-transparency: reduce) {
  .app-hoja-panel, .app-hoja-acciones { background: var(--card-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .app-hoja-panel { background: var(--card-bg); box-shadow: 0 0 0 1px var(--ink-soft); }
  .app-hoja-acciones { border-top-color: var(--ink-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .app-hoja-x { transition: none; }
  .app-hoja-x:active { transform: none; opacity: 0.85; }
}
