/* The look every server-rendered CEagle site shares: accounts, domains and
   roost all link this before their own app.css.

   Plain CSS, no build step, no JavaScript — the CSP for these pages allows a
   stylesheet from self and nothing else.

   Three rules hold the whole thing together:
     1. A nav rail on the left; the content fills the rest of the window.
     2. Nothing is a card. Rules and spacing separate things, not boxes,
        shadows or rounded corners.
     3. Grey does the work. The accent marks one thing at a time — where you
        are, what the primary action is, what has focus. Colour otherwise
        only ever means state. */

:root {
  color-scheme: light dark;

  --rail-width: 14rem;

  --canvas: #ffffff;
  --sunken: #fafafa;
  --hover: #f4f4f5;

  --rule: #e4e4e5;
  --rule-strong: #c9c9cb;

  --ink: #131315;
  --muted: #67676c;
  --faint: #98989e;

  /* The one accent. Two shades: one that reads on the canvas, one to fill. */
  --accent: #a8620a;
  --accent-fill: #e0900d;
  --accent-wash: #fdf5e7;

  --ok: #1a7f45;
  --warn: #8a6100;
  --bad: #bd2f28;

  /* Solid buttons are ink, not accent: the accent stays scarce. */
  --solid: #131315;
  --solid-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0c0c0d;
    --sunken: #121213;
    --hover: #191919;

    --rule: #262628;
    --rule-strong: #3e3e42;

    --ink: #ededee;
    --muted: #9b9ba1;
    --faint: #6d6d73;

    --accent: #f0a83a;
    --accent-fill: #f0a83a;
    --accent-wash: #23190a;

    --ok: #48b96b;
    --warn: #d7a53c;
    --bad: #ef6c66;

    --solid: #ededee;
    --solid-ink: #0c0c0d;
  }
}

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

code,
pre,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --------------------------------------------------------------- the frame */

.shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  min-height: 100dvh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  border-right: 1px solid var(--rule);
  background: var(--sunken);
}

.rail .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.rail .brand::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  flex: none;
  background: var(--accent-fill);
}

.rail nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 0.35rem 0;
  overflow-y: auto;
}

