/* Valhal. One bold element: the landing page's doorways, each painted in its
   site's own colours. Everything else is quiet stone and ink. */

:root {
  --stone: #e4e7e2;
  --stone-2: #d7dcd6;
  --paper: #f2f4f0;
  --rule: #bfc7c0;
  --ink: #1f2729;
  --iron: #56626a;
  --brass: #8c6d2e;
  --brass-ink: #6b5222;
  --error: #9e3128;
  --ok: #3d6a4e;
  --run: #2c5a78;

  --display: "IM Fell English", Georgia, serif;
  --text: "Source Serif 4", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.65rem;
  --step-3: 2.4rem;

  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--stone);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--text);
  font-variant-numeric: oldstyle-nums proportional-nums;
}

h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; margin: 0 0 0.5em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); margin-top: 1.6em; }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1em; }

a { color: var(--ink); text-decoration-color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--brass-ink); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; border-radius: 2px; }

.mono { font-family: var(--mono); font-size: 0.86em; font-variant-numeric: normal; }
.muted { color: var(--iron); }
.help { color: var(--iron); font-size: var(--step--1); margin: 0.35em 0 0; max-width: 62ch; }
.lede { color: var(--iron); max-width: 64ch; font-size: var(--step-1); line-height: 1.45; }
.empty { color: var(--iron); font-style: italic; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: 0.5rem 1rem; z-index: 10; }

/* Public pages ----------------------------------------------------------- */

.public { display: flex; flex-direction: column; min-height: 100vh; }
.public main { flex: 1; width: min(76rem, 100% - 3rem); margin: 0 auto; }

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  width: min(76rem, 100% - 3rem); margin: 0 auto; padding: 1.25rem 0;
}
.wordmark { font-family: var(--display); font-size: 1.7rem; text-decoration: none; color: var(--ink); }

.hero { padding: clamp(2rem, 8vw, 6rem) 0 clamp(2rem, 6vw, 4rem); }
.hero-title {
  font-size: clamp(5rem, 17vw, 12.5rem);
  line-height: 0.82;
  letter-spacing: -0.02em;
  margin: 0 0 0.25em -0.04em;
}
.hero-text { font-size: var(--step-1); max-width: 40ch; color: var(--iron); line-height: 1.45; }
.hero--small .hero-title { font-size: clamp(3.5rem, 10vw, 7rem); }

.doors {
  list-style: none; margin: 0 0 4rem; padding: 0;
  display: grid; gap: 2.5rem 2rem;
  grid-template-columns: repeat(auto-fill, minmax(min(14.5rem, 40vw), 1fr));
}
.door { --door-bg: var(--ink); --door-fg: var(--stone); --door-accent: var(--brass); }
.door-link { display: block; text-decoration: none; color: var(--ink); }
.door-arch {
  position: relative; display: grid; place-items: end center;
  aspect-ratio: 5 / 7;
  padding-bottom: 14%;
  background: var(--door-bg);
  border: 3px solid var(--door-accent);
  border-radius: 999px 999px 3px 3px;
  overflow: hidden;
  isolation: isolate;
}
/* Light through the doorway when it is chosen. */
.door-arch::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 70% at 50% 100%, var(--door-accent), transparent 70%);
  opacity: 0;
  transition: opacity 0.35s ease-out;
}
.door-link:hover .door-arch::after, .door-link:focus-visible .door-arch::after { opacity: 0.55; }
.door-logo { width: 38%; height: auto; max-height: 40%; object-fit: contain; }
.door-title { display: block; font-family: var(--display); font-size: 1.75rem; line-height: 1.1; margin-top: 0.7rem; }
.door-link:hover .door-title { color: var(--brass-ink); }
.door-text { margin: 0.3rem 0 0.2rem; color: var(--ink); max-width: 34ch; }
.door-meta { font-size: var(--step--1); color: var(--iron); margin: 0; }
.empty--hall { font-size: var(--step-1); }

