/* Tag crossword (crossword.html) only.
   Full-page layout: the grid fills the main area, the clue list sits on the right. No boxes or separator
   lines, except the one rule between the grid and the clue list. */

body.xw-page { background: var(--surface); }
body.xw-page .topbar { border-bottom: 0; }
body.xw-page .footer { border-top: 0; background: none; padding-top: 4px; }
.app.xw-app { max-width: none; padding: 0; gap: 0; align-items: stretch; }
.xw-main { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 8px 24px 16px; background: var(--bg); }
.xw-help { margin: 0; }

/* grid: empty squares are transparent, letter and label cells drawn with single 1px lines.
   --cell is set from the available space by crossword.js (sizeGrid). */
.xw-wrap { overflow-x: auto; }
.xw {
  --cell: 40px;
  display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell);
  width: max-content; margin: 0 auto;
}
.xw { position: relative; padding: 0 1px 1px 0; } /* padding: room for the last right/bottom line */
.xw-cell { position: relative; background: var(--surface); }
.xw-lines {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none; overflow: visible;
  fill: none; stroke: var(--text); stroke-width: 1; shape-rendering: crispEdges;
}
.xw-cell input {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: calc(var(--cell) * 0.3) 0 0;
  background: transparent; text-align: center; text-transform: uppercase; caret-color: transparent;
  font: 700 max(16px, calc(var(--cell) * 0.46)) / 1 var(--sans); color: var(--text); cursor: pointer;
}
.xw-cell input:focus { outline: none; }
.xw-cell.in-word { background: var(--primary-soft); }
.xw-cell.cursor { background: #c3d6fb; box-shadow: inset 0 0 0 2px var(--primary); }
.xw-cell.ok input { color: var(--good); }
.xw-cell.wrong input { color: var(--bad); }
.xw-cell.wrong { background-image: linear-gradient(to top right, transparent 47%, rgba(179, 36, 36, .35) 49% 51%, transparent 53%); }
.xw-cell.revealed input { color: var(--primary); }

/* label cells: number + "railway=" in the cell before a word, with an arrow into it.
   No fill and no lines: they sit on the off-white canvas, only letter cells are white.
   The label of the current word turns blue. */
.xw-label { position: relative; background: none; color: var(--text); }
.xw-label.active { color: var(--primary); }
.xw-label.active .xw-key { color: var(--primary); }
.xw-lab {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: 2px 3px; margin: 0; border: 0; background: none; text-align: center; color: inherit; overflow: hidden;
}
.xw-lab:hover { color: var(--link); }
.xw-n { font: 700 max(10px, calc(var(--cell) * 0.3)) / 1 var(--sans); }
.xw-key {
  flex: 1 1 0; min-height: 0; width: 100%; margin-top: 2px; overflow: hidden; overflow-wrap: anywhere;
  font: 400 max(8px, calc(var(--cell) * 0.17))/1.15 var(--mono); color: var(--muted); letter-spacing: -0.02em;
}
.xw-lab:hover .xw-key { color: var(--link); }
.xw-arr { position: absolute; fill: currentColor; pointer-events: none; }
.xw-arr { --a: max(6px, calc(var(--cell) * 0.14)); }
.xw-arr.right { width: calc(var(--a) * 0.6); height: var(--a); right: 1px; top: calc(50% - var(--a) / 2); }
.xw-arr.down { width: var(--a); height: calc(var(--a) * 0.6); bottom: 1px; left: calc(50% - var(--a) / 2); }
.xw-bend-svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: currentColor; }
.xw-bend-svg .line { fill: none; stroke: currentColor; stroke-width: 5; }

/* plain number in the first letter, for a word that had no room for a label cell */
.xw-num {
  position: absolute; z-index: 1; top: 0; left: 0; padding: 1px 2px 0; margin: 0;
  border: 0; background: none; color: var(--text); font: 700 max(8px, calc(var(--cell) * 0.22)) / 1 var(--sans);
}
.xw-num:hover { color: var(--link); }

.xw-done { padding: 10px 14px; background: #ccf5cc; color: #14532d; }

/* clue list on the right; on wide screens the page does not scroll, the list does */
.clues { flex: 0 1 440px; min-width: 0; padding: 4px 20px 16px; font-size: 14px; border-left: 1px solid var(--border); }
@media (min-width: 980px) {
  body.xw-page { height: 100vh; overflow: hidden; }
  body.xw-page .app { min-height: 0; flex: 1 1 0; flex-wrap: nowrap; } /* one row: both columns get the viewport height */
  .xw-main { overflow: auto; }
  .xw-wrap { flex: 1 1 0; min-height: 0; display: grid; place-items: center; overflow: hidden; }
  .clues { overflow-y: auto; }
}
@media (max-width: 979px) {
  .clues { flex-basis: 100%; border-left: 0; border-top: 1px solid var(--border); }
}
.clue-list { list-style: none; margin: 0; padding: 0; }
/* one clue: number | photo (fixed size) | tag as heading with the details below */
.clue {
  display: grid; grid-template-columns: auto 120px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; margin: 0 -12px 6px; border-radius: 3px;
}
.clue.active { background: var(--primary-soft); }
.clue-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.clue-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.clue-num {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 28px; width: 44px; padding: 0; border: 0; border-radius: 2px;
  background: var(--box-head); font-weight: 700; color: var(--text);
}
.clue-num:hover { color: var(--link); }
.clue-num svg { fill: currentColor; }
.clue-num .dir.right { width: 6px; height: 10px; }
.clue-num .dir.down { width: 10px; height: 6px; }
.clue-tag { font-size: 16px; word-break: break-all; }
.clue-tag .blank { display: inline-block; min-width: 2.5em; border-bottom: 2px solid var(--border-strong); color: transparent; }
/* number badge with the word length(s) below it */
.clue-side { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 44px; }
.clue-enum { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: center; overflow-wrap: anywhere; }
.clue-ok { color: var(--good); font-weight: 700; }
.clue.solved .clue-tag a { color: var(--good); }
/* fixed size, so opening the description does not change the photo's shape */
.clue-photo {
  position: relative; align-self: start; width: 100%; height: 130px; padding: 0; border: 0;
  background: var(--text); cursor: zoom-in; overflow: hidden;
}
.clue-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clue-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clue-line .elements { gap: 3px; }
/* details below the heading: smaller than the heading */
.clue-hint, .clue-desc { font-size: 12.5px; }
.clue-k { color: var(--muted); }
.clue-hint .tagchip { margin-bottom: 2px; font-size: 12px; border: 0; background: var(--box-head); }
.clue-desc summary { cursor: pointer; color: var(--link); }
.clue-desc .desc { margin-top: 4px; }

.lightbox { border: 0; padding: 12px; max-width: min(92vw, 1100px); background: var(--surface); }
.lightbox::backdrop { background: rgba(0, 0, 0, .7); }
.lightbox form { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; margin: 0; }
.lightbox img { display: block; max-width: 100%; max-height: 80vh; object-fit: contain; }

@media (max-width: 640px) {
  .clue { grid-template-columns: auto 88px minmax(0, 1fr); }
  .clue-photo { height: 100px; }
}
