/* pico-ate: a sidebar and a column, system fonts, two PICO-8 accent colours. */

:root {
  --dark-blue: #1d2b53; /* PICO-8 colour 1 */
  --red: #ff004d;       /* PICO-8 colour 8 */
  --text: #222;
  --muted: #666;
  --background: #fff;
}

body {
  max-width: var(--shell, 64em);
  margin: 0 auto;
  padding: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

/* The admin keeps the single narrow column the public page grew out of. */
body.admin {
  --shell: 40em;
}

a {
  color: var(--dark-blue);
}

a:hover,
a:focus-visible {
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
}

h1 {
  margin-bottom: 0;
  color: var(--dark-blue);
}

h2 {
  margin-top: 0;
  border-bottom: 2px solid var(--red);
  font-size: 1.25rem;
}

.subtitle {
  margin-top: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 2rem;
}

.sidebar h1 {
  font-size: 1.5rem;
}

.sidebar h1 a {
  text-decoration: none;
}

/* On a narrow screen this is the only sight of the sidebar, so it is a bar
   that says where the reader is and opens the rest. */
.toc summary {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--dark-blue);
  border-radius: 0.25rem;
  font-weight: bold;
  cursor: pointer;
}

.toc summary .current {
  color: var(--muted);
  font-weight: normal;
}

.toc[open] summary {
  margin-bottom: 0.5rem;
}

.toc nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: 0.125rem 0.5rem;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.toc a:hover,
.toc a:focus-visible {
  text-decoration: underline;
}

.toc a[aria-current="true"] {
  border-left-color: var(--red);
  font-weight: bold;
}

.count {
  color: var(--muted);
  font-size: 0.875rem;
}

@media (min-width: 48em) {
  .layout {
    grid-template-columns: 16em minmax(0, 1fr);
  }

  /* Tall enough windows keep the whole list in view; short ones scroll it. */
  .sidebar {
    position: sticky;
    top: 1rem;
    align-self: start;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  .toc summary {
    display: none;
  }
}

/* Admin filter row */

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter a {
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--dark-blue);
  border-radius: 0.25rem;
  text-decoration: none;
}

.filter a[aria-current="true"] {
  color: var(--background);
  background: var(--dark-blue);
  box-shadow: inset 0 -3px 0 var(--red);
}

ul {
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.375rem;
}

.author {
  color: var(--muted);
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--muted);
  font-size: 0.875rem;
}

/* Admin */

.admin-nav {
  display: flex;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--red);
  font-weight: bold;
}

.flash,
.form-errors {
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--dark-blue);
  background: #f2f2f2;
}

.flash-alert,
.form-errors {
  border-left-color: var(--red);
}

.table-scroll {
  overflow-x: auto;
}

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

th,
td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #ddd;
  text-align: left;
  vertical-align: top;
}

.drag-handle {
  color: #888;
  cursor: grab;
  user-select: none;
}

.hint {
  color: #555;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.actions form {
  display: inline;
}

.field legend {
  padding: 0;
  font-weight: bold;
}

.checkbox {
  display: block;
  font-weight: normal;
}

.field {
  margin-bottom: 0.75rem;
}

.field label {
  display: block;
  font-weight: bold;
}

.field input:not([type="number"]),
.field select,
.field textarea {
  box-sizing: border-box;
  width: 100%;
}

input,
select,
textarea,
button {
  font: inherit;
}

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