/*
 * Yggdrasill theme for the AgentConnect directory (agents.yggdrasill.network).
 *
 * Styles the markup of agent-connect directory/src/render.rs; the selectors
 * follow its output (header.site, .site-name, .kicker, the search form,
 * ul.results, article.listing, .door, .card-text, .empty, #about, #listed,
 * #api, footer.site, .note, .warning). The
 * directory serves this file at /static/directory.css when
 * AC_DIRECTORY_STYLESHEET points at it.
 *
 * Its CSP is default-src 'none'; style-src 'self'; img-src 'self', plus
 * font-src 'self' when AC_DIRECTORY_FONT_DIR is set: no images and no other
 * URLs. The fonts are the site's own, subset (scripts/directory-fonts.sh)
 * and served by the directory from AC_DIRECTORY_FONT_DIR at
 * /static/fonts/<file>. Without that directory the system stacks after each
 * face take over. Dark only, in the site's palette (src/styles/site.css; the
 * shared tokens must keep the same values, which tests/output.test.mjs
 * checks).
 */

@font-face {
  font-family: 'Chakra Petch';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/chakra-petch-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/static/fonts/space-grotesk-300.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/jetbrains-mono-400.woff2') format('woff2');
}

:root {
  /* Northern night, as in site.css */
  --night: #0a0f14;
  --deep: #0f161c;
  --line: #1c2830;
  --verdigris: #35504e;
  --birch: #e8e3d6;
  --mist: #93a0a8;
  --aurora: #8fe0c6;
  --frost: #9fb8c8;
  --birch-dim: #c9c4b8;
  --rule: #2c3d44;

  /* Headings and the wordmark; a condensed, technical system sans after it */
  --font-display: 'Chakra Petch', 'Bahnschrift', 'DIN Alternate', 'Barlow Condensed',
    'Roboto Condensed', 'Arial Narrow', system-ui, sans-serif;
  --display-weight: 500;
  /* Body */
  --font-body: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif;
  --body-weight: 300;
  /* Labels, status, commands */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, Consolas,
    'Liberation Mono', monospace;

  --measure: 1200px;
  --gutter: clamp(16px, 5vw, 32px);
  --radius: 2px;
  --target: 44px;

  color-scheme: dark;
  background: var(--night);
}

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

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

body {
  margin: 0;
  background: var(--night);
  color: var(--birch);
  font-family: var(--font-body);
  font-weight: var(--body-weight);
  font-size: 17px;
  line-height: 1.6;
}

a {
  color: var(--birch);
  text-decoration-color: var(--rule);
  text-underline-offset: 4px;
}
a:hover {
  color: var(--aurora);
  text-decoration-color: var(--aurora);
}
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--aurora);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ---------- Research preview strip ---------- */

/* The notice above the header, as the strip on the Heimdall board: a hollow
   diamond, "Research preview" in frost (the notice's <strong>), the rest in
   mist. */
.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  align-items: center;
  min-height: var(--target);
  margin: 0;
  padding: 0 max(var(--gutter), calc((100% - var(--measure)) / 2 + var(--gutter)));
  background: var(--deep);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--mist);
}
.notice::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  margin-right: -10px;
  border: 1px solid var(--frost);
  transform: rotate(45deg);
}
.notice strong {
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--frost);
}
.notice a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--birch-dim);
}
.notice a:hover {
  color: var(--aurora);
}

/* ---------- Shell ---------- */

header.site,
main,
footer.site {
  max-width: var(--measure);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

header.site {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  padding-bottom: 24px;
}

.site-name {
  display: inline-flex;
  gap: 14px;
  align-items: center;
  min-height: var(--target);
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: var(--display-weight);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--birch);
}
/* A lit node of the tree: decoration, no text. */
.site-name::before {
  content: '';
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--aurora);
  box-shadow: 0 0 0 5px rgb(143 224 198 / 0.14);
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target);
  min-width: var(--target);
  text-decoration: none;
}
/* The operator's home link (AC_DIRECTORY_HOME) leaves the directory. */
nav a[href^='https://'] {
  color: var(--mist);
}
nav a[href^='https://']:hover {
  color: var(--aurora);
}
nav a[href^='https://']::after {
  content: ' ↗';
  white-space: pre;
}

main {
  display: flex;
  flex-direction: column;
  padding-bottom: 32px;
}

main a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

/* ---------- Title ---------- */

h1 {
  margin-top: 40px;
  font-family: var(--font-display);
  font-size: clamp(34px, 8.5vw, 104px);
  font-weight: var(--display-weight);
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* The listing page: the card follows the title. */
main > h1 + .listing {
  margin-top: 32px;
}

/* The kicker names the software above the title, which names the instance. */
.kicker {
  margin-top: 40px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--aurora);
}
.kicker + h1 {
  margin-top: 22px;
}

/* The description under the title: body text, not a lore line. */
main > h1 + p {
  margin-top: 22px;
  max-width: 34em;
  font-size: 21px;
  line-height: 1.5;
  color: var(--birch-dim);
}

/* ---------- Sections ---------- */

main > section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 48px;
  padding-bottom: 8px;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(30px, 3.6vw, 44px);
  font-weight: var(--display-weight);
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

/* Search and the list read as labels, as on the board. */
#search-h,
#results-h {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.18em;
  color: var(--mist);
}

#about,
#listed,
#api,
main > section:has(#details-h) {
  margin-top: 40px;
  padding-top: 56px;
  border-top: 1px solid var(--line);
}

