/* Additions to Pico. All other styles are the Pico defaults. */

/* The brand palette. logo.svg and favicon.svg use the same colors. The lime is the
   --millwork token of the Ember Workbench site. */
:root {
  --brand-lime: #4d7c0f;
  --brand-amber: #f59e0b;
  --brand-ink: #0f172a;
  --brand-ink-light: #f8fafc;
  --pico-font-family-sans-serif:
    Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --pico-font-family: var(--pico-font-family-sans-serif);
}

/* The same selectors as Pico, so these rules win by source order. */
:root:not([data-theme='dark']),
[data-theme='light'] {
  --pico-primary: #4d7c0f;
  --pico-primary-background: #4d7c0f;
  --pico-primary-border: #4d7c0f;
  --pico-primary-underline: rgb(77 124 15 / 0.5);
  --pico-primary-hover: #3f6212;
  --pico-primary-hover-background: #3f6212;
  --pico-primary-hover-border: #3f6212;
  --pico-primary-hover-underline: #3f6212;
  --pico-primary-focus: rgb(77 124 15 / 0.4);
  --pico-primary-inverse: #fff;
  --pico-text-selection-color: rgb(77 124 15 / 0.25);
}

@media only screen and (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --pico-primary: #a3e635;
    --pico-primary-background: #4d7c0f;
    --pico-primary-border: #4d7c0f;
    --pico-primary-underline: rgb(163 230 53 / 0.5);
    --pico-primary-hover: #bef264;
    --pico-primary-hover-background: #3f6212;
    --pico-primary-hover-border: #3f6212;
    --pico-primary-hover-underline: #bef264;
    --pico-primary-focus: rgb(163 230 53 / 0.4);
    --pico-primary-inverse: #fff;
    --pico-text-selection-color: rgb(163 230 53 / 0.3);
  }
}

[data-theme='dark'] {
  --pico-primary: #a3e635;
  --pico-primary-background: #4d7c0f;
  --pico-primary-border: #4d7c0f;
  --pico-primary-underline: rgb(163 230 53 / 0.5);
  --pico-primary-hover: #bef264;
  --pico-primary-hover-background: #3f6212;
  --pico-primary-hover-border: #3f6212;
  --pico-primary-hover-underline: #bef264;
  --pico-primary-focus: rgb(163 230 53 / 0.4);
  --pico-primary-inverse: #fff;
  --pico-text-selection-color: rgb(163 230 53 / 0.3);
}

/* Spacing scale. Every gap on the page comes from these. */
:root {
  --space-gutter: clamp(1rem, 4vw, 2rem);
  --space-section: clamp(4rem, 9vw, 7rem);
  --space-block: 2.5rem; /* section intro to its content */
  --space-gap: 1.5rem; /* between cards in a grid */
  --measure: 42rem; /* readable line length */
}

/* One fluid content width for nav, hero, sections and footer, replacing Pico's
   stepped max-widths, which drop the side padding from 576px up. */
.container {
  max-width: calc(1200px + 2 * var(--space-gutter));
  padding-inline: var(--space-gutter);
}

/* Eyebrow labels above headings */
.eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pico-primary);
}

/* Sticky nav */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--pico-background-color);
  background: color-mix(in srgb, var(--pico-background-color) 80%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.site-nav > .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Keeps the nav on one row at phone width. */
@media (max-width: 575px) {
  .site-nav .wide-only {
    display: none;
  }
}

.site-nav a {
  color: var(--pico-muted-color);
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--pico-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hero band: dark in both schemes. */
.hero-band {
  --pico-color: #f8fafc;
  --pico-h1-color: #f8fafc;
  --pico-muted-color: #cbd5e1;
  --pico-primary: #a3e635;
  position: relative;
  isolation: isolate;
  padding-block: 0;
  overflow: hidden;
  background-color: #0b0b14;
  color: var(--pico-color);
}

/* Faint grid, faded out towards the edges. */
.hero-band::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  /* Pico sets no-repeat on each pseudo-element. Without this line, one cell shows. */
  background-repeat: repeat;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 25%, transparent 75%);
}

.hero-band::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(40rem 28rem at 75% 45%, rgb(101 163 13 / 0.3), transparent 70%);
}

.hero {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  align-items: center;
  padding-block: var(--space-section);
}

/* Lets the install pill scroll inside its column instead of widening the page. */
.hero > *,
.hero-copy > * {
  min-width: 0;
}

