/* ==========================================
   ACCID LAYER SYSTEM CSS (Filter-in-Place)
   ==========================================

   Layers are tags on modules, all in #moduleContainer.
   Switching layers shows/hides modules by their tag.
   No separate DOM containers needed for editing.
*/


/* ==================== PER-LAYER CONTAINERS ==================== */
/* Per LAYER-SYSTEM-FINAL-SPEC.md — each layer is its own DOM container,
   absolutely stacked. Layers don't share a flow; spacers within each
   layer reserve cross-layer space. */

#moduleContainer.accid-page {
  position: relative;
  min-height: 100vh;
  /* Kill the 20px top/horizontal padding that ships in accid_grid.css —
     layers and the .accid-content-wrap need to render flush at top:0.
     Any site-wide padding/centering lives on .accid-content-wrap (set by
     PAGE-scope vars via applySiteStyleVars in page-renderer.js). */
  padding: 0 !important;
  /* Kill the grid layout from accid_grid.css too — we use stacked layers
     here, not a grid of cells. Without this override the .accid-content-wrap
     gets crammed into a 150px grid cell. */
  display: block !important;
  grid-template-columns: none !important;
  grid-template-rows: none !important;
  grid-auto-rows: auto !important;
}

/* The wrap is the canonical styling target for PAGE / BODY scopes. Page layer
   (z 100) stays a sibling above it so its BG can span the full viewport. */
.accid-content-wrap {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

.accid-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* 6-layer z-stack — back → front (see accid-layers.js for full spec). */
.accid-layer[data-layer="page"]       { z-index: 100; }  /* site-wide BG */
.accid-layer[data-layer="body"]       { z-index: 200; }  /* per-page BG (was 'background') */
.accid-layer[data-layer="guides"]     { z-index: 300; }  /* RESERVED — task #9 */
.accid-layer[data-layer="templates"]  { z-index: 400; }
.accid-layer[data-layer="content"]    { z-index: 500; }
.accid-layer[data-layer="ui"]         { z-index: 600; }

/* Edit-mode dimming — only the active layer is at 100%; the rest fade so
   you know which layer is "live." Preview/view mode leaves all layers
   at full opacity (the body.creator-mode gate is what edit mode sets). */
body.creator-mode .accid-layer:not(.accid-layer--active) {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.4);
}
body.creator-mode .accid-layer--active {
  opacity: 1;
  pointer-events: auto;
  /* Promote the active layer above the other layers (max z is 600 for `ui`)
     so its modules paint on top. No background veil — dim+grayscale on
     inactive layers already signals what's live. */
  z-index: 2000;
}

/* Spacer cells reserve vertical space — height comes from inline style. */
.module-wrapper-v2[data-module-type="spacer"] {
  width: 100%;
  flex-shrink: 0;
}
body.creator-mode .module-wrapper-v2[data-module-type="spacer"] {
  background: rgba(156, 163, 175, 0.12);
  border: 1px dashed rgba(156, 163, 175, 0.35);
}
/* In view mode, spacers are pure layout reservations — they shouldn't
   eat hover/click on anything overlapping them from other layers. */
body:not(.creator-mode) .module-wrapper-v2[data-module-type="spacer"] {
  pointer-events: none;
}

/* Same trick for the content layer overall: the layer's empty space
   (between modules) is click-through so anything underneath (template
   header sticking down into the content zone, BG video, etc.) stays
   reachable. Real modules inside the layer re-enable pointer-events
   so links/buttons/forms still work. Spacer rule above wins on
   specificity, so spacers remain click-through too. */
body:not(.creator-mode) .accid-layer[data-layer="content"] {
  pointer-events: none;
}
body:not(.creator-mode) .accid-layer[data-layer="content"] > .module-wrapper-v2 {
  pointer-events: auto;
}
body:not(.creator-mode) .accid-layer[data-layer="content"] > .module-wrapper-v2[data-module-type="spacer"] {
  pointer-events: none;
}

/* Legacy .layer-hidden — pre-refactor filter-in-place class. Kept as a
   no-op so any code still applying it during transition doesn't break. */
.layer-hidden {
  opacity: 1;
}


/* ==================== BACKGROUND MODULE TYPES ==================== */

.module-background {
  width: 100%;
  height: 100%;
  min-height: 180px;
}


/* ==================== EDITOR: LAYER SWITCHER ==================== */

.layer-switcher {
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: rgba(0, 0, 0, 0.85);
  padding: 0;
  border-radius: 12px 0 0 0;
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 100000;
  box-shadow: -4px -4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  overflow: visible;
}

/* Closed: hide layer buttons, only tab visible */
.layer-switcher .layer-btn {
  display: none;
}

/* Open: show layer buttons with padding */
.layer-switcher--open {
  padding: 8px;
}

.layer-switcher--open .layer-btn {
  display: flex;
}

.layer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 14px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 8px;
  color: #888;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.layer-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.layer-btn.active {
  color: white;
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.25);
}

.layer-btn .layer-icon {
  font-size: 20px;
  line-height: 1;
}

.layer-btn .layer-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Layer indicator dot */
.layer-btn::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  margin-top: 4px;
}

.layer-btn.active::after {
  opacity: 1;
  background: #3b82f6;
}

.layer-btn.has-content::after {
  background: #10b981;
  opacity: 0.8;
}


/* ==================== LAYER SWITCHER TOGGLE TAB ==================== */

.layer-switcher-tab {
  position: absolute;
  top: -32px;
  right: 0;
  width: 48px;
  height: 32px;
  background: rgba(0, 0, 0, 0.85);
  border: none;
  border-radius: 8px 0 0 0;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  box-shadow: -2px -4px 10px rgba(0, 0, 0, 0.2);
  transition: background 0.2s;
}

.layer-switcher-tab:hover {
  background: rgba(59, 130, 246, 0.5);
}


/* ==================== LAYER BADGE ON MODULES ==================== */

/* Small badge showing which layer a module belongs to (edit mode) */
.layer-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
  .layer-btn {
    padding: 8px 10px;
    min-width: 50px;
  }
  .layer-btn .layer-icon {
    font-size: 18px;
  }
  .layer-btn .layer-label {
    font-size: 8px;
  }
}


/* ==================== PRINT ==================== */

@media print {
  .layer-switcher {
    display: none;
  }
}
