/* ============================================================
   Sliding Puzzle — sliding-puzzle.css  v1.1
   Wayne Intelligence / hudsoncw.com
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* Page wrapper — isolates from theme */
#sliding-puzzle-page {
  box-sizing: border-box;
}

#sliding-puzzle-page *,
#sliding-puzzle-page *::before,
#sliding-puzzle-page *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.puzzle-desktop {
  background: #008080;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px 40px;
  font-family: 'MS Sans Serif', Tahoma, Geneva, Arial, sans-serif;
  font-size: 11px;
}

/* ── Desktop label ──────────────────────────────────────── */

.desktop-label {
  font-family: 'VT323', monospace;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 14px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  opacity: 0.7;
  user-select: none;
}

/* ── Window chrome ──────────────────────────────────────── */

.window {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: 3px 3px 0 #000000;
  width: 440px;
  max-width: 100%;
  user-select: none;
}

.title-bar {
  background: linear-gradient(90deg, #000080 0%, #1084d0 100%);
  color: #ffffff;
  padding: 2px 3px 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 11px;
  cursor: default;
  gap: 4px;
  min-height: 22px;
}

.title-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 14px;
}

.title-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.title-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.title-controls button {
  width: 16px;
  height: 14px;
  background: #c0c0c0;
  border: 1.5px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  color: #000;
  font-size: 8px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-controls button:active {
  border-color: #404040 #ffffff #ffffff #404040;
}

/* ── Menu bar ───────────────────────────────────────────── */

.menu-bar {
  background: #c0c0c0;
  border-bottom: 1px solid #808080;
  padding: 1px 4px;
  display: flex;
  gap: 0;
}

.menu-btn {
  background: none;
  border: 1px solid transparent;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  color: #000;
}

.menu-btn:hover { background: #000080; color: #fff; }
.menu-btn:active { background: #000060; color: #fff; }

/* ── Window body ────────────────────────────────────────── */

.window-body {
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Artwork label ──────────────────────────────────────── */

.artwork-label {
  height: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: 0 2px;
}

#artworkTitle {
  font-weight: bold;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #000;
}

#artworkArtist {
  font-size: 10px;
  color: #555555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Toggle rows (shared: source + grid size) ───────────── */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
}

.toggle-label {
  font-size: 10px;
  color: #444;
  width: 42px;
  flex-shrink: 0;
}

/* Source buttons */
.src-btn {
  background: #c0c0c0;
  border: 1.5px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 1px 8px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  color: #000;
  flex: 1;
  text-align: center;
}

.src-btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #a8a8a8;
  font-weight: bold;
}

.src-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

/* Grid size buttons */
.size-btn {
  background: #c0c0c0;
  border: 1.5px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 1px 10px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  color: #000;
}

.size-btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #a8a8a8;
  font-weight: bold;
}

.size-btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
}

/* ── Puzzle area ────────────────────────────────────────── */

.puzzle-wrapper {
  position: relative;
  width: 400px;
  height: 400px;
  margin: 0 auto;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  overflow: hidden;
  background: #404040;
}

.puzzle-grid {
  display: grid;
  width: 400px;
  height: 400px;
}

.tile {
  cursor: pointer;
  background-repeat: no-repeat;
  position: relative;
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(0,0,0,0.15);
  pointer-events: none;
}

.tile:not(.blank):hover::after  { background: rgba(255,255,255,0.12); }
.tile:not(.blank):active::after { background: rgba(0,0,0,0.1); }

.tile.blank {
  background: #606060 !important;
  cursor: default;
}
.tile.blank::after { display: none; }

/* ── Loading state ──────────────────────────────────────── */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 12px;
  color: #a0a0a0;
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 1px;
}

.loading-dot {
  display: inline-block;
  animation: sp-blink 1s step-start infinite;
}

@keyframes sp-blink { 50% { opacity: 0; } }

/* ── Peek overlay ───────────────────────────────────────── */

.peek-overlay {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 9;
  pointer-events: none;
}
.peek-overlay.visible { display: block; }

/* ── Win overlay ────────────────────────────────────────── */

.win-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 100, 0.90);
  color: #fff;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 10;
  text-align: center;
}
.win-overlay.visible { display: flex; }

.win-title {
  font-family: 'VT323', monospace;
  font-size: 28px;
  letter-spacing: 2px;
  color: #ffff80;
}

.win-sub { font-size: 11px; color: #c0c0ff; }

.win-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border: 2px solid #8080ff;
}

/* ── Controls ───────────────────────────────────────────── */

.controls-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.btn {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  padding: 3px 16px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  color: #000;
  min-width: 80px;
  text-align: center;
}
.btn:active {
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 4px 15px 2px 17px;
}
.btn:disabled { color: #808080; cursor: default; }
.btn.primary  { font-weight: bold; }

/* ── Status bar ─────────────────────────────────────────── */

.status-bar {
  display: flex;
  gap: 4px;
  border-top: 1px solid #808080;
  padding-top: 4px;
  margin-top: 1px;
}

.status-panel {
  border: 1px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  padding: 1px 6px;
  font-size: 10px;
  color: #333;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-panel.wide { flex: 2; text-align: left; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 460px) {
  .window { width: 100%; }
  .puzzle-wrapper,
  .puzzle-grid { width: 320px; height: 320px; }
}