/* ==========================================================================
   RightsExplained - Wordle Game Stylesheet (wordle.css)
   Dedicated modular CSS for Wordle Game across US, UK, AU, and CA editions.
   Features fluid grid, flip & bounce animations, virtual keyboard, modals,
   country switcher badges, and dark/light mode responsiveness.
   ========================================================================== */

.game-container {
  max-width: 620px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Game Header & Region Selector */
.game-header-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.game-title-group {
  text-align: center;
}

.game-main-title {
  font-size: clamp(1.75rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.game-main-title .wordle-letter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  background: var(--brand-blue);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-weight: 900;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Region Switcher Navigation (US, UK, AU, CA) */
.region-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-full);
}

.region-nav-label {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  padding: 0 0.5rem;
  letter-spacing: 0.05em;
}

.region-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.region-btn:hover {
  color: var(--brand-blue);
  background: var(--bg-surface);
}

.region-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: var(--shadow-sm);
}

/* Game Toolbar (Mode switch + Modal Buttons) */
.game-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.game-mode-toggle {
  display: flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn.active {
  background: var(--bg-surface);
  color: var(--brand-navy);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .mode-btn.active {
  color: var(--brand-blue);
}

.game-action-icons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--brand-blue);
  border-color: var(--brand-blue);
  background: var(--bg-subtle);
}

/* Wordle Game Board Grid */
.board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  width: 100%;
}

.wordle-board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: min(340px, 92vw);
  height: min(410px, 110vw);
}

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

.wordle-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 4vw, 1.95rem);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-main);
  background: var(--bg-surface);
  user-select: none;
  box-sizing: border-box;
  perspective: 1000px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

[data-theme="dark"] .wordle-tile {
  border-color: #3f4a5c;
  background: #111827;
}

/* Tile States */
.wordle-tile[data-state="active"] {
  border-color: var(--brand-blue);
  animation: tilePop 0.1s ease-in-out;
}

.wordle-tile[data-state="correct"] {
  background: #059669 !important; /* Emerald green */
  border-color: #059669 !important;
  color: #ffffff !important;
}

.wordle-tile[data-state="present"] {
  background: #d97706 !important; /* Amber / gold */
  border-color: #d97706 !important;
  color: #ffffff !important;
}

.wordle-tile[data-state="absent"] {
  background: #475569 !important; /* Slate */
  border-color: #475569 !important;
  color: #ffffff !important;
}

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

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

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

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

.wordle-tile.flip {
  animation: tileFlip 0.5s ease-in-out forwards;
}

.wordle-row.shake {
  animation: rowShake 0.4s ease-in-out;
}

.wordle-tile.bounce {
  animation: winBounce 0.8s ease-in-out;
}

/* Virtual Keyboard */
.keyboard-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  touch-action: manipulation;
}

.key-btn {
  height: 54px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 32px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.08s ease;
}

[data-theme="dark"] .key-btn {
  background: #1f2937;
  color: #f3f4f6;
}

.key-btn:active {
  transform: scale(0.94);
}

.key-btn.key-wide {
  flex: 1.5;
  font-size: 0.775rem;
}

.key-btn[data-state="correct"] {
  background: #059669 !important;
  color: #ffffff !important;
}

.key-btn[data-state="present"] {
  background: #d97706 !important;
  color: #ffffff !important;
}

.key-btn[data-state="absent"] {
  background: #334155 !important;
  color: #94a3b8 !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}

.wordle-toast {
  background: #0f172a;
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-8px);
  animation: toastFadeInOut 2.4s ease forwards;
}

@keyframes toastFadeInOut {
  0% { opacity: 0; transform: translateY(-8px); }
  15% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* Modals (Stats, Help, Info) */
.game-modal-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(3px);
}

.game-modal-backdrop.open,
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.game-modal,
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  position: relative;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.game-modal-backdrop.open .game-modal,
.modal-backdrop.open .modal-card {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close-btn,
.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  line-height: 1;
}

.modal-close-btn:hover,
.btn-close-modal:hover {
  color: var(--text-main);
}

/* Stats Modal Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  text-align: center;
  margin: 1.25rem 0 1.75rem;
}

.stat-item-number,
.stat-val {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-navy);
  line-height: 1;
}

[data-theme="dark"] .stat-item-number,
[data-theme="dark"] .stat-val {
  color: var(--brand-blue);
}

.stat-item-label,
.stat-lbl {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  margin-top: 0.35rem;
}

/* Guess Distribution Graph */
.guess-distribution {
  margin-bottom: 1.75rem;
}

.distribution-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.dist-bar-num {
  width: 12px;
}

.dist-bar-track {
  flex: 1;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}

.dist-bar-fill {
  background: var(--border-dark);
  color: #ffffff;
  padding: 2px 6px;
  min-width: 24px;
  border-radius: 3px;
  text-align: right;
  font-size: 0.75rem;
  transition: width 0.5s ease;
}

.dist-bar-fill.active {
  background: #059669;
}

/* Modal Actions (Share / Next Puzzle) */
.modal-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.btn-share {
  background: #059669;
  color: #ffffff;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color var(--transition-fast);
}

.btn-share:hover {
  background: #047857;
}

/* Word Definition Card (Educational Legal Value) */
.word-def-card {
  background: var(--brand-blue-light);
  border: 1px solid var(--brand-blue-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  text-align: left;
}

.word-def-term {
  font-weight: 800;
  color: var(--brand-navy);
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

[data-theme="dark"] .word-def-term {
  color: var(--brand-blue);
}

.word-def-text {
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.word-def-link {
  color: var(--brand-blue);
  font-weight: 600;
  text-decoration: underline;
  font-size: 0.85rem;
}

/* Instructions Example Tiles */
.example-row {
  display: flex;
  gap: 5px;
  margin: 0.75rem 0;
}

.example-tile {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-main);
}

/* SEO Content Section Underneath the Game */
.game-seo-section {
  width: 100%;
  max-width: 760px;
  margin: 3rem auto 0;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border-light);
}

.game-seo-section h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 1.75rem 0 0.75rem;
  color: var(--text-main);
}

.game-seo-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-main);
}

.game-seo-section p, .game-seo-section li {
  color: var(--text-muted);
  line-height: 1.7;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

/* Country Specific Hero Pill */
.country-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
