/* --- VARIABLES PARA MODO DÍA / NOCHE --- */
:root {
  --bg-color: #f4f7f6;
  --text-color: #2c3e50;
  --sub-text: #2c3e50;
  --card-bg: white;
  --border-color: #aed581;
}

/* Ocultar barra en Chrome, Safari y Edge */
body::-webkit-scrollbar,
#sidebar::-webkit-scrollbar {
  display: none;
}

/* Ocultar barra en Firefox */
body, 
#sidebar {
  scrollbar-width: none;
}

body, 
#sidebar {
  -ms-overflow-style: none;
}

/*Seccion Formar Palabras */

/* --- Contenedores Principales --- */
#display-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  padding: 10px;
  box-sizing: border-box;
}

#big-letter {
  font-size: 8rem;
  font-weight: bold;
  transition: transform 0.1s ease;
}

/* --- Contenedor de palabras formado --- */
#word-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 10px;
  padding: 6px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  min-height: 80px;
  border-radius: 8px;
  overflow-wrap: break-word;
}

#btn-borrar {
  background-color: #ff6b6b;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

/* Ocultar botón borrar y el contenedor de palabras por defecto */
#btn-borrar,
#word-display {
  display: none;
}

/* Solo mostrar ambos cuando el body tenga la clase 'modo-palabras' */
body.modo-palabras #btn-borrar,
body.modo-palabras #word-display {
  display: block; /* O 'flex' si prefieres que se mantengan alineados */
}
/* --- Estilo de cada letra dentro del contenedor --- */
.letter-in-word {
  font-size: clamp(1.5rem, 5vw, 3rem); /* clamp(mínimo, preferido, máximo) */
  font-weight: bold;
  color: inherit;
  padding: 2px 2px;
  border-radius: 0px;
  box-shadow: none; /* Elimina la sombra completamente */
  animation: aparecer 0.2s ease-out;
}

/* Animación simple para que las letras se vean bien al aparecer */
@keyframes aparecer {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Responsive para dispositivos móviles --- */
@media (max-width: 480px) {
  #big-letter {
    font-size: 5rem;
  }
  .letter-in-word {
    font-size: 1.2rem;
    font-size: bold;
  }
}

/*Hmtl Normal */

body.dark-mode {
  --bg-color: #1a1a1a;
  --text-color: #f4f7f6;
  --sub-text: #b0bec5;
  --card-bg: #2d2d2d;
  --border-color: #8cbd5c;
}

* {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

/* Pantalla con scroll natural e inteligente */
html,
body {
 /*min-height: 80dvh; /* El fondo siempre cubrirá toda la pantalla */
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Evita movimientos hacia los lados */
  overflow-y: auto; /* Permite scroll vertical solo si es necesario */
  overscroll-behavior-y: contain;
  touch-action: pan-x, pan-y;
}

body {
  font-family: "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 80px arriba para dar espacio limpio a los botones de Menú y Día */
  padding: 80px 15px 30px 15px;
  background-color: var(--bg-color);
  color: var(--text-color);
  box-sizing: border-box;
  transition: 0.3s;
}

h1 {
  color: var(--text-color);
  text-align: center;
  margin-top: 0;
  margin-bottom: 5px;
  font-size: 1.8rem;
}

#seccion-titulo {
  color: var(--sub-text);
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 15px;
  text-transform: uppercase;
  text-align: center;
  font-size: 0.95rem;
}

/* --- BOTÓN MODE DÍA/NOCHE --- */
#theme-toggle {
  position: fixed;
  top: 15px;
  right: 15px;
  background-color: #2c3e50;
  color: white;
  border: none;
  padding: 10px 15px;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 20px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 0 #1a252f;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.1s;
}
body.dark-mode #theme-toggle {
  background-color: #8cbd5c;
  color: #2c3e50;
  box-shadow: 0 4px 0 #d4aa00;
}
#theme-toggle:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 transparent;
}

