/* ==========================================================================
   layout.css
   Structural grid/flex layout only — no color, no visual styling of
   components (that's components.css). Desktop Explorer shell + the
   breakpoints that swap it for the mobile Drive shell.

   Phase 7.2 status:
     - Folder tree is FLAT (7 section rows, no branches, no disclosure).
       render.js no longer emits .folder-tree__toggle or .folder-tree__branch.
     - .folder-tree__toggle and .folder-tree__branch rules below are
       DORMANT. Kept per Phase 7.2 guardrail: cannot verify base.css /
       utilities.css / styles.css don't reference them. Flagged for a
       cleanup pass with full grep access.
     - .dashboard-filters / .drive-filters structural rules added (flex row,
       horizontal scroll, chip row sits above the grid in both shells).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESKTOP EXPLORER SHELL — CSS Grid
   -------------------------------------------------------------------------- */
.explorer-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--toolbar-height) 1fr;
  grid-template-areas:
    "sidebar toolbar"
    "sidebar main";
  min-height: 100vh;
}

.explorer-shell.is-sidebar-collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

.explorer-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--toolbar-height);
  padding-inline: var(--space-4);
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-3);
}

.explorer-toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--toolbar-height);
  padding-inline: var(--space-4);
  position: sticky;
  top: 0;
  z-index: var(--z-toolbar);
}

.breadcrumb {
  /* Fixed to the widest breadcrumb (Portfolio / Certifications = 189.05px) so the search bar does not shift between sections */
  flex: 0 0 12rem;
}

.breadcrumb__list {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
  white-space: nowrap;
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb__item:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-2);
}

.toolbar-search {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 480px;
  margin-inline: auto;
}

.toolbar-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.explorer-main {
  grid-area: main;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-6);
}

.dashboard-section__header {
  margin-bottom: var(--space-6);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

/* Folder tree structural layout.
   The __toggle rules are DORMANT (flat tree). Kept per Phase 7.2 guardrail. */
.folder-tree__item {
  display: flex;
  flex-direction: column;
}

.folder-tree__toggle,
.folder-tree__leaf {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-4);
}

.folder-tree__count {
  margin-left: auto;
}

/* DORMANT: no branch element is rendered since Phase 7.2. Kept per guardrail. */
.folder-tree__branch {
  display: flex;
  flex-direction: column;
  padding-left: var(--space-4);
}

.folder-tree__branch.is-collapsed,
.folder-tree__branch[hidden] {
  display: none;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
}

/* --------------------------------------------------------------------------
   2. MOBILE DRIVE SHELL — structural layout
   -------------------------------------------------------------------------- */
.drive-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.drive-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--drive-topbar-height);
  padding-inline: var(--space-3);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: var(--z-toolbar);
}

.drive-topbar__search {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drive-topbar__search input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
}

.avatar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
}

.drive-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--drive-tabs-height);
  padding-inline: var(--space-3);
  overflow-x: auto;
  flex-shrink: 0;
}

/* Filter chip rows: sit above the grid in both shells.
   Structural only — colors/paddings live in components.css §4a. */
.dashboard-filters,
.drive-filters {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.drive-main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--drive-bottom-nav-height) + var(--space-4));
}

.drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.drive-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  padding: var(--space-3);
}

.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--drive-bottom-nav-height) + var(--space-4));
  width: var(--drive-fab-size);
  height: var(--drive-fab-size);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-fab);
}

.drive-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  height: var(--drive-bottom-nav-height);
  z-index: var(--z-toolbar);
}

.drive-bottom-nav__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.drive-drawer[hidden] {
  display: none;
}

.drive-drawer {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-panel);
}

.drive-drawer__backdrop {
  position: absolute;
  inset: 0;
  z-index: var(--z-drawer-backdrop);
}

.drive-drawer__panel {
  position: relative;
  z-index: var(--z-drawer-panel);
  width: min(80vw, 320px);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
}

.drive-drawer__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.drive-drawer__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 auto;
}

.drive-drawer__link {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
}

.drive-drawer__footer {
  margin-top: auto;
}

/* --------------------------------------------------------------------------
   3. RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .explorer-shell {
    display: none;
  }

  .drive-shell[hidden] {
    display: flex;
  }
}

@media (min-width: 769px) {
  .drive-shell {
    display: none !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .explorer-shell {
    grid-template-columns: var(--sidebar-width-collapsed) 1fr;
  }
}