/* 
  Reset and Base 
  Estilo Vanilla CSS enfocado en rendimiento puro y Mobile-First.
*/
:root {
  --bg-color: #FFD7B5; /* Naranja/salmón de fondo */
  --book-bg: #FFEAF3; /* Color de la página */
  --text-color: #6C5B7B; 
  --menu-color: #7B8A96;
  --menu-active: #E06C8B; /* Rojo/rosa del DIARY */
  --line-color: rgba(224, 108, 139, 0.2); /* Líneas de cuaderno */
  --glass-bg: rgba(255, 255, 255, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: sans-serif;
  overflow: hidden; /* App estilo nativo */
  user-select: none;
  touch-action: none; /* Previene pull-to-refresh en Chrome mobile */
}

.hidden {
  display: none !important;
}

.screen {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center; /* Centrar hoja en PC */
}

/* Background grid (Mesa/entorno) */
.bg-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(rgba(248, 202, 231, 0.3) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(248, 202, 231, 0.3) 1px, transparent 1px);
  background-size: 20px 20px;
  z-index: -1;
}

/* --- Lock Screen --- */
#lock-screen {
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(5px);
}

.glass-panel {
  background: var(--glass-bg);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  border: 1px solid rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 90%;
}

.lock-logo {
  width: 100px;
  margin: 0 auto;
}

.glass-panel input {
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
  font-size: 1.2rem;
  text-align: center;
  outline: none;
}

.glass-panel button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--menu-active);
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s;
}
.glass-panel button:active { transform: scale(0.95); }

#lock-error {
  color: #D32F2F;
  font-weight: bold;
}

/* --- Diario Mobile First --- */
.page-container {
  background-color: var(--book-bg);
  width: 100%;
  max-width: 500px; /* En móviles ocupa el 100%, en PC parece una hoja centrada */
  height: 100%;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Oculta polaroids que se salgan */
  transition: transform 0.3s ease-out; /* Animación de swipe opcional */
  padding-top: 24px; /* Evita que la decoración se corte arriba */
}

.page-decor {
  width: 100%;
  height: auto;
  pointer-events: none;
}

/* Cabecera y Fecha */
.date-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 20px;
  gap: 15px;
  margin-top: -10px;
}

.page-date {
  font-family: 'Jura', sans-serif;
  color: var(--menu-active);
  font-weight: bold;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.nav-arrow {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--menu-color);
  padding: 5px 10px;
  cursor: pointer;
}
.nav-arrow:active { color: var(--menu-active); transform: scale(1.1); }

/* Área de Texto */
.page-textarea {
  flex: 1;
  margin: 10px 20px 20px 20px;
  font-family: 'Caveat', cursive;
  font-size: 1.8rem;
  line-height: 32px;
  color: #333;
  outline: none;
  cursor: text;
  white-space: pre-wrap;
  overflow-y: auto; /* Scroll si se llena de texto */
  user-select: text; /* Permitir texto en móviles */
  
  /* Líneas horizontales de cuaderno */
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    var(--line-color) 31px,
    var(--line-color) 32px
  );
  background-attachment: local; /* Las líneas scrollean con el texto */
}

.page-textarea:empty::before {
  content: attr(data-placeholder);
  color: rgba(0,0,0,0.3);
}

/* --- Botón Invisible Mariposa --- */
#butterfly-trigger {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 60px;
  background: transparent;
  border: none;
  z-index: 50;
  cursor: pointer;
}

/* --- Menú Desplegable Mariposa --- */
.glass-menu {
  position: absolute;
  top: 84px; /* 60px + 24px de padding */
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass-bg);
  padding: 1.5rem;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.6);
  border-top: none;
  backdrop-filter: blur(15px);
  z-index: 40;
  width: 90%;
  max-width: 400px;
}

.menu-list {
  list-style: none;
  font-family: 'Jura', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--menu-color);
  letter-spacing: 2px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.menu-list li {
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: color 0.2s;
}
.menu-list li:active {
  color: var(--menu-active);
}
.menu-list li:active .circle {
  border-color: var(--menu-active);
}

.circle {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--menu-color);
  border-radius: 50%;
  margin-right: 12px;
  background-color: transparent;
  transition: border-color 0.2s;
}

/* --- Imágenes Estilo Polaroid con Tesafí --- */
.page-images {
  position: absolute;
  top: 120px;
  right: 20px;
  width: calc(100% - 40px);
  height: 0; /* Para no bloquear clicks en el textarea */
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 15px;
}

.polaroid {
  background: white;
  padding: 6px 6px 20px 6px;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.15);
  transform: rotate(-3deg);
  position: relative;
  width: 120px; /* Un poco más pequeño para móvil */
  pointer-events: auto; /* Permitir click/dobleclick */
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.polaroid.transparent {
  opacity: 0.2;
}

.polaroid img {
  width: 100%;
  height: auto;
  display: block;
}

/* Tesafí / Celo */
.polaroid::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(2deg);
  width: 50px;
  height: 15px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid rgba(255,255,255,0.6);
  z-index: 10;
}
.polaroid:nth-child(even) { transform: rotate(4deg); }

/* --- Modal Base --- */
.modal {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  gap: 15px;
}
.close-btn { background: #aaa !important; }
