/**
 * Crossword Game CSS
 * PuzzleDepot.com Crossword Library
 * Adapted from Sudoku Game CSS for consistency
 * Dark theme matching trivia puzzle styling
 */

/* ===== CSS RESET AND BASE STYLES ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: #333;
  background-color: #f5f5f5;
  padding-top: 52px;
  min-height: 100vh;
  overflow-x: hidden;
}

body.has-navbar-fixed-top {
  background-image: url("https://puzzledepot.com/pics/xword_ba.gif");
  background-repeat: repeat;
  background-size: 64px 64px;
  background-color: #e0e0e0;
  padding-top: 52px;
}

/* ===== LAYOUT UTILITIES ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.columns {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.5rem;
}

.columns.is-centered {
  justify-content: center;
}

.column {
  flex: 1;
  padding: 0 0.5rem;
  min-width: 0;
}

.column.is-narrow {
  flex: none;
}

/* ===== NAVBAR ===== */
.navbar {
  background-color: #3273dc;
  color: white;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  contain: layout style;
}

.navbar-brand {
  display: flex;
  align-items: stretch;
  min-height: 3.25rem;
}

.navbar-item {
  display: flex;
  align-items: center;
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
}

.navbar-item:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.navbar-item.is-active {
  background-color: rgba(0, 0, 0, 0.2);
  font-weight: bold;
}

.navbar-burger {
  color: white;
  cursor: pointer;
  display: block;
  height: 3.25rem;
  position: relative;
  width: 3.25rem;
  margin-left: auto;
  background: none;
  border: none;
}

.navbar-burger span {
  background-color: currentColor;
  display: block;
  height: 1px;
  left: calc(50% - 8px);
  position: absolute;
  transform-origin: center;
  transition: all 86ms ease-out;
  width: 16px;
}

.navbar-burger span:nth-child(1) {
  top: calc(50% - 6px);
}

.navbar-burger span:nth-child(2) {
  top: calc(50% - 1px);
}

.navbar-burger span:nth-child(3) {
  top: calc(50% + 4px);
}

.navbar-burger.is-active span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.navbar-burger.is-active span:nth-child(2) {
  opacity: 0;
}

.navbar-burger.is-active span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.navbar-menu {
  display: none;
}

.navbar-menu.is-active {
  display: block;
  background-color: #3273dc;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 0.5rem 0;
}

@media screen and (min-width: 1024px) {
  .navbar {
    display: flex;
    align-items: stretch;
  }

  .navbar-burger {
    display: none;
  }

  .navbar-menu {
    display: flex;
    flex-grow: 1;
    align-items: stretch;
  }

  .navbar-start {
    display: flex;
    justify-content: flex-start;
    margin-right: auto;
    align-items: stretch;
  }

  .navbar-end {
    display: flex;
    justify-content: flex-end;
    margin-left: auto;
    align-items: stretch;
  }
}

/* ===== BUTTONS ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: calc(0.5em - 1px) 1em;
  text-align: center;
  white-space: nowrap;
  font-size: 1rem;
  height: 2.5em;
  line-height: 1.5;
  position: relative;
  vertical-align: top;
  user-select: none;
  transition: all 0.15s ease;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button.is-small {
  font-size: 0.75rem;
  border-radius: 2px;
}

.button.is-medium {
  font-size: 1.25rem;
  min-width: 100px;
  min-height: 40px;
}

.button.is-link {
  background-color: #3273dc;
  border-color: transparent;
  color: #fff;
}

.button.is-link:hover:not(:disabled) {
  background-color: #276cda;
}

.button.is-primary {
  background-color: #0f8f8f !important;
  border-color: #0c7070 !important;
  color: #fefefe !important;
  font-weight: 800 !important;
}

.button.is-primary:hover:not(:disabled) {
  background-color: #0c7a7a !important;
}

.button.is-warning {
  background-color: #ffdd57;
  border-color: transparent;
  color: rgba(0, 0, 0, 0.7);
}

.button.is-warning:hover:not(:disabled) {
  background-color: #ffdb4a;
}

.button.is-info {
  background-color: #3298dc;
  border-color: transparent;
  color: #fff;
}

.button.is-success {
  background-color: #146b2c !important;
  border-color: #0f5621 !important;
  color: #ffffff !important;
  font-weight: 800 !important;
}

.button.is-success:hover:not(:disabled) {
  background-color: #0f5621 !important;
}

.button.is-danger {
  background-color: #f14668;
  border-color: transparent;
  color: #fff;
}

.button.is-danger:hover:not(:disabled) {
  background-color: #ef3d5d;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Navigation buttons - horizontal layout */
