/* ===========================================
   COMIX CLUB - Main Stylesheet
   Fun & Colorful Comic Book Theme
   Blue & Purple Primary Color Scheme
   =========================================== */

/* --- 1. CSS Variables & Custom Properties --- */
:root {
  /* Primary Colors */
  --primary-blue: #4A90D9;
  --primary-purple: #8B5CF6;

  /* Secondary/Accent Colors */
  --accent-pink: #EC4899;
  --accent-yellow: #FBBF24;
  --accent-cyan: #22D3EE;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #4A90D9 0%, #8B5CF6 100%);
  --gradient-button: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  --gradient-fun: linear-gradient(135deg, #22D3EE 0%, #8B5CF6 50%, #EC4899 100%);

  /* Neutrals */
  --bg-light: #F8FAFF;
  --bg-card: #FFFFFF;
  --text-dark: #1E293B;
  --text-medium: #64748B;
  --text-light: #FFFFFF;

  /* Borders & Shadows */
  --border-color: #E2E8F0;
  --shadow-sm: 0 2px 4px rgba(74, 144, 217, 0.1);
  --shadow-md: 0 4px 12px rgba(139, 92, 246, 0.15);
  --shadow-lg: 0 8px 24px rgba(139, 92, 246, 0.2);
  --shadow-comic: 4px 4px 0px #1E293B;

  /* Spacing Scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-display: 'Bangers', 'Comic Sans MS', cursive;
  --font-body: 'Nunito', 'Arial Rounded MT Bold', Arial, sans-serif;
}

/* --- 2. Reset & Base Styles --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: 0.2px;
  color: var(--text-dark);
  background-color: var(--bg-light);
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--primary-blue);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- 3. Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: 2px;
  margin: 0 0 var(--space-md) 0;
}

h1 {
  font-size: 3rem;
  color: var(--primary-purple);
  text-shadow: 3px 3px 0px var(--primary-blue);
  text-transform: uppercase;
  letter-spacing: 3px;
}

h2 {
  font-size: 1.75rem;
  color: var(--primary-blue);
  letter-spacing: 2px;
}

h3 {
  font-size: 1.25rem;
  color: var(--primary-purple);
  letter-spacing: 1.5px;
}

p {
  margin: 0 0 var(--space-md) 0;
  letter-spacing: 0.3px;
  line-height: 1.7;
}

/* --- 4. Layout Components --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.page-wrapper {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

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

/* --- 5. Navigation --- */
.comix-header {
  background: var(--gradient-primary);
  padding: var(--space-md) var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 0 var(--text-dark);
}

.comix-nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--text-light);
  text-shadow: 2px 2px 0px var(--accent-pink);
  letter-spacing: 3px;
}

.logo-icon {
  font-size: 1.5rem;
  color: var(--accent-yellow);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2) rotate(10deg); }
}

.nav-links {
  display: flex;
  gap: var(--space-sm);
}

.nav-link {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text-light);
  text-decoration: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--accent-yellow);
  transform: translateY(-2px);
  color: var(--text-light);
}

.nav-link.active {
  background: var(--accent-yellow);
  color: var(--text-dark);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 2px solid var(--text-light);
  color: var(--text-light);
  font-size: 1.5rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- 6. Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-comic);
  position: relative;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--text-dark);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--text-dark);
}

.btn-primary {
  background: var(--gradient-button);
  color: var(--text-light);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--primary-purple);
}

.btn-accent {
  background: var(--accent-yellow);
  color: var(--text-dark);
}

.btn-blue {
  background: var(--primary-blue);
  color: var(--text-light);
}

.btn-danger {
  background: #EF4444;
  color: var(--text-light);
}

.btn-green {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: var(--text-light);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  box-shadow: 3px 3px 0px var(--text-dark);
}

.btn-sm:hover {
  box-shadow: 5px 5px 0px var(--text-dark);
}

/* --- 7. Cards --- */
.card {
  background: var(--bg-card);
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-comic);
  transition: all 0.2s ease;
}

.card:hover {
  transform: translate(-4px, -4px);
  box-shadow: 8px 8px 0px var(--text-dark);
}

.card-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
}

.card-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  margin-top: var(--space-sm);
  color: var(--text-dark);
  text-align: center;
}

/* --- 8. Forms --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: var(--text-dark);
}

.form-input {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-body);
  font-size: 1rem;
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

.form-select {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 1rem;
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary-purple);
}

/* --- 9. Page-Specific Styles --- */

