/*
 * The page shell that templates/base.html draws around every page.
 * Reads only tokens.css.
 *
 *   1. Top bar and logo
 *   2. Navigation (a row in the top bar; on a phone, a bar at the bottom of the screen)
 *   3. Menus that open: "More", the account menu
 *   4. Language switch
 *   5. Main column, page title, notices
 *   6. The login page
 *
 * Widths: under 760px is the phone layout. From 960px the bar has room for one more page.
 * The "More" menu and the account menu are <details> elements, which open and close
 * without any script.
 */

/* --- 1. Top bar and logo ------------------------------------------------------------------ */
.gc-topbar {
  border-bottom: 1px solid var(--gc-line);
  background: var(--gc-header);
}
.gc-topbar__inner {
  max-width: var(--gc-page-width);
  margin: 0 auto;
  padding: 12px var(--gc-gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}
.gc-topbar__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.gc-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--gc-tap);
  color: var(--gc-ink);
  text-decoration: none;
}
.gc-brand__mark {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gc-brand);
  color: var(--gc-on-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px; /* the size of the paw inside */
}
.gc-brand__name {
  font-family: var(--gc-font-display);
  font-weight: 600;
  font-size: 20px;
  white-space: nowrap;
}

/* --- 2. Navigation ------------------------------------------------------------------------ */
.gc-nav {
  flex: 1 1 auto;
  min-width: 0;
}
.gc-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.gc-nav__item {
  position: relative; /* the "More" menu opens under its own button */
}
/* A page that is in the bar only on a wide screen. */
.gc-nav__item--wide {
  display: none;
}
.gc-nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--gc-tap);
  padding: 0 14px;
  border-radius: var(--gc-radius-pill);
  color: var(--gc-ink);
  font-size: var(--gc-text-md);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.gc-nav__link:hover {
  background: var(--gc-chip);
  color: var(--gc-ink);
}
/* The open page. */
.gc-nav__link[aria-current="page"],
.gc-more[data-active="more"] > .gc-nav__link {
  background: var(--gc-brand);
  color: var(--gc-on-brand);
  font-weight: 600;
}

@media (min-width: 960px) {
  .gc-nav__item--wide {
    display: block;
  }
  /* On a wide screen this page is in the bar, so its copy under "More" is not needed. */
  .gc-more__item--wide {
    display: none;
  }
}
@media (max-width: 959.98px) {
  /* The open page is under "More" at this width, so "More" is the open button. */
  .gc-more[data-active="wide"] > .gc-nav__link {
    background: var(--gc-brand);
    color: var(--gc-on-brand);
    font-weight: 600;
  }
}

/* --- 3. Menus that open ------------------------------------------------------------------- */
.gc-more > summary,
.gc-menu > summary {
  list-style: none; /* no triangle */
  user-select: none;
}
.gc-more > summary::-webkit-details-marker,
.gc-menu > summary::-webkit-details-marker {
  display: none;
}
/* A small arrow after "More", turned over while the menu is open. */
.gc-more > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 0 0 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.gc-more[open] > summary::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.gc-more__panel,
.gc-menu__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  min-width: 220px;
  margin: 0;
  padding: 8px;
  list-style: none;
  border: 1px solid var(--gc-line);
  border-radius: var(--gc-radius-tile);
  background: var(--gc-surface);
  box-shadow: var(--gc-shadow-menu);
}
.gc-more__panel {
  left: 0;
}
.gc-more__link,
.gc-menu__link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--gc-tap);
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--gc-ink);
  font-size: var(--gc-text-md);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.gc-more__link:hover,
.gc-menu__link:hover {
  background: var(--gc-ground);
  color: var(--gc-ink);
}
.gc-more__link[aria-current="page"] {
  background: var(--gc-brand);
  color: var(--gc-on-brand);
  font-weight: 600;
}

