/* Spot the Difference. */

.sd { display: grid; gap: 0.75rem; }
.sd-pictures { display: grid; gap: 0.75rem; justify-items: center; }

/* Below 1024px the pictures are stacked, each sized so that both pictures and the zoom buttons
   fit one phone screen. The rows above and below take 15.5rem at the usual text size (measured
   at 320 by 568 and 390 by 668), half a rem is kept below the buttons, and the rows grow with the
   text, so the allowance is in rem. With large text the rows grow faster than that, so the pictures
   never go below 208px wide (a 320 by 568 phone's size at the usual text): smaller, a difference is
   too small to see, and the page scrolls to the buttons instead. */
.sd-figure { margin: 0; width: min(100%, max(208px, calc((100svh - 16rem) * 2 / 3))); }
.sd-figure figcaption { margin-top: 0.25rem; font-size: 0.9375rem; color: var(--stone); }

.sd-frame {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden; margin: 0;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--sheet);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  cursor: crosshair;
}
.sd-frame.zoomed { touch-action: none; cursor: grab; }
.sd-frame:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sd-view { position: absolute; inset: 0; transform-origin: 0 0; }
.sd-view img, .sd-frame > img { display: block; width: 100%; height: 100%; }
.sd-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

.sd-halo { fill: none; stroke: #fff; stroke-width: 14; }
.sd-ring { fill: none; stroke: var(--c); stroke-width: 7; }
.sd-miss line { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; }
.sd-hint { fill: var(--c); opacity: 0.2; }
.sd-cross { display: none; }
.sd-frame:focus-visible .sd-cross { display: inline; }
.sd-cross line, .sd-cross circle { fill: none; stroke: var(--ink); stroke-width: 4; }

/* With large text the pictures and the buttons cannot share one screen: the buttons stay at its foot. */
.sd-controls { display: flex; justify-content: center; gap: 0.5rem; position: sticky; bottom: 0; z-index: 1; background: var(--paper); }
.sd-zoom {
  min-width: 44px; min-height: 44px; padding: 0 0.75rem; font: inherit; font-weight: 600;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--sheet); color: var(--ink); cursor: pointer;
}
.sd-zoom:disabled { color: var(--stone); cursor: default; }
.sd-zoom:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* From 1024px the pictures sit side by side in a wider column than the other games'. The column
   is keyed on the page as served (its main's data-game), not on the board the script draws, so
   that it is wide from the first paint: one that widened when the pictures arrived moved the whole
   page. No #main here: an id would outweigh game.css's rules for an ad in the rail, and the bar
   would run across the rail, its buttons 50px from the ad. */
@media (min-width: 1024px) {
  .wrap.game:has([data-game="spot-the-difference"]) { max-width: 56rem; }
  .wrap.game:has([data-game="spot-the-difference"]):has(.rail .ad:not([hidden])) { max-width: calc(59rem + 300px); }
  .wrap.game:has([data-game="spot-the-difference"]):has(.rail .ad:not([hidden])) .game-layout { grid-template-columns: minmax(0, 56rem) 300px; }
  .wrap.game:has([data-game="spot-the-difference"]) > .gbar { max-width: none; }
  .sd-pictures { grid-template-columns: 1fr 1fr; }
  .sd-figure { width: 100%; }
}

/* The answers page: both pictures, the seven places circled and numbered. */
.sd-answer { display: grid; gap: 1rem; }
.sd-answer .sd-frame { cursor: default; touch-action: auto; }
.sd-answer .sd-marks ellipse { fill: none; stroke: var(--c, #9A4A55); stroke-width: 6; }
.sd-answer .sd-marks text { font: 600 48px system-ui, sans-serif; fill: var(--c, #9A4A55); stroke: #fff; stroke-width: 8; paint-order: stroke; }

/* The pictures' frame is sized by the screen, not by the day's puzzle: while the board loads, what
   follows it waits, only where scripts run (game.css keeps no room for a board of changing size). */
@media (scripting: enabled) {
  #main:has(> #board > .loading) > #board ~ *,
  .wrap:has(#board > .loading) > .foot {
    display: none;
  }
}
