/* --------------------------------------------------------------------------
   GENERATIVE AUTOMATA STYLES (Dark Floating Card Aesthetic)
   -------------------------------------------------------------------------- */

.generative-card {
  background: #141414;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 1px rgba(255,255,255,0.05);
  padding: 2rem;
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  overflow: hidden; /* Contains the scribbles */
  border: 1px solid rgba(255,255,255,0.05);
  margin: 0 auto;
}

.scribble-outline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}


.card-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 110;
  gap: 0.5rem;
}

.card-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 2.2rem;
  color: #ff7eb3;
  margin: 0;
  transform: rotate(-3deg);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.card-desc {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: #a1a1aa;
  text-align: center;
  max-width: 85%;
  margin: 0;
}

.power-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.start-btn {
  background-color: rgba(255, 126, 179, 0.1);
  color: #ff7eb3;
  border: 2px solid #ff7eb3;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  padding: 1.5rem 3rem;
  font-size: 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s;
  animation: pulse 2s infinite;
  text-transform: uppercase;
}
@keyframes pulse {
  0% { box-shadow: 0 0 15px 5px rgba(255, 126, 179, 0.3); }
  50% { box-shadow: 0 0 35px 15px rgba(255, 126, 179, 0.6); }
  100% { box-shadow: 0 0 15px 5px rgba(255, 126, 179, 0.3); }
}
.start-btn:hover {
  transform: scale(1.05);
}

.power-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #ef4444; /* red when off */
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  transition: all 0.3s ease;
}
.power-light.is-on {
  background-color: #10b981; /* green when on */
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.8);
}

.grid-container {
  width: 100%;
  /* Enforce 2:1 aspect ratio to ensure cells are perfect squares (32 cols, 16 rows) */
  aspect-ratio: 2 / 1;
  background: #000000;
  border: 1px solid #1e293b;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.8);
  margin-bottom: 1.5rem;
  z-index: 10;
}

.card-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(5, 5, 16, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease;
}
.card-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.overlay { /* old overlay */
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.5s ease;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.overlay p {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}

canvas#grid-canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
}

.card-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.03);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.05);
}

.icon-btn {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.icon-btn:hover {
  background: #334155;
  color: #ff7eb3;
  border-color: #ff7eb3;
  transform: translateY(-2px);
}
.icon-btn i.fa-play {
  color: #10b981;
}
.icon-btn i.fa-trash-can {
  color: #ef4444;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-left: 0.5rem;
  color: #cbd5e1;
}

.fx-controls {
  display: flex;
  gap: 1.5rem;
  background: rgba(255,255,255,0.03);
  padding: 0.5rem 1.5rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
}

.fx-knob-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.fx-icon {
  color: #ff7eb3;
  font-size: 1.2rem;
}

/* Groovebox Style Toggles */
.style-toggles {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  margin-top: 2rem;
}

/* --------------------------------------------------------------------------
   WHEEL SELECTORS & DRUM PADS
   -------------------------------------------------------------------------- */
.wheel-selector-container {
  position: relative;
  width: 150px;
  margin: 0;
  overscroll-behavior: none;
}

.wheel-selector {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
  width: 100%;
  gap: 1.5rem;
  padding: 0 50px; /* Space for peeking */
  scroll-behavior: smooth;
  cursor: pointer;
  touch-action: pan-x; /* Prevent vertical scrolling on touch devices while using wheel */
  overscroll-behavior: none; /* Prevent scroll chaining to parent card on desktop */
  border: 1px solid var(--accent-color);
  border-radius: 20px;
  background: linear-gradient(to bottom, #050505 0%, #2a2a2a 50%, #050505 100%);
  box-shadow: inset 0 5px 10px rgba(0,0,0,1), inset 0 -5px 10px rgba(0,0,0,1);
  -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
  mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
  height: 36px;
  align-items: center;
}

.wheel-selector::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  flex: 0 0 auto;
  width: auto;
  min-width: 60px;
  scroll-snap-align: center;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: all 0.3s;
  user-select: none;
  white-space: nowrap;
}

.wheel-item.active {
  color: var(--accent-color);
  text-shadow: 0 0 5px rgba(255,126,179,0.5);
  transform: scale(1.1);
}

.drum-pad-btn {
  background: rgba(255, 126, 179, 0.1);
  border: 1px solid rgba(255, 126, 179, 0.3);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
}

.drum-pad-btn:active, .drum-pad-btn.active-hit {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 0 15px var(--accent-color);
  transform: scale(0.95);
}

.drum-pads-drawer-content {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  padding: 0 1rem;
  background: rgba(0,0,0,0.5);
  border-radius: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, margin-top 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.drum-pads-drawer-content.open {
  max-height: 250px;
  opacity: 1;
  margin-top: 0.5rem;
  padding: .1rem;
}

#toggle-drum-pads i {
  transition: transform 0.3s ease;
}

#toggle-drum-pads.open i {
  transform: rotate(180deg);
}

