/* One plain stylesheet for every page. No framework. Colors are set once here and changed for dark mode below. */

:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #1b1f24;
  --muted: #5b6470;
  --border: #d5d9df;
  --link: #1f5fbf;
  --button-bg: #1f5fbf;
  --button-text: #ffffff;
  --button-hover: #184c99;
  --notice-bg: #eaf3ea;
  --notice-border: #9cc79c;
  --alert-bg: #fbeceb;
  --alert-border: #e0a3a0;
  --focus: #f0a500;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1e2227;
    --text: #e6e8eb;
    --muted: #a0a8b3;
    --border: #3a4049;
    --link: #8ab4f8;
    --button-bg: #3b74d1;
    --button-text: #ffffff;
    --button-hover: #4c84e0;
    --notice-bg: #1d2d1f;
    --notice-border: #3f6b44;
    --alert-bg: #33201f;
    --alert-border: #7a3f3b;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1rem;
}

main.wrap {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

/* Header and footer */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  padding-top: 1rem;
  padding-bottom: 1.5rem;
}

/* Text */

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 1.5rem 0 0.75rem;
}

h1 {
  font-size: 1.6rem;
  margin-top: 0.5rem;
}

h2 {
  font-size: 1.2rem;
}

p,
ul,
ol {
  margin: 0 0 1rem;
  max-width: 70ch;
}

li {
  margin-bottom: 0.4rem;
}

li > ul,
li > ol {
  margin-top: 0.4rem;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Messages after an action */

[role="status"],
[role="alert"] {
  padding: 0.6rem 0.9rem;
  border: 1px solid;
  border-radius: 6px;
  max-width: none;
}

[role="status"] {
  background: var(--notice-bg);
  border-color: var(--notice-border);
}

[role="alert"] {
  background: var(--alert-bg);
  border-color: var(--alert-border);
}

/* Tables. Wide tables scroll inside their own box, so the page itself never scrolls sideways. */

.table-scroll {
  overflow-x: auto;
  margin: 0 0 1rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface);
  font-weight: 600;
}

/* Forms and buttons */

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

td label {
  font-weight: normal;
}

input[type="text"],
input[type="email"],
input:not([type]),
select,
textarea {
  width: 100%;
  max-width: 32rem;
  padding: 0.45rem 0.55rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

td input[type="text"],
td select {
  max-width: none;
  min-width: 10rem;
}

button,
input[type="submit"] {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button-bg);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: var(--button-hover);
}

form.button_to {
  display: inline-block;
  margin: 0.25rem 0.5rem 0.25rem 0;
}

td form.button_to {
  margin: 0;
}

td button {
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
}

@media (max-width: 40rem) {
  h1 {
    font-size: 1.35rem;
  }

  input[type="text"],
  input[type="email"],
  input:not([type]),
  select,
  textarea {
    max-width: none;
  }

  button,
  input[type="submit"] {
    width: 100%;
  }

  form.button_to {
    display: block;
    margin-right: 0;
  }

  td button {
    width: auto;
  }
}

/* On phones, tables marked .stack show each row as a block, with each cell's column name above its value. */
@media (max-width: 40rem) {
  table.stack,
  .stack tbody,
  .stack tr,
  .stack td {
    display: block;
    width: 100%;
  }

  .stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .stack tr {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    padding: 0.35rem 0;
  }

  .stack td {
    border: none;
    padding: 0.3rem 0.75rem;
  }

  .stack td:empty {
    display: none;
  }

  .stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
  }

  .stack td select,
  .stack td input[type="text"] {
    min-width: 0;
  }
}
