/* =========================
   The shell of every page, as in a terminal: one bar on top, the tabs at its left, who is
   logged in (or the login), the language and the theme at its right. It stays on top of the
   screen, on a phone too.
   Its colors are tokens of theme.css; its sizes, the scales of theme.css.
========================= */
/* The height of the bar, measured by shell.js once drawn (two lines on a phone): what stays
   under it is placed from it */
:root {
  --shell-height: 45px;
}

/* The keyboard focus never hides under the bar (2.4.11). Safari on a phone enlarges a small text
   by itself, which pushed the i of a trace out of its card: the page keeps the sizes it sets; a
   pinch still zooms */
html {
  scroll-padding-top: calc(var(--shell-height) + 11px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* The link that passes the bar: off the screen until Tab reaches it, first of the page, then
   over the bar at its left (2.4.1) */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius);
  background: var(--action);
  color: var(--on-action);
  font-family: var(--font-mono);
  font-size: var(--size-2);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-4)));
}

.skip-link:focus {
  transform: none;
}

/* A session that ended, told under the bar until a new login: its words, then the command to log
   in again, under them on a phone */
.shell-notice {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: calc(-1 * var(--space-3)) var(--space-3) var(--space-3);
}

.shell-notice[hidden] {
  display: none;
}

/* Over the commands of the generator, under the tooltips */
.shell-top {
  position: sticky;
  top: 0;
  z-index: 10;
  align-self: stretch;
  display: flex;
  align-items: center;
  background: var(--surface);
  font-family: var(--font-mono);
  gap: var(--space-2);
  min-height: 44px;
  margin-bottom: var(--space-4);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--card-border);
  font-size: var(--size-2);
}

.shell-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  /* The logo alone on a phone: a target of 44 px all the same (2.5.8) */
  min-width: 44px;
  margin-right: var(--space-2);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.shell-name img {
  width: 22px;
  height: 22px;
}

.shell-tabs {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
}

.shell-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.shell-tabs a:hover {
  color: var(--text);
}

/* The current tab: written in the text color and underlined in the ink of the logo */
.shell-tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

/* At the right of the tabs, never squeezed */
.shell-status {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
  font-size: var(--size-1);
}

/* A sign or two letters still make a target of at least 24 px (2.5.8) */
.shell-segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.shell-segment:hover {
  border-color: var(--card-border);
}

/* Who is logged in, in the color of the user of the prompt */
.shell-user {
  color: var(--terminal-user);
  font-weight: 700;
}

/* A narrow phone: the name of the app is read, not written, so that every tab fits */
@media (max-width: 400px) {
  .shell-name span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .shell-tabs a {
    padding: 0 var(--space-2);
  }

  .shell-segment {
    padding: 0 var(--space-1);
  }

  /* The logo and the status share their line, a visitor's login and coffee too: 320 px left the
     logo alone on a line of its own */
  .shell-top {
    column-gap: 0;
  }

  .shell-name {
    margin-right: 0;
  }

  .shell-status {
    gap: 0;
  }
}

/* A phone or a narrow tablet: the tabs on a line of their own, under the name and the status,
   spread over it, and on two lines when they still do not hold: a bar never slides sideways; from
   768 px the bar of the admin holds on one line */
@media (max-width: 767px) {
  .shell-top {
    flex-wrap: wrap;
    row-gap: 0;
  }

  .shell-tabs {
    order: 1;
    flex: 1 1 100%;
  }

  .shell-tabs a {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* A phone, logged in: the name alone, without its host, cut when long; it is the only way to the
   account, which has no tab */
@media (max-width: 480px) {
  .shell-host {
    display: none;
  }

  .shell-whoami {
    max-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The command of an ended session under its words, the whole width */
  .shell-notice .cmd {
    flex: 1 1 100%;
    justify-content: center;
  }
}

/* The sign-ups waiting for the admin: their number on its tab, in the colors of a warning */
.shell-badge {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--warning-surface);
  color: var(--warning-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

/* A closed site: the content hidden while the state of the site is read, never longer */
html.site-pending #content {
  visibility: hidden;
}

/* The page of a closed site: its message and the login, alone, centered whatever grid the page
   has */
.site-closed {
  grid-column: 1 / -1;
  align-self: start;
  justify-self: center;
  width: 100%;
  max-width: 40rem;
  margin: var(--space-4) auto;
}

.site-closed .site-message {
  white-space: pre-line;
}

/* For the admin, a closed site said on top of each page */
.site-note {
  margin: 0 0 var(--space-2);
}