/* The account menu: a round button with the person's initial, top right. */
.gc-menu {
  position: relative;
}
.gc-menu__button {
  width: var(--gc-tap);
  height: var(--gc-tap);
  border-radius: 50%;
  background: var(--gc-chip);
  color: var(--gc-ink);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.gc-menu__panel {
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gc-menu__name {
  padding: 8px 12px 4px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.gc-menu__group {
  padding: 4px 12px 8px;
}
.gc-menu__form {
  margin: 0;
  border-top: 1px solid var(--gc-line);
  padding-top: 4px;
}

/* --- 4. Language switch ------------------------------------------------------------------- */
.gc-lang {
  margin: 0;
  display: inline-flex;
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: var(--gc-radius-pill);
  background: var(--gc-chip);
}
.gc-lang__button {
  min-width: var(--gc-tap);
  min-height: var(--gc-tap);
  padding: 0 12px;
  border: 0;
  border-radius: var(--gc-radius-pill);
  background: transparent;
  color: var(--gc-muted);
  font-size: var(--gc-text-sm);
  font-weight: 600;
  cursor: pointer;
}
/* The language the page is in. */
.gc-lang__button[aria-pressed="true"] {
  background: var(--gc-surface);
  color: var(--gc-ink);
  box-shadow: var(--gc-shadow-raised);
}

/* --- 5. Main column, page title, notices --------------------------------------------------- */
.gc-main {
  max-width: var(--gc-page-width);
  margin: 0 auto;
  padding: 32px var(--gc-gutter) 64px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
/* The children of a column may shrink below the width of their content. */
.gc-main > * {
  min-width: 0;
}

/* The title of a page, with a sentence under it and its buttons on the right. */
.gc-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.gc-page-head__lead {
  margin-top: 6px;
  max-width: 640px;
  color: var(--gc-muted);
}

/* A row of things that wraps: buttons next to each other, badges, filters. */
.gc-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* One-time notices from Django's messages ("Saved"), above the page's content. */
.gc-notices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gc-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--gc-radius-field);
  background: var(--gc-chip);
  color: var(--gc-ink);
  font-size: var(--gc-text-md);
}
.gc-notice__text {
  flex: 1;
  min-width: 0;
}
/* The close button: a full-size touch target that does not make the notice taller. */
.gc-notice__close {
  flex: none;
  margin: -12px -12px -12px 0;
}
.gc-notice__close button {
  width: var(--gc-tap);
  height: var(--gc-tap);
  border: 0;
  border-radius: var(--gc-radius-field);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--gc-text-lead);
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
.gc-notice__close button:hover {
  opacity: 1;
}
.gc-notice--success {
  background: var(--gc-ok-soft);
  color: var(--gc-ok-soft-ink);
}
.gc-notice--warning {
  background: var(--gc-warn-soft);
  color: var(--gc-warn-soft-ink);
}
.gc-notice--error {
  background: var(--gc-late-soft);
  color: var(--gc-late-soft-ink);
}

/* --- 6. The login page ----------------------------------------------------------------------
 * One narrow card in the middle of the page (templates/accounts/login.html).
 */
.gc-login {
  width: 100%;
  max-width: 420px;
  margin: 24px auto 0;
  gap: 20px;
}

/* --- Phone layout ---------------------------------------------------------------------------
 * The navigation leaves the top bar and becomes a bar fixed to the bottom of the screen: the
 * four main pages and "More", within reach of a thumb. The menu of "More" opens upwards.
 */
@media (max-width: 759.98px) {
  .gc-topbar__inner {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .gc-nav {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gc-line);
    background: var(--gc-header);
  }
  .gc-nav__list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    flex-wrap: nowrap;
  }
  .gc-nav__item {
    position: static; /* the menu of "More" is as wide as the bar, not as its button */
  }
  .gc-nav__link {
    min-height: 48px;
    padding: 0 2px;
    font-size: clamp(12px, 3.6vw, 14px);
    font-weight: 500;
  }
  .gc-more > summary::after {
    display: none;
  }
  .gc-more__panel {
    top: auto;
    bottom: calc(100% + 8px);
    left: 8px;
    right: 8px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  .gc-main {
    padding-top: 20px;
    /* Room for the bar at the bottom, so it never covers the end of the page. */
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
}
