/* Daily Crossword — play page styles.
 *
 * Lives alongside word_showers.css under /static/. The grid is rendered
 * as a CSS grid with one cell per letter; black cells get a solid fill,
 * letter cells host an <input maxlength="1">. The clue list is a plain
 * <ol> per direction so JAWS H-key navigation lands on a heading per
 * direction, then arrows through the list.
 */

#cw-root {
  --cw-cell: 36px;
  --cw-gap: 2px;
  --cw-border: #2c3e50;
  --cw-cell-bg: #ffffff;
  --cw-cell-bg-active: #fff7d6;
  --cw-cell-bg-word: #f0f6ff;
  --cw-cell-bg-wrong: #ffe2e2;
  --cw-black: #1f2933;
  --cw-text: #1a202c;
  --cw-clue-num: #506478;
  margin: 1rem 0 2rem;
}

#cw-root.cw-large { --cw-cell: 32px; }
#cw-root.cw-xl    { --cw-cell: 28px; }

.cw-loading {
  text-align: center;
  padding: 2rem;
  color: #506478;
  font-style: italic;
}

.cw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f4f7fb;
  border-radius: 6px;
}

.cw-toolbar .cw-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--cw-text);
}

.cw-toolbar .cw-counter {
  font-size: 0.95rem;
  color: var(--cw-clue-num);
}

.cw-toolbar button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--cw-border);
  background: #fff;
  color: var(--cw-text);
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}
.cw-toolbar button:hover { background: var(--cw-cell-bg-active); }
.cw-toolbar button:focus { outline: 3px solid #2563eb; outline-offset: 2px; }
.cw-toolbar button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.cw-status {
  margin: 0.5rem 0 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  background: #eef5ff;
  border: 1px solid #c5d8f5;
  color: var(--cw-text);
}
.cw-status.cw-status-ok    { background: #e0f7e9; border-color: #9bd3b1; }
.cw-status.cw-status-bad   { background: #ffe2e2; border-color: #f0a3a3; }

.cw-board {
  display: flex;
  flex-direction: column;
  gap: var(--cw-gap);
  width: max-content;
  margin: 0 auto;
  background: var(--cw-border);
  padding: var(--cw-gap);
  border: 2px solid var(--cw-border);
  border-radius: 4px;
}

.cw-row {
  display: flex;
  gap: var(--cw-gap);
}

.cw-cell {
  position: relative;
  width: var(--cw-cell);
  height: var(--cw-cell);
  background: var(--cw-cell-bg);
  display: block;
}

.cw-cell.cw-black {
  background: var(--cw-black);
}

.cw-cell.cw-active { background: var(--cw-cell-bg-active); }
.cw-cell.cw-word   { background: var(--cw-cell-bg-word); }
.cw-cell.cw-wrong  { background: var(--cw-cell-bg-wrong); }

.cw-cell .cw-num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.65rem;
  color: var(--cw-clue-num);
  pointer-events: none;
  line-height: 1;
}

.cw-cell input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: calc(var(--cw-cell) * 0.55);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--cw-text);
  caret-color: transparent;
  padding: 0;
  margin: 0;
  outline: none;
}

.cw-cell input:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.cw-clues {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 720px) {
  .cw-clues { grid-template-columns: 1fr 1fr; }
}

.cw-clue-block h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.cw-clue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #d4dbe6;
  border-radius: 4px;
  overflow: hidden;
}

.cw-clue-list li {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #eaeef5;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  background: #fff;
}

.cw-clue-list li:last-child { border-bottom: 0; }
.cw-clue-list li:hover  { background: var(--cw-cell-bg-active); }
.cw-clue-list li.cw-clue-active { background: var(--cw-cell-bg-word); font-weight: 600; }
.cw-clue-list li.cw-clue-done   { color: #5a7065; }
.cw-clue-list li.cw-clue-done::after {
  content: " ✓";
  margin-left: auto;
  color: #2f8f4d;
}

.cw-clue-list .cw-clue-num {
  font-weight: 700;
  color: var(--cw-clue-num);
  min-width: 1.5rem;
}

@media (max-width: 540px) {
  #cw-root { --cw-cell: 28px; }
  #cw-root.cw-large { --cw-cell: 24px; }
  #cw-root.cw-xl    { --cw-cell: 22px; }
}

/* Restart / Leave game links inside the toolbar share the toolbar
 * button styling but the leave link is an <a> so we restyle for hover.
 */
.cw-toolbar .cw-leave {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--cw-border);
  background: #fff;
  color: var(--cw-text);
  border-radius: 4px;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.cw-toolbar .cw-leave:hover { background: var(--cw-cell-bg-active); }
.cw-toolbar .cw-leave:focus { outline: 3px solid #2563eb; outline-offset: 2px; }

/* aria-live region — visible to screen readers, off-screen visually.
 * Mirrors the .ws-live pattern used in Word Showers. */
.cw-live {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Hinted cells — a soft yellow tint so the player can spot which
 * letters were revealed rather than typed. The class is purely
 * visual; functionally a hinted cell is identical to a typed one. */
.cw-cell.cw-hint {
  background: #fff3a6;
}
.cw-cell.cw-hint.cw-word { background: #ffe97a; }
