/*
 * The rules of the Dovetail site: its layout, type and brand. It is the layout of the other
 * Workbench sites, with the cyan accent of the Dovetail gem. Each component on the page (button,
 * card, table, 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. Only the accent is the own colour of
 * Dovetail.
 *
 * 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 gem of Dovetail: bright, mid and deep cyan. The mid tone is AA on white. */
  --gem-bright: #06b6d4;
  --gem-mid: #155e75;
  --gem-deep: #083344;
  --site-accent: var(--gem-mid);
  /* The hero and the code blocks are dark in the two schemes, as an editor is. */
  --site-ink: var(--gem-deep);
  --site-ink-text: #f0fdff;
  --site-ink-muted: #bfe3ea;
  --site-ink-accent: #67e8f9;
  --site-code: #061f28;
  --site-code-text: #e6f7fa;
  --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 {
  --gem-bright: #22d3ee;
  --gem-mid: #0e7490;
  --gem-deep: #0b3b4a;
  --site-accent: var(--gem-bright);
  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(
      48rem 30rem at 70% 70%,
      color-mix(in oklab, var(--gem-bright) 30%, transparent),
      transparent 70%
    ),
    var(--site-ink);
  color: var(--site-ink-text);
}

/* Faint dovetail joints: crossed strips that fade 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;
}

.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, #67e8f9, #a5f3fc);
  -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: #7fb8c4;
  user-select: none;
}

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

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

.wb-footer {
  /* The shared Ember Workbench footer (workbench-footer.css) with the Dovetail accent. */
  --wb-accent: var(--site-accent);
}

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

/* ---- the live demo: an iframe of the demo route of test-app ------------------------------- */
/* On a wide screen the copy and the demo are side by side, so the demo is above the fold. */

@media (min-width: 1100px) {
  .hero {
    grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
    padding-block: 3rem 4rem;
  }

  .hero h1 {
    font-size: 3rem;
  }

  .hero-sub {
    font-size: 1rem;
  }
}

.demo-frame {
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: calc(var(--radius) * 2);
  background: var(--background);
  box-shadow:
    0 30px 80px -20px color-mix(in oklab, var(--gem-bright) 55%, transparent),
    0 0 0 1px rgb(255 255 255 / 0.04);
}

.demo-frame iframe {
  display: block;
  width: 100%;
  /* The two panes stack on a phone, so the frame is taller there. */
  height: 58rem;
  border: 0;
}

@media (min-width: 46rem) {
  .demo-frame iframe {
    height: 32rem;
  }
}

.demo-caption {
  margin: 0.75rem 0 0;
  color: var(--site-ink-muted);
  font-size: 0.875rem;
}
