/* =========================================
   BASE DESKTOP LAYOUT
========================================= */
.app-root {
  display: grid;
  grid-template-rows: 56px 1fr 32px;
  height: 100vh;
  width: 100vw;
  background: var(--bg);
}

.main-grid {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.sidebar {
  display: grid;
  grid-template-columns: 78px 1fr;
  background: var(--bg-elev-1);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.properties {
  background: var(--bg-elev-1);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 18px;
}

.editor {
  position: relative;
  overflow: hidden;
  background: var(--editor-bg);
}

.editor::before {
  /* subtle grain */
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  opacity: var(--grain-opacity);
  pointer-events: none;
  mix-blend-mode: overlay;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-elev-1);
  color: var(--text-muted);
  font-size: 12px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* =========================================
   MOBILE & TABLET STRUCTURAL OVERRIDES
========================================= */
@media (max-width: 900px) {
  /* 1. Hide status bar to save vertical space */
  .app-root {
    grid-template-rows: 56px 1fr;
  }
  .status-bar {
    display: none !important;
  }

  /* 2. Kill the 3-column grid and stack vertically */
  .main-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100vw !important;
    height: calc(100vh - 56px) !important;
    padding-bottom: 64px !important; /* Leave space for bottom nav */
    border: none !important;
  }

  /* 3. Force the editor to expand and claim the entire width */
  .editor {
    width: 100% !important;
    flex: 1 !important;
    display: block !important;
  }

  /* 4. Move Sidebar to the bottom as the navigation base */
  .sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 64px !important;
    display: block !important; 
    border-right: none !important;
    border-top: 1px solid var(--border) !important;
    z-index: 500 !important;
    overflow: visible !important;
  }

  /* 5. Properties panel becomes a sliding bottom sheet */
  .properties {
    display: block !important;
    position: fixed !important;
    bottom: 64px !important; /* Sits right above the bottom nav */
    left: 0 !important;
    width: 100vw !important;
    height: 50vh !important; /* Takes up bottom half of screen */
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.4) !important;
    z-index: 400 !important;
    padding: 16px !important;
    
    /* Hide off-screen by default. Toggle class via JS to show */
    transform: translateY(150%) !important;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
  }
  
  /* Add this class via Javascript when an element is clicked/selected */
  .properties.active {
    transform: translateY(0) !important;
  }
}