/* Arrow Escape. */

.ae { container-type: inline-size; display: grid; justify-content: center; }

/* A square is as large as the width allows, but never so large that the board and its two
   buttons run off a phone screen. The bars above the board and the buttons below it take
   205px at the usual text size (measured), and the line of the run above the board 20px more,
   and they grow with the text, so the allowance is in rem. */
.ae-grid {
  --sq: max(24px, min(calc(100cqw / var(--cols)), calc((100svh - 14.5rem) / var(--rows)), 3.5rem));
  display: grid; grid-auto-rows: var(--sq);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ae-row { display: grid; grid-template-columns: repeat(var(--cols), var(--sq)); }
.ae-gc { display: block; }

.ae-sq {
  position: relative; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 22%;
  -webkit-tap-highlight-color: transparent;
}
.ae-sq:focus-visible { outline: 3px solid var(--ink); outline-offset: -1px; z-index: 2; }

.ae-tile {
  position: absolute; inset: 5.5%; display: grid; place-items: center;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 18%; color: var(--ink);
}
.ae-tile svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 0.95; stroke-linecap: round; stroke-linejoin: round; }
[data-dir="R"] > .ae-tile svg, .ae-ghost[data-dir="R"] svg { transform: rotate(90deg); }
[data-dir="D"] > .ae-tile svg, .ae-ghost[data-dir="D"] svg { transform: rotate(180deg); }
[data-dir="L"] > .ae-tile svg, .ae-ghost[data-dir="L"] svg { transform: rotate(270deg); }

/* an arrow marked by a hint */
.ae-sq.hint > .ae-tile { background: var(--c); border-color: var(--c); color: #fff; }

/* a square whose arrow has gone: a faint dot */
.ae-sq.gone { cursor: default; }
.ae-sq.gone > .ae-tile:not(.ae-ghost) { background: none; border-color: transparent; }
.ae-sq.gone > .ae-tile:not(.ae-ghost) svg { display: none; }
.ae-sq.gone > .ae-tile:not(.ae-ghost)::after { content: ""; width: 14%; height: 14%; border-radius: 50%; background: #CFCABC; }

/* a blocked tap: a heavier outline that stays for a moment, and a shake when motion is allowed */
.ae-sq.blocked > .ae-tile { border: 2px solid var(--ink); animation: ae-shake 0.28s ease-in-out; }
@keyframes ae-shake {
  25% { transform: translateX(-9%); }
  75% { transform: translateX(9%); }
}

.ae-ghost { pointer-events: none; z-index: 1; }

/* Where the system sets the colours, a hinted arrow keeps a sign of its own. */
@media (forced-colors: active) {
  .ae-sq.hint > .ae-tile { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .ae-sq.blocked > .ae-tile { border-style: dashed; }
}


/* While the board loads, what follows it waits and comes in with the drawn board (game.css keeps
   the caption's line). This board's size changes with the day's puzzle (its shape: 3 to 12 squares tall), so no room kept
   for it would hold. Only where scripts run: without them the page shows as it is, and a script
   that cannot be fetched turns the line into a notice, which lets the page show. */
@media (scripting: enabled) {
  #main:has(> #board > .loading) > #board ~ *,
  .wrap:has(#board > .loading) > .foot { display: none; }
}

/* The specials page: its heading, then a group for each occasion, each special a card with its board in miniature. */
.sp-title { padding: 1.25rem var(--gutter) 0; font: 500 1.75rem/1.15 var(--serif); }
.sp-title + .lead { padding-top: 0.5rem; }
.sp-group { padding: 1.5rem var(--gutter) 0; }
.sp-group h3 { font: 500 1.5rem/1.15 var(--serif); margin-bottom: 0.75rem; }
.sp-season { margin-left: 0.375rem; padding: 0.25rem 0.5rem; border-radius: 999px; background: var(--ink); color: var(--paper); font: 600 0.78125rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; vertical-align: 0.25rem; white-space: nowrap; }
.sp-season[hidden] { display: none; }
.sp-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.75rem; }
.sp {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 0.5rem; height: 100%; padding: 0.875rem 0.5rem 0.75rem;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); text-decoration: none; text-align: center; font: 600 0.9375rem/1.25 var(--sans);
}
.sp:hover { border-color: var(--ink); }
.sp-pic { display: block; height: 4.5rem; width: auto; max-width: 100%; }
/* solved: the game's ink around it and a tick; played to the end unsolved: a dashed edge, as on the levels page */
.sp.done { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.sp.ended { border-style: dashed; border-color: var(--stone); }
.sp-state .ic { position: absolute; top: 0.375rem; right: 0.375rem; width: 1rem; height: 1rem; color: var(--c); stroke-width: 3; }

/* The arrows cleared in a row: a line of its own above the board, at the board's right edge. Its
   height is kept whether or not a run shows, so nothing moves when one does; it never takes a tap.
   It is as wide as the board and gives nothing to its column's width (width 0, at least the whole
   column), so words wider than a narrow board (×9 Extraordinary) run past it rather than move it. */
.ae-run { width: 0; min-width: 100%; min-height: 1.25rem; margin: 0; text-align: right; font: 600 0.9375rem/1.25rem var(--sans); color: var(--stone); font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.ae-run b { color: var(--ink); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .ae-run.up { animation: ae-run-up 180ms ease-out; }
  @keyframes ae-run-up { from { opacity: 0.4; transform: translateY(3px); } to { opacity: 1; transform: none; } }
}
