/**
 * styles.css - Bead Pattern Builder Styling
 * 
 * Responsive design for image-to-pattern conversion tool.
 * Features: modular control cards, responsive grid, canvas preview,
 * custom range sliders, accessible form controls, and landing page sections.
 * 
 * Layout:
 * - Navigation bar
 * - Hero section with CTA
 * - Showcase gallery
 * - How it works steps
 * - App interface (controls, preview, legend)
 * - Resources and FAQ
 * - Footer
 */

/* ========================================================================
   Root CSS Variables & Global Styles
   ======================================================================== */

:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background-color: #f7f7fb;
  color: #1e1e2f;
  --primary: #4CAF50;
  --primary-dark: #45a049;
  --secondary: #FF6B6B;
  --accent: #4ECDC4;
  --light-bg: #f7f7fb;
  --card-bg: #ffffff;
  --border-color: #d6d6e7;
  --text-dark: #1e1e2f;
  --text-light: #5a5a74;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--light-bg);
}

html {
  scroll-behavior: smooth;
}

/* ========================================================================
   Navigation Bar
   ======================================================================== */

.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.navbar-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
}

.navbar-links {
  display: flex;
  gap: 24px;
}

.navbar-links a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.3s ease;
}

.navbar-links a:hover {
  color: var(--primary);
}

/* ========================================================================
   Hero Section
   ======================================================================== */

.hero-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  margin-bottom: 60px;
}

.hero-content h1 {
  font-size: 3rem;
  font-weight: 800;
  margin: 0 0 16px;
  color: var(--text-dark);
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-light);
  margin: 0 0 32px;
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.btn-primary {
  padding: 14px 32px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
  padding: 14px 32px;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: var(--primary);
  color: white;
}