/* --- BOTÓN MENÚ HAMBURGUESA --- */
#menu-toggle {
  position: fixed;
  top: 15px;
  left: 15px;
  background-color: #ffce00;
  border: none;
  padding: 10px 15px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #d4aa00;
  z-index: 100;
  transition: all 0.1s;
  color: #2c3e50;
}
#menu-toggle:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d4aa00;
}

/* --- MENÚ LATERAL (SIDEBAR) --- */
#sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: 260px;
  height: 100vh;
  background-color: var(--card-bg);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
  z-index: 101;
  transition: left 0.3s ease;
  overflow-y: auto;
  padding: 40px 15px 20px 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#sidebar.open {
  left: 0;
}

.sidebar-title {
  font-size: 1.2rem;
  color: var(--text-color);
  text-align: center;
  margin-bottom: 15px;
  font-weight: bold;
  border-bottom: 2px solid var(--bg-color);
  padding-bottom: 10px;
}

.menu-btn {
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  background-color: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}
.menu-btn:hover {
  background-color: #e0f7fa;
}

body.dark-mode .menu-btn:hover {
  background-color: #37474f;
}

.menu-btn.btn-abecedario,
.menu-btn.btn-palabras {
  background-color: #aed581;
  color: white;
  text-align: center;
  margin-bottom: 20px;
}

.btn-ll {
  background-color: #e8f5e9; /* Un color distinto para identificarla */
  font-weight: bold;
}

/* Correo electronico */

#e-mail {
  background-color: #ffce00;
  color: rgb(0, 0, 0);
  text-align: center;
  margin-top: auto;
  padding: 12px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px;
}

/* --- CONTENEDOR PRINCIPAL --- */
.main-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1050px;
  gap: 15px;
}

/* --- CUADRO VERDE --- */
#display-container {
  min-width: 280px;
  width: 85vw;
  width: 380px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  border-radius: 25px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  border: 6px solid var(--border-color);
  flex-shrink: 0;
  transition:
    background-color 0.3s,
    border-color 0.3s;
}

#big-letter {
  font-size: 100px;
  font-weight: bold;
  color: #ff6600;
  transition: transform 0.15s ease-out;
}

.content-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* --- SELECTOR DE COLORES --- */
.selector-colores {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 5px;
  margin-bottom: 10px;
  background: var(--card-bg);
  padding: 8px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: background-color 0.3s;
}

.punto-color {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 0.1s ease;
}
body.dark-mode .punto-color {
  border: 3px solid #444444;
}
.punto-color:active {
  transform: scale(0.85);
}

.color-naranja {
  background-color: #ff6600;
}
.color-negro {
  background-color: #000000;
}
body.dark-mode .color-negro {
  background-color: #ffffff;
}
.color-azul {
  background-color: #0056b3;
}
.color-verde {
  background-color: #1e7e34;
}
.color-amarillo {
  background-color: #ffc107;
}

/* --- INTERRUPTOR SWITCH --- */
.switch-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 5px;
  margin-bottom: 15px;
  background: var(--card-bg);
  padding: 8px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: background-color 0.3s;
  width: fit-content;
}

.switch-label {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--sub-text);
  transition: color 0.3s;
}
.switch-label.active {
  color: var(--text-color);
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #33ccff;
  transition: 0.4s;
  border-radius: 28px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #0099cc;
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* --- REJILLA DE BOTONES PRINCIPALES --- */

#alphabet-grid {
  display: flex;
  flex-wrap: wrap; /* Esto hace que los botones salten a la siguiente línea */
  justify-content: center; /* Centra los botones en la pantalla */
  gap: 10px; /* Espacio entre botones */
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 10px;
}

/* --- Nuevas reglas --- */
img,
button,
div,
span {
  max-width: 100%;
}

.letter-btn {
  /* Eliminamos aspect-ratio para tener control total */
  width: 55px;
  height: 55px;
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Evita que el botón se encoja o estire */
  flex-shrink: 0;
}

