/* docs.rtemis.org index and 404 pages. Colors follow the rtemis-theme gray
   ramp and accent; every color is a token on :root, redefined for dark mode. */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f7f7f7;
  --fg: #181818;
  --muted: #555555;
  --faint: #9a9a9a;
  --line: #d2d2d2;
  --row-hover: #ededed;
  /* Tile ramp, lightest to darkest. */
  --t1: #f0f0f0;
  --t2: #e8e8e8;
  --t3: #e0e0e0;
  --t4: #d7d7d7;
  /* Hovered tile: the far end of the ramp. */
  --inv-bg: #2a2a2a;
  --inv-fg: #e8e8e8;
  --inv-muted: #a6a6a6;
  --inv-accent: #6ca3a0;
  --accent: #3d7470;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(1rem, 4vw, 3rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141414;
    --fg: #ededed;
    --muted: #a3a3a3;
    --faint: #6a6a6a;
    --line: #2c2c2c;
    --row-hover: #1c1c1c;
    --t1: #1a1a1a;
    --t2: #202020;
    --t3: #272727;
    --t4: #2e2e2e;
    --inv-bg: #cfcfcf;
    --inv-fg: #222222;
    --inv-muted: #4f4f4f;
    --inv-accent: #2f5f5c;
    --accent: #6ca3a0;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