.hero-features {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.feature-badge {
  padding: 8px 16px;
  background: rgba(76, 175, 80, 0.1);
  color: var(--primary);
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
}

.hero-image {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-preview {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(76, 175, 80, 0.2);
}

.preview-grid {
  font-size: 3rem;
}

/* ========================================================================
   Showcase Gallery
   ======================================================================== */

.showcase {
  margin-bottom: 60px;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-header h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-dark);
}

.section-header p {
  font-size: 1.1rem;
  color: var(--text-light);
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
}

.gallery-item {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.gallery-placeholder {
  font-size: 3rem;
  margin-bottom: 12px;
}

.gallery-item p {
  margin: 0;
  font-weight: 600;
  color: var(--text-dark);
}

/* ========================================================================
   How It Works Section
   ======================================================================== */

.how-it-works {
  margin-bottom: 60px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
}

.step {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.step-number {
  display: inline-block;
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.step h3 {
  font-size: 1.3rem;
  margin: 16px 0 12px;
  color: var(--text-dark);
}

.step p {
  color: var(--text-light);
  line-height: 1.6;
  margin: 0;
}

/* ========================================================================
   App Section
   ======================================================================== */

.app-section {
  margin-bottom: 60px;
}

/* ========================================================================
   Resources Section
   ======================================================================== */

.resources {
  margin-bottom: 60px;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.resource-card {
  background: var(--card-bg);
  padding: 28px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.resource-card h3 {
  font-size: 1.2rem;
  margin: 0 0 12px;
  color: var(--text-dark);
}

.resource-card p {
  color: var(--text-light);
  margin: 0 0 16px;
  font-size: 0.95rem;
}

.resource-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.resource-card li {
  margin-bottom: 10px;
}

.resource-card a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.resource-card a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.affiliate-link::after {
  content: " ↗";
  font-size: 0.8rem;
}

/* ========================================================================
   FAQ Section
   ======================================================================== */

.faq-section {
  margin-bottom: 60px;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.faq-item {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.faq-item h4 {
  margin: 0 0 12px;
  color: var(--text-dark);
  font-size: 1.05rem;
}

.faq-item p {
  margin: 0;
  color: var(--text-light);
  line-height: 1.6;
  font-size: 0.95rem;
}

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

.footer {
  background: var(--text-dark);
  color: white;
  padding: 48px 20px 32px;
  margin-top: 80px;
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  margin-bottom: 32px;
}

.footer-section h4 {
  font-size: 1.05rem;
  margin: 0 0 16px;
  color: white;
}

.footer-section p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  font-size: 0.95rem;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section li {
  margin-bottom: 10px;
}

.footer-section a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-section a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.footer-bottom p {
  margin: 8px 0;
}

/* ========================================================================
   Page Layout
   ======================================================================== */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Hero Header */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e2e2f2;
  color: #3f3f5f;
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
  box-shadow: 0 6px 16px rgba(30, 30, 47, 0.08);
}

.hero h1 {
  margin: 16px 0 12px;
  font-size: 2.6rem;
}

.hero p {
  margin: 0;
  max-width: 600px;
  color: #4a4a68;
  line-height: 1.5;
}

/* ========================================================================
   Control Panels (Upload, Palette, Grid)
   ======================================================================== */

.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Card layout for grouped controls */
.control-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #d6d6e7;
  box-shadow: 0 8px 20px rgba(30, 30, 47, 0.08);
}

.control-card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.control-card p {
  margin: 0;
  color: #4a4a68;
}

.control-card .hint {
  font-size: 0.85rem;
  color: #5a5a74;
  margin: 8px 0 0;
  font-style: italic;
}

/* Action buttons and controls grouping */
.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* Form elements (labels, inputs, selects) */
.form-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group.checkbox {
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Select dropdown styling */
.form-group select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #d6d6e7;
  background: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
}

/* Checkbox input styling */
.form-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1e1e2f;
}

/* ========================================================================
   Custom Range Slider (Grid Size)
   ======================================================================== */

input[type="range"] {
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #d6d6e7;
  border-radius: 3px;
  outline: none;
}

/* Webkit (Chrome, Safari, Edge) slider thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1e1e2f;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(30, 30, 47, 0.2);
}

/* Firefox slider thumb */
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1e1e2f;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(30, 30, 47, 0.2);
}

/* ========================================================================
   Buttons & Upload Control
   ======================================================================== */

.upload {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #f7f7fb;
  border: 1px solid #d6d6e7;
  font-weight: 600;
  cursor: pointer;
}

.upload input {
  display: none;
}

button {
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  background: #1e1e2f;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

/* Secondary button style for crop tool actions */
.button-secondary {
  background: #e0e0f0 !important;
  color: #1e1e2f !important;
  padding: 8px 14px !important;
  font-size: 0.9rem !important;
  flex: 1;
}

.button-secondary:not(:disabled):hover {
  background: #d0d0e0 !important;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(200px, 1fr);
  gap: 24px;
  align-items: start;
}

.canvas-wrapper {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #e0e0f0;
  box-shadow: 0 12px 30px rgba(30, 30, 47, 0.08);
}

.canvas-wrapper h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.helper-text {
  margin: -8px 0 16px;
  color: #5a5a74;
  font-size: 0.95rem;
}

.canvas-container {
  position: relative;
  display: inline-block;
  max-width: 540px;
  width: 100%;
}

#patternCanvas {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f7;
  border-radius: 12px;
  display: block;
}

/* Grid labels styling */
#patternCanvas.with-labels {
  margin: 0;
  padding: 0;
}

.legend {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #e0e0f0;
}

.legend h2 {
  margin-top: 0;
}

.legend h3 {
  margin: 20px 0 12px;
  font-size: 1rem;
  border-top: 1px solid #e0e0f0;
  padding-top: 16px;
}

.legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: #3f3f54;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.summary-section {
  margin-top: 0;
}

.bead-summary {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
}

.bead-summary li {
  display: flex;
  justify-content: space-between;
  color: #4a4a68;
}

.total-beads {
  margin: 12px 0 0;
  padding: 12px;
  background: #f7f7fb;
  border-radius: 8px;
  font-weight: 600;
  color: #1e1e2f;
  text-align: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.steps article {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px;
  border: 1px solid #e0e0f0;
  box-shadow: 0 10px 22px rgba(30, 30, 47, 0.06);
}

.steps h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.steps p {
  margin: 0;
  color: #4a4a68;
}

.tips {
  background: #fff8e1;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #f2e2a0;
}

.tips h2 {
  margin-top: 0;
}


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

@media (max-width: 1024px) {
  .hero-section {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-content h1 {
    font-size: 2.2rem;
  }

  .hero-image {
    order: -1;
  }
}

@media (max-width: 840px) {
  .navbar-links {
    display: none;
  }

  .hero-section {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hero-content h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .hero-cta {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    text-align: center;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .control-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .hero-content h1 {
    font-size: 1.6rem;
  }

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

  .hero-features {
    flex-direction: column;
  }

  .feature-badge {
    width: 100%;
  }

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

  .gallery-item {
    padding: 16px;
  }

  .section-header h2 {
    font-size: 1.6rem;
  }

  .footer-content {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 0 16px;
  }
}

