/* Sky Crossword (/play/crossword, ADR 0109). Dark theme overrides in
   crossword-dark.css; Night vision filters the whole page (ADR 0086). */

.cw-page {
  --cw-ink: var(--text);
  --cw-block: #2b3040;
  --cw-cell: var(--surface);
  --cw-line: #9aa1b2;
  --cw-word: var(--accent-moon-soft);
  --cw-focus: #ffd99a;
  --cw-focus-line: var(--accent-sun);
  --cw-wrong: #c0392b;
  --cw-revealed: var(--accent-moon);
  --cw-today: var(--accent-sun);
}

.cw-intro h1 { margin-bottom: 2px; }
.cw-sizes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cw-sizes a {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.95rem;
}
.cw-sizes a span { color: var(--muted); font-size: 0.85rem; }
.cw-sizes a[aria-current="page"] { border-color: var(--accent-moon); background: var(--accent-moon-soft); }
.cw-sizes a:hover, .cw-sizes a:focus-visible { border-color: var(--accent-moon); }

.cw-small { --cw-n: 5; }
.cw-medium { --cw-n: 9; }
.cw-large { --cw-n: 13; }

.cw {
  display: grid; gap: 16px 28px; margin: 16px 0;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
  .cw { grid-template-columns: minmax(0, var(--cw-board, 560px)) minmax(260px, 1fr); align-items: start; }
  .cw-small { --cw-board: 360px; }
  .cw-medium { --cw-board: 520px; }
  .cw-large { --cw-board: 620px; }
  .cw-board, .cw-play { grid-column: 1; }
  .cw-clues { grid-column: 2; grid-row: 1 / span 2; max-height: 80vh; overflow: auto; }
}

.cw-board { position: relative; width: 100%; max-width: var(--cw-board, 620px); container-type: inline-size; }
.cw-grid {
  display: grid; grid-template-columns: repeat(var(--cw-n), minmax(0, 1fr));
  gap: 1px; padding: 1px; background: var(--cw-line);
  border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.cw-row { display: contents; }
.cw-block { background: var(--cw-block); aspect-ratio: 1; }
.cw-cell {
  position: relative; aspect-ratio: 1; background: var(--cw-cell); color: var(--cw-ink);
  display: grid; place-items: center; cursor: pointer;
}
.cw-n {
  position: absolute; inset-block-start: 1px; inset-inline-start: 2px;
  font-size: max(9px, calc(100cqi / var(--cw-n) * 0.24)); line-height: 1; color: var(--muted); font-weight: 600;
}
.cw-l {
  font-size: calc(100cqi / var(--cw-n) * 0.56); line-height: 1; font-weight: 650; text-transform: none;
  padding-top: calc(100cqi / var(--cw-n) * 0.08);
}
.cw-cell.is-word { background: var(--cw-word); }
.cw-cell.is-focus { background: var(--cw-focus); box-shadow: inset 0 0 0 2px var(--cw-focus-line); }
.cw-cell.is-wrong .cw-l { color: var(--cw-wrong); text-decoration: line-through; text-decoration-thickness: 2px; }
.cw-cell.is-revealed .cw-l { color: var(--cw-revealed); }
.cw-cell.is-revealed::after {
  content: ""; position: absolute; inset-block-start: 0; inset-inline-end: 0;
  border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--cw-revealed) transparent transparent;
}
[dir="rtl"] .cw-cell.is-revealed::after { border-width: 0 0 7px 7px; border-color: transparent transparent transparent var(--cw-revealed); }
.cw.is-solved .cw-cell { background: color-mix(in srgb, var(--cw-cell) 82%, var(--aurora-dot) 18%); }

/* The field that brings up the keyboard: on the grid, invisible. */
.cw-input {
  position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; font-size: 16px; caret-color: transparent; pointer-events: none;
}

.cw-bar {
  display: flex; align-items: center; gap: 6px; min-height: 52px;
  padding: 6px; border-radius: 12px; background: var(--cw-word); color: var(--text);
}
.cw-bar button, .cw-tools button {
  font: inherit; color: inherit; cursor: pointer;
}
.cw-bar button {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; display: grid; place-items: center;
}
.cw-bar button:hover, .cw-bar button:focus-visible { background: color-mix(in srgb, var(--cw-word) 70%, var(--text) 12%); }
.cw-bar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .cw-bar svg { transform: scaleX(-1); }
.cw-current { flex: 1; margin: 0; font-size: 1rem; line-height: 1.3; }
.cw-current b { margin-inline-end: 6px; }
.cw-hint-link { margin: 8px 4px 0; font-size: 0.95rem; }
.cw-hint-link a { color: var(--accent-moon); font-weight: 600; }