#about p,
#listed p,
#listed li {
  max-width: 40em;
  font-size: 18px;
  color: var(--birch-dim);
}
#listed p code,
#listed li code {
  color: var(--frost);
}

/* About listings: what a listing proves and what it doesn't, side by side
   (stacked under 640px), each under a mono label; then how a knock works. */
.about-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 56px;
}
.about-cols > div {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
#about p.label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aurora);
}
#about .about-cols > div + div p.label {
  color: var(--frost);
}
#about > p.label {
  margin-top: 16px;
}

/* The knock, step by step: numbered, each under a rule. */
ol.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
ol.steps li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 17px;
  line-height: 1.55;
  color: var(--birch-dim);
  counter-increment: step;
}
ol.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--aurora);
}

/* The publish command. */
#listed pre {
  margin: 0;
  padding: 16px 20px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.9;
  color: var(--birch);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#listed pre code {
  font-size: inherit;
}

.note {
  max-width: 48em;
  font-size: 15px;
  color: var(--mist);
}

.warning {
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--verdigris);
  color: var(--birch);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* ---------- Search ---------- */

form[role='search'] {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: end;
}
form[role='search'] label[for='q'] {
  grid-column: 1;
  grid-row: 1;
}
form[role='search'] #q {
  grid-column: 1;
  grid-row: 2;
}
form[role='search'] label[for='skill'] {
  grid-column: 2;
  grid-row: 1;
}
form[role='search'] #skill {
  grid-column: 2;
  grid-row: 2;
}
form[role='search'] button {
  grid-column: 3;
  grid-row: 2;
}

label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  background: var(--deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--birch);
  font-family: var(--font-body);
  font-size: 18px;
}
input:hover {
  border-color: var(--verdigris);
}

button {
  min-height: 52px;
  padding: 0 28px;
  background: var(--birch);
  border: 1px solid var(--birch);
  border-radius: var(--radius);
  color: var(--night);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
button:hover {
  background: var(--aurora);
  border-color: var(--aurora);
}

/* ---------- Listings ---------- */

.results {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.listing {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.listing .name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: var(--display-weight);
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
.listing .name a {
  text-decoration: none;
}

/* Label and value rows: the card's facts. */
.listing dl,
main > section:not(#api) > dl {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr);
  gap: 10px 24px;
  margin: 0;
}
.listing dt,
main > section:not(#api) > dl dt {
  padding-top: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
}
.listing dd,
main > section:not(#api) > dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--birch-dim);
}
.listing dd code,
main > section:not(#api) > dl dd code {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--frost);
}
.door {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.door[data-state='open'] {
  color: var(--aurora);
}
.door[data-state='closed'] {
  color: var(--mist);
}

/* What the listing's key holder wrote, which the directory doesn't check. */
.card-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 16px;
  border-left: 2px solid var(--rule);
}
.card-text::before {
  content: 'Card text · not checked';
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mist);
}
/* The knock command: the last row, set as a command. */
.listing dd:last-of-type code {
  display: block;
  padding: 14px 16px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0;
  color: var(--birch);
}

.empty {
  padding: 28px 24px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}
.empty p:first-child {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: var(--display-weight);
  letter-spacing: 0.02em;
}
.empty p + p {
  font-size: 17px;
  color: var(--mist);
}
.empty a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
}
.empty a::after {
  content: ' →';
  white-space: pre;
}

/* ---------- API ---------- */

#api dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  margin: 0;
  padding: 8px 22px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#api dt,
#api dd {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
#api dt:first-of-type,
#api dd:first-of-type {
  border-top: 0;
}
#api dt {
  padding-right: 24px;
  overflow-wrap: anywhere;
  color: var(--birch);
}
#api dt code {
  font-size: 13px;
}
/* The method before each URL: GET in aurora, POST in frost. The markup says
   only <span class="method">, so POST is picked by its place: the fifth
   endpoint, /mcp, at the pinned directory commit (tests/directory.spec.mjs
   checks that it still is). */
#api .method {
  color: var(--aurora);
}
#api dt:nth-of-type(5) .method {
  color: var(--frost);
}
#api dd {
  margin: 0;
  color: var(--mist);
}

/* ---------- Footer ---------- */

footer.site {
  margin-top: 56px;
  padding-bottom: 48px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--mist);
}
/* The rule sits on the text, so it lines up with main's content. */
footer.site p {
  padding-top: 28px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
/* Terms, Report abuse and security.txt: like the site's footer links. */
footer.site a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  min-width: var(--target);
  text-decoration: none;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 640px) {
  form[role='search'] {
    grid-template-columns: minmax(0, 1fr);
  }
  form[role='search'] > * {
    grid-column: auto !important;
    grid-row: auto !important;
  }
  form[role='search'] label[for='skill'] {
    margin-top: 8px;
  }
  form[role='search'] button {
    justify-self: start;
    margin-top: 8px;
  }
  .listing {
    padding: 20px 16px;
  }
  .about-cols {
    grid-template-columns: minmax(0, 1fr);
  }
  .listing dl,
  main > section:not(#api) > dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px 0;
  }
  .listing dd,
  main > section:not(#api) > dl dd {
    margin-bottom: 10px;
  }
  #api dl {
    grid-template-columns: minmax(0, 1fr);
    padding: 4px 16px;
  }
  #api dd {
    padding-top: 0;
    border-top: 0;
  }
  #api dd:first-of-type {
    padding-top: 0;
  }
}

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