/* Utility & Modal Visibility Guarantee */
.hidden {
  display: none !important;
}

/* Custom Scrollbars — Lumen Edge Palette */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-void, #1b1c22); }
::-webkit-scrollbar-thumb { background: var(--color-hairline, #2f3441); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-slate-rise, #47515c); }

/* Canvas Diode Styling */
.matrix-board {
  background: #000000;
  box-shadow: 0 0 50px -10px rgba(0,0,0,0.9), inset 0 0 15px rgba(0,0,0,0.8);
  border: 3px solid var(--color-hairline, #2f3441);
  width: fit-content !important;
  height: fit-content !important;
  max-width: none !important;
  margin: auto;
}

.matrix-board.view-round {
  gap: 2px !important;
}

.matrix-board.view-square {
  gap: 1px !important;
}

.diode-cell {
  position: relative;
  transition: background-color 0.05s ease;
  cursor: crosshair;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Round Diode Simulation */
.view-round .diode-cell {
  border-radius: 50% !important;
}

/* Square Pixel Simulation */
.view-square .diode-cell {
  border-radius: 1px !important;
}

/* LED Glow / Bloom Shader Simulation */
.glow-active .diode-cell[data-lit="true"] {
  box-shadow: 0 0 6px var(--diode-glow-color, rgba(255,255,255,0.4));
  z-index: 1;
}

/* Peg Lite Staggered Alternating Row Grid & Photorealistic Refractive Peg Underlayment */
.matrix-board.grid-peglite-active {
  padding-right: calc(var(--cell-size, 16px) * 0.5 + 1px) !important;
  background-color: #08080a;
}

.matrix-board.grid-peglite-active .diode-cell {
  position: relative;
  border-radius: 50% !important;
  box-sizing: border-box;
}

/* Unlit Board Sockets: Deep black hole with slightly lighter beveled socket rim */
.matrix-board.grid-peglite-active .diode-cell[data-lit="false"] {
  background: radial-gradient(circle at 50% 50%, #020204 42%, #151720 66%, #2b2e3c 82%, #121318 95%) !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.9), 0 0 1px rgba(255,255,255,0.08);
  border: 1px solid #1e212b;
  opacity: 1;
}

/* Lit Refractive Pegs: Saturated glowing acrylic with embossed lens facets & specular shine */
.matrix-board.grid-peglite-active .diode-cell[data-lit="true"] {
  background-color: var(--diode-color, var(--diode-glow-color, #ffffff)) !important;
  box-shadow: 0 0 8px var(--diode-glow-color, var(--diode-color)), 0 0 2px rgba(255,255,255,0.4);
  overflow: hidden;
  opacity: 1;
}

.matrix-board.grid-peglite-active .diode-cell[data-lit="true"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../greyscale-peg.svg');
  background-size: 100% 100%;
  mix-blend-mode: overlay;
  opacity: 0.88;
  pointer-events: none;
}

.matrix-board.grid-peglite-active .diode-cell[data-lit="true"]::after {
  content: '';
  position: absolute;
  top: 12%;
  left: 16%;
  width: 35%;
  height: 35%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.2) 45%, transparent 70%);
  pointer-events: none;
}

.matrix-board.grid-peglite-active .diode-cell[data-row-odd="true"] {
  transform: translateX(calc(50% + 1px));
}

/* Grid lines */
.grid-lines-active .diode-cell {
  outline: 1px solid rgba(255,255,255,0.06);
}

/* Onion Skinning ghost overlay (using ::before to preserve ::after for peg color) */
.diode-cell[data-onion="true"]::before {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: inherit;
  background-color: var(--onion-color, rgba(255,255,255,0.25));
  opacity: 0.45;
  pointer-events: none;
}

/* Live Interactive Shape Preview (Rubberbanding) */
.diode-cell.shape-preview {
  background-color: var(--shape-preview-color, #cfd8e6) !important;
  opacity: 0.75;
  outline: 1px solid white !important;
  z-index: 2;
}

/* Marquee Selection outline (No background fill to prevent grey tinting) */
.diode-cell.marquee-selected {
  outline: 2px dashed var(--color-lumen, #cfd8e6) !important;
  outline-offset: -2px;
  z-index: 3;
}

/* Stamp Hover Preview */
.diode-cell.stamp-preview {
  background-color: var(--stamp-preview-color, #cfd8e6) !important;
  opacity: 0.85;
  outline: 1px solid var(--color-lumen, #cfd8e6) !important;
  z-index: 4;
}

/* Range slider styling */
input[type=range] {
  accent-color: var(--color-lumen, #cfd8e6);
}

/* Media Query Visibility Helpers */
@media (min-width: 1024px) {
  .mobile-only {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  .desktop-only {
    display: none !important;
  }

  /* Mobile Bottom Sheet Sidebar */
  #tools-sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 3.5rem !important; /* 56px / h-14 */
    max-height: 65vh !important;
    z-index: 60 !important;
    border-top: 1px solid var(--color-hairline, #2f3441) !important;
    border-top-left-radius: 1rem !important;
    border-top-right-radius: 1rem !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.8) !important;
    background-color: var(--color-panel, #20222a) !important;
    padding: 0.75rem !important;
    overflow-y: auto !important;
  }

  #tools-sidebar.sheet-closed {
    display: none !important;
  }

  #tools-sidebar.sheet-open {
    display: block !important;
  }
}

@media (min-width: 1024px) {
  #main-workspace-layout {
    display: grid !important;
    grid-template-columns: 320px minmax(0, 1fr) !important;
    gap: 0.75rem !important;
    align-items: start !important;
  }

  /* On desktop (>= 1024px), sidebar is ALWAYS column 1 */
  #tools-sidebar {
    grid-column: 1 !important;
    position: static !important;
    display: block !important;
    width: 320px !important;
    max-width: 320px !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  /* On desktop (>= 1024px), canvas & timeline is ALWAYS column 2 */
  #canvas-main-section {
    grid-column: 2 !important;
    min-width: 0 !important;
    width: 100% !important;
  }
}

@media (min-width: 1440px) {
  #main-workspace-layout {
    grid-template-columns: 340px minmax(0, 1fr) !important;
  }
  #tools-sidebar {
    width: 340px !important;
    max-width: 340px !important;
  }
}

/* Touch & Mobile Optimizations */
#matrix-board-container {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile Backdrops */
.mobile-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(27, 28, 34, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.mobile-backdrop.backdrop-closed {
  display: none !important;
}

.mobile-backdrop.backdrop-open {
  display: block !important;
}

#mobile-sheet-backdrop {
  z-index: 55;
}

#mobile-drawer-backdrop {
  z-index: 75;
}

/* Mobile Right-Hand Studio Drawer */
.mobile-studio-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 18.5rem; /* 296px */
  background-color: var(--color-panel, #20222a);
  border-left: 1px solid var(--color-hairline, #2f3441);
  z-index: 80;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8);
}

.mobile-studio-drawer.drawer-closed {
  display: none !important;
}

.mobile-studio-drawer.drawer-open {
  display: flex !important;
}

/* Brand Entry Toast Animation */
@keyframes toastSlideFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.95);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  85% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -15px) scale(0.95);
    visibility: hidden;
  }
}

.animate-brand-toast {
  animation: toastSlideFade 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}



