/* ==========================================================================
   layout.css — Structural layout of the application shell.
   Top toolbar + workspace (sidebar | main column | properties).
   Panel sizes are controlled via CSS custom properties (--panel-w /
   --timeline-h) that js/utils/PanelResizer.js updates on drag.
   ========================================================================== */

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
  background: var(--bg-app);
}

.workspace {
  display: flex;
  min-height: 0; /* allow children to scroll instead of overflowing */
  min-width: 0;
}

/* ---- Sidebar (rail + panel) ------------------------------------------------ */
.sidebar {
  display: flex;
  min-width: 0;
  flex: 0 0 auto;
  width: calc(var(--rail-w) + var(--panel-w));
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  position: relative;
}

.sidebar__rail {
  flex: 0 0 var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-right: 1px solid var(--border-subtle);
}

.sidebar__panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ---- Main column (preview stacked on timeline) ----------------------------- */
.main-column {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-area {
  flex: 1 1 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
}

/* ---- Timeline (fixed via --timeline-h, resizable) ------------------------- */
.timeline {
  flex: 0 0 var(--timeline-h);
  min-height: 140px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

/* ---- Properties panel ------------------------------------------------------- */
.properties {
  flex: 0 0 var(--panel-w);
  min-width: 220px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  overflow-y: auto;
}

/* ---- Resizer handles --------------------------------------------------------- */
.resizer {
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
}
.resizer--vertical {
  width: 5px;
  cursor: col-resize;
  margin-left: -2.5px;
}
.resizer--horizontal {
  height: 5px;
  cursor: row-resize;
  margin-top: -2.5px;
}
.resizer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.15s ease;
}
.resizer:hover::after,
.resizer.is-dragging::after {
  background: var(--accent-primary);
}
/* The sidebar/properties resizers live inside flex items positioned via
   absolute so dragging doesn't disturb sibling layout order. */
.sidebar > .resizer--vertical,
.workspace > .resizer--vertical {
  position: relative;
  width: 5px;
  margin: 0;
}

/* ---- Responsive behaviour ----------------------------------------------------- */
@media (max-width: 1080px) {
  .sidebar { width: calc(var(--rail-w) + 200px); }
  .properties { flex-basis: 240px; }
}

@media (max-width: 860px) {
  .sidebar__panel .panel-header h2 { font-size: 11px; }
  .properties { display: none; } /* collapse least-critical panel first */
}

@media (max-width: 640px) {
  :root { --rail-w: 56px; }
  .sidebar { width: var(--rail-w); }
  .sidebar__panel { display: none; }
  .sidebar > .resizer--vertical { display: none; }
}
