/* Fase 8 · piezas comunes (SPEC-INTEGRACION.md §0).
 *
 * Lo que comparten todas las pantallas: arrastrar y soltar con respuesta
 * visual, la casilla de «hecha» animada y las asas para cambiar el tamaño de
 * los paneles. Cada área tiene además su hoja (f8-correo.css, f8-tareas.css,
 * f8-calendario.css, f8-aijs.css, f8-shell.css).
 *
 * Colores siempre con los tokens de theme.js (rgb(var(--c-…))): valen en claro
 * y en oscuro sin tocar nada. Las animaciones se apagan con
 * prefers-reduced-motion o con html.sin-animaciones (Ajustes › Apariencia).
 */

/* ── Arrastrar y soltar (js/arrastrar.js) ───────────────────────────── */

/* El hueco donde caerá la tarjeta: se ve el sitio, no la tarjeta repetida. */
.f8-fantasma {
  position: relative;
  border-radius: 12px !important;
  background: rgb(var(--c-primary-container) / 0.06) !important;
  outline: 2px dashed rgb(var(--c-primary-container) / 0.45);
  outline-offset: -2px;
  box-shadow: none !important;
}
.f8-fantasma > * { visibility: hidden; }

/* La que se ha cogido (antes de moverla): un aro suave. */
.f8-elegida { box-shadow: 0 0 0 2px rgb(var(--c-primary-container) / 0.35); }

/* La copia que sigue al ratón o al dedo: levantada, algo girada, opaca. */
.f8-arrastrando {
  opacity: 1 !important;
  transform: rotate(1.5deg) scale(1.03);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.10) !important;
  cursor: grabbing !important;
  z-index: 9999 !important;
}
html.dark .f8-arrastrando { box-shadow: 0 18px 38px rgba(0, 0, 0, 0.55), 0 4px 10px rgba(0, 0, 0, 0.35) !important; }

/* La lista o columna sobre la que se va a soltar. */
.f8-destino {
  background-color: rgb(var(--c-primary-container) / 0.05);
  box-shadow: inset 0 0 0 2px rgb(var(--c-primary-container) / 0.25);
  border-radius: 12px;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

body.f8-arrastrando-activo, body.f8-arrastrando-activo * { cursor: grabbing !important; user-select: none !important; }

/* Al caer: un pequeño asentamiento y un destello del color de la marca. */
@keyframes f8-asentar {
  0%   { transform: scale(1.03); box-shadow: 0 0 0 3px rgb(var(--c-primary-container) / 0.35); }
  60%  { transform: scale(0.995); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgb(var(--c-primary-container) / 0); }
}
.f8-asentada { animation: f8-asentar 420ms cubic-bezier(.2, .8, .2, 1); }

/* ── Casilla de «hecha» (js/completar.js) ───────────────────────────── */

.f8-casilla {
  --f8-tam: 20px;
  width: var(--f8-tam); height: var(--f8-tam);
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9999px;
  color: rgb(var(--c-outline));
  transition: color 150ms ease, transform 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.f8-casilla svg { width: 100%; height: 100%; overflow: visible; }
.f8-casilla-aro {
  fill: transparent;
  stroke: currentColor; stroke-width: 1.8;
  transition: fill 180ms ease, stroke 180ms ease;
}
.f8-casilla-check {
  fill: none;
  stroke: rgb(var(--c-success-vivo)); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 16; stroke-dashoffset: 16;
  opacity: 0;
  transition: stroke-dashoffset 260ms cubic-bezier(.2, .8, .2, 1), opacity 120ms ease;
}
/* Al pasar por encima se insinúa el check: se sabe qué va a pasar. */
.f8-casilla:hover { color: rgb(var(--c-success-vivo)); }
.f8-casilla:hover .f8-casilla-check { opacity: 0.45; stroke-dashoffset: 0; }
.f8-casilla:focus-visible { outline: 2px solid rgb(var(--c-primary-container) / 0.6); outline-offset: 2px; }
.f8-casilla:active { transform: scale(0.88); }

.f8-casilla[aria-pressed="true"] { color: rgb(var(--c-success-vivo)); }
.f8-casilla[aria-pressed="true"] .f8-casilla-aro { fill: rgb(var(--c-success-vivo)); }
.f8-casilla[aria-pressed="true"] .f8-casilla-check { stroke: #fff; opacity: 1; stroke-dashoffset: 0; }

/* Cuadrada (las listas densas que ya lo eran). */
.f8-casilla.f8-cuadrada { border-radius: 6px; }

@keyframes f8-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); }
  100% { transform: scale(1); }
}
@keyframes f8-onda {
  0% { box-shadow: 0 0 0 0 rgb(var(--c-success-vivo) / 0.45); }
  100% { box-shadow: 0 0 0 10px rgb(var(--c-success-vivo) / 0); }
}
.f8-casilla.f8-pop { animation: f8-pop 320ms cubic-bezier(.2, .8, .2, 1), f8-onda 520ms ease-out; }

/* La fila que se acaba de completar: el título se tacha de izquierda a
   derecha y la fila se apaga (y, si la pantalla lo pide, se va). */
.f8-tachable {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 55%;
  background-size: 0 1.5px;
  transition: background-size 280ms cubic-bezier(.2, .8, .2, 1), color 200ms ease;
}
.f8-completada .f8-tachable { background-size: 100% 1.5px; color: rgb(var(--c-on-surface-variant)); }
.f8-completada { transition: opacity 260ms ease; opacity: 0.6; }
@keyframes f8-salir {
  0% { opacity: 0.6; transform: translateX(0); max-height: var(--f8-alto, 80px); }
  60% { opacity: 0; transform: translateX(12px); max-height: var(--f8-alto, 80px); }
  100% { opacity: 0; transform: translateX(12px); max-height: 0; margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}
.f8-saliendo { overflow: hidden; animation: f8-salir 420ms cubic-bezier(.4, 0, .2, 1) forwards; pointer-events: none; }

/* ── Asas para cambiar el tamaño de un panel (js/paneles.js) ────────── */

.f8-asa {
  position: relative;
  flex: none;
  width: 9px;
  margin: 0 -4px;              /* no ocupa sitio: se monta sobre el borde */
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}
.f8-asa::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 4px;
  width: 1px;
  background: transparent;
  transition: background-color 120ms ease, width 120ms ease, left 120ms ease;
}
.f8-asa:hover::before, .f8-asa:focus-visible::before, .f8-asa.f8-activa::before {
  left: 3px; width: 3px;
  background: rgb(var(--c-primary-container) / 0.55);
}
.f8-asa.f8-activa::before { background: rgb(var(--c-primary-container)); }
body.f8-redimensionando, body.f8-redimensionando * { cursor: col-resize !important; user-select: none !important; }
/* Mientras se arrastra, nada de transiciones de anchura: va pegado al ratón. */
body.f8-redimensionando [data-f8-panel] { transition: none !important; }

/* ── Sin animaciones (preferencia del sistema o de Ajustes) ─────────── */

@media (prefers-reduced-motion: reduce) {
  .f8-asentada, .f8-casilla.f8-pop, .f8-saliendo { animation: none !important; }
  .f8-arrastrando { transform: none; }
  .f8-casilla-check, .f8-tachable, .f8-completada { transition: none !important; }
}
html.sin-animaciones .f8-asentada, html.sin-animaciones .f8-casilla.f8-pop, html.sin-animaciones .f8-saliendo { animation: none !important; }
html.sin-animaciones .f8-arrastrando { transform: none; }
html.sin-animaciones .f8-casilla-check, html.sin-animaciones .f8-tachable, html.sin-animaciones .f8-completada { transition: none !important; }
