/* Headers: the list header (title with switcher, ⋯ menu, plan/shop toggle) and the page header of every
   other page (‹ back, title, ⋯). */

.list-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-block-end: var(--space-4);
}

.list-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* Right side: Done (reordering) or the View only badge, then the round ⋯ button */
.list-header__end {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-1);
}

/* Every other page (shared/_page_header) */
.page-header {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-block-end: var(--space-4);
}

.page-header__title { flex: 1; min-width: 0; }


/* List switcher: the title opens a dropdown with all lists */

.switcher {
  position: relative;
  min-width: 0;
}

.switcher__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-size);
  list-style: none;
  cursor: pointer;
  user-select: none;

  &::-webkit-details-marker { display: none; }
}

/* The chevron in a round grey button; it turns while the menu is open */
.switcher__chevron .icon { transition: rotate 0.15s; }
.switcher[open] .switcher__chevron .icon { rotate: 180deg; }

.switcher__menu {
  inset-inline-start: 0;
  width: min(22rem, calc(100vw - 2 * var(--space-3)));
  padding-block: var(--space-3) var(--space-1);

  /* "Add list", right-aligned below a divider */
  .dropdown__actions {
    align-items: flex-end;
    margin-block-start: var(--space-2);
    padding-block-start: var(--space-1);
    border-block-start: 1px solid var(--color-border);
  }
}


/* ⋯ menu: Profile, Sign out */

.more-menu { position: relative; }

.more-menu__toggle {
  list-style: none;
  color: var(--color-text);

  &::-webkit-details-marker { display: none; }
  .icon { width: 1.375rem; height: 1.375rem; }
}

.more-menu__menu {
  inset-inline-end: calc((var(--tap-size) - var(--circle-size)) / 2);
  min-width: 11rem;
  padding-block: var(--space-1);

  /* Divider between entries, like the one above "Add list" */
  li + li {
    margin-block-start: var(--space-2);
    padding-block-start: var(--space-1);
    border-block-start: 1px solid var(--color-border);
  }
}


/* Saved copy shown offline (lib/offline_copy.js): the banner, and greyed-out controls (they're inert) */
.offline-banner { display: none; }
html.offline .offline-banner { display: block; }

html.offline :is(.items, .bought) .circle-button,
html.offline :is(.fab, .item__edit, .directory__actions, .switcher__menu .dropdown__actions) { opacity: 0.35; }


/* "Install app": only while the app can be installed (lib/install.js marks <html>) */
.install { display: contents; }
.install-entry { display: none; }
html.installable .install-entry { display: list-item; }


/* Plan | Shop */

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: var(--color-surface);
  border-radius: var(--radius);

  a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: calc(var(--radius) - 3px);
  }

  a[aria-current="page"] {
    color: var(--color-on-accent);
    background: var(--color-accent);
  }
}
