/* ===============================
   Escritorio Web - style.css (mejorado)
   Paleta: alegre, amigable, moderna
   Ideal para niños de 10 años
   =============================== */

/* ----- Variables y ajustes globales ----- */
:root {
  --main-bg1: #57C1EB;
  --main-bg2: #8EDB9D;
  --accent-pink: #FF4D6D;
  --accent-yellow: #FFD93D;
  --accent-violet: #7F6FFF;
  --accent-orange: #FFAD5E;
  --accent-blue: #38BDF8;
  --glass-bg: rgba(255,255,255,0.55);
  --shadow-main: 0 8px 24px 0 rgba(50, 50, 93, 0.10);
  --window-radius: 18px;
  --window-border: 3px solid var(--accent-blue);
  --shortcut-size: 100px;
  --taskbar-height: 64px;            /* <-- usado para calcular alto disponible */
  --window-title-height: 38px;
  --font-main: 'Inter', 'Roboto', Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background: linear-gradient(135deg, var(--main-bg1), var(--main-bg2));
  background-size: 200% 200%;             /* animación de fondo más fluida */
  min-height: 100vh;
  user-select: none;                       /* se sobreescribe dentro de ventanas */
  animation: move-bg 12s ease-in-out infinite alternate;
}

@keyframes move-bg {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* Respeto a usuarios con reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  html, body { animation: none !important; }
}

/* Utilidad de enfoque accesible */
:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 2px;
  border-radius: 10px;
}

/* ----- Escritorio principal ----- */
.desktop {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
}

/* ----- Accesos directos (iconos/apps) ----- */
.desktop-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  padding: 36px;
  position: absolute;
  top: 40px;
  left: 36px;
  max-height: calc(100vh - var(--taskbar-height) - 80px); /* ahora desplazable si hay muchos */
  overflow: auto;
}

.shortcut {
  width: var(--shortcut-size);
  height: var(--shortcut-size);
  background: var(--glass-bg);
  border-radius: 22px;
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.17s cubic-bezier(.5,1.8,.5,1), box-shadow 0.2s, border 0.2s;
  border: 2px solid transparent;
  text-align: center;
}
.shortcut:hover, .shortcut:focus {
  transform: scale(1.12) rotate(-4deg);
  box-shadow: 0 8px 32px 0 var(--accent-yellow);
  border: 2px solid var(--accent-violet);
  background: rgba(255,255,255,0.72);
}
.shortcut:active { transform: scale(0.98) rotate(1deg); }
.shortcut-icon {
  font-size: 2.8em;
  margin-bottom: 8px;
  color: var(--accent-blue);
  text-shadow: 0 2px 8px #fff8;
}
.shortcut span {
  font-size: 1.08em;
  font-weight: 600;
  color: #23294d;
  letter-spacing: 0.5px;
}

