/*
 * notas5 — estilos
 *
 * Estética neubrutalist: bordes gruesos negros, sombras duras sin blur,
 * colores saturados por categoría, tipografía monospace (Space Mono).
 *
 * Estructura:
 *   escritorio → carpetas de colores (home)
 *   ventana    → titlebar + toolbar + contenido (grid / lista / lectura)
 *   sneak-peek → barra inferior en lectura con título de la nota actual
 */

/* ── reset & base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Space Mono', 'Courier New', monospace;
  background: #fffce8;  /* crema suave */
  color: #1a1a1a;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── escritorio (home) ── */
#escritorio {
  width: 100vw;
  min-height: 100vh;
  padding: 40px;
}

#escritorio > h1 {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
  border-bottom: 3px solid #1a1a1a;
  padding-bottom: 12px;
  display: inline-block;
}

#carpetas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

/* ── carpeta card ──
   el color viene de --cat-color, inyectado por JS desde catColors */
@keyframes carpeta-in {
  from { opacity: 0; transform: translateY(16px) rotate(-1deg); }
  to   { opacity: 1; transform: translateY(0) rotate(0); }
}

.carpeta {
  min-height: 100px;
  padding: 22px 24px;
  border: 3px solid #1a1a1a;
  background: var(--cat-color, #f0f0f0);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 6px 6px 0 #1a1a1a;
  position: relative;
  overflow: hidden;
  animation: carpeta-in 0.35s ease-out backwards;
  animation-delay: calc(var(--i, 0) * 0.04s);
}

.carpeta:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #1a1a1a;
}

.carpeta:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #1a1a1a;
}

.carpeta-nombre {
  font-size: 1.15rem;
  font-weight: 900;
  text-transform: lowercase;
  line-height: 1.2;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.carpeta-count {
  position: absolute;
  bottom: -18px;
  right: 6px;
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
}

/* ── ventana ──
   overlay fullscreen tipo Finder.
   contiene: titlebar → toolbar → contenido scrollable → sneak-peek */
.ventana {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #fffce8;
  border: none;
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: pop-in 0.15s ease-out;
}

.ventana.hidden { display: none; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.95) translate(10px, 10px); }
  to   { opacity: 1; transform: scale(1) translate(0, 0); }
}

@keyframes pop-out {
  from { opacity: 1; transform: scale(1) translate(0, 0); }
  to   { opacity: 0; transform: scale(0.96) translate(10px, 10px); }
}

.ventana.closing {
  animation: pop-out 0.15s ease-in forwards;
}

/* titlebar — color de fondo se pone inline desde JS */
.ventana-titlebar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 3px solid #1a1a1a;
  background: var(--ventana-color, #f0f0f0);
  gap: 16px;
  flex-shrink: 0;
  user-select: none;
}

.ventana-cerrar-btn {
  width: 32px;
  height: 32px;
  border: 3px solid #1a1a1a;
  background: #ff6b6b;
  cursor: pointer;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 #1a1a1a;
  transition: transform 0.1s, box-shadow 0.1s;
  line-height: 1;
  font-family: inherit;
  color: #1a1a1a;
}

.ventana-cerrar-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a1a1a;
}

.ventana-cerrar-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

.ventana-titulo {
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: lowercase;
}

.ventana-count {
  font-size: 0.8rem;
  font-weight: 700;
  margin-left: auto;
  opacity: 0.5;
}

/* toolbar — icono de vista cycle + zoom + buscador */
.ventana-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 2px solid #1a1a1a;
  flex-shrink: 0;
}

.vista-btn {
  background: #fffce8;
  border: 2px solid #1a1a1a;
  padding: 6px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: 2px 2px 0 #1a1a1a;
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.vista-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a1a1a;
}

.vista-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

/* ── mini CSS icons para el cycle button ── */

/* solo se muestra el icono de la vista activa */
#btn-vista-cycle { padding: 5px 7px; }
#btn-vista-cycle .icon-grid,
#btn-vista-cycle .icon-lista,
#btn-vista-cycle .icon-lectura { display: none; }
#btn-vista-cycle .icon-grid.active,
#btn-vista-cycle .icon-lista.active,
#btn-vista-cycle .icon-lectura.active { display: flex; }

/* grid icon: 2x2 cuadraditos */
.icon-grid {
  display: flex;
  flex-wrap: wrap;
  width: 14px;
  height: 14px;
  gap: 2px;
}
.icon-grid > span {
  width: 6px;
  height: 6px;
  background: #1a1a1a;
}

