/* Layout fixes only: the look is that of simple.css. */

/* The lists need more width than a column of text. */
body {
  grid-template-columns: 1fr min(80rem, 95%) 1fr;
}

/* The title and, once logged in, who is logged in share the bar: side by side
   where there is room, one under the other on a narrow screen. */
body > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  /* Room above and below, so that the button keeps clear of the edges. */
  padding-block: 0.5rem;
  text-align: start;
  /* In line with the column of the page (see body above). */
  padding-inline: max(0.5rem, calc((100% - min(80rem, 95%)) / 2));
}

/* Small headings: the page is a list to look things up in. Title and login line
   have equal margins above and below, so their centres line up. */
body > header > h1 {
  margin-block: 0.25rem;
  margin-inline: 0;
  font-size: 1.4rem;
}

/* The logo is the title, and stands above the login. */
body > header > h1 > img {
  display: block;
}

#login .logo {
  display: block;
  margin: 1.5rem 0 0;
}

/* A long username wraps instead of widening the page. */
#session {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
}

#session button {
  margin: 0 0 0 0.5rem;
}

/* A quiet line at the end of the page; a long version wraps. */
body > footer {
  margin-top: 2rem;
  padding-block: 0.75rem;
  overflow-wrap: anywhere;
}

h2 {
  margin-top: 2rem;
  font-size: 1.4rem;
}

/* Hidden elements stay hidden, whatever display another rule gives them. */
[hidden] {
  display: none !important;
}

/* The facts of a node share one line, as far as it is wide enough. */
.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1.5rem;
}

article .facts h3 {
  margin: 0;
  font-size: 1.15rem;
}

article > details,
article > p,
.template {
  margin: 0.75rem 0 0;
}

/* The button of the command template follows its text. */
.template {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.ports {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A port is one line: its label takes the room left. */
.ports li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding-block: 0.25rem;
}

.ports li > :first-child {
  min-width: 7rem;
}

.ports li > :nth-child(2) {
  flex: 1 1 12rem;
  min-width: 0;
}

/* The copy button and the SSH link drawn as one are a pair of one size: simple.css
   pads a link wider than a button. The fixed width holds "Copied" too, so a
   button keeps its size when its text changes. */
article button,
article .button {
  box-sizing: border-box;
  width: 5em;
  margin: 0;
  padding: 0.25rem 0.5em;
  text-align: center;
}

article code {
  flex-basis: 100%;
}

/* Long names and commands wrap: the page never scrolls sideways. */
.facts h3,
article span,
article code {
  overflow-wrap: anywhere;
}

/* Port names and labels break after a "-" where they can, inside a word only
   where nothing else fits. */
.ports li > span:first-child,
.ports li > span:nth-child(2) {
  overflow-wrap: break-word;
}

/* Words that only a screen reader says, such as "in use by" before the names
   that follow the circle of a port in use. */
.spoken {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

figure > table {
  width: 100%;
}

@media only screen and (max-width: 40rem) {
  /* Room between the ports sets each apart with its link and button. */
  .ports li {
    padding-block: 0.75rem;
  }

  /* Name and label share a line, the ways to connect take the next. A narrower
     name column leaves a label such as a host name room to stay whole. */
  .ports li > :first-child {
    min-width: 5rem;
  }

  .ports li > :nth-child(2) {
    flex-basis: calc(100% - 6rem);
  }

  /* Who uses a port takes a line of its own, above the ways to connect. */
  .ports .in-use {
    flex-basis: 100%;
  }

  td,
  th {
    padding: 0.2rem;
    overflow-wrap: break-word;
    font-size: 0.85rem;
  }

  /* Node ids stay whole; port names break only after a "-", never inside a
     word; operators may be long and wrap anywhere. Short times then fit the
     sessions into 320px. Where they are still wider than the page, the table
     scrolls in its own frame (simple.css), not the page. */
  td:first-child {
    white-space: nowrap;
  }

  td:nth-child(2) {
    overflow-wrap: normal;
  }

  td:nth-child(3) {
    overflow-wrap: anywhere;
  }
}

/* The one colour: the filled circle of a connected node is green, at least
   3:1 against the backgrounds of simple.css in light and dark mode. */
.connected {
  color: #1a7f37;
}

@media (prefers-color-scheme: dark) {
  .connected {
    color: #3fb950;
  }

  /* simple.css dims images in dark mode; the logo has dark-mode colours. */
  .logo {
    opacity: 1;
  }
}