.field.is-grouped {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.field.is-grouped.is-grouped-centered {
  justify-content: center;
}

.field.is-grouped .control {
  flex: 0 0 auto;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  max-width: 1000px; /* Wider for Crosswords */
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  contain: paint;
}

.game-container.dark-theme {
  background: #1d1f26;
  color: #f0f2f7;
  border: 1px solid #2a2d38;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

/* ===== HERO INTRO ===== */
.hero-intro {
  background: linear-gradient(135deg, #1f1f2b 0%, #252c3b 100%);
  color: #f5f7fb;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  min-height: 200px;
}

.hero-intro h1,
.hero-intro p,
.hero-intro span {
  color: #f5f7fb !important;
}

.hero-intro .title {
  color: #f5f7fb !important;
  font-weight: 700;
}

.hero-intro .subtitle {
  color: #f5f7fb !important;
  font-weight: 700;
}

/* ===== CROSSWORD GRID ===== */
.crossword-board {
  background: #252836;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.crossword-grid-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
}

.crossword-grid {
  display: grid;
  /* Columns will be set by JS usually, but default to 15 */
  grid-template-columns: repeat(15, 1fr);
  gap: 0;
  background: #1a1c24;
  border: 3px solid #3273dc;
  border-radius: 4px;
  overflow: hidden;
  max-width: 600px; /* Larger than sudoku */
  width: 100%;
  aspect-ratio: 1;
}

.crossword-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.8rem, 2vw, 1.25rem); /* Smaller font for dense grids */
  font-weight: 700;
  background: #ffffff; /* White cells for crosswords */
  color: #1a1c24;
  border: 1px solid #3a3f52;
  cursor: pointer;
  transition: all 0.1s ease;
  position: relative;
  user-select: none;
}

/* Blocked Cells (Black) */
.crossword-cell.blocked {
  background-color: #1a1c24;
  border-color: #3a3f52;
  cursor: default;
}

/* Cell Numbers */
.crossword-cell-number {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 0.6rem;
  line-height: 1;
  color: #333;
  pointer-events: none;
}

/* Input Field */
.crossword-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-transform: uppercase;
  padding: 0;
  margin: 0;
  outline: none;
  caret-color: transparent; /* Hide cursor */
}

/* Selection States */
.crossword-cell.active {
  background-color: #ffdd57; /* Highlight active cell */
}

.crossword-cell.highlighted-word {
  background-color: #e0f2f1; /* Light highlight for current word */
}

.crossword-cell.correct {
  background: #e8f5e9; /* Light green */
  color: #1b5e20;
}

.crossword-cell.incorrect {
  background: #ffebee; /* Light red */
  color: #b71c1c;
  animation: shake 0.3s ease;
}

.crossword-cell:hover:not(.blocked):not(.active) {
  background: #f0f0f0;
}

/* Clues Panel */
.clues-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.clue-column {
  flex: 1;
  min-width: 250px;
  background: #1d1f26;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #2a2d38;
}

