/* Hot Puzzle: jigsaw page (templates/hotpuzzle/jigsaw.html). The puzzle pane is the Image Jigsaw Chrome
   extension's page - its dark toolbar over a canvas that fills the rest of the screen above the bottom tabs. */

/* The page is exactly one screen tall: header, then the game taking whatever height is left */
body.jigsaw-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-bottom: calc(var(--bottom-tabs-height) + env(safe-area-inset-bottom));
}
body.jigsaw-page > header { flex: none; }

#puzzleMain {
  --jig-bg: #1d2127;
  --jig-bar: #262b33;
  --jig-border: #353c47;
  --jig-text: #e6e9ee;
  --jig-muted: #9aa4b2;
  --jig-accent: #5b9dff;

  flex: 1;
  min-height: 0;
  overflow-y: auto;                /* the Help tab scrolls; the puzzle pane fits exactly */
}
#bottomTabsContent { height: 100%; }
#puzzle-pane.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--jig-bg);
  color: var(--jig-text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  animation: none;
}

.jig-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--jig-bar);
  border-bottom: 1px solid var(--jig-border);
  user-select: none;
}
.jig-toolbar label { margin: 0; }

.jig-brand { font-weight: 600; margin-right: 6px; }
.jig-spacer { flex: 1; }
.jig-stat { color: var(--jig-muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }

#puzzle-pane button, #puzzle-pane select, .jig-file {
  font: inherit;
  color: var(--jig-text);
  background: #313844;
  border: 1px solid var(--jig-border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  line-height: 1.4;
}
#puzzle-pane button:hover, #puzzle-pane select:hover, .jig-file:hover { background: #3a4250; }
#puzzle-pane button[aria-pressed="true"] { background: var(--jig-accent); border-color: var(--jig-accent); color: #fff; }
#puzzle-pane select { padding: 4px 6px; margin-left: 4px; }
#puzzle-pane input[type="range"] { width: 110px; margin: 0 0 0 4px; vertical-align: middle; accent-color: var(--jig-accent); cursor: pointer; }

.jig-file input { display: none; }
.jig-hint { color: var(--jig-muted); font-size: 13px; }

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.jig-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--jig-muted);
  font-size: 16px;
  pointer-events: none;
}

#stage.dragover { outline: 3px dashed var(--jig-accent); outline-offset: -12px; }

.jig-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;         /* the solved picture shows through */
}

.jig-overlay[hidden], .jig-message[hidden] { display: none; }

.jig-card {
  background: rgba(38, 43, 51, 0.55);  /* see-through, with just enough tint to read on any picture */
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 24px 32px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  max-width: calc(100% - 32px);
}

/* Phones: keep the toolbar compact so the board gets the space. */
@media (max-width: 600px) {
  .jig-toolbar { gap: 6px; padding: 6px 8px; }
  .jig-brand { display: none; }
  .jig-spacer { display: none; }
  .jig-hint { display: none; }     /* phones have no keyboard paste */
  #puzzle-pane button, #puzzle-pane select, .jig-file { padding: 4px 8px; }
  #puzzle-pane input[type="range"] { width: 70px; }
  .jig-stat { min-width: 0; }
  .jig-card { padding: 20px; }
}

.jig-card h2 { margin: 0 0 8px; font-size: 26px; font-weight: 700; color: var(--jig-text); }
.jig-card p { margin: 0 0 18px; color: var(--jig-muted); }
.jig-card .jig-actions { display: flex; gap: 10px; justify-content: center; }
#puzzle-pane .jig-card button { background: var(--jig-accent); border-color: var(--jig-accent); color: #fff; padding: 8px 20px; }
#puzzle-pane .jig-card button.secondary { background: #313844; border-color: var(--jig-border); }
#puzzle-pane .jig-card button.secondary:hover { background: #3a4250; }
#puzzle-pane .jig-card button[hidden] { display: none; }