@media (min-width: 992px) {
  .hero {
    grid-template-columns: 1.05fr 1fr;
  }
}

.hero h1 {
  margin-bottom: 1.25rem;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.gradient-text {
  background: linear-gradient(90deg, #a3e635, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 36rem;
  margin-bottom: 2rem;
  font-size: 1.125rem;
  color: var(--pico-muted-color);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.hero-actions [role='button'] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.hero-actions .ghost {
  --pico-background-color: transparent;
  --pico-border-color: rgb(255 255 255 / 0.25);
  --pico-color: #f8fafc;
}

.hero-actions .ghost:is(:hover, :focus-visible) {
  --pico-background-color: rgb(255 255 255 / 0.06);
  --pico-border-color: rgb(255 255 255 / 0.5);
  --pico-color: #fff;
}

.install {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  width: fit-content;
  padding: 0.6rem 1.25rem;
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
  font-family: var(--pico-font-family-monospace);
  font-size: 0.9rem;
  white-space: nowrap;
}

.install .prompt {
  color: #64748b;
  user-select: none;
}

.install code {
  padding: 0;
  background: none;
  color: #e2e8f0;
  font-size: inherit;
}

.install-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* Hero illustration: rough stock in, finished parts out. The band is always dark, so the
   colors are fixed. */
.hero-art {
  width: 100%;
  height: auto;
}

.hero-art .flow use {
  fill: none;
  stroke: rgb(163 230 53 / 0.35);
  stroke-width: 1.25;
}

.hero-art .pulses use {
  fill: none;
  stroke: #bef264;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-dasharray: 12 88;
  animation: flow-pulse 3.2s linear infinite;
  animation-delay: calc(var(--i) * -0.5s);
}

@keyframes flow-pulse {
  from {
    stroke-dashoffset: 12;
  }
  to {
    stroke-dashoffset: -88;
  }
}

.hero-art .group {
  fill: #a3e635;
  font-family: var(--pico-font-family-sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-art .stock rect {
  fill: rgb(245 158 11 / 0.08);
  stroke: rgb(245 158 11 / 0.5);
}

.hero-art .stock text {
  fill: #fbbf24;
  font-family: var(--pico-font-family-monospace);
  font-size: 12px;
}

.hero-art .mill-glow {
  fill: #65a30d;
  opacity: 0.5;
  filter: url(#mill-blur);
}

.hero-art .mill rect {
  fill: #0f172a;
  stroke: url(#mill-stroke);
}

.hero-art .mill text {
  fill: #f8fafc;
  font-family: var(--pico-font-family-monospace);
  font-size: 13px;
  text-anchor: middle;
}

.hero-art .mill .muted {
  fill: #94a3b8;
  font-family: var(--pico-font-family-sans-serif);
  font-size: 11px;
}

.hero-art .part rect {
  fill: #151527;
  stroke: rgb(255 255 255 / 0.22);
}

.hero-art .part .name {
  fill: #f8fafc;
  font-family: var(--pico-font-family-monospace);
  font-size: 13px;
}

.hero-art .part .kind {
  fill: #a3e635;
  font-family: var(--pico-font-family-sans-serif);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-art .part .note {
  fill: #94a3b8;
  font-family: var(--pico-font-family-monospace);
  font-size: 11px;
}

/* Section rhythm: one gap between sections, never doubled. */
body > main {
  padding-block: 0 var(--space-section);
}

main > section {
  margin: 0;
  padding-top: var(--space-section);
}

main > section > h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

/* The intro paragraph under a heading: readable width, then a fixed gap. */
main > section > h2 + p {
  max-width: var(--measure);
  margin-bottom: var(--space-block);
  font-size: 1.0625rem;
  color: var(--pico-muted-color);
}

main > section > h2:not(:has(+ p)) {
  margin-bottom: var(--space-block);
}

main > section > h3 {
  margin-block: var(--space-block) 0.75rem;
}

main > section p {
  max-width: var(--measure);
}

/* Cards in a grid space by the grid gap, not their own margins. */
.grid {
  gap: var(--space-gap);
}

.grid > article,
.grid > pre,
.features article {
  margin: 0;
}

.grid + * {
  margin-top: var(--space-gap);
}

.grid > article > pre:last-child,
.grid > pre {
  margin-bottom: 0;
}

details {
  margin-bottom: 0.5rem;
}

/* Features */
.features {
  display: grid;
  gap: var(--space-gap);
}

@media (min-width: 576px) {
  .features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .features {
    grid-template-columns: repeat(4, 1fr);
  }
}

.features article {
  margin: 0;
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: none;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease;
}

.features article:hover {
  border-color: var(--pico-primary-underline);
  transform: translateY(-2px);
}

.features h3 {
  margin-block: 1rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.features p {
  margin: 0;
  color: var(--pico-muted-color);
}

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--pico-primary);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .hero-art .pulses {
    display: none;
  }

  .features article {
    transition: none;
  }

  .features article:hover {
    transform: none;
  }
}

/* Footer */
body > footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding-block: 2.5rem;
  color: var(--pico-muted-color);
}

body > footer a {
  color: inherit;
}

/* The row of sibling projects under the footer's own links. */
body > footer .family {
  margin: 0.5rem 0 0;
}

body > footer [aria-current='page'] {
  font-weight: 600;
  text-decoration: none;
}

/* Code blocks: one editor-style surface in both schemes. Pico pads the inner
   <code> and Prism pads the <pre>; only the <pre> pads here, so indents don't double. */
pre,
pre[class*='language-'] {
  margin: 0 0 var(--pico-typography-spacing-vertical);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 12px;
  background: #0d1117;
  color: #e2e8f0;
  font-size: clamp(0.75rem, 0.65rem + 0.35vw, 0.875rem);
  line-height: 1.65;
  tab-size: 2;
}

pre > code,
pre > code[class*='language-'] {
  display: block;
  padding: 0;
  background: none;
  color: inherit;
  font-family: var(--pico-font-family-monospace);
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
  /* Wrap long lines instead of scrolling sideways. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Side-by-side code pairs only once each half is wide enough to read. */
@media (max-width: 1099px) {
  .grid:has(> article > pre, > pre) {
    grid-template-columns: 1fr;
  }
}

:root:not([data-theme='dark']) pre {
  border-color: transparent;
}

.hero code {
  padding: 0.05em 0.3em;
  background: rgb(255 255 255 / 0.08);
  color: inherit;
}

.features {
  margin-top: var(--space-block);
}

/* A wide table scrolls inside its box, so the page never scrolls sideways on a phone. */
.table-wrap {
  max-width: 100%;
  margin-bottom: var(--pico-typography-spacing-vertical);
  overflow-x: auto;
}

.table-wrap table {
  margin-bottom: 0;
}

/* Only the name column keeps each name on one line. */
.table-wrap td:first-child code {
  white-space: nowrap;
}

/* The package grid: one card for each package. */
.packages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-gap);
}

.packages article {
  margin: 0;
  padding: 1.25rem;
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: none;
}

.packages h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-family: var(--pico-font-family-monospace);
  overflow-wrap: anywhere;
}

.packages h3 a {
  text-decoration: none;
}

.packages .peer {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}

.packages .codecs {
  margin: 0;
  font-size: 0.85rem;
}

.packages .codecs code {
  font-size: 0.8rem;
}

/* The two doors: side by side on a wide screen. */
.doors {
  display: grid;
  gap: var(--space-gap);
}

@media (min-width: 1100px) {
  .doors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.doors > article {
  margin: 0;
}

/* Terms table on the landing page: entity, shape, value. */
.terms th[scope='row'] {
  font-weight: 700;
}

/* A short note in the guide, for a limit or a trap. */
.note {
  max-width: var(--measure);
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--pico-primary);
  background: var(--pico-card-sectioning-background-color);
  border-radius: 0 8px 8px 0;
}

/* Guide: a sticky contents column beside the sections. On a narrow screen, it is above them. */
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
}

.guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 3rem;
}

.guide > section {
  min-width: 0;
  padding-top: 3.5rem;
}

.guide-toc nav {
  padding-top: 2rem;
}

/* Pico moves the first list of a nav to the left. The contents column does not need that. */
.guide-toc ul,
.guide-toc ul:first-of-type {
  margin: 0 0 1.25rem;
  padding: 0;
}

.guide-toc li {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0;
}

.guide-toc a {
  color: var(--pico-muted-color);
  text-decoration: none;
}

.guide-toc a:hover {
  color: var(--pico-primary);
}

@media (min-width: 900px) {
  .guide {
    grid-template-columns: 13rem minmax(0, 1fr);
  }

  .guide > section {
    grid-column: 2;
  }

  .guide-toc {
    grid-column: 1;
    grid-row: 1 / span 20;
  }

  .guide-toc nav {
    position: sticky;
    top: 4rem;
  }
}