.clue-column h3 {
  color: #fff;
  border-bottom: 2px solid #3273dc;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

.clues-list {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar styling for clues */
.clues-list::-webkit-scrollbar {
  width: 6px;
}
.clues-list::-webkit-scrollbar-track {
  background: #2b2f3c;
}
.clues-list::-webkit-scrollbar-thumb {
  background: #3273dc;
  border-radius: 3px;
}

.clue-item {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 2px;
  color: #b0b3c7;
  font-size: 0.9rem;
}

.clue-item:hover {
  background-color: #2b2f3c;
  color: #fff;
}

.clue-item.active {
  background-color: #3273dc;
  color: #fff;
}

.clue-number {
  font-weight: bold;
  margin-right: 0.5rem;
  color: #ffd447;
}

.clue-item.active .clue-number {
  color: #fff;
}

/* Sticky Clue (Mobile) */
.sticky-clue {
  position: sticky;
  bottom: 0;
  background: #3273dc;
  color: white;
  padding: 0.75rem;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 20;
  display: block; /* Visible by default, might hide on desktop if needed */
}

/* Animation */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* ===== CONTROL BUTTONS ===== */
.game-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.control-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn.check-btn {
  background: #252836;
  color: #8b9cc4;
  border-color: #3a3f52;
}

.control-btn.menu-btn {
  background: #252836;
  color: #8b9cc4;
}

.control-btn:hover {
  background: #363b4f;
  color: #fff;
}

/* ===== TIMER & STATS ===== */
.game-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: #8b9cc4;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd447;
}

.timer {
  font-family: "Courier New", monospace;
  font-size: 2rem;
  font-weight: 700;
  color: #ffd447;
  text-align: center;
  margin: 1rem 0;
}

/* ===== MODALS ===== */
.modal {
  display: none;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  z-index: 40;
}

.modal.is-active {
  display: flex;
}

.modal-background {
  background-color: rgba(10, 10, 10, 0.86);
  position: absolute;
  inset: 0;
}

.modal-card {
  margin: 0 auto;
  max-height: calc(100vh - 40px);
  width: 640px;
  background-color: white;
  border-radius: 6px;
  box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.modal-card-head {
  background-color: #3273dc;
  border-bottom: 1px solid #dbdbdb;
  border-radius: 6px 6px 0 0;
  display: flex;
  flex-shrink: 0;
  justify-content: flex-start;
  padding: 20px;
  position: relative;
}

.modal-card-title {
  color: white;
  flex-grow: 1;
  font-size: 1.5rem;
  font-weight: 600;
}

.modal-card-body {
  background-color: white;
  flex-grow: 1;
  overflow: auto;
  padding: 20px;
}

.modal-card-foot {
  background-color: #f5f5f5;
  border-top: 1px solid #dbdbdb;
  border-radius: 0 0 6px 6px;
  display: flex;
  flex-shrink: 0;
  justify-content: flex-end;
  padding: 20px;
  gap: 0.5rem;
}

.delete {
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: inline-block;
  height: 24px;
  width: 24px;
  position: relative;
}

.delete::before,
.delete::after {
  background-color: white;
  content: "";
  display: block;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translateX(-50%) translateY(-50%) rotate(45deg);
}

.delete::before {
  height: 2px;
  width: 50%;
}

.delete::after {
  height: 50%;
  width: 2px;
}

/* ===== FOOTER ===== */
.footer {
  padding: 3rem 1.5rem;
  background-color: #363636;
  color: #fefefe;
}

.footer a {
  color: #fefefe !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover {
  color: #ffd447 !important;
}

/* ===== UTILITIES ===== */
.has-text-centered {
  text-align: center;
}
.has-text-white {
  color: white !important;
}
.has-text-warning {
  color: #ffdd57 !important;
}
.has-text-weight-bold {
  font-weight: 700 !important;
}
.has-background-dark {
  background-color: #363636 !important;
}
.mb-2 {
  margin-bottom: 0.5rem !important;
}
.mb-3 {
  margin-bottom: 0.75rem !important;
}
.mb-4 {
  margin-bottom: 1rem !important;
}
.mb-5 {
  margin-bottom: 1.5rem !important;
}
.mt-3 {
  margin-top: 0.75rem !important;
}
.mt-4 {
  margin-top: 1rem !important;
}
.mt-5 {
  margin-top: 1.5rem !important;
}
.p-5 {
  padding: 1.5rem !important;
}

/* ===== RESPONSIVE ===== */
@media screen and (max-width: 768px) {
  .crossword-grid {
    width: 100%;
    /* On mobile, use max width */
  }

  .clues-container {
    flex-direction: column;
  }

  .game-container {
    padding: 0.5rem;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .navbar,
  .footer,
  .button,
  .game-controls,
  .hero-intro {
    display: none !important;
  }

  .game-container {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  .crossword-cell {
    border: 1px solid #000;
  }
}
