/* Hojas de dibujo flotantes (sheets.js) y editor de dibujo a pantalla completa (draw.js). */

/* ---------- hojas sobre la página ---------- */
.page { position: relative; }
.cal-sheets { position: absolute; inset: 0 0 auto 0; height: 0; z-index: 20; pointer-events: none; }
.cal-sheet {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: grab; outline: none; transition: filter 0.15s;
}
.cal-sheet.is-pinned { touch-action: pan-y; cursor: pointer; }
.cal-sheet-paper {
  line-height: 0; border-radius: 3px; overflow: hidden; background: #fdfcf7;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 6px 16px rgb(0 0 0 / 0.14);
  rotate: -1.2deg; transition: rotate 0.15s, box-shadow 0.15s;
}
.cal-sheet:nth-child(even) .cal-sheet-paper { rotate: 1deg; }
.cal-sheet:hover .cal-sheet-paper, .cal-sheet:focus-visible .cal-sheet-paper { box-shadow: 0 2px 4px rgb(0 0 0 / 0.14), 0 10px 26px rgb(0 0 0 / 0.2); }
.cal-sheet:focus-visible .cal-sheet-paper { outline: 2px solid var(--accent); outline-offset: 2px; }
:root[data-theme="dark"] .cal-sheet-paper { filter: brightness(0.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal-sheet-paper { filter: brightness(0.9); } }
.cal-sheet.dragging { cursor: grabbing; z-index: 2; }
.cal-sheet.dragging .cal-sheet-paper { rotate: 0deg; box-shadow: 0 4px 8px rgb(0 0 0 / 0.16), 0 18px 40px rgb(0 0 0 / 0.26); }
.cal-sheet-tab {
  display: inline-flex; align-items: center; gap: 6px; max-width: 200px; padding: 6px 11px;
  border-radius: 8px 8px 8px 2px; background: #fdfcf7; color: #1b1c1e; font: 600 0.82rem var(--font-sans);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 4px 12px rgb(0 0 0 / 0.14);
}
.cal-sheet-tab span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-sheet-tab svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
.cal-sheet-pin {
  position: absolute; top: -9px; right: -7px; width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 6px rgb(0 0 0 / 0.25);
}
.cal-sheet-pin svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cal-sheet-label {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); max-width: 240px;
  padding: 5px 10px; border-radius: 7px; background: var(--text); color: var(--bg); font: 600 0.8rem var(--font-sans);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; animation: cal-label 2.5s ease forwards;
}
@keyframes cal-label { 0% { opacity: 0; translate: 0 4px; } 10%, 85% { opacity: 1; translate: 0 0; } 100% { opacity: 0; } }
.cal-sheet.is-new .cal-sheet-paper, .cal-sheet.is-new .cal-sheet-tab { animation: cal-unfold 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25); }
@keyframes cal-unfold {
  0% { transform: scale(0.15) rotate(-14deg); opacity: 0; transform-origin: 24px 24px; }
  60% { opacity: 1; }
  100% { transform: none; transform-origin: 24px 24px; }
}
.cal-sheet.shake .cal-sheet-paper, .cal-sheet.shake .cal-sheet-tab { animation: cal-shake 0.35s; }
@keyframes cal-shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

/* anillo mientras se mantiene pulsado un hueco */
.cal-press-ring {
  position: absolute; z-index: 60; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  border: 3px solid var(--accent); pointer-events: none; animation: cal-ring 0.38s linear forwards;
}
@keyframes cal-ring { from { transform: scale(0.3); opacity: 0.2; } to { transform: scale(1); opacity: 0.9; } }

@media (prefers-reduced-motion: reduce) {
  .cal-sheet.is-new .cal-sheet-paper, .cal-sheet.is-new .cal-sheet-tab, .cal-sheet.shake .cal-sheet-paper, .cal-press-ring { animation-duration: 0.01s; }
}

/* ---------- editor de dibujo ---------- */
body.cal-drawing { overflow: hidden; }
.cal-draw { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--bg); }
.cal-draw-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.cal-draw-title {
  min-width: 120px; max-width: 260px; flex: 0 1 220px; padding: 6px 9px; border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--text); font: 650 0.98rem var(--font-sans);
}
.cal-draw-title:hover, .cal-draw-title:focus { border-color: var(--border-strong); outline: none; background: var(--surface); }
.cal-draw-spacer { flex: 1; }
.cal-draw-group { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.cal-draw-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 8px; background: none; color: var(--text); cursor: pointer;
}
.cal-draw-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cal-draw-btn:hover { background: var(--surface); }
.cal-draw-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.cal-draw-btn:disabled { opacity: 0.35; cursor: default; }
.cal-draw-btn.back { background: var(--surface-2); }
.cal-draw-swatch {
  width: 30px; height: 30px; margin: 4px; padding: 0; border: 2px solid var(--surface); border-radius: 50%;
  background: var(--c); cursor: pointer; box-shadow: 0 0 0 1px var(--border-strong);
}
.cal-draw-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.cal-draw-picker { width: 34px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer; }
.cal-draw-bar .cal-draw-width { width: 110px; flex: none; accent-color: var(--accent); }
/* «dibujar con el dedo» solo tiene sentido en pantallas táctiles */
@media (hover: hover) and (pointer: fine) { .cal-draw-btn.finger { display: none; } }
.cal-draw-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; cursor: crosshair; }
.cal-draw-stage[data-tool="borrador"] { cursor: cell; }
.cal-draw-stage canvas { position: absolute; inset: 0; }
.cal-draw-live { pointer-events: none; }
@media (max-width: 720px) {
  .cal-draw-title { flex-basis: 140px; }
  .cal-draw-bar .cal-draw-width { width: 80px; }
  .cal-draw-spacer { display: none; }
}
