/*
 * The rules of the Lattice site: its layout, type and brand. It is the layout of the Marquetry
 * site, with the fuchsia accent of the Lattice gem. Each component on the page (button, card,
 * table, tabs, badge) 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 are the Joinery tokens, the
 * same tokens that a Lattice grid reads. Only the accent is the own colour of Lattice.
 *
 * 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 {
  --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 Lattice: the gem tile. AA on white. */
  --site-accent: #a21caf;
  /* The hero and the code blocks are dark in the two schemes, as an editor is. */
  --site-ink: #140a16;
  --site-ink-text: #f8eefa;
  --site-ink-muted: #d9c6dd;
  --site-ink-accent: #f0abfc;
  --site-code: #1a111c;
  --site-code-text: #f1e6f3;
  --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: #f0abfc;
  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,
  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);
    border-radius: calc(var(--radius) * 0.6);
    background: var(--muted);
    font-size: 0.88em;
    overflow-wrap: anywhere;
  }

  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;
}

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

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 85%, 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.7rem, 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);
}

@media (max-width: 1099px) {
  .site-nav .roomy-only {
    display: none;
  }
}

@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 ------------------------------------------------------- */
/* The copy is on the dark band, so it takes the dark tokens of Joinery (`.dark` on it). */

.hero-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(40rem 28rem at 78% 40%, rgb(192 38 211 / 0.3), transparent 70%), var(--site-ink);
  color: var(--site-ink-text);
}

/* A faint lattice of crossed strips that fades to the edges. */
.hero-band::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    repeating-linear-gradient(45deg, rgb(255 255 255 / 0.035) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(-45deg, rgb(255 255 255 / 0.035) 0 1px, transparent 1px 40px);
  -webkit-mask-image: radial-gradient(ellipse at 40% 40%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse at 40% 40%, #000 25%, transparent 75%);
}

.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: 1fr 1fr;
  }
}

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

.hero-copy .eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  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, #f0abfc, #fbbf24);
  -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-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;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: 1.4rem;
  background: rgb(255 255 255 / 0.05);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

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

.hero-copy .install code {
  padding: 0;
  background: none;
  color: var(--site-code-text);
  font-size: inherit;
}

/* ---- the preview: one data set in four views, with Joinery tabs, tables and badges -------- */

.preview {
  width: 100%;
  max-width: 36rem;
  justify-self: center;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: calc(var(--radius) * 2);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow:
    0 30px 80px -20px rgb(192 38 211 / 0.55),
    0 0 0 1px rgb(255 255 255 / 0.04);
}

