/* =====================================================================
   escritura.css — Ayudas para escribir: lupa de escritura, protector de
   palma, marcador de página y modo para zurdos.
   ===================================================================== */

/* --- Lupa de escritura ------------------------------------------------- */

/* Con la lupa abierta, la hoja ocupa solo la parte de arriba. */
.pantalla-editor[data-lupa] .lienzo { bottom: var(--alto-lupa, 30%); }
.pantalla-editor[data-lupa] .pildora { bottom: calc(var(--alto-lupa, 30%) + 10px); }

.lupa {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  height: var(--alto-lupa, 30%);
  padding: 0 var(--seguro-der) var(--seguro-abajo) var(--seguro-izq);
  border-top: 1px solid var(--borde);
  background: var(--superficie);
  box-shadow: 0 -4px 16px rgba(40, 35, 25, .12);
}

/* Asa para cambiar el alto, sobre el borde superior */
.lupa-asa {
  position: absolute;
  left: 50%;
  top: -12px;
  z-index: 1;
  width: 72px;
  height: 24px;
  margin-left: -36px;
  touch-action: none;
  cursor: ns-resize;
}
.lupa-asa::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 9px;
  height: 6px;
  border-radius: 3px;
  background: var(--tinta-suave);
  opacity: .55;
}

/* Botones: del lado contrario a la mano que escribe */
.lupa-controles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border-right: 1px solid var(--borde);
}
[data-mano="zurda"] .lupa-controles {
  order: 2;
  border-right: 0;
  border-left: 1px solid var(--borde);
}
.lupa-par { display: flex; gap: 4px; }
.lupa-boton {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--superficie);
  color: var(--tinta);
}
.lupa-controles > .lupa-boton { width: 92px; }
.lupa-boton:active { background: var(--borde); }
.lupa-boton svg { width: 20px; height: 20px; }

.lupa-area {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}
.lupa-capa { position: absolute; left: 0; top: 0; display: block; }
.lupa-vivo { pointer-events: none; }

/* Franja de la derecha: al escribir ahí, la zona avanza sola */
.lupa-franja {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 25%;
  pointer-events: none;
  background: linear-gradient(to right, transparent, color-mix(in srgb, var(--acento) 12%, transparent));
  border-left: 1px dashed color-mix(in srgb, var(--acento) 45%, transparent);
}

/* Rectángulo sobre la hoja: muestra qué parte se ve en la lupa.
   No estorba: se puede escribir dentro. Se mueve desde su asa. */
.lupa-caja {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  border: 2px solid var(--acento);
  border-radius: 3px;
  pointer-events: none;
}
.lupa-caja-asa {
  position: absolute;
  left: -2px;
  top: -34px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  border-radius: 8px 8px 0 0;
  background: var(--acento);
  color: var(--sobre-acento);
  pointer-events: auto;
  touch-action: none;
  cursor: move;
}
.lupa-caja-asa svg { width: 18px; height: 18px; transform: rotate(90deg); }

/* --- Protector de palma --------------------------------------------------- */

.protector {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  pointer-events: none; /* el lápiz escribe encima; los dedos los ignora entrada.js */
  background:
    repeating-linear-gradient(135deg,
      color-mix(in srgb, var(--tinta-suave) 13%, transparent) 0 10px,
      color-mix(in srgb, var(--tinta-suave) 7%, transparent) 10px 20px);
  border-top: 2px solid color-mix(in srgb, var(--tinta-suave) 55%, transparent);
}
.protector-asa {
  position: absolute;
  left: 50%;
  top: -22px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 8px;
  border: 1px solid var(--borde);
  border-radius: 20px;
  background: var(--superficie);
  color: var(--tinta-suave);
  font-size: .8rem;
  box-shadow: var(--sombra);
  pointer-events: auto;
  touch-action: none;
  transform: translateX(-50%);
  cursor: ns-resize;
}
.protector-agarre svg { width: 18px; height: 18px; transform: rotate(90deg); }
.protector-moviendo { background: var(--borde); }

