/*
 * The rules of the Marquetry site: its layout, type and brand. It is the layout of the Joinery
 * site, with the teal accent of the Marquetry guide. Each component on the page gets its look
 * from the CSS of Joinery, as in an app: joinery/tokens.css and joinery/joinery.css, which
 * `pnpm site:css` copies in. The colours of the page are the tokens of Joinery too. Only the
 * accent is the own colour of Marquetry.
 *
 * This sheet loads before the CSS of Joinery, to put the layers in order. The element defaults
 * of the site (site-base) are below the layer of Joinery, so a component keeps its own look. The
 * classes of the site have no layer, as the CSS of an app, so they win.
 */
@layer site-base, joinery;

/* ---- tokens -------------------------------------------------------------------------------- */

:root {
  /* The type of the siblings. The parts of Joinery read --font-sans too. */
  --font-sans:
    Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  /* The accent of Marquetry: the deep teal veneer of the guide and the logo. AA on white. */
  --site-accent: #0f766e;
  --site-glow: rgb(20 184 166 / 0.3);
  /* The hero and the code blocks are dark in the two schemes, as an editor is. */
  --site-ink: #0d1413;
  --site-ink-text: #eef6f5;
  --site-ink-muted: #c4d3d1;
  --site-ink-accent: #5eead4;
  --site-code: #0f1716;
  --site-code-text: #e3eeec;
  /* Spacing: each gap on the page comes from these. */
  --space-gutter: clamp(1rem, 4vw, 2rem);
  --space-section: clamp(4rem, 9vw, 7rem);
  --space-block: 2.5rem;
  --space-gap: 1.5rem;
  --measure: 42rem;
  color-scheme: light;
}

:root.dark {
  --site-accent: #2dd4bf;
  --site-glow: rgb(45 212 191 / 0.2);
  color-scheme: dark;
}

/* ---- element defaults, below Joinery's layer -------------------------------------------- */

@layer site-base {
  *,
  ::before,
  ::after {
    box-sizing: border-box;
  }

  html {
    scroll-padding-top: 5rem;
    -webkit-text-size-adjust: 100%;
  }

  body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font: 400 1rem/1.65 var(--font-sans);
    -webkit-font-smoothing: antialiased;
  }

  a {
    color: var(--site-accent);
    text-underline-offset: 0.2em;
  }

  img {
    max-width: 100%;
  }

  h1,
  h2,
  h3 {
    color: var(--foreground);
    text-wrap: balance;
  }

  code,
  kbd,
  pre {
    font-family: var(--font-mono);
  }

  /* In the foreground colour, also in muted text: muted on muted is not AA. */
  :not(pre) > code {
    padding: 0.1em 0.35em;
    color: var(--foreground);
    white-space: nowrap;
    border-radius: calc(var(--radius) * 0.6);
    background: var(--muted);
    font-size: 0.88em;
  }

  table {
    border-collapse: collapse;
  }
}

/* ---- layout ----------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: calc(1200px + 2 * var(--space-gutter));
  margin-inline: auto;
  padding-inline: var(--space-gutter);
}

.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  inset-block-start: 0.75rem;
  z-index: 20;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
}

.skip-link:focus {
  inset-inline-start: 0.75rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--site-accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted-foreground);
}

/* ---- nav -------------------------------------------------------------------------------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.site-nav > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  color: var(--foreground);
  font-weight: 700;
  text-decoration: none;
}

.site-nav ul {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav ul a {
  color: var(--muted-foreground);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
}

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

/* On a screen that is not wide, the nav keeps only the most used links. */
@media (max-width: 1099px) {
  .site-nav .roomy-only {
    display: none;
  }
}

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

/* The light and dark toggle shows the icon of the other scheme. */
.mode-toggle .when-dark,
.dark .mode-toggle .when-light {
  display: none;
}

.dark .mode-toggle .when-dark {
  display: block;
}

/* ---- hero: dark in the two schemes, as the hero of Formwright -------------------------- */
/* The copy is on the dark band, so it takes the dark tokens of the theme (`.dark` on it). */

.hero-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--site-ink);
  color: var(--site-ink-text);
}

/* A faint grid that fades to 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;
  -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(20 184 166 / 0.28), transparent 70%);
}

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

.hero > *,
.hero-copy > * {
  min-width: 0;
}

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

.hero-copy {
  color: var(--site-ink-text);
}

.hero-copy .eyebrow {
  color: var(--site-ink-accent);
}

.hero h1 {
  margin: 0 0 1.25rem;
  color: var(--site-ink-text);
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.accent-text {
  display: block;
  background: linear-gradient(90deg, #5eead4, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.hero-copy :not(pre) > code {
  background: rgb(255 255 255 / 0.08);
  color: inherit;
}

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

.install {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: fit-content;
  max-width: 100%;
  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(--font-mono);
  font-size: 0.9rem;
  white-space: nowrap;
}

.install .prompt {
  color: #8fa3a0;
  user-select: none;
}

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

/* The hero plays a recorded stream: the prompt, the patches, and the interface they build. */
.hero-demo {
  width: 100%;
  max-width: 34rem;
  justify-self: center;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: calc(var(--radius) * 2);
  background: var(--site-code);
  box-shadow:
    0 30px 80px -20px rgb(20 184 166 / 0.5),
    0 0 0 1px rgb(255 255 255 / 0.04);
}

