/* ============================================================
   Puzzle PNG Generator — Main Stylesheet
   Mathematics Marvels | Royal Technologies
   ============================================================ */

/* ---------- CSS Custom Properties (Dark Default) ---------- */
:root {
  --primary:        #6C63FF;
  --primary-hover:  #5B52E0;
  --secondary:      #2EC4B6;
  --secondary-hover:#25A99D;
  --accent:         #EF4444;
  --gold:           #F59E0B;

  --bg:             #0B0F19;
  --surface:        #131B2E;
  --surface2:       #1E293B;
  --surface3:       #293548;
  --text:           #F8FAFC;
  --text-muted:     #94A3B8;
  --border:         #334155;
  --border-focus:   #6C63FF;

  --checker-a:      #161F36;
  --checker-b:      #1B2642;

  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --transition:     0.2s ease;
  --shadow-card:    0 10px 30px rgba(0,0,0,0.35);
}

/* Light Theme Variables */
body[data-theme="light"] {
  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --surface2:       #F1F5F9;
  --surface3:       #E2E8F0;
  --text:           #0F172A;
  --text-muted:     #64748B;
  --border:         #CBD5E1;
  --border-focus:   #6C63FF;

  --checker-a:      #E2E8F0;
  --checker-b:      #F1F5F9;
  --shadow-card:    0 8px 24px rgba(0,0,0,0.08);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: var(--secondary);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover { opacity: 0.8; }

/* ---------- Navbar ---------- */
.navbar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.navbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 26px;
  line-height: 1;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
}

.logo-subtitle {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.theme-toggle-btn:hover {
  border-color: var(--primary);
}

/* ---------- Main Layout (Left Panel Wider: 480px) ---------- */
.main-layout {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1560px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* ---------- Controls Panel ---------- */
.controls-panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: fit-content;
  box-shadow: var(--shadow-card);
}

/* Control Row for side-by-side selects */
.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

/* Select element styling */
.subtype-select {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.subtype-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}

.type-select {
  font-weight: 700;
  border-color: var(--primary);
  background-color: var(--surface2);
  color: var(--text);
}

/* Difficulty Buttons */
.difficulty-btns {
  display: flex;
  gap: 8px;
}

.diff-btn {
  flex: 1;
  padding: 8px 0;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-align: center;
}

.diff-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.diff-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.btn-generate {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #6C63FF 0%, #4F46E5 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(108,99,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108,99,255,0.45);
}

.btn-export {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #0D9488 0%, #0F766E 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(13,148,136,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(13,148,136,0.45);
}

/* Answer & Hint Boxes */
.info-box {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.answer-box {
  border-left: 4px solid #10B981;
}

.hint-box {
  border-left: 4px solid #F59E0B;
}

.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.info-label-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-verified {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid #10B981;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
}

.badge-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border: 1px solid #EF4444;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
}

.btn-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: #64748B;
}

.info-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-mini-toggle {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-mini-toggle:hover {
  background: var(--primary);
  color: #fff;
}

.info-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

/* ---------- Canvas Section (Compact Preview) ---------- */
.canvas-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* Checkerboard wrapper — compact height so user doesn't scroll */
.canvas-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--checker-a);
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-card);
  min-height: 480px;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 2;
}

.placeholder-icon {
  font-size: 44px;
  opacity: 0.4;
}

.placeholder-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* The Canvas preview: strictly scaled down so it fits screen viewport,
   while keeping full 1080x1080 native resolution for export! */
#puzzle-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 500px; /* Compact preview as requested! */
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.3);
  display: none;
  position: relative;
  z-index: 3;
}

#puzzle-canvas.visible {
  display: block;
}

.canvas-meta-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
}

/* ---------- Footer (Only place for royaltechbd.com) ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-sep { opacity: 0.3; }

/* Responsive */
@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  #puzzle-canvas {
    max-height: 400px;
  }
}
