/* The page around the list: the header menu, the shortcuts dialog, the top
   bar with its tabs and search, and the product name. */

/* The header menu: a native popover, so it opens, closes on Esc or an
   outside click, and returns focus with no JavaScript. */
.menu-button {
  anchor-name: --menu-button;
}

.menu {
  /* Fallback: below the top right corner of the window. */
  inset: auto;
  top: calc(var(--space-4) + var(--size-tap) + var(--space-1));
  right: var(--space-4);
  min-width: 14rem;
  margin: 0;
  padding: var(--space-1);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-md);
}

@supports (position-anchor: --menu-button) {
  .menu {
    position-anchor: --menu-button;
    inset: auto;
    top: calc(anchor(bottom) + var(--space-1));
    right: anchor(right);
  }
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  min-height: var(--size-tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--color-accent-subtle);
}

/* Keyboard shortcut help: a native <dialog>, opened with `?`. */
.dialog {
  max-width: 28rem;
  padding: var(--space-5);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-md);
}

.dialog::backdrop {
  background: var(--color-shadow);
}

.dialog h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-lg);
}

.shortcuts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-4);
}

.shortcuts dd {
  margin: 0;
}

kbd {
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg-sunken);
  font: inherit;
  font-size: var(--font-size-sm);
}

/* The top bar: the logo, the view tabs, and at the right the trash (the
   Deleted view), the search magnifier and the menu. The current tab is
   underlined. The search box opens in a line of its own under the bar. */
.tabbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border-subtle);
}

/* The bar stays at the top while the list scrolls under it (and the quick-add
   box under the bar, see components.css). `--bar-height` is how tall it is,
   for what sticks beneath it and for scrolling a row clear of both. */
.page {
  --bar-height: calc(var(--space-4) + var(--size-tap) + 1px);
}

.page:has(.search[open]) {
  --bar-height: calc(var(--space-4) + var(--size-tap) + 1px + var(--space-5) + 2.25rem + var(--space-4));
}

/* The bar keeps the page's top margin while it is stuck: padding above it,
   pulled back by the margin so nothing moves before it sticks. */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 15;
  padding-top: var(--space-4);
  margin-top: calc(-1 * var(--space-4));
  background: var(--color-bg-page);
}

.tabbar:has(.search[open]) {
  /* Room for the open search box: its padding and the box itself. */
  padding-bottom: calc(var(--space-5) + 2.25rem + var(--space-4));
}

.logo {
  display: flex;
  margin: 0;
}

.tabs {
  display: flex;
  gap: var(--space-1);
  min-width: 0;
}

.bar-end {
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* An icon-only control on the bar: no border, like the tabs. */
.bar-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--size-tap);
  height: var(--size-tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  list-style: none;
}

.bar-icon::-webkit-details-marker {
  display: none;
}

.bar-icon:hover,
.bar-icon[aria-current="page"],
.search[open] > .bar-icon {
  color: var(--color-text-primary);
}

.bar-icon[aria-current="page"] {
  background: var(--color-accent-subtle);
}

/* The open box sits under the bar, across its full width. */
.search[open] form {
  position: absolute;
  right: 0;
  bottom: var(--space-4);
  left: 0;
}

/* Where the bar runs edge to edge (see rows.css), the open box stays inside
   the page's margins, in line with the quick-add box below it. */
@media not all and (min-width: 72rem) {
  .search[open] form {
    right: var(--space-4);
    left: var(--space-4);
  }
}

.search-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font: inherit;
  font-size: var(--font-size-sm);
}

/* iOS Safari zooms into any box whose text is smaller than 16px when it gets
   focus, and doesn't zoom back out. On touchscreens the box uses the full
   size (we don't turn zoom off: people need it). */
@media (pointer: coarse) {
  .search-input {
    font-size: var(--font-size-base);
  }
}

.search-input::placeholder {
  color: var(--color-text-muted);
}


.tab {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-tap);
  padding: 0 var(--space-4);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}

/* On a narrow phone the tabs tighten up so the bar's icons all fit. */
@media (max-width: 30rem) {
  .tabbar,
  .tabs {
    gap: 0;
  }

  .tabs {
    flex: none;
  }

  .tab {
    padding: 0 var(--space-2);
  }

  .bar-icon {
    width: 2.5rem;
  }

  .logo .bar-icon {
    width: 2.25rem;
  }
}

.tab:hover {
  color: var(--color-text-primary);
}

.tab[aria-current="page"] {
  border-bottom-color: var(--color-accent-base);
  color: var(--color-text-primary);
}

.btn-small {
  min-height: 1.75rem;
  padding: 0 var(--space-3);
  font-size: var(--font-size-sm);
}

/* The Taskrat logo (the rat and the name) on the sign-in page. It is an image,
   one file per theme (see the <picture> in login.html), because an SVG used as
   an image can't read our colours. Change `height`; the width follows. */
.brand {
  margin: 0;
}

.brand a {
  display: inline-block;
}

.wordmark {
  display: block;
  width: auto;
  height: 4.5rem;
}