/* ----- Contenedor de ventanas ----- */
.windows-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--taskbar-height)); /* usa variable de taskbar */
  pointer-events: none; /* ventanas tendrán pointer-events */
  z-index: 10;
}
.window[data-app="appstore"] .window-content,
.appstore-scroll {
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

/* ----- Ventanas flotantes ----- */
.window {
  position: absolute;
  min-width: 340px;
  min-height: 220px;
  max-width: 95vw;                                  /* + espacio */
  max-height: calc(100vh - var(--taskbar-height) - 24px); /* permite crecer casi a pantalla completa */
  background: rgba(255,255,255,0.96);
  border-radius: var(--window-radius);
  box-shadow: 0 12px 48px 0 rgba(50,50,100,0.14);
  border: var(--window-border);
  overflow: hidden;                                  /* necesario para resize y para que no se desborde */
  pointer-events: all;
  transition: box-shadow 0.18s, transform 0.2s, width .15s, height .15s, left .15s, top .15s;
  animation: pop-in 0.28s cubic-bezier(.8,1.8,.3,1) backwards;
  resize: both;                                      /* <-- ahora se puede redimensionar manualmente */
}

/* Modo maximizado / pantalla completa (lo aplicará JS) */
.window.maximized,
.window.fullscreen {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: calc(100vh - var(--taskbar-height)) !important;
  max-width: 100vw !important;
  max-height: calc(100vh - var(--taskbar-height)) !important;
  border-radius: 0;
  /* opcional: mantener un borde sutil en modo completo */
  border-width: 2px;
}

@keyframes pop-in {
  0% { transform: scale(0.85) translateY(40px); opacity: 0.2; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.window.active {
  z-index: 9999;
  box-shadow: 0 16px 60px 0 var(--accent-violet), 0 0 0 4px var(--accent-blue);
}

.window .window-title {
  height: var(--window-title-height);
  background: linear-gradient(90deg, var(--accent-violet) 40%, var(--accent-blue) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 1.12em;
  border-bottom: 1px solid #e7e9fd;
  cursor: grab;
  user-select: none;
}
.window:active .window-title { cursor: grabbing; }

.window .window-title .window-controls {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.window .window-controls button {
  background: transparent;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  color: #fff;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s, transform 0.12s;
  padding: 4px 7px;
  border-radius: 6px;
}
.window .window-controls button:hover,
.window .window-controls button:focus-visible {
  opacity: 1;
  background: var(--accent-pink);
  transform: translateY(-1px);
}

.window .window-content {
  padding: 22px 18px 16px 18px;
  height: calc(100% - var(--window-title-height));
  overflow: auto;                     /* <-- asegura scroll interno cuando el contenido crece */
  font-size: 1em;
  -webkit-overflow-scrolling: touch;  /* scroll suave en móviles */
  user-select: text;                  /* <-- permite seleccionar/copy dentro de ventanas */
}
.window .window-content * { user-select: text; }

/* Mejora para apps con canvas: que puedan estirarse en ventana grande */
.window[data-app="draw"] canvas,
.window[data-app="blockcraft"] .bc-canvas {
  width: 100% !important;
  height: min(720px, calc(100% - 160px)) !important; /* ocupa más alto al maximizar */
}

/* ----- Barra de tareas / Taskbar ----- */
.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-height);
  display: flex;
  align-items: center;
  background: rgba(41, 45, 50, 0.80);
  box-shadow: 0 -4px 24px 0 rgba(50, 50, 93, 0.10);
  padding: 0 22px;
  z-index: 10000;
  backdrop-filter: blur(6px);
  gap: 16px;
}
@supports not (backdrop-filter: blur(6px)) {
  .taskbar { background: rgba(41,45,50,0.92); }
}

.taskbar-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2em;
  margin-right: 14px;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, color 0.13s, transform 0.12s;
  outline: none;
  padding: 6px 10px;
}
.taskbar-btn:hover,
.taskbar-btn:focus-visible {
  background: var(--accent-yellow);
  color: var(--accent-blue);
  transform: translateY(-1px);
}

.taskbar-apps {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
}
.taskbar-apps .taskbar-app-icon {
  font-size: 2em;
  color: var(--accent-orange);
  margin: 0 6px;
  opacity: 0.85;
  cursor: pointer;
  transition: color 0.16s, opacity 0.13s, transform 0.18s, background 0.12s;
  border-radius: 8px;
  outline: none;
  padding: 2px;
}
.taskbar-apps .taskbar-app-icon.active,
.taskbar-apps .taskbar-app-icon:hover,
.taskbar-apps .taskbar-app-icon:focus-visible {
  color: var(--accent-pink);
  opacity: 1;
  background: var(--accent-yellow);
  transform: scale(1.12) rotate(-6deg);
}

.taskbar-clock {
  font-family: 'Roboto', Arial, sans-serif;
  color: #fff;
  font-size: 1.28em;
  letter-spacing: 1.1px;
  font-weight: 700;
  margin-right: 16px;
  background: rgba(0,0,0,0.13);
  border-radius: 10px;
  padding: 6px 18px;
}

/* ----- Menú de inicio ----- */
.start-menu {
  position: fixed;
  left: 32px;
  bottom: calc(var(--taskbar-height) + 16px);
  width: 320px;
  background: rgba(255,255,255,0.97);
  border-radius: 24px;
  box-shadow: 0 8px 32px 0 rgba(50,50,93,0.18);
  z-index: 15000;
  overflow: hidden;
  animation: pop-in 0.24s;
  max-height: calc(100vh - var(--taskbar-height) - 40px); /* ahora desplazable si crece */
}
.start-menu-header {
  background: linear-gradient(90deg, var(--accent-violet) 0%, var(--accent-blue) 100%);
  color: #fff;
  font-size: 1.12em;
  font-weight: 700;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.start-menu-list {
  list-style: none;
  margin: 0;
  padding: 14px 0;
  font-size: 1.08em;
  max-height: calc(100% - 62px);
  overflow: auto;
}
.start-menu-list li {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  color: #262D47;
  transition: background 0.12s, color 0.13s, transform 0.14s;
  font-weight: 500;
  outline: none;
}
.start-menu-list li:hover,
.start-menu-list li:focus-visible {
  background: var(--accent-yellow);
  color: var(--accent-pink);
  transform: scale(1.06);
}

/* ----- Fondo personalizado ----- */
.desktop.custom-wallpaper {
  background: center/cover no-repeat !important;
  animation: none; /* evita competir con animación del gradiente */
}

/* ----- Scrollbars ----- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background: #eee;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 8px;
  border: 2px solid #e9eef7;
}

/* ----- Cursor divertido (con fallback) ----- */
body {
  cursor: url('https://cdn.jsdelivr.net/gh/ionic-team/ionicons@5.5.2/src/svg/hand-right-outline.svg') 16 0, pointer;
}
textarea, input, button, canvas, a, .window, .shortcut, .taskbar-btn, .taskbar-app-icon, .start-menu-list li {
  cursor: auto; /* evita cursor de "mano" en todo, usa el adecuado por control */
}

/* ----- Responsive ----- */
@media (max-width: 700px) {
  :root { --taskbar-height: 48px; } /* se reutiliza automáticamente en cálculos */

  .desktop-shortcuts {
    flex-direction: column;
    gap: 16px;
    left: 12px;
    top: 18px;
    padding: 0 8px;
  }
  .shortcut {
    width: 78px;
    height: 78px;
    font-size: 0.95em;
  }
  .taskbar {
    font-size: 0.95em;
    padding: 0 7px;
  }
  .taskbar-clock {
    padding: 4px 7px;
    font-size: 1em;
    margin-right: 7px;
  }
  .start-menu {
    left: 10px;
    width: 90vw;
    min-width: 200px;
  }
}

/* ----- Selección de texto dentro de apps ----- */
.window .window-content, 
.window .window-content * {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

/* ===============================
   Fin de style.css mejorado
   =============================== */