.preview .chrome {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.preview .chrome i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.preview .chrome h2 {
  margin: 0 0 0 0.4rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  font-weight: 500;
}

.preview [data-slot='tabs'] {
  padding: 0.9rem 1rem 0.25rem;
}

.preview [data-slot='tabs-list'] {
  width: 100%;
}

.preview [data-slot='tabs-content'] {
  min-height: 18.5rem;
  padding-top: 0.75rem;
}

.preview [data-slot='tabs-content'][hidden] {
  display: none;
}

.preview .num {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.view-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.view-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.1rem 1rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.view-list .sub {
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.view-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.view-board section {
  min-width: 0;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: var(--muted);
}

.view-board h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
}

.view-board ul {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.view-board li {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  background: var(--card);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.view-board li span {
  display: block;
  color: var(--muted-foreground);
}

.view-board li.held {
  outline: 2px solid var(--site-accent);
  outline-offset: -1px;
}

.formula-bar {
  display: flex;
  gap: 0.6rem;
  margin: 0 0 0.5rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.formula-bar b {
  font-weight: 600;
}

/* The sheet: A1 headers and grid lines, as the sheet preset of the Lattice theme draws them. */
.view-sheet {
  width: 100%;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.view-sheet th,
.view-sheet td {
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
}

.view-sheet thead th,
.view-sheet thead td,
.view-sheet tbody th {
  background: var(--muted);
  font-weight: 500;
  text-align: center;
}

.view-sheet .active {
  outline: 2px solid var(--site-accent);
  outline-offset: -2px;
}

.view-sheet .peer {
  position: relative;
  outline: 2px solid #d97706;
  outline-offset: -2px;
}

.peer-name {
  position: absolute;
  inset-inline-end: -2px;
  inset-block-start: -1.1rem;
  padding: 0 0.3rem;
  border-radius: 3px 3px 0 0;
  background: #92400e;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
}

.preview-note {
  margin: 0;
  padding: 0.25rem 1rem 0.9rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

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

/* On a phone, a wide table of the preview scrolls in its panel, not the page. */
.scroll-x {
  overflow-x: auto;
}

/* ---- 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;
}

main > section > h2 + p {
  margin-bottom: var(--space-block);
  color: var(--muted-foreground);
  font-size: 1.0625rem;
}

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;
  }
}

.pair {
  display: grid;
  gap: var(--space-gap);
  align-items: start;
}

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

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

.pair + *,
.features + *,
.stats + *,
[data-slot='table-container'] + * {
  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);
}

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

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

  .features.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.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;
}

/* ---- the parity numbers -------------------------------------------------------------------- */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-gap) 3rem;
  margin: 0 0 var(--space-block);
}

.stats p {
  margin: 0;
  color: var(--muted-foreground);
}

.stats strong {
  display: block;
  color: var(--foreground);
  font-size: clamp(2.25rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 60rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

pre {
  margin: 0 0 var(--space-gap);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  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 {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dark pre {
  border: 1px solid rgb(255 255 255 / 0.08);
}

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

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

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

/* On a phone, each row is a stack: the name, then the values. */
@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;
  }
}

.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);
}

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

/* The shared Ember Workbench footer (workbench-footer.css): the accent and the width of the site. */
.wb-footer {
  --wb-accent: var(--site-accent);
  --wb-max: 1200px; /* .container, less its gutters */
}

/* The bar is dark in both themes, so it is one piece with the hero. It is the bar of the
   skillsaw site: the same colour, line, height and type on each Workbench site. */
body .site-nav {
  background: #0b0b14;
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
  box-shadow: none;
  color-scheme: dark;
}

body .site-nav > .container {
  min-height: 56px;
  padding-block: 0;
}

body .site-nav ul,
body .site-nav li {
  margin-block: 0;
  padding-block: 0;
}

body .site-nav a,
body .site-nav a:visited {
  color: #cbd5e1 !important;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

body .site-nav a:hover,
body .site-nav .brand a,
body .site-nav a.brand,
body .site-nav .brand-link,
body .site-nav .brand-link strong {
  color: #f8fafc !important;
}

body .site-nav a.brand,
body .site-nav .brand a,
body .site-nav .brand-link {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

body .site-nav button,
body .site-nav [role='button'] {
  color: #f8fafc;
  background: rgb(255 255 255 / 0.08);
  border-color: rgb(255 255 255 / 0.12);
}

body .site-nav :focus-visible {
  outline-color: #f8fafc;
}

@media (max-width: 575px) {
  body .site-nav a,
  body .site-nav a:visited {
    font-size: 14px;
  }
}

/* A wood grain under the hero, the same on each Workbench site. It is drawn by an SVG filter:
   long, thin noise, cut into bands. */
.hero-band > .wood {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'1600'%20height%3D'900'%20viewBox%3D'0%200%201600%20900'%20preserveAspectRatio%3D'none'%3E%3Cfilter%20id%3D'g'%20x%3D'0'%20y%3D'0'%20width%3D'100%25'%20height%3D'100%25'%3E%3CfeTurbulence%20type%3D'fractalNoise'%20baseFrequency%3D'0.0006%200.009'%20numOctaves%3D'2'%20seed%3D'11'%2F%3E%3CfeColorMatrix%20type%3D'matrix'%20values%3D'0%200%200%200%201%20%200%200%200%200%200.83%20%200%200%200%200%200.64%20%201%200%200%200%200'%2F%3E%3CfeComponentTransfer%3E%3CfeFuncA%20type%3D'table'%20tableValues%3D'0%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200%200%200.35%201%200.35%200%200'%2F%3E%3C%2FfeComponentTransfer%3E%3C%2Ffilter%3E%3Crect%20width%3D'1600'%20height%3D'900'%20filter%3D'url(%23g)'%20opacity%3D'1'%2F%3E%3C%2Fsvg%3E")
    center / cover no-repeat;
  opacity: 0.12;
}