.hero-demo .chrome {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.hero-demo .chrome i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #33403e;
}

.hero-demo .chrome h2 {
  margin: 0 0 0 0.5rem;
  color: var(--site-ink-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.hero-demo .chrome [data-hero-replay] {
  margin-inline-start: auto;
  color: var(--site-ink-text);
}

.hero-demo .chrome [data-hero-replay]:hover {
  background: rgb(255 255 255 / 0.08);
}

.hero-prompt {
  margin: 0;
  padding: 0.75rem 1rem 0.25rem;
  color: var(--site-ink-text);
  font-size: 0.95rem;
}

.hero-prompt .caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-inline-start: 2px;
  vertical-align: text-bottom;
  background: var(--site-ink-accent);
}

[data-state='done'] .hero-prompt .caret {
  visibility: hidden;
}

pre.hero-stream {
  height: 4.6rem;
  margin: 0;
  padding: 0.5rem 1rem;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--site-ink-muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

pre.hero-stream > code {
  white-space: pre;
}

/* The charts of the hero in the accent. The other tokens are the tokens of Joinery. */
.hero-preview {
  --chart-1: #0f766e;
  --chart-2: #5eead4;
  --chart-3: #14b8a6;
  --chart-4: #134e4a;
  min-height: 27rem;
  padding: 1rem;
  background: var(--muted);
  color: var(--foreground);
}

.dark .hero-preview {
  --chart-1: #2dd4bf;
  --chart-2: #0f766e;
  --chart-3: #99f6e4;
  --chart-4: #115e59;
}

.hero-stack {
  display: flex;
  flex-direction: column;
}

.hero-figure {
  margin: 0;
}

.hero-chart {
  display: block;
  width: 100%;
  max-height: 9rem;
}

.hero-chart text {
  fill: var(--muted-foreground);
  font-size: 10px;
  text-anchor: middle;
}

.hero-pie {
  max-height: 7rem;
}

.hero-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
}

.hero-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hero-swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
}

/* A new element fades in. */
.hero-preview .hero-new {
  animation: hero-in 0.3s ease-out;
}

@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-preview .hero-new {
    animation: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- sections ----------------------------------------------------------------------------- */

main {
  padding-bottom: var(--space-section);
}

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

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

/* The first paragraph below a heading: a width to read, then a fixed gap. */
main > section > h2 + p {
  margin-bottom: var(--space-block);
  color: var(--muted-foreground);
  font-size: 1.0625rem;
}

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

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

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

/* The "#" link of a section heading, to share it. It shows on hover or focus. */
.section-link {
  margin-inline-start: 0.4rem;
  color: var(--muted-foreground);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}

h2:hover > .section-link,
.section-link:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .section-link {
    opacity: 0.6;
  }
}

/* Two blocks side by side, when each block is wide enough to read. */
.pair {
  display: grid;
  gap: var(--space-gap);
  align-items: start;
}

.pair > * {
  min-width: 0;
  margin: 0;
}

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

.pair + *,
.features + * {
  margin-top: var(--space-gap);
}

.label-above {
  margin: 0 0 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---- features: a grid of Joinery Cards ----------------------------------------------------- */

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

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

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

/* Four cards show as two rows of two. */
@media (min-width: 1024px) {
  .features.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.features .icon {
  width: 22px;
  height: 22px;
  color: var(--site-accent);
}

.features [data-slot='card-title'] {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.features p {
  margin: 0;
}

/* A card with a link as its title (the siblings): the base of Joinery gives it the parent colour. */
.features [data-slot='card-title'] a {
  color: var(--site-accent);
  text-decoration: underline;
}

/* ---- code blocks: one dark surface in the two schemes ---------------------------------- */

pre,
pre[class*='language-'] {
  margin: 0 0 var(--space-gap);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: calc(var(--radius) * 1.4);
  background: var(--site-code);
  color: var(--site-code-text);
  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(--font-mono);
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:root:not(.dark) pre {
  border-color: transparent;
}

.pair pre {
  margin: 0;
}

/* ---- tables ----------------------------------------------------------------------------- */

.site-table code {
  white-space: nowrap;
}

.site-table th[scope='row'] {
  text-align: start;
}

/* On a phone, each row is a stack: the name, then what it does. */
@media (max-width: 639px) {
  .site-table thead {
    display: none;
  }

  .site-table tr {
    display: grid;
    padding-block: 0.5rem;
  }

  .site-table [data-slot='table-cell'] {
    padding-block: 0.15rem;
  }
}

.site-table [data-slot='table-cell'] {
  white-space: normal;
  vertical-align: top;
}

/* ---- footer ------------------------------------------------------------------------------- */

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

.site-footer p {
  max-width: 60rem;
  margin: 0 0 0.75rem;
}

.site-footer a {
  color: inherit;
}

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

/* ---- the safety list -------------------------------------------------------------------- */

.checklist {
  display: grid;
  gap: 0.5rem;
  max-width: var(--measure);
  margin: 0 0 var(--space-gap);
  padding-inline-start: 1.25rem;
}

.checklist li::marker {
  color: var(--site-accent);
}