.saga { max-width: 46rem; padding: 2rem 0 4rem; }
.saga-head { border-left: 6px solid var(--door-accent, var(--brass)); padding-left: 1.5rem; margin-bottom: 2rem; }
.saga-logo { width: 5rem; height: 5rem; object-fit: contain; background: var(--door-bg, transparent); border-radius: 999px 999px 3px 3px; padding: 0.6rem; }
.saga h1 { font-size: clamp(2.6rem, 7vw, 4.5rem); }
.scenes { padding-left: 1.4rem; columns: 2 16rem; column-gap: 2rem; }
.scenes li { break-inside: avoid; margin-bottom: 0.3rem; }
.button--door { background: var(--door-bg, var(--brass)); color: var(--door-fg, #fff); border-color: var(--door-accent, var(--brass)); }

.foot { width: min(76rem, 100% - 3rem); margin: 0 auto; padding: 2rem 0; border-top: 1px solid var(--rule); color: var(--iron); font-size: var(--step--1); }

.signin { max-width: 24rem; padding: 3rem 0 5rem; }

/* Admin ------------------------------------------------------------------ */

.admin { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--stone-2); border-right: 1px solid var(--rule);
  padding: 1.4rem 1.1rem; display: flex; flex-direction: column; gap: 0.5rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .wordmark { font-size: 2rem; margin-bottom: 0.8rem; }
.nav { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 0.3rem 0.6rem; text-decoration: none; border-left: 3px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav a[aria-current="page"] { border-left-color: var(--brass); background: var(--stone); }
.nav a:hover { background: var(--stone); }
.nav-heading { font-family: var(--text); font-size: var(--step--1); font-weight: 600; color: var(--iron); margin: 1.4rem 0 0.3rem 0.75rem; }
.nav-add { color: var(--brass-ink); }
.whoami { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: var(--step--1); display: grid; gap: 0.25rem; }

.content { padding: 2rem clamp(1.25rem, 4vw, 3.5rem) 5rem; max-width: 74rem; }
.pagehead { margin-bottom: 1.5rem; }
.pagehead .lede { margin: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 0 1.6rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.6rem; }
.tabs a { padding: 0.5rem 0; text-decoration: none; color: var(--iron); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }
.tabs a:hover { color: var(--ink); }

.table { width: 100%; border-collapse: collapse; font-size: 0.97rem; font-variant-numeric: lining-nums tabular-nums; }
.table th { text-align: left; font-weight: 600; color: var(--iron); font-size: var(--step--1); padding: 0.4rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--ink); }
.table td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tr.is-current td { background: var(--paper); }
.table td:first-child, .table th:first-child { padding-left: 0.25rem; }

.state { white-space: nowrap; }
.state::before { content: ""; display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; margin-right: 0.4em; background: currentColor; vertical-align: 0.08em; }
.state--queued { color: var(--iron); }
.state--running { color: var(--run); }
.state--running::before { animation: pulse 1.4s ease-in-out infinite; }
.state--succeeded { color: var(--ok); }
.state--failed { color: var(--error); }
.state--canceled { color: var(--iron); font-style: italic; }
@keyframes pulse { 50% { opacity: 0.25; } }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.5rem; margin: 0 0 1.5rem; }
.facts dt { color: var(--iron); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 2rem; align-items: start; }
.aside { background: var(--paper); border: 1px solid var(--rule); padding: 1rem 1.1rem; border-radius: 3px; }

.flash { padding: 0.7rem 1rem; border-left: 4px solid var(--ok); background: var(--paper); max-width: 70ch; }
.flash--error { border-left-color: var(--error); color: var(--error); }
.public > .flash { width: min(76rem, 100% - 3rem); margin: 0 auto 1rem; }

.problems { border-left: 4px solid var(--error); padding-left: 1rem; }
.problems h2 { margin-top: 0; }
.danger { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.secret { background: var(--paper); border: 2px solid var(--brass); padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.secret h2 { margin-top: 0; }
.secret input { width: 100%; }

/* Forms */
.stack { display: grid; gap: 1rem; justify-items: start; }
.stack > .formrow, .stack > fieldset { width: 100%; }
.narrow { max-width: 34rem; }
.formrow label, fieldset legend { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
fieldset { border: 0; padding: 0; margin: 0; }
.check, .formrow .check { display: flex; gap: 0.5rem; align-items: baseline; font-weight: 400; font-size: var(--step-0); margin: 0.25rem 0; }
.check input { accent-color: var(--brass); }

input:not([type=checkbox]):not([type=hidden]), select, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--iron); border-radius: 3px; padding: 0.45rem 0.6rem; width: 100%;
}
textarea { line-height: 1.5; resize: vertical; }
.editor textarea, textarea#domains { font-family: var(--mono); font-size: 0.9rem; tab-size: 2; }
.affix { display: flex; align-items: center; gap: 0.3rem; }
.affix span { color: var(--iron); white-space: nowrap; }

.inline { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin-bottom: 1.25rem; }
.inline input:not([type=checkbox]):not([type=hidden]), .inline select { width: auto; min-width: 10rem; flex: 0 1 auto; }
.inline input[type=search] { min-width: min(26rem, 100%); }
.inline label:not(.check) { font-weight: 600; font-size: 0.95rem; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.8rem 1.2rem; align-items: start; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form > .button { justify-self: start; }

.editor { display: grid; gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }

.button {
  font: 600 0.95rem/1.2 var(--text); cursor: pointer;
  background: var(--brass); color: #fff; border: 1px solid var(--brass);
  padding: 0.55rem 1.05rem; border-radius: 3px; text-decoration: none; display: inline-block;
}
.button:hover { background: var(--brass-ink); border-color: var(--brass-ink); color: #fff; }
.button--quiet { background: transparent; color: var(--ink); border-color: var(--iron); }
.button--quiet:hover { background: var(--stone-2); color: var(--ink); border-color: var(--ink); }
.button--danger { background: var(--error); border-color: var(--error); }
.button--danger:hover { background: #7e271f; border-color: #7e271f; }
.button[disabled] { opacity: 0.55; cursor: progress; }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--brass); text-underline-offset: 0.18em; cursor: pointer; }
.linklike:hover { color: var(--brass-ink); }

/* Pipeline */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.step { counter-increment: step; position: relative; padding: 0 0 1.75rem 3rem; border-left: 1px solid var(--rule); margin-left: 1rem; }
.step:last-child { border-left-color: transparent; }
.step::before {
  content: counter(step); position: absolute; left: -1rem; top: -0.15rem;
  width: 2rem; height: 2rem; display: grid; place-items: center;
  font: 600 0.95rem/1 var(--text); font-variant-numeric: lining-nums; background: var(--stone); border: 1px solid var(--iron); border-radius: 50%;
}
.step h2 { margin: 0 0 0.3rem; font-size: var(--step-1); }
.step form { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.step .grid-form { display: grid; }

/* Search */
.hits { list-style: none; padding: 0; margin: 0 0 2rem; }
.hit { border-bottom: 1px solid var(--rule); padding: 0.9rem 0; }
.hit blockquote { margin: 0.3rem 0 0.6rem; padding-left: 1rem; border-left: 3px solid var(--stone-2); max-width: 70ch; }
.hit-source { margin: 0; font-weight: 600; }
.hit .inline { margin: 0; }

.files { columns: 3 14rem; column-gap: 2rem; padding-left: 1.2rem; }
.files li { break-inside: avoid; margin-bottom: 0.2rem; }
.hosts { columns: 2 18rem; padding-left: 1.2rem; }

.disclose { margin-top: 1rem; }
.disclose summary { cursor: pointer; color: var(--brass-ink); font-weight: 600; }
.disclose[open] summary { margin-bottom: 1rem; }

/* Job output */
.jobbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.jobbar p { margin: 0; }
.log {
  background: var(--ink); color: #dfe4df; font: 0.84rem/1.55 var(--mono);
  padding: 1rem 1.2rem; border-radius: 3px; min-height: 8rem; max-height: 70vh;
  overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.log:empty::before { content: "Waiting for output…"; color: #9aa49d; }

.step > p:first-of-type { margin-bottom: 0.6rem; }
.content > .help { margin-bottom: 1.5rem; }
.sitedir { display: block; font-size: var(--step--1); margin-top: 0.2rem; }

/* Small screens */
@media (max-width: 52rem) {
  .admin { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sidebar .nav { display: flex; flex-wrap: wrap; gap: 0.1rem 0.4rem; }
  .split { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 0 0; }
  .facts dd { margin-bottom: 0.6rem; }
  .table { display: block; overflow-x: auto; }
}

@media (max-width: 30rem) {
  .doors { gap: 1.75rem 1rem; }
  .door-title { font-size: 1.35rem; }
  .door-text { font-size: var(--step--1); }
  .door-arch { border-width: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
