/**
 * Hojas de estilo para Wordle en español
 * Fijate Tools - https://fijate.com/tools/wordle/
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores de juego clásicos Wordle */
  --color-correct: #10b981;    /* Verde esmeralda */
  --color-present: #f59e0b;    /* Amarillo ámbar */
  --color-absent: #64748b;     /* Gris pizarra */
  --color-tile-bg: rgba(255, 255, 255, 0.04);
  --color-tile-border: #334155;
  --color-tile-active: #64748b;
  --color-tile-text: #f8fafc;

  /* Teclado */
  --color-key-bg: #334155;
  --color-key-hover: #475569;
  --color-key-text: #f8fafc;

  /* Contenedores y modales */
  --wordle-card-bg: #1e293b;
  --wordle-card-border: rgba(255, 255, 255, 0.08);
}

/* Modo alto contraste (para daltónicos: azul y naranja) */
body.high-contrast {
  --color-correct: #ea580c; /* Naranja intenso */
  --color-present: #2563eb; /* Azul cobalto */
}

/* Modo claro (cuando html tiene data-theme='light' o clase light) */
[data-theme='light'] {
  --color-correct: #059669;
  --color-present: #d97706;
  --color-absent: #94a3b8;
  --color-tile-bg: #f8fafc;
  --color-tile-border: #cbd5e1;
  --color-tile-active: #64748b;
  --color-tile-text: #0f172a;

  --color-key-bg: #e2e8f0;
  --color-key-hover: #cbd5e1;
  --color-key-text: #0f172a;

  --wordle-card-bg: #ffffff;
  --wordle-card-border: #e2e8f0;
}

[data-theme='light'] body.high-contrast {
  --color-correct: #ea580c;
  --color-present: #2563eb;
}

