/* App shell: top bar, side navigation and content area. */

/* ---- Top app bar ---- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--app-bar-h);
  padding-inline: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 8px 12px;
  color: var(--ink);
}

.brand:hover {
  text-decoration: none;
}

/* The ☰ with a small arrow beside it, so it reads as the menu of workspaces. */
.workspace-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 40px;
  padding: 0 2px 0 8px;
  border: 0;
  border-radius: 20px;
  background: none;
  color: var(--ink-2);
}

.workspace-btn:hover,
.workspace-btn[aria-expanded="true"] {
  background: var(--hover);
}

.workspace-btn__arrow {
  margin-left: -4px;
  transition: transform 150ms ease;
}

.workspace-btn[aria-expanded="true"] .workspace-btn__arrow {
  transform: rotate(180deg);
}

/* "Active workspace" in small type, with the workspace's name under it. */
.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand__label {
  color: var(--ink-3);
  font-size: 11px;
  line-height: 14px;
  letter-spacing: 0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
}

.brand__mark .ms {
  font-size: 20px;
}

/* The workspace that's open, where the product name used to be. */
.brand__name {
  max-width: 260px;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.search {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  height: 48px;
  margin-inline: 24px;
  padding-inline: 16px;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink-2);
}

.search:focus-within {
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.app-bar__actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* The drawer button is only for phones, where the menus are tucked away. (Scoped, so it beats .icon-btn.) */
.app-bar .app-bar__drawer {
  display: none;
}

.app-bar__search {
  display: none;
}

/* ---- Side navigation ---- */
.app-body {
  display: flex;
  align-items: flex-start;
}

.side-nav {
  position: sticky;
  top: var(--app-bar-h);
  z-index: 20;
  display: flex;
  flex-shrink: 0;
  height: calc(100dvh - var(--app-bar-h));
}

.nav-rail {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  width: var(--rail-w);
}

.nav-rail__list {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: var(--rail-w);
  margin: 0;
  padding: 8px 12px;
  overflow: hidden;
  list-style: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: width 0.2s ease, box-shadow 0.2s ease;
}

.nav-rail:hover .nav-rail__list {
  width: var(--rail-expanded-w);
  box-shadow: var(--shadow-raised);
  transition-delay: 0.25s;
}

.nav-rail:has(:focus-visible) .nav-rail__list {
  width: var(--rail-expanded-w);
  box-shadow: var(--shadow-raised);
}

.nav-rail__bottom {
  margin-top: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 48px;
  padding-inline: 12px;
  border-radius: 24px;
  color: var(--ink-2);
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--hover);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--blue-wash);
  color: var(--blue);
}