.style-btn {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.style-btn:hover {
  background: rgba(236,72,153,0.1);
  border-color: #ff7eb3;
  color: #ff7eb3;
}

.style-btn.active {
  background: #ff7eb3;
  color: #0f172a;
  border-color: #ff7eb3;
  box-shadow: 0 0 10px rgba(236,72,153,0.4);
}

/* Custom minimal range slider */
.line-slider {
  -webkit-appearance: none;
  width: 100%;
  min-width: 0; /* Fixes browser default min-width preventing it from shrinking */
  background: transparent;
}
.line-slider:focus {
  outline: none;
}
.line-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: #334155;
  border-radius: 2px;
}
.line-slider::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #ff7eb3;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -6px;
  box-shadow: 0 2px 5px rgba(236,72,153,0.5);
}

.waveshaper-iframe {
  height: 850px;
}

@media (max-width: 768px) {
  .card-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .playback-controls, .fx-controls {
    justify-content: center;
  }
  

  .main-content {
    padding-top: 60px !important;
  }

  .carousel-wrapper {
    gap: 0;
    width: 100vw;
    margin-left: -1rem; /* Adjust for parent padding */
    position: relative; /* Anchor absolute nav buttons */
  }
  
  .carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px !important;
    height: 32px !important;
    z-index: 10;
    background: rgba(15, 15, 20, 0.8) !important;
    border: none !important;
  }
  
  #carousel-prev { left: 4px; }
  #carousel-next { right: 4px; }
  
  .carousel-slide {
    flex: 0 0 100%; /* Take full width on mobile */
    padding: 0 40px; /* Leave padding on edges for the nav buttons! */
  }
  
  .generative-card {
    padding: 0.9rem !important; /* Reduce padding to give elements room */
  }
  
  .card-header {
    margin-bottom: 0.5rem;
  }
  
  .card-title {
    font-size: 1.4rem;
  }
  
  .card-desc {
    font-size: 0.7rem;
    line-height: 1.2;
  }
  
  .grid-container {
    margin-bottom: 0.75rem;
  }
  
  .card-controls {
    gap: 0.75rem;
  }
  
  .playback-controls {
    padding: 0.25rem 0.5rem;
    gap: 0.5rem;
  }
  
  .fx-controls {
    padding: 0.25rem 0.5rem;
    gap: 0.5rem;
    width: 100%;
  }

  .fx-knob-group {
    flex: 1;
    min-width: 0;
    gap: 0.4rem;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  
  .carousel-track {
    padding-left: 4%; /* Center the 92% width slide */
  }
  
  .section-header {
    display: none !important; /* Reclaim space occupied by Lab Audio / Visual on mobile */
  }

  .waveshaper-iframe {
    height: 420px;
  }

  .line-slider::-webkit-slider-thumb {
    height: 12px;
    width: 12px;
    margin-top: -5px;
  }

  .line-slider::-webkit-slider-runnable-track {
    height: 3px;
  }
  
  .minimal-select {
    font-size: 0.7rem;
    padding: 0.2rem;
  }
}

.carousel-dots {
  display: none;
  justify-content: center;
  gap: 12px;
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .carousel-dots {
    display: flex;
  }
  .wheel-selector {
    height: 28px !important;
    padding: 0 20px !important;
    gap: 1rem !important;
  }
  .wheel-item {
    font-size: 0.65rem !important;
    min-width: 40px !important;
  }
  .wheel-selector-container {
    width: 120px !important;
  }
  /* Fix Microbe beats card wheel container specifically */
  div[style*="width: 220px;"] {
    width: 140px !important;
  }
}

.carousel-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  cursor: pointer;
}

.carousel-dots .dot.active {
  background-color: #ff7eb3;
  box-shadow: 0 0 10px rgba(255, 126, 179, 0.6);
}

/* --------------------------------------------------------------------------
   CAROUSEL LAYOUT
   -------------------------------------------------------------------------- */
.carousel-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.carousel-nav-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: #cbd5e1;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
}
.carousel-nav-btn:hover {
  background: rgba(236,72,153,0.1);
  color: #ff7eb3;
  border-color: #ff7eb3;
}

.carousel-viewport {
  overflow: hidden;
  width: 100%;
}

.carousel-track {
  display: flex;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  width: 100%;
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  padding: 10px;
}

.minimal-select {
  background: transparent;
  color: #fff;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.5rem;
  outline: none;
  cursor: pointer;
  border-bottom: 1px solid #ff7eb3;
}
.minimal-select option {
  background: #141414;
  color: #fff;
}
.fractal-card .grid-container {
  box-shadow: inset 0 5px 25px rgba(0,0,0,0.9);
}

#fractal-canvas { width: 100%; height: 100%; object-fit: fill; image-rendering: pixelated; }

