/* ============================================================
   notas-margen.css — Estudio Vivo · Fase 8
   Notas al margen con estilo manuscrito (Caveat font)
   Solo visible en tablet landscape y desktop (≥820px)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600&display=swap');

/* ── WRAPPER PRINCIPAL ──────────────────────────────────────── */
#notasMargen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 220px;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

/* Solo visible en ≥820px */
@media (max-width: 819px) {
  #notasMargen {
    display: none;
  }
}

/* Más ancho en desktop grande */
@media (min-width: 1180px) {
  #notasMargen {
    width: 240px;
  }
}

/* ── NOTA INDIVIDUAL ────────────────────────────────────────── */
.nota-margen {
  position: absolute;
  right: 0;
  width: 200px;
  background: linear-gradient(
    135deg,
    rgba(255, 248, 220, 0.95) 0%,
    rgba(255, 243, 200, 0.90) 100%
  );
  border: 1px solid rgba(220, 185, 100, 0.4);
  border-radius: 6px 12px 12px 6px;
  padding: 10px 12px;
  box-shadow:
    2px 4px 16px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font-family: 'Caveat', cursive;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #4a3728;
  cursor: text;
  pointer-events: all;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 10;
}

/* Ajuste light theme — más blanco, más limpio */
[data-theme="light"] .nota-margen {
  background: linear-gradient(
    135deg,
    rgba(255, 253, 240, 0.97) 0%,
    rgba(255, 248, 220, 0.93) 100%
  );
  border-color: rgba(200, 165, 80, 0.35);
  box-shadow:
    2px 4px 14px rgba(0, 0, 0, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ── CONNECTOR LINE (línea al versículo) ────────────────────── */
.nota-margen::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  width: 16px;
  height: 1px;
  background: rgba(220, 185, 100, 0.5);
  transform: translateY(-50%);
}

/* ── HOVER STATE ────────────────────────────────────────────── */
.nota-margen:hover {
  transform: scale(1.02) translateX(-4px);
  box-shadow:
    4px 8px 24px rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  z-index: 20;
}

/* ── EDITOR INLINE ──────────────────────────────────────────── */
.nota-margen-editor {
  width: 100%;
  min-height: 60px;
  background: transparent;
  border: none;
  font-family: 'Caveat', cursive;
  font-size: 0.92rem;
  color: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.4;
  display: block;
  box-sizing: border-box;
  /* Prevent textarea default UA styles */
  margin: 0;
  padding: 0;
}

.nota-margen-editor::placeholder {
  color: rgba(74, 55, 40, 0.4);
  font-style: italic;
}

/* ── TOOLBAR ────────────────────────────────────────────────── */
.nota-margen-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.nota-margen:hover .nota-margen-toolbar,
.nota-margen:focus-within .nota-margen-toolbar {
  opacity: 1;
}

/* ── BOTONES DE TOOLBAR ─────────────────────────────────────── */
.nota-margen-btn {
  background: rgba(0, 0, 0, 0.08);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  color: #4a3728;
  font-family: var(--font-ui, 'Inter', sans-serif);
  transition: background 0.15s ease, transform 0.1s ease;
  line-height: 1.4;
}

.nota-margen-btn:hover {
  background: rgba(0, 0, 0, 0.14);
}

.nota-margen-btn:active {
  transform: scale(0.95);
}

.nota-margen-btn--delete {
  color: #b54040;
  background: rgba(181, 64, 64, 0.08);
}

.nota-margen-btn--delete:hover {
  background: rgba(181, 64, 64, 0.15);
}

.nota-margen-btn--save {
  color: #2d6a4a;
  background: rgba(45, 106, 74, 0.10);
}

.nota-margen-btn--save:hover {
  background: rgba(45, 106, 74, 0.18);
}

/* ── INDICADOR DE NOTA EN VERSÍCULO ─────────────────────────── */
.verse-note-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--studio-accent, #d4a530);
  color: #111827;
  font-size: 0.6rem;
  font-weight: 900;
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-ui, 'Inter', sans-serif);
  line-height: 1;
  user-select: none;
  position: relative;
  top: -1px;
}

.verse-note-indicator:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── ANIMACIÓN DE ENTRADA PARA NOTAS ────────────────────────── */
@keyframes nota-enter {
  from {
    opacity: 0;
    transform: translateX(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.nota-margen {
  animation: nota-enter 0.25s ease both;
}

/* ── NOTA EN MODO LECTURA (body.reading-mode) ───────────────── */
body.reading-mode #notasMargen {
  width: 200px;
  opacity: 0.85;
}

body.reading-mode #notasMargen:hover {
  opacity: 1;
}

/* ── ESTADO DE GUARDADO (feedback visual) ───────────────────── */
.nota-margen.saving {
  border-color: rgba(45, 106, 74, 0.6);
  transition: border-color 0.3s ease;
}

.nota-margen.saved {
  border-color: rgba(45, 106, 74, 0.3);
}