ul,
ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.wrap {
  max-width: 76rem;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.mark {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  -webkit-mask: url("mark.svg") center / contain no-repeat;
  mask: url("mark.svg") center / contain no-repeat;
}

/* Top bar */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-sep {
  color: var(--faint);
  font-weight: 400;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.bar-link {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 160ms var(--ease);
}

.bar-link:hover {
  color: var(--fg);
}

/* Hero */

.hero {
  display: grid;
  gap: 1.75rem;
  padding-block: clamp(3.5rem, 10vw, 7.5rem) clamp(2.5rem, 6vw, 4.5rem);
}

.hero h1 {
  max-width: 18ch;
  font-size: clamp(2.4rem, 6.4vw, 5.25rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.hero h1 span {
  color: var(--faint);
}

.hero-path {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Gray ramp: ten steps from the foreground to the background color. */

.ramp {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  max-width: 22rem;
  height: 0.75rem;
}

.ramp li {
  background: color-mix(in srgb, var(--fg) calc(100% - var(--i) * 10%), var(--bg));
  transform-origin: bottom;
  animation: ramp-in 520ms var(--ease) both;
  animation-delay: calc(var(--i) * 45ms + 120ms);
}

@keyframes ramp-in {
  from {
    transform: scaleY(0);
  }
}

/* Section heading: eyebrow followed by a hairline. */

.section-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  order: 1;
}

.section-head .eyebrow:last-child:not(:first-child) {
  order: 2;
}

/* Package tiles. The 1px gap shows the grid background as hairlines. */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

@media (min-width: 48rem) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.tile {
  --tile-bg: var(--t1);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: clamp(17rem, 30vw, 22rem);
  padding: clamp(1.5rem, 3.2vw, 2.75rem);
  background: var(--tile-bg);
  isolation: isolate;
  transition:
    background-color 220ms var(--ease),
    color 220ms var(--ease);
}

/* Cover image of the guide, shown on hover. `--cover` is set per tile in the
   generated covers.css; the image is grayscale at build time. The gradient keeps
   the text side of the tile at the hover color. `isolation` on the tile lets
   z-index -1 place the layer above the tile background and below its content. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(
      to right,
      var(--inv-bg) 8%,
      color-mix(in srgb, var(--inv-bg) 72%, transparent) 50%,
      color-mix(in srgb, var(--inv-bg) 45%, transparent)
    ),
    var(--cover, none) center / cover no-repeat;
  opacity: 0;
  transition: opacity 320ms var(--ease);
}

.tile:hover::before,
.tile:focus-within::before {
  opacity: 1;
}

.tile:nth-child(2) {
  --tile-bg: var(--t2);
}

.tile:nth-child(3) {
  --tile-bg: var(--t3);
}

.tile:nth-child(4) {
  --tile-bg: var(--t4);
}

.tile-index {
  position: absolute;
  top: calc(clamp(1.5rem, 3.2vw, 2.75rem) - 0.2rem);
  right: calc(clamp(1.5rem, 3.2vw, 2.75rem) - 0.45rem);
  padding: 0.2rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
  transition: color 220ms var(--ease);
}

.tile-name {
  margin-top: auto;
  padding-top: 2.5rem;
  font-size: clamp(2.5rem, 5vw, 4.25rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

/* The name link covers the whole tile; the action links sit above it. */
.tile-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tile-link:focus-visible {
  outline: none;
}

.tile:has(.tile-link:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tile-desc {
  max-width: 34ch;
  font-size: 1.0625rem;
  color: var(--muted);
  transition: color 220ms var(--ease);
}

.tile-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-top: 0.5rem;
}

.tile-actions {
  display: flex;
  gap: 1.5rem;
}

.tile-actions a {
  position: relative;
  z-index: 1;
  display: inline-flex;
  gap: 0.4rem;
  padding-block: 0.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid currentColor;
}

.tile-actions a span {
  transition: transform 200ms var(--ease);
}

.tile-actions a:hover span {
  transform: translateX(0.25rem);
}

.tile-snippet {
  margin-right: -0.45rem;
  padding: 0.2rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--inv-muted);
  opacity: 0;
  transform: translateY(0.35rem);
  transition:
    opacity 220ms var(--ease),
    transform 220ms var(--ease);
}

.tile-snippet::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 0.2em;
  vertical-align: text-bottom;
  background: var(--inv-accent);
  animation: caret 1.1s steps(1) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

.tile:hover,
.tile:focus-within {
  background: var(--inv-bg);
  color: var(--inv-fg);
}

.tile:hover .tile-desc,
.tile:focus-within .tile-desc,
.tile:hover .eyebrow,
.tile:focus-within .eyebrow {
  color: var(--inv-muted);
}

.tile:hover .tile-index,
.tile:focus-within .tile-index,
.tile:hover .tile-actions a:hover,
.tile:focus-within .tile-actions a:hover {
  color: var(--inv-accent);
}

.tile:hover .tile-snippet,
.tile:focus-within .tile-snippet {
  opacity: 1;
  transform: none;
}

/* Solid chips keep the index and snippet legible over the cover image. */
.tile:hover .tile-snippet,
.tile:focus-within .tile-snippet,
.tile:hover .tile-index,
.tile:focus-within .tile-index {
  background: var(--inv-bg);
}

/* Touch screens have no hover state, so the snippet stays visible. */
@media (hover: none) {
  .tile-snippet {
    opacity: 1;
    transform: none;
    color: var(--muted);
  }
}

/* Elsewhere: a ruled ledger of sites outside docs.rtemis.org. */

.elsewhere {
  padding-block: clamp(4rem, 9vw, 6.5rem) 0;
}

.group {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line);
}

.group:last-child {
  border-bottom: 1px solid var(--line);
}

.group > .eyebrow {
  padding-block: 1.25rem 0.25rem;
}

@media (min-width: 48rem) {
  .group {
    grid-template-columns: 13rem 1fr;
  }

  .group > .eyebrow {
    padding-block: 1.6rem;
  }
}

.entry + .entry {
  border-top: 1px solid var(--line);
}

.entry a {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
  padding: 1.25rem 0.75rem;
  transition: background-color 160ms var(--ease);
}

.entry a:hover {
  background: var(--row-hover);
}

.entry-name {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.entry-host {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 160ms var(--ease);
}

.entry a:hover .entry-host {
  color: var(--accent);
}

.entry-desc {
  grid-column: 1 / -1;
  color: var(--muted);
}

@media (min-width: 64rem) {
  .entry a {
    grid-template-columns: 11rem 1fr auto;
  }

  .entry-desc {
    grid-column: auto;
    grid-row: 1;
    grid-column-start: 2;
  }
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: clamp(3rem, 7vw, 5rem) 2.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.foot-brand .mark {
  width: 1rem;
  height: 1rem;
}

.foot a:hover {
  color: var(--fg);
}

/* 404 page */

.notfound-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.notfound-actions a {
  display: inline-flex;
  gap: 0.4rem;
  padding-block: 0.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid currentColor;
}

.notfound-actions a:hover {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
