/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
*/

.ascii-grid {
  font-family: monospace;
  font-size: 0.85rem;
}

/* ===============================================
   Crossword styles
   =============================================== */
.crossword-cell {
  border: 1px solid #666;
  position: relative;
  background: white;
  width: 100%;
  height: 100%;
  margin: -1px 0 0 -1px;
}

.crossword-cell.blocked {
  background: #333;
  border: 1px solid #555;
}

.crossword-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  color: black;
  border: none;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  text-align: center;
  font-weight: bold;
  text-transform: uppercase;
  line-height: 1;
}

.crossword-input:focus {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
}

.crossword-input.current-word {
  background: #fff3cd;
}

.crossword-input.selected {
  background: #cff4fc;
}

.crossword-cell-number {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: clamp(7px, 1.5vw, 9px);
  color: black;
  font-weight: bold;
  z-index: 1;
}

.crossword-grid,
.crossword-mini {
  --grid-max: 320px;
  --grid-viewport: 85vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-left: auto;
  margin-right: auto;
  width: min(
    100%,
    var(--grid-viewport),
    var(--grid-max),
    calc(var(--grid-max) * var(--crossword-cols, 1) / var(--crossword-rows, 1)),
    calc(var(--grid-viewport) * var(--crossword-cols, 1) / var(--crossword-rows, 1))
  );
  aspect-ratio: var(--crossword-cols, 1) / var(--crossword-rows, 1);
}

.crossword-grid .row,
.crossword-mini .row {
  flex: 1 0 0;
}

.crossword-grid .col,
.crossword-mini .col {
  flex: 1 0 0;
}

.crossword-grid .row:first-child .crossword-cell,
.crossword-mini .row:first-child .crossword-cell {
  margin-top: 0;
}

.crossword-grid .col:first-child .crossword-cell,
.crossword-mini .col:first-child .crossword-cell {
  margin-left: 0;
}

@media (max-width: 576px) {
  .crossword-grid {
    --grid-max: 260px;
  }
}

@media (min-width: 577px) and (max-width: 767px) {
  .crossword-grid {
    --grid-max: 300px;
  }
}

@media (min-width: 768px) {
  .crossword-grid {
    --grid-max: 320px;
  }
}

.crossword-mini {
  border: 2px solid #333;
  --grid-max: 120px;
}

.crossword-mini .crossword-input {
  font-size: clamp(0.6rem, 2vw, 0.8rem);
}

.crossword-mini .crossword-cell-number {
  font-size: clamp(6px, 1.2vw, 8px);
}

.crossword-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(220, 53, 69, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.crossword-error::before {
  content: "✗";
  color: #dc3545;
  font-size: 1.2em;
  font-weight: bold;
}

.crossword-grid.shake,
.crossword-mini.shake {
  animation: crossword-shake 0.5s ease-in-out;
}

@keyframes crossword-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.clue-highlighted {
  background-color: rgba(255, 193, 7, 0.2) !important;
  font-weight: 600;
}

.crossword-active-clue {
  display: none;
}

.crossword-active-clue--visible {
  display: flex;
}

.crossword-active-clue__nav:hover {
  color: var(--color-primary) !important;
  transform: scale(1.1);
  transition: all 0.2s ease;
}

.crossword-active-clue__nav:active {
  transform: scale(0.95);
}

.crossword-grid .crossword-input[readonly] {
  pointer-events: none;
  cursor: default;
}