.mayuscula {
  background-color: #33ccff;
  color: #000000;
}
.minuscula {
  background-color: #0099cc;
  color: #ffffff;
}
.letter-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

body.ver-minusculas .mayuscula {
  display: none !important;
}
body.ver-mayusculas .minuscula {
  display: none !important;
}

/* --- NOTA PEDAGÓGICA --- */
#nota-c,
#nota-q,
#nota-k,
#nota-x {
  display: none;
  width: 95%;
  max-width: 600px;
  padding: 12px;
  margin: 10px 0;
  border-left: 5px solid #3b82f6;
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  text-align: left;
}

#nota-c p,
#nota-q p,
#nota-k p,
#nota-x p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text-color);
}

/* --- MODAL DE APOYO --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background-color: var(--card-bg);
  color: var(--text-color);
  padding: 25px;
  border-radius: 25px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 {
  margin-top: 0;
  margin-bottom: 5px;
  font-size: 1.3rem;
}
.modal-content h3.rojo {
  color: #ff5f5f;
}
.modal-content p.descripcion-modal {
  color: var(--sub-text);
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 15px;
  margin-top: 0;
}

.subtitulo-seccion {
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--sub-text);
  text-align: left;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.datos-caja {
  background-color: var(--bg-color);
  padding: 12px 15px;
  border-radius: 15px;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-color);
  margin-bottom: 15px;
  border: 1px dashed var(--sub-text);
}
.datos-caja div {
  margin-bottom: 6px;
}
.datos-caja div:last-child {
  margin-bottom: 0;
}

.valor-bloque {
  font-family: monospace;
  font-size: 1.05rem;
  background: #e0f7fa;
  color: #006064;
  padding: 6px 10px;
  border-radius: 8px;
  display: block;
  margin-top: 5px;
  text-align: center;
  font-weight: bold;
}
body.dark-mode .valor-bloque {
  background: #124d50;
  color: #e0f7fa;
}

.btn-modal-copiar {
  width: 100%;
  background-color: #aed581;
  color: white;
  border: none;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #8cbd5c;
  transition: all 0.1s;
  margin-top: 5px;
  margin-bottom: 5px;
}
.btn-modal-copiar:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8cbd5c;
}

.btn-modal-cerrar {
  position: absolute;
  top: 12px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #95a5a6;
  cursor: pointer;
  line-height: 1;
}

/* --- AJUSTES EN SMARTPHONES --- */
@media (max-width: 380px) {
  h1 {
    font-size: 1.5rem;
  }
  #display-container {
    height: 160px;
    max-width: 240px;
    border-width: 5px;
  }
  #big-letter {
    font-size: 90px;
  }

  .letter-btn {
    max-width: 50px;
    font-size: 1.2rem;
    border-radius: 8px;
  }
  .switch-container {
    margin-bottom: 10px;
    padding: 6px 15px;
  }
  .switch-label {
    font-size: 0.8rem;
  }
}

/* --- modo Landscape --- */

@media (orientation: landscape) {
  #word-display {
    gap: 1.5px; /* Menos espacio entre letras para ganar lugar */
  }

  .letter-in-word {
    font-size: clamp(
      1rem,
      5vw,
      2rem
    ); /* Letras un poco más pequeñas en horizontal */
  }
}

#seccion-titulo {
  /*margin-bottom: 10px;*/
  font-size: 0.85rem;
  /*display: none;*/
}

@media (orientation: landscape) and (max-height: 500px) {
  body {
    padding-top: 65px;
  }
  h1 {
    font-size: 1.4rem;
  }
  #seccion-titulo {
    /*margin-bottom: 10px;*/
    font-size: 0.85rem;
    /*display: none;*/
  }
  .main-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
  }
  #display-container {
    max-width: 200px;
    height: 160px;
  }
  #big-letter {
    font-size: 80px;
  }

  .switch-container {
    margin-top: 0;
    margin-bottom: 5px;
  }
}
