/* You Can't Fix Me: the jigsaw puzzle on /games/jigsaw/ (jigsaw.js, tools/jigsaw_page.py).
   A Win98 game window: menu bar, a Solitaire-green table with the frame in the middle, the covers below. */
.jz { --felt: #008000; }
.jz .titlebar-btns button, .jz .titlebar-btns a {
  font: 700 11px/1 var(--f-ui); color: #000; text-shadow: none; text-decoration: none; cursor: pointer;
  width: 18px; height: 16px; display: grid; place-items: center; padding: 0; border: 0; background: var(--silver); box-shadow: var(--bevel-out);
}
.jz .titlebar-btns a { margin-left: 2px; }
.jz .titlebar-btns button:active, .jz .titlebar-btns a:active { box-shadow: var(--bevel-in); }

/* menu bar */
.jz-menubar { position: relative; z-index: 6; display: flex; padding: 2px 0 1px; font: 12px/1 var(--f-ui); }
.jz-menu { position: relative; }
.jz-top { padding: 4px 8px; border: 0; background: none; font: inherit; color: #000; cursor: default; }
.jz-top:hover { box-shadow: inset -1px -1px #808080, inset 1px 1px #fff; }
.jz-top[aria-expanded="true"] { box-shadow: inset 1px 1px #808080, inset -1px -1px #fff; }
.jz-top:focus-visible { outline: 1px dotted #000; outline-offset: -3px; }
.jz-drop {
  position: absolute; left: 0; top: 100%; min-width: 200px; padding: 2px; background: var(--silver);
  box-shadow: var(--bevel-out), 2px 2px 0 rgba(0,0,0,.35);
}
.jz-drop[hidden] { display: none; }
.jz-drop > button, .jz-drop > a {
  display: flex; justify-content: space-between; gap: 24px; width: 100%; padding: 5px 18px 5px 22px; position: relative;
  border: 0; background: none; font: 12px/1.2 var(--f-ui); color: #000; text-align: left; text-decoration: none; white-space: nowrap; cursor: default;
}
.jz-drop > :is(button, a):is(:hover, :focus) { background: #000080; color: #fff; outline: 0; }
.jz-drop > [aria-checked="true"]::before { content: "\2713"; position: absolute; left: 7px; font-weight: 700; }
.jz-drop > [role="menuitemradio"][aria-checked="true"]::before { content: ""; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px; background: currentColor; border-radius: 50%; }
.jz-drop > [aria-disabled="true"] { color: #808080; text-shadow: 1px 1px #fff; }
.jz-drop > [aria-disabled="true"]:is(:hover, :focus) { background: #000080; color: #808080; text-shadow: none; }
.jz-drop kbd { font: inherit; }
.jz-drop hr { margin: 3px 1px; border: 0; border-top: 1px solid #808080; border-bottom: 1px solid #fff; }

/* the table: pieces live in .jz-layer, the frame sits under them, the finished cover over them */
.jz-table {
  position: relative; overflow: hidden; height: 560px; margin-top: 2px; background: var(--felt);
  box-shadow: var(--bevel-in); touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.jz-frame, .jz-done { position: absolute; left: 0; top: 0; }
.jz-frame { background: rgba(0,0,0,.2); box-shadow: inset 1px 1px rgba(0,0,0,.55), inset -1px -1px rgba(255,255,255,.35), 0 0 0 1px rgba(255,255,255,.18); }
.jz-ghost { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .3; }
.jz-ghost:not([src]), .jz.no-ghost .jz-ghost { display: none; }
.jz-layer { position: absolute; inset: 0; z-index: 1; isolation: isolate; }
.jz-piece { position: absolute; left: 0; top: 0; pointer-events: none; }
.jz-piece.is-lifted { filter: drop-shadow(4px 6px 3px rgba(0,0,0,.45)); }
.jz-piece.is-flying { transition: transform .65s cubic-bezier(.25, .8, .3, 1); }
.jz-piece.is-out { opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s; }
.jz-piece.snap { animation: jz-snap .26s steps(2); }
@keyframes jz-snap { 50% { filter: brightness(1.4); } }
.jz-done { z-index: 2; opacity: 0; transition: opacity .35s; }
.jz-done.is-on { opacity: 1; }
.jz-cascade { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; }
.jz-help {
  position: absolute; left: 10px; bottom: 8px; z-index: 0; margin: 0; max-width: calc(100% - 20px); pointer-events: none;
  font: 12px/1.3 var(--f-ui); color: #d8f5d0; text-shadow: 1px 1px 0 rgba(0,0,0,.5); transition: opacity .3s;
}
.jz-help.is-gone { opacity: 0; }
.jz-nojs { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font: 700 14px var(--f-ui); color: #fff; }

/* message boxes over the table */
.jz-dlg {
  position: absolute; z-index: 4; left: 50%; top: 50%; translate: -50% -50%; width: min(380px, calc(100% - 24px));
  background: var(--silver); padding: 3px; box-shadow: var(--bevel-out), 6px 8px 18px rgba(0,0,0,.55); animation: hackwin-in .18s steps(3);
}
.jz-dlg .titlebar { height: 22px; font-size: 12px; }
.jz-dlg-body { display: flex; gap: 14px; align-items: flex-start; padding: 14px 12px 6px; font: 12px/1.5 var(--f-ui); color: #000; }
.jz-dlg-body img { flex: none; width: 64px; height: 64px; box-shadow: 0 0 0 1px #000, 2px 2px 0 rgba(0,0,0,.35); }
.jz-dlg-body p { margin: 0 0 6px; }
.jz-dlg-body strong { font-weight: 700; }
.jz-dlg-btns { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px 10px; }

/* the covers: pick one; fixed ones get their color and a check */
.jz-shelf { margin-top: 3px; padding: 4px 4px 6px; }
.jz-shelf-label { margin: 0 0 5px 2px; font: 12px/1.2 var(--f-ui); color: #000; }
.jz-covers {
  display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 6px; list-style: none;
  background: #fff; box-shadow: var(--bevel-in);
}
.jz-cover { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.jz-cover img { width: 100%; height: auto; aspect-ratio: 1; opacity: .45; filter: saturate(.3); box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.jz-cover:hover img, .jz-cover:focus-visible img { opacity: .9; filter: none; }
.jz-cover.is-fixed img, .jz-cover[aria-pressed="true"] img { opacity: 1; filter: none; }
.jz-cover[aria-pressed="true"] { outline: 2px solid #000080; outline-offset: 2px; }
.jz-cover:focus-visible { outline: 1px dotted #000; outline-offset: 3px; }
.jz-cover.is-fixed::after {
  content: "\2713"; position: absolute; right: -3px; bottom: -3px; width: 15px; height: 15px; display: grid; place-items: center;
  font: 700 11px/1 var(--f-ui); color: #fff; background: #008000; box-shadow: 0 0 0 1px #fff, 0 0 0 2px #000;
}
.jz-status span:first-child { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.jz-status span:nth-child(2) { min-width: 9em; }
.jz-status span:last-child { min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }

/* maximized: fills the screen above the taskbar, like a real window */
.jz.is-max { position: fixed; z-index: 29; inset: 0 0 var(--taskbar-h) 0; display: flex; flex-direction: column; margin: 0; }
.jz.is-max .jz-table { flex: 1; height: auto !important; }
html.jz-maxed { overflow: hidden; }

@media (max-width: 640px) {
  .jz-covers { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; padding: 5px; }
  .jz-help { display: none; } /* the pile covers it; Help > How to play says it */
  .jz-status span:nth-child(2) { min-width: 0; }
  .jz-drop { min-width: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  .jz-piece.is-flying { transition: none; }
  .jz-piece.snap { animation: none; }
  .jz-done { transition: none; }
}
