/* Jigsaw Puzzle Styles - Priyanka Portfolio */

:root {
  --bg-gradient: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  --surface-card: rgba(22, 27, 34, 0.85);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --accent-color: #64ffda;
  --accent-glow: rgba(100, 255, 218, 0.25);
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --border-color: rgba(240, 246, 252, 0.12);
  --border-glow: rgba(100, 255, 218, 0.4);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-drop: 0 12px 32px rgba(0, 0, 0, 0.5);
}

body {
  background: #0d1117;
  color: var(--text-main);
  overflow-x: hidden;
}

.full-bleed-wrapper {
  max-width: 100% !important;
  padding: 0 1.5rem !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.jigsaw-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Toolbar Header */
.puzzle-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  z-index: 10;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.puzzle-toolbar.hidden {
  display: none !important;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scenery-name-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-color);
  background: rgba(100, 255, 218, 0.08);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(100, 255, 218, 0.2);
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.zoom-controls {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: background 0.15s ease;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.zoom-level {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
  min-width: 42px;
  text-align: center;
}

/* Puzzle Viewport & Canvas */
.puzzle-viewport {
  position: relative;
  flex: 1;
  min-height: 72vh;
  background: #080b0f;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
  user-select: none;
  touch-action: none;
}

.puzzle-viewport.hidden {
  display: none !important;
}

#puzzle-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#puzzle-canvas:active {
  cursor: grabbing;
}

/* Floating Piece Tray Drawer */
.piece-tray {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 320px;
  max-height: 380px;
  background: rgba(15, 20, 28, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-drop);
  z-index: 15;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.piece-tray.collapsed {
  transform: translateY(calc(100% + 2rem));
  pointer-events: none;
  opacity: 0;
}

.tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tray-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-xs {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.btn-xs:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tray-content {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 0.6rem;
  align-items: center;
  justify-items: center;
  max-height: 300px;
}

.tray-piece-thumb {
  width: 60px;
  height: 60px;
  object-fit: contain;
  cursor: grab;
  transition: transform 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.tray-piece-thumb:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 4px 8px rgba(100, 255, 218, 0.4));
}

/* Setup Overlay Modal */
.setup-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 15, 0.88);
  backdrop-filter: blur(14px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.setup-modal-overlay.hidden {
  display: none !important;
}

.setup-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 780px;
  width: 100%;
  box-shadow: var(--shadow-drop);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.setup-header {
  text-align: center;
}

.setup-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.setup-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.setup-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scenery-filters {
  display: flex;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab.active {
  background: var(--accent-color);
  color: #0d1117;
  font-weight: 700;
}

.scenery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.scenery-card {
  position: relative;
  aspect-ratio: 16/10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #080c14;
}

.scenery-card.hidden {
  display: none !important;
}

.portrait-tag {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: var(--accent-color);
  color: #0d1117;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  z-index: 2;
}

.scenery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scenery-card-title {
  position: absolute;
  bottom: 0;
  inset-x: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: #fff;
  padding: 0.5rem 0.2rem 0.25rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scenery-card:hover {
  transform: translateY(-2px);
  border-color: rgba(100, 255, 218, 0.5);
}

.scenery-card.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 16px var(--accent-glow);
}

.custom-upload-box {
  display: flex;
  justify-content: center;
  margin-top: 0.25rem;
}

.custom-upload-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-color);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-upload-label:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: rgba(100, 255, 218, 0.05);
}

.hidden-file-input {
  display: none;
}

.preview-box {
  position: relative;
  width: 100%;
  height: 260px;
  background: #080c14;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.preview-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-color);
  border: 1px solid var(--border-color);
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.diff-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-pcs {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.diff-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(100, 255, 218, 0.4);
}

.diff-btn.active {
  background: rgba(100, 255, 218, 0.12);
  border-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
}

.diff-btn.active .diff-pcs {
  color: var(--accent-color);
}

.setup-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.btn-primary {
  background: var(--accent-color);
  color: #0a0f1a;
  font-weight: 700;
  padding: 0.8rem 2rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(100, 255, 218, 0.4);
}

/* Victory Overlay Modal */
.victory-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 15, 0.92);
  backdrop-filter: blur(20px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.victory-modal-overlay.hidden {
  display: none !important;
}

.victory-card {
  background: var(--surface-card);
  border: 1px solid var(--accent-color);
  box-shadow: 0 0 40px var(--accent-glow);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  animation: modalPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.victory-emoji {
  font-size: 3.5rem;
}

.victory-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  color: var(--accent-color);
}

.victory-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.victory-stats {
  display: flex;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
}

.victory-stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.v-label {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
}

.v-val {
  font-size: 1.1rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-color);
}

.victory-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  justify-content: center;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .scenery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .difficulty-options {
    grid-template-columns: repeat(2, 1fr);
  }
  .puzzle-toolbar {
    flex-wrap: wrap;
    padding: 0.5rem;
  }
}