.nav-item.is-active .ms {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

.nav-item__label {
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.nav-rail:hover .nav-item__label {
  opacity: 1;
  transition-delay: 0.25s;
}

.nav-rail:has(:focus-visible) .nav-item__label {
  opacity: 1;
}

.nav-scrim {
  display: none;
}

/* ---- Content ---- */
.content {
  flex: 1;
  min-width: 0;
  padding: 20px 32px 48px;
  outline: none;
}

/* Pages use the full width beside the rail. */
.content__inner {
  min-width: 0;
}

/*
 * The row above every page: the section's tabs on the left, when it has several pages, and the
 * page's add buttons on the right. Pages with neither don't show it.
 */
.page-head {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

/* The trail and this page's buttons on one line, so the page starts right under them. */
.page-head__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.page-head__tabs {
  flex: 1 1 auto;
  min-width: 0;
}

.page-head__tabs:empty,
body:not(.has-subnav) .page-head__tabs {
  display: none;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.page-head__actions:empty {
  display: none;
}


/*
 * The trail in the header: home, the pages above this one, then this page, which is also the page's
 * title and reads as one. Earlier steps are quieter links. It stays on one line; long names shorten
 * with an ellipsis.
 */
/* The trail at the head of the page, ending in the page's own title. */
.breadcrumb {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 16px;
  line-height: 24px;
}

.breadcrumb:empty {
  display: none;
}

.breadcrumb__step {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 320px;
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: 999px;
  color: var(--ink-2);
  transition: background-color 120ms ease, color 120ms ease;
}

.breadcrumb__step > span:last-child,
.breadcrumb__here > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb__step:hover {
  background: var(--hover);
  color: var(--ink);
  text-decoration: none;
}

.breadcrumb__step .ms {
  font-size: 22px;
}

.breadcrumb .breadcrumb__divider {
  flex: none;
  color: var(--ink-3);
  font-size: 20px;
}

/* The page itself: the last step is the page's title. */
.breadcrumb__here {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 32px;
  letter-spacing: -0.01em;
}

/* A step that is only a label, such as a section with no page of its own. */
.breadcrumb > .breadcrumb__here:not(:last-child) {
  padding-inline: 6px;
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
}

/* ---- Workspace switcher menu (like GA's account picker) ---- */
.workspace-menu {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--app-bar-h) - 4px);
  left: 8px;
  z-index: 55;
  width: min(400px, calc(100vw - 16px));
  max-height: calc(100vh - var(--app-bar-h) - 24px);
  padding-block: 8px;
  overflow-y: auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.workspace-menu__group + .workspace-menu__group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--grid);
}

.workspace-menu__heading {
  margin: 8px 24px 4px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

.workspace-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 56px;
  padding: 8px 24px;
  border: 0;
  background: none;
  text-align: left;
}

.workspace-option:hover {
  background: var(--hover);
}

.workspace-option:focus-visible {
  outline-offset: -2px;
}

.workspace-option[aria-checked="true"] {
  background: var(--blue-wash);
}

.workspace-option__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--field);
  color: var(--ink-2);
}

.workspace-option__icon .ms {
  font-size: 20px;
}

.workspace-option[aria-checked="true"] .workspace-option__icon {
  background: var(--blue);
  color: #fff;
}

.workspace-option__name {
  display: block;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-option__meta {
  display: block;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-option__check {
  color: var(--blue);
  font-size: 20px;
  visibility: hidden;
}

.workspace-option[aria-checked="true"] .workspace-option__check {
  visibility: visible;
}

.workspace-option--action .workspace-option__icon {
  background: none;
  color: var(--blue);
}

.workspace-option--action .workspace-option__name {
  color: var(--blue);
}

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .app-bar .app-bar__drawer {
    display: grid;
  }

  .side-nav {
    position: fixed;
    inset: var(--app-bar-h) auto 0 0;
    z-index: 40;
    flex-direction: column;
    width: min(304px, calc(100vw - 48px));
    height: auto;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow-raised);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .nav-open .side-nav {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .nav-rail {
    width: auto;
  }

  .nav-rail__list,
  .nav-rail:hover .nav-rail__list,
  .nav-rail:has(:focus-visible) .nav-rail__list {
    position: static;
    width: auto;
    border-right: 0;
    box-shadow: none;
  }

  .nav-item__label {
    opacity: 1;
  }

  .nav-rail__bottom {
    margin-top: 0;
  }

  .nav-scrim {
    position: fixed;
    inset: var(--app-bar-h) 0 0;
    z-index: 35;
    background: rgb(32 33 36 / 40%);
  }

  .nav-open .nav-scrim {
    display: block;
  }

  .content {
    padding: 16px 16px 40px;
  }
}

@media (max-width: 720px) {
  .search {
    display: none;
  }

  .brand__name {
    max-width: 120px;
    font-size: 16px;
  }

  /* Only this page's name fits; the steps above it are a tap away in the menus. */
  .breadcrumb__here {
    font-size: 19px;
    line-height: 28px;
  }

  .app-bar__search {
    display: inline-grid;
  }

  .search ~ .app-bar__actions {
    margin-left: auto;
  }
}

/* The smallest screens keep the workspace's name; the logo goes. */
@media (max-width: 560px) {
  /* The workspace name and the page name need the room more than the logo does. */
  .brand__mark {
    display: none;
  }

  .brand {
    padding-inline: 4px 8px;
  }
}
