/* Encspect landing page. System fonts only, light and dark from the visitor's setting. */

:root {
  --surface-light: #fbfbfd;
  --surface-dark: #14161c;
  --raised-light: #ffffff;
  --raised-dark: #1d2029;
  --text-light: #1b1d24;
  --text-dark: #e8e9ee;
  --muted-light: #50566a;
  --muted-dark: #a9aebf;
  --border-light: #dcdfe8;
  --border-dark: #333847;
  --brand-light: #3b4cca;
  --brand-dark: #9aa8ff;
  --brand-text-light: #ffffff;
  --brand-text-dark: #10142e;

  /* Fallback for browsers without light-dark(): the light values, switched by the media query. */
  --surface: var(--surface-light);
  --raised: var(--raised-light);
  --text: var(--text-light);
  --muted: var(--muted-light);
  --border: var(--border-light);
  --brand: var(--brand-light);
  --brand-text: var(--brand-text-light);

  @media (prefers-color-scheme: dark) {
    --surface: var(--surface-dark);
    --raised: var(--raised-dark);
    --text: var(--text-dark);
    --muted: var(--muted-dark);
    --border: var(--border-dark);
    --brand: var(--brand-dark);
    --brand-text: var(--brand-text-dark);
  }

  @supports (color: light-dark(white, black)) {
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --raised: light-dark(var(--raised-light), var(--raised-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --brand: light-dark(var(--brand-light), var(--brand-dark));
    --brand-text: light-dark(var(--brand-text-light), var(--brand-text-dark));
  }

  color-scheme: light dark;
  accent-color: var(--brand);
}

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  overflow-wrap: break-word;
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}

a:focus-visible,
button:focus-visible,
pre:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  inset-block-start: -10rem;
  padding: 0.5rem 1rem;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.skip-link:focus {
  inset-block-start: 1rem;
}

/* One measure for running text everywhere: paragraphs, lists, captions, code blocks and the descriptions of
   definition lists end at 70 characters (the lead paragraphs, in a larger font, at 60). Card grids keep the full width. */
main :where(p, ul, ol, figcaption, dd, .code) {
  max-inline-size: 70ch;
}

.cards {
  max-inline-size: none;
}

/* Page width: content up to 72rem, with a gutter that never drops below 1rem. */
.header-inner,
main > section,
.site-footer {
  inline-size: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

/* The header is a full-width sticky bar. --header-height is the bar's height: one row holding the brand mark or the
   2.75rem Menu button, the inner padding and the bottom border. Where popovers are missing the row wraps, so the value
   is raised there. Anchor jumps and focus land below the bar through scroll-padding-top. */
:root {
  --header-height: 5.25rem;
}

@supports not selector(:popover-open) {
  :root {
    --header-height: 7.5rem;
  }
}

html {
  scroll-padding-block-start: calc(var(--header-height) + 1rem);
}

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem;
}

/* Kept at their natural width, so the script can tell whether the inline row fits. */
.header-inner > * {
  flex-shrink: 0;
  white-space: nowrap;
}

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

.brand-mark {
  inline-size: 2rem;
  block-size: 2rem;
}


.site-header nav a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

main > section {
  padding-block: clamp(2.5rem, 1.5rem + 3vw, 4.5rem);
}

main > section + section {
  border-block-start: 1px solid var(--border);
}

/* A jump to a section lands with its top border under the bar rather than 1rem below it, so the separator above the
   section's heading is not left showing; the section's own padding keeps the heading clear of the bar. */
main > section[id] {
  scroll-margin-block-start: calc(-1rem - 1px);
}

.hero {
  text-align: center;
}

.hero :where(p) {
  margin-inline: auto;
}

.hero h1 {
  margin-block: 1rem 1.25rem;
  font-size: clamp(2.25rem, 1.5rem + 3vw, 4rem);
  letter-spacing: -0.02em;
}

.lead {
  max-inline-size: 60ch;
  margin-inline: auto;
  color: var(--muted);
  font-size: 1.2rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-block: 2rem 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.button:hover {
  border-color: var(--brand);
}

.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-text);
}

.note {
  margin-block-end: 2.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.shot img {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 0.12);
}

h2 {
  margin-block: 0 1.5rem;
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.25rem);
}

.section-lead {
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--raised);
}