.cw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.cw-tools button {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 0.95rem;
}
.cw-tools button:hover, .cw-tools button:focus-visible { border-color: var(--accent-moon); }
.cw-clock { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.cw-status { min-height: 1.4em; margin: 8px 4px 0; color: var(--muted); font-size: 0.95rem; }
.cw-done {
  margin-top: 10px; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface);
}
.cw-done p { margin: 0 0 8px; }
.cw-done-line { font-size: 1.1rem; font-weight: 650; }
.cw-done-streak { color: var(--muted); }

.cw-clues h2 { margin: 0 0 6px; font-size: 1.05rem; }
.cw-clues section + section { margin-top: 18px; }
.cw-list { list-style: none; margin: 0; padding: 0; }
.cw-list li {
  display: grid; grid-template-columns: 2.2em 1fr; gap: 2px 4px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; line-height: 1.35;
}
.cw-list li.is-current { background: var(--cw-word); }
.cw-list li.is-done .cw-text { color: var(--muted); }
.cw-num { font-weight: 700; }
.cw-enum { color: var(--muted); white-space: nowrap; }
.cw-today {
  display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 650; color: var(--cw-today); border: 1px solid currentColor; vertical-align: 1px;
}
.cw-learn { grid-column: 2; font-size: 0.9rem; color: var(--accent-moon); }

.cw-days { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 18px; }
.cw-days a { color: var(--accent-moon); font-weight: 600; text-decoration: none; }
.cw-days a:hover { text-decoration: underline; }
.cw-about { max-width: 70ch; color: var(--muted); }
.cw-about h2 { color: var(--text); font-size: 1.05rem; }

/* Streak tracker: the shared games record as numbers and a month of stars. */
.cw-streak { margin: 10px 0 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); max-width: 560px; }
.cw-streak h2 { margin: 0 0 10px; font-size: 1.05rem; }
.cw-streak-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.cw-streak-stats div { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--cw-word); }
.cw-streak-stats dt { font-size: 0.8rem; color: var(--muted); }
.cw-streak-stats dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cw-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cw-cal-head h3 { margin: 0; font-size: 1rem; text-transform: capitalize; }
.cw-cal-head button {
  width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer;
}
.cw-cal-head button:disabled { opacity: 0.35; cursor: default; }
.cw-cal-head svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .cw-cal-head svg { transform: scaleX(-1); }
.cw-cal-days, .cw-cal-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cw-cal-days span { text-align: center; font-size: 0.75rem; color: var(--muted); padding-bottom: 2px; }
.cw-cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; font-size: 0.9rem;
  border: 1px solid transparent; min-width: 0;
}
a.cw-cal-day:hover { border-color: var(--accent-moon); }
.cw-cal-day.is-out { visibility: hidden; }
.cw-cal-day.is-today { border-color: var(--cw-focus-line); font-weight: 700; }
.cw-cal-day.is-solved { background: var(--cw-word); }
.cw-cal-day i { font-style: normal; font-size: 0.6rem; line-height: 1; color: var(--cw-today); letter-spacing: -1px; }
span.cw-cal-day:not(.is-out) { color: var(--muted); }
.cw-streak-note { margin: 12px 0 0; font-size: 0.9rem; color: var(--muted); }
.cw-streak-note a { color: var(--accent-moon); }

/* Full screen on phones (ADR 0108): the grid, the clue bar and the tools first. */
.game-stage.is-full .cw { margin: 0; gap: 10px; }
.game-stage.is-full .cw-clues { display: none; }

@media (max-width: 599px) {
  .cw-tools button { padding: 7px 11px; font-size: 0.9rem; }
  .cw-n { inset-inline-start: 1px; }
}

@media print {
  .cw-play, .cw-sizes, .cw-days, .cw-streak, .game-stage-bar, .game-stage-start { display: none !important; }
  .cw-cell { background: #fff !important; }
  .cw-block { background: #000 !important; }
}
.cw-intro .place-meta a { color: var(--accent-moon); font-weight: 600; }