.rail nav a {
  padding: 0.35rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.rail nav a:hover {
  background: var(--hover);
  color: var(--ink);
}

/* Where you are: the only place the accent appears in the rail. */
.rail nav a.active {
  border-left-color: var(--accent-fill);
  color: var(--ink);
  font-weight: 550;
}

.rail .who {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.86rem;
}

.rail .who form {
  display: inline;
}

.rail .who button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.rail .who button:hover {
  color: var(--ink);
}

.rail .who a {
  color: var(--muted);
}

.rail .who a:hover {
  color: var(--ink);
}

.page {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 1.5rem 1.75rem 3.5rem;
}

/* Prose stays readable even though the column does not end. */
main p,
main li,
.lead {
  max-width: 68ch;
}

footer.site {
  border-top: 1px solid var(--rule);
  padding: 0.85rem 1.75rem;
  color: var(--faint);
  font-size: 0.84rem;
}

footer.site p {
  max-width: none;
  margin: 0;
}

/* ---------------------------------------------------------------- the text */

h1 {
  margin: 0 0 0.2rem;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

h2 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

h3 {
  margin: 0 0 0.2rem;
  font-size: 0.98rem;
  font-weight: 600;
}

p {
  margin: 0 0 0.9rem;
}

ol,
ul {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
}

li {
  margin-bottom: 0.2rem;
}

.lead {
  margin-bottom: 1.6rem;
  color: var(--muted);
}

.meta,
small.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

small.hint {
  display: block;
  margin-top: 0.3rem;
}

code {
  color: inherit;
}

pre {
  margin: 0 0 1rem;
}

code.secret {
  display: block;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--sunken);
  word-break: break-all;
  margin-bottom: 0.7rem;
}

/* -------------------------------------------------------------- the blocks */

/* A section, not a card: a rule above it and room around it. */
section.card {
  padding-top: 1.3rem;
  margin-top: 1.3rem;
  border-top: 1px solid var(--rule);
}

section.card:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

section.card > :last-child {
  margin-bottom: 0;
}

.list-item {
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
}

.list-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.list-item h3 a {
  text-decoration: none;
}

.list-item h3 a:hover {
  color: var(--accent);
}

dl.kv {
  display: grid;
  grid-template-columns: minmax(6rem, max-content) 1fr;
  gap: 0.25rem 1.5rem;
  margin: 0 0 1rem;
  font-size: 0.94rem;
}

dl.kv dt {
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: 0.94rem;
}

th,
td {
  padding: 0.4rem 1.25rem 0.4rem 0;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}

th {
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Only a column heading gets a rule; a row label is just a label. */
thead th {
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}

table.listing td {
  border-bottom: 1px solid var(--rule);
}

table.listing tbody tr:hover td {
  background: var(--hover);
}

table.listing th:last-child,
table.listing td:last-child {
  padding-right: 0;
  text-align: right;
  white-space: nowrap;
}

/* ------------------------------------------------------------ state, plain */

/* No pills. State is a word in the colour that means it. */
.status,
.tag,
.lang {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.status.active,
.status.released,
.tag.on,
.lang.basic {
  color: var(--ok);
}

.status.disabled,
.status.failed {
  color: var(--bad);
}

.status.building,
.status.pending {
  color: var(--warn);
}

.lang.asm {
  color: var(--accent);
}

.lang.lib {
  color: var(--warn);
}

/* ------------------------------------------------------------- the notices */

.notice,
.error {
  padding: 0.6rem 0.85rem;
  margin: 0 0 1.4rem;
  max-width: 68ch;
  border-left: 2px solid var(--accent-fill);
  background: var(--accent-wash);
  font-size: 0.94rem;
}

.error {
  border-left-color: var(--bad);
  background: none;
  color: var(--bad);
}

/* --------------------------------------------------------------- the forms */

.field {
  margin-bottom: 0.9rem;
  max-width: 30rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.94rem;
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--rule-strong);
  border-radius: 0;
}

select {
  max-width: 16rem;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: -2px;
}

textarea {
  height: 7rem;
  resize: vertical;
}

input[type="checkbox"] {
  accent-color: var(--accent-fill);
}

label input[type="checkbox"] {
  width: auto;
  margin-right: 0.4rem;
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-weight: 400;
}

label.check input {
  width: auto;
  margin: 0;
}

/* ------------------------------------------------------------- the buttons */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--solid-ink);
  background: var(--solid);
  border: 1px solid var(--solid);
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  opacity: 0.85;
}

button.secondary,
.button.secondary {
  color: var(--ink);
  background: none;
  border-color: var(--rule-strong);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--hover);
  border-color: var(--ink);
  opacity: 1;
}

button.danger,
.button.danger {
  color: var(--bad);
  background: none;
  border-color: var(--bad);
}

button.danger:hover,
.button.danger:hover {
  color: var(--solid-ink);
  background: var(--bad);
  opacity: 1;
}

button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* A button in a table is a row action, quieter than the page action. */
td button,
td .button {
  padding: 0.15rem 0.55rem;
  font-size: 0.85rem;
  color: var(--ink);
  background: none;
  border-color: var(--rule-strong);
}

td button:hover,
td .button:hover {
  background: var(--hover);
  border-color: var(--ink);
  opacity: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.actions form {
  display: inline;
}

.actions a:not(.button) {
  color: var(--muted);
  font-size: 0.9rem;
}

/* -------------------------------------------------------- narrow displays */

@media (max-width: 52rem) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .rail nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 0.5rem 0.4rem;
  }

  .rail nav a {
    padding: 0.25rem 0.5rem;
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }

  .rail nav a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent-fill);
  }

  .rail .brand {
    padding: 0.7rem 1rem 0.4rem;
  }

  .rail .who {
    border-top: 0;
    padding: 0 1rem 0.7rem;
  }

  main {
    padding: 1.25rem 1rem 2.5rem;
  }

  footer.site {
    padding: 0.85rem 1rem;
  }
}