/* --- REGLAS GENERALES Y CONTENCIÓN --- */
body {
  font-family: var(--font-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.game-mode-title,
.modal-title,
.seo-section-title {
  font-family: var(--font-heading);
}

.mono,
.key,
.grid-tile,
.countdown-clock {
  font-family: var(--font-mono);
}

/* --- LAYOUT PRINCIPAL --- */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* --- TARJETA PRINCIPAL DEL JUEGO --- */
.wordle-game-card {
  background: var(--wordle-card-bg);
  border: 1px solid var(--wordle-card-border);
  border-radius: 20px;
  padding: 1.5rem 1rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  margin-bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 640px) {
  .wordle-game-card {
    padding: 2rem 1.5rem;
  }
}

/* --- SELECTOR DE PESTAÑAS DE MODO --- */
.game-mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  margin-bottom: 1.25rem;
  max-width: 100%;
  overflow-x: auto;
}

[data-theme='light'] .game-mode-tabs {
  background: #f1f5f9;
}

.mode-tab-btn {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.75;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-tab-btn:hover {
  opacity: 1;
}

.mode-tab-btn.active {
  background: #2563eb;
  color: #ffffff;
  opacity: 1;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

/* --- CABECERA DE CONTROLES DEL JUEGO --- */
.game-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--wordle-card-border);
}

.game-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-daily {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-practice {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-custom {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.game-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-game-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--wordle-card-border);
  color: inherit;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

[data-theme='light'] .btn-game-icon {
  background: #f1f5f9;
}

.btn-game-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-text-action {
  background: transparent;
  border: 1px solid var(--wordle-card-border);
  color: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-text-action:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* --- CUADRÍCULA DE JUEGO (GRID) --- */
.wordle-grid-container {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 1.5rem;
}

.wordle-grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-gap: 6px;
  width: 100%;
  max-width: 350px;
  box-sizing: border-box;
}

@media (min-width: 480px) {
  .wordle-grid {
    grid-gap: 8px;
    max-width: 360px;
  }
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-gap: 6px;
}

@media (min-width: 480px) {
  .grid-row {
    grid-gap: 8px;
  }
}

.grid-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--color-tile-bg);
  border: 2px solid var(--color-tile-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-tile-text);
  user-select: none;
  box-sizing: border-box;
  text-transform: uppercase;
  transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
}

@media (max-width: 380px) {
  .grid-tile {
    font-size: 1.4rem;
  }
}

.grid-tile[data-state='filled'] {
  border-color: var(--color-tile-active);
  transform: scale(1.02);
}

.grid-tile[data-state='correct'] {
  background-color: var(--color-correct);
  border-color: var(--color-correct);
  color: #ffffff;
}

.grid-tile[data-state='present'] {
  background-color: var(--color-present);
  border-color: var(--color-present);
  color: #ffffff;
}

.grid-tile[data-state='absent'] {
  background-color: var(--color-absent);
  border-color: var(--color-absent);
  color: #ffffff;
}

/* --- ANIMACIONES DE CASILLAS --- */
/* Animación Pop al introducir letra */
.grid-tile.pop {
  animation: tilePop 0.15s ease-in-out;
}

@keyframes tilePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Animación Flip 3D al revelar resultado */
.grid-tile.flip {
  animation: tileFlip 0.5s ease-in-out;
}

@keyframes tileFlip {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* Animación Rebote de victoria */
.grid-tile.bounce {
  animation: tileBounce 0.6s ease;
}

@keyframes tileBounce {
  0%, 20% { transform: translateY(0); }
  40% { transform: translateY(-24px); }
  50% { transform: translateY(0); }
  60% { transform: translateY(-10px); }
  80% { transform: translateY(0); }
  100% { transform: translateY(0); }
}

/* Animación Sacudida de error */
.grid-row.shake {
  animation: rowShake 0.4s ease-in-out;
}

@keyframes rowShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* --- TECLADO VIRTUAL TÁCTIL --- */
.wordle-keyboard-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0.5rem;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

@media (min-width: 480px) {
  .keyboard-row {
    gap: 6px;
  }
}

.key {
  background: var(--color-key-bg);
  color: var(--color-key-text);
  border: none;
  border-radius: 6px;
  height: 52px;
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  padding: 0;
}

.key:hover {
  background: var(--color-key-hover);
  transform: translateY(-1px);
}

.key:active {
  transform: translateY(1px);
}

.key-large {
  flex: 1.5 1 0%;
  font-size: 0.85rem;
}

.key[data-state='correct'] {
  background-color: var(--color-correct) !important;
  color: #ffffff !important;
}

.key[data-state='present'] {
  background-color: var(--color-present) !important;
  color: #ffffff !important;
}

.key[data-state='absent'] {
  background-color: var(--color-absent) !important;
  color: rgba(255, 255, 255, 0.5) !important;
  opacity: 0.6;
}

[data-theme='light'] .key[data-state='absent'] {
  color: #ffffff !important;
  opacity: 0.65;
}

@media (max-width: 380px) {
  .key {
    height: 46px;
    font-size: 0.95rem;
  }
  .key-large {
    font-size: 0.72rem;
  }
}

/* --- TOASTS / AVISOS FLOTANTES --- */
.toast-container {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-success {
  background: #065f46;
  border-color: #10b981;
}

.toast.toast-error {
  background: #991b1b;
  border-color: #ef4444;
}

.toast.toast-warning {
  background: #92400e;
  border-color: #f59e0b;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-15px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- MODALES ACCESIBLES --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: var(--wordle-card-bg);
  border: 1px solid var(--wordle-card-border);
  border-radius: 18px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 1.75rem;
  box-sizing: border-box;
  position: relative;
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--wordle-card-border);
}

.modal-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.modal-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  opacity: 0.7;
}

.modal-close:hover {
  opacity: 1;
}

/* Modales: Ejemplos de ayuda */
.help-example-row {
  display: flex;
  gap: 6px;
  margin: 12px 0 8px;
}

.help-tile {
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-tile-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

.help-tile.correct { background: var(--color-correct); border-color: var(--color-correct); }
.help-tile.present { background: var(--color-present); border-color: var(--color-present); }
.help-tile.absent { background: var(--color-absent); border-color: var(--color-absent); }

/* Modales: Estadísticas */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--wordle-card-border);
}

[data-theme='light'] .stat-box {
  background: #f8fafc;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-heading);
}

.stat-label {
  font-size: 0.72rem;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}

.dist-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 1rem 0 1.5rem;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.dist-num {
  font-weight: 700;
  width: 14px;
}

.dist-bar-wrap {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow: hidden;
}

.dist-bar {
  background: var(--color-key-bg);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 20px;
  text-align: right;
  transition: width 0.4s ease;
  box-sizing: border-box;
}

.dist-row.current .dist-bar {
  background: var(--color-correct);
}

.solution-card {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--color-correct);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 1.25rem;
  text-align: center;
  font-size: 1.1rem;
}

.solution-card strong {
  color: var(--color-correct);
  letter-spacing: 2px;
  font-size: 1.3rem;
  margin-left: 6px;
}

.stats-share-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--wordle-card-border);
  padding-top: 1.25rem;
}

.countdown-box {
  text-align: center;
  font-size: 0.88rem;
  opacity: 0.9;
}

.countdown-clock {
  font-size: 1.3rem;
  font-weight: 800;
  color: #3b82f6;
  margin-top: 2px;
}

.btn-primary-action {
  background: #10b981;
  color: #ffffff;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary-action:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* Modales: Ajustes */
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--wordle-card-border);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-text h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.setting-text p {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.75;
}

/* Switch toggle */
.switch-label {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch-label input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-key-bg);
  transition: .3s;
  border-radius: 26px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .switch-slider {
  background-color: #2563eb;
}

input:checked + .switch-slider:before {
  transform: translateX(22px);
}

/* Canvas para confeti */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10001;
  display: none;
}

