/* Page furniture: the shell, navigation, forms, buttons, and messages. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

main {
  margin: 0 auto;
  max-width: 68rem;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 var(--space-4);
}

h2 {
  font-size: 1.25rem;
}

a {
  color: var(--accent);
}

/* A visible focus ring everywhere, on every interactive element: the keyboard
   is the only way some people use this. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* `hidden` means hidden. The button and input rules below set `display`,
   which would otherwise beat the browser's own `[hidden]` rule and leave a
   control that a controller hid (Copy, Set colour, the theme toggle) on
   screen. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header and navigation */

.site-header {
  background: var(--bar);
  color: var(--bar-ink);
  border-bottom: 1px solid var(--bar-line);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
  margin: 0 auto;
  max-width: 68rem;
  padding: var(--space-2) var(--space-4);
  min-height: 3.5rem;
}

.site-header :focus-visible {
  outline-color: var(--bar-ink);
}

.site-header__brand {
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--bar-ink);
}

.site-header__menu {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a,
.site-header__icon-link {
  color: var(--bar-ink-quiet);
  text-decoration: none;
}

.site-nav a:hover,
.site-header__icon-link:hover,
.user-menu__summary:hover {
  color: var(--bar-ink);
}

/* The current page is said in words to assistive technology (aria-current)
   and shown by more than colour: it is white and underlined. */
.site-nav a[aria-current="page"],
.site-header__icon-link[aria-current="page"],
.user-menu__summary--current {
  color: var(--bar-ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.4em;
}

.site-header__end {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.site-header .site-header__add {
  padding: var(--space-1) var(--space-3);
}

.site-header__icon-link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1);
}

/* The theme toggle shows the theme a click would switch to: the sun while
   dark is showing, the moon while light is. */
.site-header__theme {
  border: 0;
  background: none;
  margin-right: var(--space-2);
}

.site-header__theme-sun,
.site-header__theme[data-showing="light"] .site-header__theme-moon {
  display: block;
}

.site-header__theme-moon,
.site-header__theme[data-showing="light"] .site-header__theme-sun {
  display: none;
}

.site-header__divider {
  align-self: stretch;
  width: 1px;
  margin: var(--space-1) var(--space-3);
  background: var(--bar-ink-quiet);
  opacity: 0.5;
}

.site-header__toggle {
  display: inline-flex;
  margin-left: auto;
  padding: var(--space-1) var(--space-2);
  border-color: var(--bar-line);
  background: transparent;
  color: var(--bar-ink-quiet);
}

/* Account menu: a disclosure, so it opens and closes without JavaScript. */

.user-menu {
  position: relative;
}

.user-menu__summary {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  color: var(--bar-ink-quiet);
  cursor: pointer;
  list-style: none;
}

.user-menu__summary::-webkit-details-marker {
  display: none;
}

.user-menu__summary::after {
  content: "";
  border: 0.3em solid transparent;
  border-top-color: currentColor;
  border-bottom: 0;
}

.user-menu__items {
  position: absolute;
  right: 0;
  z-index: 1100;
  min-width: 11rem;
  margin: var(--space-2) 0 0;
  padding: var(--space-2) 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 0.15);
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: var(--space-1) var(--space-4);
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.user-menu__item:hover {
  background: var(--page);
}

.user-menu__separator {
  margin: var(--space-2) 0;
  border-top: 1px solid var(--line);
}

/* Narrow screens: with JavaScript, the bar folds behind the menu button and
   opens as a column; without it, everything simply wraps. */
@media (min-width: 48rem) {
  .site-header__toggle {
    display: none;
  }
}

@media (max-width: 47.99rem) {
  .site-header--collapsible .site-header__menu {
    display: none;
  }

  .site-header--collapsible .site-header__menu--open {
    display: flex;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: var(--space-2);
  }

  .site-header--collapsible .site-nav ul {
    flex-direction: column;
  }

  .site-header--collapsible .site-header__end {
    flex-wrap: wrap;
    margin-left: 0;
  }

  .user-menu__items {
    left: 0;
    right: auto;
  }
}

/* Buttons and forms */

.button,
input[type="submit"],
button {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.button--primary,
input[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button--quiet {
  background: transparent;
}

/* Present but not usable yet, like Clear before there is a filter. A link
   is disabled by taking its `href` away and saying so with `aria-disabled`. */
.button:disabled,
.button[aria-disabled="true"] {
  color: var(--ink-quiet);
  opacity: 0.6;
  cursor: default;
}

.button--danger {
  background: transparent;
  border-color: var(--alert);
  color: var(--alert);
}

.field {
  margin-bottom: var(--space-4);
}

.field label,
.field-group legend {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="search"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea,
.field trix-editor {
  width: 100%;
  max-width: var(--measure);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

/* Browsers keep a select's line height at `normal` whatever the page sets,
   which leaves it a few pixels shorter than an input beside it. So it is
   given an input's height outright: one line of text, its padding, and its
   border. */
.field select {
  min-height: calc(1.5em + 2 * var(--space-2) + 2px);
}

.field--narrow input {
  max-width: 8rem;
}

.field__hint {
  margin: var(--space-1) 0 0;
  color: var(--ink-quiet);
  font-size: 0.875rem;
}

.field-group {
  margin: 0 0 var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.checkbox {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  margin-right: var(--space-4);
  font-weight: 400;
}

/* Panels, facts, and tables, shared by the account and administration pages */

.panel {
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel > :last-child,
.panel > form > :last-child {
  margin-bottom: 0;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.page-header h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.back-link {
  margin: 0 0 var(--space-2);
  font-size: 0.875rem;
}

.back-link a::before {
  content: "← ";
}

/* Fields side by side where there is room. */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 var(--space-4);
}

/* A term above its value, the pairs side by side where there is room. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3) var(--space-5);
  margin: 0 0 var(--space-4);
}

.facts dt {
  color: var(--ink-quiet);
  font-size: 0.875rem;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts--inline {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  margin: 0;
}

/* A value shown in full to be copied: a token, or a one-time link. */
.copyable {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin: 0 0 var(--space-4);
}

.copyable code {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.table-wrapper {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.data-table thead th {
  color: var(--ink-quiet);
  font-size: 0.875rem;
  font-weight: 600;
}

.data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.data-table tbody th {
  font-weight: 400;
}

/* A state said in a word, with a dot that is only decoration. */
.status {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  font-size: 0.875rem;
}

.status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--notice);
}

.status--off {
  color: var(--ink-quiet);
}

.status--off::before {
  background: var(--ink-quiet);
}

/* Messages */


.flash,
.errors,
.warning,
.warnings,
.home-prompt,
.filters__error,
.field-error {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.flash--notice {
  background: var(--notice-surface);
  border-color: var(--notice);
}

.flash--alert,
.errors,
.filters__error,
.field-error {
  background: var(--alert-surface);
  border-color: var(--alert);
  color: var(--alert);
}

.field-error {
  margin: var(--space-1) 0 0;
  padding: var(--space-1) var(--space-2);
  font-size: 0.875rem;
}

.errors h2 {
  margin-top: 0;
  font-size: 1rem;
}

.warnings,
.home-prompt {
  background: var(--surface);
}

.note,
.empty-state {
  color: var(--ink-quiet);
  max-width: var(--measure);
}
