/* The site borrows the cards' own language: hairline rules, GitHub blue for
   anything you can act on, heat orange kept for the ring itself so it still
   means intensity rather than decoration. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --ink: #1f2328;
  --ink-soft: #59636e;
  --line: #d8dee4;
  --line-soft: #eaeef2;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --heat: #fb8c00;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.06);
  --radius: 10px;
  --measure: 74ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-soft: #151b23;
    --ink: #e6edf3;
    --ink-soft: #9198a1;
    --line: #3d444d;
    --line-soft: #21262d;
    --accent: #4493f8;
    --accent-soft: #121d2f;
    --heat: #ffa726;
    --code-bg: #151b23;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* Anchored headings should not hide under the sticky masthead. */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
}

/* Masthead ---------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand img {
  display: block;
  height: 34px;
  width: auto;
}

.masthead nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.masthead nav a {
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.masthead nav a:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.masthead nav a.current {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.repo {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.32rem 0.75rem;
}

.repo:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Landing ---------------------------------------------------------------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--line-soft);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.14;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}

.lede {
  font-size: 1.075rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  max-width: 56ch;
}

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

.button {
  display: inline-block;
  padding: 0.55rem 1.15rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
}

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

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

.fineprint {
  margin: 1.25rem 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
  max-width: 48ch;
}

.hero-art img,
.gallery img {
  display: block;
  width: 100%;
  height: auto;
}

.section {
  padding-top: 2.75rem;
}

.section > h2 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}

.prose {
  max-width: var(--measure);
  color: var(--ink-soft);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.gallery figure {
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* The cards have quite different proportions, so the pictures are given a shared
   band to sit in. Otherwise each caption hangs at the foot of its own image and
   the row reads as three unrelated things. */
.gallery .shot {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Takes whatever height the tallest card in the row needs, so the captions
     below sit on one line instead of stepping with each card's proportions. */
  flex: 1;
  min-height: 118px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.gallery figcaption {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

/* A card wide enough to be the point of its own section, rather than one of a
   row of three. It keeps the framing of a gallery shot without the shared band,
   because there is nothing beside it to line a caption up with. */
.wide-shot {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.wide-shot img,
.wide-shot picture {
  display: block;
  width: 100%;
  height: auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.9rem;
}

.card {
  display: block;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.card:hover {
  border-color: var(--accent);
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--accent);
}

.card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Documentation pages ---------------------------------------------------- */

.doc {
  max-width: var(--measure);
}

.doc h1 {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}

.doc h2 {
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line-soft);
}

.doc h3 {
  font-size: 1.075rem;
  margin: 2.25rem 0 0.75rem;
}

.doc p {
  margin: 0 0 1.1rem;
}

.doc ul,
.doc ol {
  margin: 0 0 1.1rem;
  padding-left: 1.35rem;
}

.doc li {
  margin-bottom: 0.4rem;
}

.doc a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* A heading's own link is quiet until the heading is hovered, so it does not
   clutter a page being read rather than linked to. */
.permalink {
  margin-left: 0.4rem;
  color: var(--ink-soft);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
}

h2:hover .permalink,
h3:hover .permalink,
.permalink:focus {
  opacity: 0.55;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 0.1em 0.36em;
}

pre {
  margin: 0 0 1.35rem;
  padding: 0.95rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.55;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.8125rem;
}

/* Tables carry most of the guide's comparisons, including side-by-side images
   of the same ring drawn differently, so they are given room to scroll rather
   than being crushed to fit. */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

th {
  background: var(--bg-soft);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td img {
  display: block;
  max-width: 100%;
  height: auto;
}

.doc p img,
.doc > img {
  max-width: 100%;
  height: auto;
}

p[align="center"] img {
  display: inline-block;
  max-width: 100%;
  height: auto;
}

/* Previous and next ------------------------------------------------------ */

.steps {
  display: flex;
  gap: 0.9rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

.steps a {
  flex: 1 1 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
}

.steps a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.steps a span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}

.steps .next {
  text-align: right;
}

.footer {
  border-top: 1px solid var(--line-soft);
  padding: 1.75rem clamp(1rem, 4vw, 2.5rem);
}

.footer p {
  margin: 0;
  max-width: 1080px;
  margin-inline: auto;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.footer a {
  color: var(--accent);
}

@media (max-width: 800px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-art {
    order: -1;
  }

  .steps {
    flex-direction: column;
  }

  .masthead {
    gap: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Side-by-side comparisons ----------------------------------------------- */

/* Column-major: each cell is one variant, so the grid can reflow to fewer
   across on a narrow screen without any variant being hidden behind a scroll
   edge, which is what a table would have to do instead. */
.comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.9rem;
  margin: 0 0 1.5rem;
}

.comparison figure {
  margin: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.comparison figcaption {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.comparison figcaption code {
  background: var(--bg);
  font-size: 0.78rem;
}

.comparison .shot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  margin-bottom: 0.6rem;
}

.comparison .shot img {
  max-width: 100%;
  height: auto;
}

.comparison p {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* A table that still has to scroll says so, rather than ending at an edge that
   looks like the end of the data. */
.table-scroll {
  position: relative;
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left / 3rem 100% no-repeat,
    linear-gradient(to left, var(--bg) 30%, transparent) right / 3rem 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, rgba(31, 35, 40, 0.16), transparent) left / 0.7rem 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(31, 35, 40, 0.16), transparent) right / 0.7rem 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}

/* A spelled-out palette is a long comma-separated string with nowhere to break,
   which sets a minimum width wider than the cell holding it and pushes the rest
   of the row out of sight. Code is allowed to wrap here; a list of hex values
   loses nothing by it, and hidden content costs more than a mid-token break. */
.comparison figcaption code,
td code {
  overflow-wrap: anywhere;
}
