:root {
  --bg: #fbfaf7;
  --text: #1c1b18;
  --text-secondary: #5f5d56;
  --hairline: #e4e2db;
  --surface: #ffffff;
  --backdrop: rgb(28 27 24 / 0.32);
  --pressed: #eeece5;
  --focus: #8a6d00;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --size-title: 1.25rem;
  --size-body: 1rem;
  --size-small: 0.875rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 3.5rem;
  --space-6: 6rem;

  --icon: 2.5rem;
  --page: 42rem;
  --gutter: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --text: #ecebe6;
    --text-secondary: #a3a199;
    --hairline: #33322e;
    --surface: #211f1d;
    --backdrop: rgb(0 0 0 / 0.56);
    --pressed: #2e2d29;
    --focus: #f2c919;
  }
}

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

/* The gutter stays when the open dialog stops the page from scrolling. */
html {
  scrollbar-gutter: stable;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0 auto;
  padding: var(--space-6) max(var(--gutter), env(safe-area-inset-right)) var(--space-5) max(var(--gutter), env(safe-area-inset-left));
  max-width: calc(var(--page) + 2 * var(--gutter));
  background: var(--bg);
  color: var(--text);
  font: 400 var(--size-body) / 1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.masthead {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

h1 {
  margin: 0;
  font-size: var(--size-title);
  font-weight: 600;
  line-height: 1.2;
}

.mark {
  display: block;
  width: 2rem;
  height: 2rem;
}

section + section {
  margin-top: var(--space-5);
}

h2 {
  margin: 0 0 var(--space-2);
  color: var(--text-secondary);
  font-size: var(--size-small);
  font-weight: 400;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  border-top: 1px solid var(--hairline);
}

.list li:last-child {
  border-bottom: 1px solid var(--hairline);
}

.product,
.project {
  display: grid;
  text-decoration: none;
  padding-block: var(--space-3);
}

.product {
  grid-template-columns: var(--icon) minmax(0, 1fr) auto;
  column-gap: var(--space-3);
  align-items: baseline;
}

.project {
  grid-template-columns: 11rem minmax(0, 1fr);
  column-gap: var(--space-3);
  align-items: baseline;
}

.icon {
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: var(--space-1);
  display: block;
  width: var(--icon);
  height: var(--icon);
  border-radius: 22%;
  object-fit: contain;
}

.name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.domain {
  color: var(--text-secondary);
  font-size: var(--size-small);
}

.about {
  color: var(--text-secondary);
}

.product .about {
  grid-column: 2 / -1;
}

.product:hover .name,
.project:hover .name {
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.product:active .name,
.project:active .name {
  color: var(--text-secondary);
}

.colophon {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
  margin-top: var(--space-5);
  color: var(--text-secondary);
  font-size: var(--size-small);
}

/* The padding is the touch target: 44pt with one line of small text. */
.colophon a {
  padding-block: 0.75rem;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.note {
  margin: 0;
  color: var(--text-secondary);
}

.note a {
  color: var(--text);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.details {
  width: min(30rem, 100% - 2 * var(--gutter));
  max-width: none;
  max-height: 85vh;
  max-height: 85dvh;
  padding: 0;
  border: 0;
  border-radius: 0.875rem;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.details::backdrop {
  background: var(--backdrop);
}

.details-panel {
  padding: var(--space-4);
}

.details-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.details-icon:empty {
  display: none;
}

.details-icon .icon {
  margin: 0;
}

.details h2 {
  flex: 1;
  margin: 0;
  color: var(--text);
  font-size: var(--size-title);
  font-weight: 600;
  line-height: 1.2;
}

/* A 44pt target, pulled out so that the cross itself lines up with the text edge. */
.details-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.5rem -0.75rem -0.5rem 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.details-close:hover {
  color: var(--text);
}

.details-close:active {
  background: var(--pressed);
}

.details-body p {
  margin: 0;
}

.facts {
  margin: var(--space-3) 0 0;
  font-size: var(--size-small);
}

.facts div {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  column-gap: var(--space-3);
  padding-block: var(--space-2);
  border-top: 1px solid var(--hairline);
}

.facts dt {
  color: var(--text-secondary);
}

.facts dd {
  margin: 0;
}

.details-body .actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: var(--space-3);
  border: 1px solid var(--text);
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--surface);
  font-weight: 500;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.button:hover {
  opacity: 0.86;
}

.button:active {
  opacity: 0.72;
}

.button-quiet {
  border-color: var(--hairline);
  background: none;
  color: var(--text);
}

.button-quiet:hover {
  border-color: var(--text-secondary);
  opacity: 1;
}

.button-quiet:active {
  background: var(--pressed);
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .details[open] {
    animation: details-in 160ms ease-out;
  }

  .details[open]::backdrop {
    animation: backdrop-in 160ms ease-out;
  }
}

@keyframes details-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

@media (max-width: 36rem) {
  body {
    padding-top: var(--space-5);
  }

  .project {
    grid-template-columns: minmax(0, 1fr);
  }

  /* On a phone the dialog is a bottom sheet, within the reach of a thumb. */
  .details {
    width: 100%;
    margin: auto 0 0;
    border-radius: 0.875rem 0.875rem 0 0;
  }

  .details-panel {
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }
}
