/*
 * Wide (desktop):  sidebar | conversations | reader
 * ≤ 1100px:        conversations | reader; the sidebar is a drawer
 * ≤ 760px:         one pane at a time: the list, or the open conversation
 */

body {
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "nav main";
  height: 100vh;
  height: 100dvh;
  background: var(--bg-app);
}

.top-bar {
  grid-area: top;
}

.sidebar {
  grid-area: nav;
  min-height: 0;
  overflow-y: auto;
}

.workspace {
  grid-area: main;
  display: grid;
  grid-template-columns: minmax(300px, var(--list-w)) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  border-top-left-radius: var(--radius-lg);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  overflow: hidden;
}

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.reader-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.scrim {
  display: none;
}

.nav-toggle,
.search-toggle,
.reader-back {
  display: none;
}

/* Boot, errors before start, an account without mailboxes */
.boot {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
  text-align: center;
  color: var(--fg-muted);
  background: var(--bg);
}

.boot-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
}

.boot-mark .icon,
.boot-icon {
  width: 26px;
  height: 26px;
}

.boot-heading {
  color: var(--fg);
  font-size: var(--text-xl);
  font-weight: 650;
}

.boot-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

@media (min-width: 1440px) {
  :root {
    --list-w: 440px;
  }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "main";
  }

  .workspace {
    border-left: 0;
    border-radius: 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    background: var(--bg-app);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    visibility: hidden;
    transition:
      transform 0.18s ease,
      visibility 0.18s;
  }

  .app.nav-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .scrim {
    display: block;
    position: fixed;
    z-index: 25;
    inset: var(--topbar-h) 0 0 0;
    background: rgb(0 0 0 / 32%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .app.nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    border-top: 0;
  }

  .list-pane {
    border-right: 0;
  }

  .app[data-pane="list"] .reader-pane,
  .app[data-pane="reader"] .list-pane {
    display: none;
  }

  .reader-back {
    display: inline-flex;
  }
}