/* lista icon: 3 rayitas */
.icon-lista {
  display: flex;
  flex-direction: column;
  width: 14px;
  height: 14px;
  justify-content: space-between;
  padding: 1px 0;
}
.icon-lista > span {
  width: 100%;
  height: 2px;
  background: #1a1a1a;
}

/* lectura icon: bloque con lineas finas */
.icon-lectura {
  display: flex;
  flex-direction: column;
  width: 14px;
  height: 14px;
  border: 2px solid #1a1a1a;
  justify-content: center;
  gap: 2px;
  padding: 1px 2px;
}
.icon-lectura > span {
  width: 100%;
  height: 1px;
  background: #1a1a1a;
}

#buscar {
  margin-left: auto;
  background: #fffce8;
  border: 2px solid #1a1a1a;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 4px 10px;
  width: 200px;
  outline: none;
  box-shadow: 2px 2px 0 #1a1a1a;
}

#buscar:focus {
  box-shadow: 3px 3px 0 #ffd43b;
  border-color: #1a1a1a;
}

/* contenido scrollable — overflow-x: hidden evita scroll horizontal al hacer zoom */
.ventana-contenido {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

/* scrollbar neubrutalist */
.ventana-contenido::-webkit-scrollbar { width: 12px; }
.ventana-contenido::-webkit-scrollbar-track { background: #fffce8; border-left: 3px solid #1a1a1a; }
.ventana-contenido::-webkit-scrollbar-thumb { background: #1a1a1a; border: 2px solid #fffce8; }

/* ── animación de entrada para vistas ── */
@keyframes vista-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vista-grid, .vista-lista, .vista-lectura {
  animation: vista-in 0.2s ease-out;
}

/* ── vista grid (masonry) ──
   CSS columns crea un layout tipo Pinterest donde cada tarjeta
   ocupa solo el espacio vertical que necesita */
.vista-grid {
  column-width: 220px;
  column-gap: 20px;
}

.grid-item {
  border: 2px solid #1a1a1a;
  padding: 12px 14px;
  cursor: pointer;
  background: #fff;
  box-shadow: 3px 3px 0 #1a1a1a;
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  flex-direction: column;
  break-inside: avoid;
  margin-bottom: 20px;
}

.grid-item:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 #1a1a1a;
}

.grid-item-nombre {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 6px;
  word-break: break-word;
  display: block;
}

.grid-item-preview {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0.45;
  flex: 1;
  overflow: hidden;
}

/* mordisco abajo a la derecha con fecha + badge de media (IMG/VID).
   negative margins hacen que sobresalga del padding de la tarjeta */
.grid-item-footer {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  margin: 8px -14px -12px 0;
  align-self: flex-end;
  gap: 3px;
}

/* ── badge tags (LNK/IMG/VID/AUD) ──
   micro etiquetas de texto compactas.
   se muestran en grid footer y lista. */
.badge-tag {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  padding: 2px 3px;
  border: 1.5px solid #1a1a1a;
  flex-shrink: 0;
  background: #fff;
}

/* en grid footer: invertido para encajar con el mordisco */
.grid-item-footer .badge-tag {
  background: #1a1a1a;
  color: #fffce8;
  border: none;
  border-top: 1.5px solid #1a1a1a;
  border-left: 1.5px solid #1a1a1a;
  padding: 3px 4px;
}

/* en lista, badges van inline junto al nombre */
.lista-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* fecha con color de la categoría (--grid-accent, set por JS) */
.grid-item-fecha {
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--grid-accent, #dee2e6);
  color: #1a1a1a;
  padding: 3px 8px;
  border-top: 2px solid #1a1a1a;
  border-left: 2px solid #1a1a1a;
}

/* ── vista lista ──
   filas compactas tipo Finder: [TXT/IMG/VID] nombre   día  fecha  hora */
.vista-lista {
  display: flex;
  flex-direction: column;
}

.lista-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 2px solid #1a1a1a;
  cursor: pointer;
  transition: background 0.1s;
}

.lista-item:hover {
  background: rgba(0,0,0,0.04);
}

/* lista-badges ya estilado arriba en la sección de badge icons */

.lista-nombre {
  font-size: 0.85rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-dia {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.35;
  flex-shrink: 0;
  text-transform: lowercase;
}

.lista-fecha {
  font-size: 0.7rem;
  opacity: 0.4;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}

.lista-hora {
  font-size: 0.7rem;
  opacity: 0.3;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── vista lectura continua ──
   las notas se muestran una tras otra sin separadores duros,
   solo con espaciado generoso entre ellas */
.vista-lectura {
  /* sin max-width: ocupa todo el ancho disponible */
}

.lectura-nota {
  padding: 20px 0 24px;
}

.lectura-nota:last-child {
  padding-bottom: 40px;
}

/* sneak peek — barra inferior que muestra título y fecha de la nota
   visible mientras haces scroll. pointer-events: none para no bloquear clicks */
.sneak-peek {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a1a;
  color: #fffce8;
  padding: 6px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  z-index: 10;
  opacity: 0.9;
  pointer-events: none;
  transition: opacity 0.2s;
}

.sneak-peek-titulo {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 12px;
}

.sneak-peek-fecha {
  flex-shrink: 0;
  opacity: 0.5;
}

/* meta de cada nota (día, fecha, hora, categoría) */
.lectura-meta {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.35;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

/* texto de la nota — serif para legibilidad */
.lectura-texto {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  line-height: 1.8;
  color: #2a2a2a;
}

.lectura-texto p {
  margin-bottom: 0.8em;
}

.lectura-texto img,
.lectura-texto video {
  max-width: 100%;
  border: 3px solid #1a1a1a;
  box-shadow: 4px 4px 0 #1a1a1a;
  margin: 16px 0;
}

/* h1 invertido (fondo negro, texto claro) */
.lectura-texto h1 {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 0.5em;
  background: #1a1a1a;
  color: #fffce8;
  padding: 4px 10px;
  display: inline-block;
}

/* h2 con borde izquierdo grueso */
.lectura-texto h2 {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 900;
  margin-bottom: 0.5em;
  border-left: 4px solid #1a1a1a;
  padding-left: 10px;
}

.lectura-texto h3 {
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 900;
}

/* links neubrutalist — botones con borde y sombra */
.lectura-texto a {
  color: #1a1a1a;
  text-decoration: none;
  background: #748ffc;
  padding: 1px 6px;
  border: 2px solid #1a1a1a;
  box-shadow: 2px 2px 0 #1a1a1a;
  font-family: 'Space Mono', 'Courier New', monospace;
  font-size: 0.85em;
  transition: transform 0.1s, box-shadow 0.1s;
  display: inline-block;
  margin: 2px 0;
  word-break: break-all;
}

.lectura-texto a:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a1a1a;
  background: #91a7ff;
}

.lectura-texto a:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

/* ── search highlight ── */
mark.highlight {
  background: #ffd43b;
  color: #1a1a1a;
  padding: 0 2px;
  border-bottom: 2px solid #1a1a1a;
}


/* ── modal contraseña (sanchai) ── */
.modal-pass {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-pass.hidden { display: none; }

.modal-pass-box {
  background: #fffce8;
  border: 3px solid #1a1a1a;
  box-shadow: 8px 8px 0 #1a1a1a;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 280px;
}

.modal-pass-titulo {
  font-size: 2.5rem;
  line-height: 1;
}

.modal-pass-box input {
  background: #fff;
  border: 3px solid #1a1a1a;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 14px;
  width: 100%;
  outline: none;
  box-shadow: 3px 3px 0 #1a1a1a;
  text-align: center;
  letter-spacing: 0.15em;
}

.modal-pass-box input:focus {
  box-shadow: 4px 4px 0 #ffd43b;
}

.modal-pass-box .vista-btn {
  width: 100%;
  padding: 8px;
  font-size: 0.9rem;
}

.modal-pass-error {
  font-size: 0.75rem;
  font-weight: 900;
  color: #ff6b6b;
  min-height: 1em;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.modal-pass-box.shake {
  animation: shake 0.4s ease-out;
}

/* ── responsive ── */
@media (max-width: 600px) {
  #escritorio { padding: 20px; }
  #escritorio > h1 { font-size: 1.8rem; }
  #carpetas { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .carpeta { min-height: 80px; }
  /* ventana ya es fullscreen por defecto */
  .vista-grid { columns: 1; }
  #buscar { width: 120px; }
  .lista-dia { display: none; }
  .lista-fecha-year { display: none; }
}