.card h3 {
  margin-block: 0 0.5rem;
  font-size: 1.1rem;
}

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

.gallery figure {
  margin: 0 0 3rem;
}

.gallery figure:last-child {
  margin-block-end: 0;
}

figcaption {
  margin-block-start: 0.75rem;
  color: var(--muted);
}

.formats {
  display: grid;
  /* The term column, the gap and the 70 characters of the description, so the rules under the rows end with the text. */
  max-inline-size: calc(9rem + 1.5rem + 70ch);
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.formats div {
  display: grid;
  grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
  gap: 0.25rem 1.5rem;
  padding-block-end: 1rem;
  border-block-end: 1px solid var(--border);
}

.formats dt {
  font-weight: 700;
}

.formats dd {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 36em) {
  .formats div {
    grid-template-columns: minmax(0, 1fr);
  }
}

.code {
  margin: 1.5rem 0;
}

.code figcaption {
  margin-block: 0 0.5rem;
  font-weight: 600;
  color: var(--text);
}

/* Code stays dark in both themes; inherited colors are set again under its own color-scheme. */
.copyable {
  color-scheme: dark;
  position: relative;
  border-radius: 0.75rem;
  background: var(--surface-dark);
  color: var(--text-dark);
  accent-color: var(--brand);
}

pre {
  margin: 0;
  padding: 1.1rem 3.75rem 1.1rem 1.25rem;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.copy {
  position: absolute;
  inset-block-start: 0.6rem;
  inset-inline-end: 0.6rem;
}

.copy-button {
  display: grid;
  place-items: center;
  min-inline-size: 2.25rem;
  min-block-size: 2.25rem;
  padding: 0.35rem;
  border: 1px solid var(--border-dark);
  border-radius: 0.5rem;
  background: var(--raised-dark);
  color: var(--text-dark);
  cursor: pointer;
}

.copy-button:hover {
  border-color: var(--brand-dark);
}

.icon {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-check,
.copy-button[data-copied] .icon-copy {
  display: none;
}

.copy-button[data-copied] .icon-check {
  display: block;
}

/* The bubble is the live region: shown and hidden by opacity, so it stays in the accessibility tree. */
.tip {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: calc(100% + 0.5rem);
  translate: 0 -50%;
  padding: 0.2rem 0.6rem;
  border-radius: 0.4rem;
  background: var(--raised-dark);
  color: var(--text-dark);
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.tip:not(:empty) {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tip {
    transition: none;
  }
}

.site-footer {
  padding-block: 2rem 3rem;
  border-block-start: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

/* Subpages: samples.html and formats.html */
main > .page-head {
  padding-block-end: 1rem;
}

.page-head h1 {
  margin-block: 1rem;
  font-size: clamp(2rem, 1.4rem + 2.5vw, 3.25rem);
  letter-spacing: -0.02em;
}

.page-head .lead {
  margin-inline: 0;
}

.prose :is(ul, ol) {
  padding-inline-start: 1.4rem;
}

.prose li + li {
  margin-block-start: 0.6rem;
}

.kinds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}

.actions-left {
  margin-block: 1.5rem;
}

.site-footer p {
  margin-block: 0 0.5rem;
}

/* The GitHub mark before links to GitHub: one masked file, so it takes the link's color in both themes. */
.github::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.35em;
  vertical-align: -0.125em;
  background-color: currentColor;
  flex: none;
  forced-color-adjust: none;
  -webkit-mask: url("github-mark.svg") center / contain no-repeat;
  mask: url("github-mark.svg") center / contain no-repeat;
}

/* Links that sit side by side wrap as whole links, without a separator that could start a line. */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em 1.25em;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Command Line and Graphical App pages */
.formats.wide {
  max-inline-size: calc(12rem + 1.5rem + 70ch);
}

.formats.wide div {
  grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
}

@media (max-width: 36em) {
  .formats.wide div {
    grid-template-columns: minmax(0, 1fr);
  }
}

.prose :is(p, li, dd) code,
.page-head code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.shot-section ul {
  padding-inline-start: 1.4rem;
}

.shot-section li + li {
  margin-block-start: 0.6rem;
}

.gallery-fig {
  margin: 0 0 1.5rem;
}

/* Header navigation. Collapsed by default, and without script: one Menu button opens the list as a popover.
   nav.js adds is-wide to the header when the whole row fits, and the list then becomes the inline navigation. */
.site-nav {
  display: flex;
  align-items: center;
}

.menu-button,
.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-block-size: 2.75rem;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.menu-button {
  anchor-name: --menu-button;
  justify-content: center;
  min-inline-size: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--raised);
  color: var(--text);
}

.dropdown-trigger {
  display: none;
}

.dropdown-trigger:hover,
.dropdown-trigger[aria-expanded="true"] {
  color: var(--text);
}

.icon-bars {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.chevron {
  margin-inline-start: 0.25em;
  inline-size: 0.45em;
  block-size: 0.45em;
  margin-block-start: -0.2em;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  rotate: 45deg;
}

.dropdown-trigger[aria-expanded="true"] .chevron {
  margin-block: 0.15em 0;
  rotate: 225deg;
}

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

.site-menu,
.dropdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-menu a,
.dropdown-list a {
  display: flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding-inline: 0.75rem;
  border-radius: 0.4rem;
}

.site-menu a:hover,
.dropdown-list a:hover {
  background: var(--surface);
  text-decoration: none;
}

@supports selector(:popover-open) {
  .site-menu[popover] {
    position: fixed;
    inset: auto;
    /* Roughly the header's height, for browsers without anchor positioning. */
    inset-block-start: 4.25rem;
    inset-block-start: anchor(--menu-button bottom);
    inset-inline-end: max(1rem, calc((100dvw - 72rem) / 2));
    inline-size: min(80dvw, 24rem);
    max-inline-size: calc(100dvw - 2rem);
    block-size: fit-content;
    max-block-size: calc(100dvh - 6rem);
    margin: 0;
    margin-block-start: 0.25rem;
    padding: 0.4rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--raised);
    color: var(--text);
    box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 0.18);
  }

  .site-menu[popover]:not(:is(:popover-open, .\:popover-open)) {
    display: none;
  }
}

/* A browser without popovers shows the whole list as a row that wraps, and no button. */
@supports not selector(:popover-open) {
  .menu-button {
    display: none;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .site-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
  }

  .site-menu a {
    min-block-size: 0;
    padding-inline: 0;
  }
}

.site-header.is-wide {
  .menu-button {
    display: none;
  }

  .dropdown-trigger {
    display: inline-flex;
  }

  .site-menu {
    position: static;
    display: flex;
    align-items: center;
    gap: 0.25rem 1.25rem;
    inline-size: auto;
    max-inline-size: none;
    block-size: auto;
    max-block-size: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .site-menu > li > a {
    min-block-size: 0;
    padding-inline: 0;
    border-radius: 0;
  }

  .site-menu > li > a:hover {
    background: none;
    text-decoration: underline;
  }

  /* Also hides the list before the script sets popover on it. */
  .dropdown-list:not(:is(:popover-open, .\:popover-open)) {
    display: none;
  }

  .dropdown-list:is(:popover-open, .\:popover-open) {
    display: grid;
    inline-size: max-content;
    min-inline-size: 13rem;
    block-size: auto;
    margin: 0;
    padding: 0.4rem;
    overflow: visible;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--raised);
    color: var(--text);
    box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 0.18);
  }

  .dropdown-list a {
    min-block-size: 2.5rem;
  }
}

@supports (position-area: block-end) {
  /* Fixed, as the popover's own default: with absolute the containing block is the page's first screen, so on a
     scrolled page the block-end space looks too small and flip-block opened the list upward, off the screen. */
  .site-header.is-wide .dropdown-list[popover] {
    position: fixed;
    position-area: block-end span-inline-end;
    position-try-fallbacks: flip-block, flip-inline;
    inset: auto;
    margin-block-start: 0.25rem;
  }
}

@supports not (position-area: block-end) {
  .site-header.is-wide .dropdown-list[popover] {
    position: fixed;
  }
}

@media (pointer: coarse) {
  .site-header.is-wide .site-menu > li > a {
    display: inline-flex;
    align-items: center;
    min-block-size: 2.75rem;
  }
}

/* Touch targets of at least 44 px for the links that sit apart from running text. */
@media (pointer: coarse) {
  .link-row a {
    display: inline-flex;
    align-items: center;
    min-block-size: 2.75rem;
  }
}