/* --- Indicador de página: marcador ------------------------------------------ */

.pildora-marcado { color: #d9822b; }
.pildora-texto { border: 0; background: transparent; font: inherit; font-size: .85rem; cursor: pointer; }

/* --- Modo para zurdos -------------------------------------------------------- */
/* La barra pasa al borde derecho (apariencia.js) y los botones de la lupa,
   a la derecha (más arriba). El indicador de página ya queda a la derecha,
   lejos de la mano izquierda. */

/* --- Escáner de documentos ------------------------------------------------ */

.capa-recorte .recorte-area { position: relative; }
.escaner-lienzo { touch-action: none; }
.escaner-contorno {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}
.escaner-contorno polygon {
  fill: rgba(46, 230, 176, .14);
  stroke: #2ee6b0;
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.escaner-punto {
  position: absolute;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  touch-action: none;
  cursor: move;
}
.escaner-punto::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 12px;
  width: 24px;
  height: 24px;
  border: 3px solid #2ee6b0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}
/* Lupa para ubicar las esquinas con precisión */
.escaner-lupa {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 2;
  width: 130px;
  height: 130px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  pointer-events: none;
}
.escaner-lupa-derecha { left: auto; right: 14px; }
.escaner-vista {
  display: block;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .45);
  background: #fff;
}
.escaner-filtros { justify-content: center; margin-top: 10px; }

/* --- Vista de las páginas -------------------------------------------------- */

/* Botón «Agregar página» bajo la última página (modo continuo) */
.agregar-continuo {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px dashed var(--acento);
  border-radius: 24px;
  background: var(--superficie);
  color: var(--acento-fuerte);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--sombra);
}
.agregar-continuo:active { background: var(--borde); }

/* Ventana para elegir la vista */
.vista-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.vista-opcion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border: 2px solid var(--borde);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
}
.vista-opcion:has(input:checked) { border-color: var(--acento); background: color-mix(in srgb, var(--acento) 8%, transparent); }
.vista-opcion input { position: absolute; opacity: 0; pointer-events: none; }
.vista-opcion small { display: block; margin-top: 3px; color: var(--tinta-suave); font-size: .8rem; line-height: 1.3; }
.vista-dibujo {
  width: 54px;
  height: 66px;
  border-radius: 4px;
  background:
    linear-gradient(var(--superficie), var(--superficie)) padding-box;
  border: 2px solid var(--tinta-suave);
}
.vista-dibujo[data-modo="continuo"] {
  height: 66px;
  border: 0;
  background:
    linear-gradient(var(--tinta-suave), var(--tinta-suave)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--tinta-suave), var(--tinta-suave)) 0 28px / 100% 2px no-repeat,
    linear-gradient(var(--tinta-suave), var(--tinta-suave)) 0 36px / 100% 2px no-repeat,
    linear-gradient(var(--tinta-suave), var(--tinta-suave)) 0 64px / 100% 2px no-repeat,
    linear-gradient(to right, var(--tinta-suave) 2px, transparent 2px, transparent calc(100% - 2px), var(--tinta-suave) calc(100% - 2px)) 0 0 / 100% 30px no-repeat,
    linear-gradient(to right, var(--tinta-suave) 2px, transparent 2px, transparent calc(100% - 2px), var(--tinta-suave) calc(100% - 2px)) 0 36px / 100% 30px no-repeat;
}

/* --- Puntero de presentación (láser o mano) ------------------------------- */

.puntero-estela {
  position: absolute;
  inset: 0;
  z-index: 12;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.puntero-laser {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 13;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 18%, var(--color) 38%, color-mix(in srgb, var(--color) 55%, transparent) 70%, transparent 72%);
  box-shadow: 0 0 14px 4px color-mix(in srgb, var(--color) 60%, transparent);
  pointer-events: none;
}
.puntero-mano {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 13;
  transform-origin: 0 0;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .35));
  pointer-events: none;
}
.puntero-mano svg { display: block; width: 100%; height: 100%; }
