/* ============================================
   MazeGenerator.com — Style global
   ============================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --success: #10b981;
  --danger: #ef4444;
  --border: #2d3748;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ============================================
   Header
   ============================================ */

header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.logo-icon {
  font-size: 1.5rem;
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}

nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

nav a.active {
  color: var(--accent);
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  border: 1px solid var(--border);
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

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

.lang-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ============================================
   Main layout
   ============================================ */

main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* ============================================
   Hero / Intro
   ============================================ */

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 1.25rem;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ============================================
   Generator controls
   ============================================ */

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  transition: background 0.2s;
}

.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.2s;
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.form-group input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.range-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

.form-group select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.form-group select:focus {
  border-color: var(--accent);
}

.form-group select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-group label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ============================================
   Maze canvas
   ============================================ */

.maze-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
  background: var(--bg-primary);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  overflow: hidden;
  margin-bottom: 1rem;
}

.maze-container canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.maze-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.maze-placeholder .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.maze-placeholder p {
  font-size: 1rem;
}

.maze-generating {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.85);
  z-index: 10;
}

.maze-generating .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   Animation: maze construction
   ============================================ */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes buildCell {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

/* ============================================
   Solver — Upload Zone
   ============================================ */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg-primary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.05);
}

.upload-zone .icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.upload-zone .sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ============================================
   Footer
   ============================================ */

footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2.5rem 1rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.footer-col ul {
  list-style: none;
}

.footer-col ul li {
  margin-bottom: 0.35rem;
}

.footer-col ul li a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-col ul li a:hover {
  color: var(--accent);
}

.cross-links {
  grid-column: 1 / -1;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.cross-links a {
  color: var(--accent);
  margin: 0 0.3rem;
}

.cross-links a:hover {
  color: var(--accent-hover);
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-bottom a {
  color: var(--text-secondary);
}

/* ============================================
   Legal pages
   ============================================ */

.legal-content {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.8;
}

.legal-content h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 1rem;
}

.legal-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.legal-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.legal-content p,
.legal-content li {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.legal-content ul,
.legal-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.legal-content li {
  margin-bottom: 0.35rem;
}

.legal-content address {
  font-style: normal;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
}

.legal-content .last-updated {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ============================================
   Ad placeholder
   ============================================ */

.ad-placeholder {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 1.5rem 0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .menu-toggle {
    display: block;
  }

  nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
  }

  nav.open {
    display: flex;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .legal-content h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }
}

/* ============================================
   Print styles
   ============================================ */

@media print {
  header, footer, .ad-placeholder, .btn-group, .lang-switcher, nav {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .card {
    background: white;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .maze-container {
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  canvas {
    max-width: 100%;
  }
}