/* Home Page */
.home-hero {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  background: var(--bg-card);
  border: 4px solid var(--text-dark);
  border-radius: var(--radius-xl);
  box-shadow: 8px 8px 0px var(--text-dark);
  margin: var(--space-xl) auto;
  max-width: 800px;
}

.home-hero h1 {
  margin-bottom: var(--space-sm);
}

.home-hero h2 {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-medium);
  font-size: 1.25rem;
  margin-bottom: var(--space-lg);
}

.home-hero p {
  font-size: 1.1rem;
  color: var(--text-medium);
  margin-bottom: var(--space-xl);
}

.home-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-md);
}

/* Comics Page */
.comics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
}

.comic-item {
  background: var(--bg-card);
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-comic);
  transition: all 0.2s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
}

.comic-item:hover {
  transform: translate(-4px, -4px) rotate(-1deg);
  box-shadow: 8px 8px 0px var(--text-dark);
}

.comic-cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3; /* Standard comic book ratio */
  overflow: hidden;
  border-bottom: 3px solid var(--text-dark);
}

.comic-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.comic-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 4rem;
  color: var(--text-light);
  background: var(--gradient-fun);
}

.comic-item .card-title {
  padding: var(--space-md);
  margin: 0;
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
  font-size: 0.9rem;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

/* Art Page */
.canvas-container {
  background: var(--bg-card);
  border: 4px solid var(--text-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: 8px 8px 0px var(--text-dark);
  margin-bottom: var(--space-xl);
}

.canvas-wrapper {
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: inline-block;
}

#drawingCanvas {
  display: block;
  background: white;
  cursor: crosshair;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
}

.controls label {
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.controls input[type="color"] {
  width: 40px;
  height: 40px;
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.controls input[type="range"] {
  width: 100px;
  cursor: pointer;
}

.saved-projects {
  margin-top: var(--space-xl);
}

.saved-projects h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}

.project-card {
  background: var(--bg-card);
  border: 3px solid var(--text-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-comic);
  transition: all 0.2s ease;
}

.project-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--text-dark);
}

.project-card img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  margin-bottom: var(--space-sm);
}

.project-card .project-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

/* Projects Page */
.projects-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
}

/* Chat Page */
.chat-container {
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 4px solid var(--text-dark);
  border-radius: var(--radius-xl);
  box-shadow: 8px 8px 0px var(--text-dark);
  overflow: hidden;
}

.chat-header {
  background: var(--gradient-primary);
  padding: var(--space-lg);
  text-align: center;
}

.chat-header h2 {
  color: var(--text-light);
  margin: 0;
  font-family: var(--font-display);
  text-shadow: 2px 2px 0px var(--accent-pink);
}

.chat-window {
  height: 400px;
  overflow-y: auto;
  padding: var(--space-lg);
  background: linear-gradient(180deg, #F8FAFF 0%, #FFFFFF 100%);
}

.message {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-purple);
  position: relative;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.message-content {
  flex: 1;
}

.message-author {
  font-weight: 800;
  color: var(--primary-blue);
  margin-right: var(--space-xs);
}

.message-text {
  color: var(--text-dark);
}

.message-delete {
  background: none;
  border: none;
  color: var(--text-medium);
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  line-height: 1;
}

.message-delete:hover {
  background: #FEE2E2;
  color: #EF4444;
}

.chat-form {
  padding: var(--space-lg);
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
  border-top: 3px solid var(--text-dark);
}

.chat-form-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.chat-form-row:last-child {
  margin-bottom: 0;
}

.chat-form .form-input {
  flex: 1;
}

.chat-form .btn {
  white-space: nowrap;
}

/* --- 10. Utility Classes --- */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.hidden { display: none !important; }

/* --- 11. Responsive Styles --- */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--gradient-primary);
    padding: var(--space-md);
    gap: var(--space-xs);
    box-shadow: 0 4px 0 var(--text-dark);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-link {
    text-align: center;
    padding: var(--space-md);
  }

  h1 {
    font-size: 2rem;
  }

  .home-hero {
    padding: var(--space-xl) var(--space-md);
    margin: var(--space-md);
  }

  .home-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .comics-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--space-md);
  }

  .canvas-container {
    padding: var(--space-md);
  }

  #drawingCanvas {
    width: 100%;
    height: auto;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls label {
    justify-content: space-between;
  }

  .chat-form-row {
    flex-direction: column;
  }

  .projects-grid,
  .projects-page-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .comics-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* --- 12. Print Styles --- */
@media print {
  .comix-header,
  .mobile-menu-btn,
  .btn {
    display: none;
  }

  body {
    background: white;
    background-image: none;
  }
}
