/* Additions to Pico. All other styles are the Pico defaults. */

/* The brand palette. logo.svg and favicon.svg use the same colors. */
:root {
  --brand-rose: #be123c;
  --brand-amber: #f59e0b;
  --pico-font-family-sans-serif:
    Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --pico-font-family: var(--pico-font-family-sans-serif);
}

/* The same selectors as Pico, so these rules win by source order. */
:root:not([data-theme='dark']),
[data-theme='light'] {
  --pico-primary: #be123c;
  --pico-primary-background: #be123c;
  --pico-primary-border: #be123c;
  --pico-primary-underline: rgb(190 18 60 / 0.5);
  --pico-primary-hover: #9f1239;
  --pico-primary-hover-background: #9f1239;
  --pico-primary-hover-border: #9f1239;
  --pico-primary-hover-underline: #9f1239;
  --pico-primary-focus: rgb(190 18 60 / 0.4);
  --pico-primary-inverse: #fff;
  --pico-text-selection-color: rgb(190 18 60 / 0.2);
}

@media only screen and (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --pico-primary: #fb7185;
    --pico-primary-background: #be123c;
    --pico-primary-border: #be123c;
    --pico-primary-underline: rgb(251 113 133 / 0.5);
    --pico-primary-hover: #fda4af;
    --pico-primary-hover-background: #9f1239;
    --pico-primary-hover-border: #9f1239;
    --pico-primary-hover-underline: #fda4af;
    --pico-primary-focus: rgb(251 113 133 / 0.4);
    --pico-primary-inverse: #fff;
    --pico-text-selection-color: rgb(251 113 133 / 0.3);
  }
}

[data-theme='dark'] {
  --pico-primary: #fb7185;
  --pico-primary-background: #be123c;
  --pico-primary-border: #be123c;
  --pico-primary-underline: rgb(251 113 133 / 0.5);
  --pico-primary-hover: #fda4af;
  --pico-primary-hover-background: #9f1239;
  --pico-primary-hover-border: #9f1239;
  --pico-primary-hover-underline: #fda4af;
  --pico-primary-focus: rgb(251 113 133 / 0.4);
  --pico-primary-inverse: #fff;
  --pico-text-selection-color: rgb(251 113 133 / 0.3);
}

/* Spacing scale. Every gap on the page comes from these. */
:root {
  --space-gutter: clamp(1rem, 4vw, 2rem);
  --space-section: clamp(4rem, 9vw, 7rem);
  --space-block: 2.5rem; /* section intro to its content */
  --space-gap: 1.5rem; /* between cards in a grid */
  --measure: 42rem; /* readable line length */
}

/* One fluid content width for nav, hero, sections and footer, replacing Pico's
   stepped max-widths, which drop the side padding from 576px up. */
.container {
  max-width: calc(1200px + 2 * var(--space-gutter));
  padding-inline: var(--space-gutter);
}

/* A keyboard user always sees where the focus is. */
:focus-visible {
  outline: 2px solid var(--pico-primary);
  outline-offset: 2px;
}

/* Eyebrow labels above headings */
.eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pico-primary);
}

/* Sticky nav */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  /* Opaque, so the links keep their contrast above the dark hero. */
  background: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.site-nav > .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Keeps the nav on one row at phone width. */
@media (max-width: 575px) {
  .site-nav .wide-only {
    display: none;
  }
}

.site-nav a {
  color: var(--pico-muted-color);
  font-weight: 500;
}

.site-nav a:hover {
  color: var(--pico-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
}

/* Hero band: dark in both schemes. */
.hero-band {
  --pico-color: #f8fafc;
  --pico-h1-color: #f8fafc;
  --pico-muted-color: #cbd5e1;
  --pico-primary: #fb7185;
  position: relative;
  isolation: isolate;
  padding-block: 0;
  overflow: hidden;
  background-color: #0b0b14;
  color: var(--pico-color);
}

/* Faint grid, faded out towards the edges. */
.hero-band::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 25%, transparent 75%);
}

.hero-band::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(40rem 28rem at 75% 35%, rgb(225 29 72 / 0.28), transparent 70%);
}

.hero {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  padding-block: var(--space-section);
}

/* Lets the install pill and the code scroll inside their column instead of widening the page. */
.hero > *,
.hero-copy > *,
.demo > * {
  min-width: 0;
}

.hero h1 {
  margin-bottom: 1.25rem;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.gradient-text {
  background: linear-gradient(90deg, #fb7185, #fbbf24);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 40rem;
  margin-bottom: 2rem;
  font-size: 1.125rem;
  color: var(--pico-muted-color);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.hero-actions [role='button'] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.hero-actions [role='button']:focus-visible {
  outline-color: #fff;
}

.hero-actions .ghost {
  --pico-background-color: transparent;
  --pico-border-color: rgb(255 255 255 / 0.25);
  --pico-color: #f8fafc;
}

.hero-actions .ghost:is(:hover, :focus-visible) {
  --pico-background-color: rgb(255 255 255 / 0.06);
  --pico-border-color: rgb(255 255 255 / 0.5);
  --pico-color: #fff;
}

.install {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  width: fit-content;
  padding: 0.6rem 1.25rem;
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
  font-family: var(--pico-font-family-monospace);
  font-size: 0.9rem;
  white-space: nowrap;
}

.install .prompt {
  color: #94a3b8;
  user-select: none;
}

.install code {
  padding: 0;
  background: none;
  color: #e2e8f0;
  font-size: inherit;
}

.install-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* The hero demo: the template, and the live map that it makes. */
.demo {
  display: grid;
  gap: var(--space-gap);
}

@media (min-width: 992px) {
  .demo {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
}

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

.demo figcaption {
  order: -1;
  margin-bottom: 0.5rem;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cbd5e1;
}

.demo pre[class*='language-'] {
  flex: 1;
  margin: 0;
  font-size: clamp(0.7rem, 0.6rem + 0.3vw, 0.72rem);
}

/* A fixed height, so the page does not move when the map loads. */
.demo-map {
  flex: 1;
  height: 440px;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 12px;
  background: #151527;
}

.demo-map-status {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  padding: 1.5rem;
  color: #cbd5e1;
  text-align: center;
}

/* MapLibre draws its own controls and popups on a light surface. Remove the Pico form styles
   from them, and keep the dark text in the two schemes. */
.demo-map .maplibregl-ctrl button {
  margin: 0;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

.demo-map .maplibregl-ctrl-attrib,
.demo-map .maplibregl-popup-content {
  color: #1f2933;
}

.demo-map .maplibregl-ctrl-attrib a {
  color: #1f2933;
}

.demo-map .maplibregl-popup-content {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.demo-map details,
.demo-map summary {
  margin: 0;
}

/* Pico gives a marker its button look, because a MapLibre marker has role="button". */
.demo-map .maplibregl-marker {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

/* Inline code wraps with its sentence, so a full stop does not start a line. */
:not(pre) > code {
  display: inline;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* An anchor target stays below the sticky nav. */
[id] {
  scroll-margin-top: 5rem;
}

/* Section rhythm: one gap between sections, never doubled. */
body > main {
  padding-block: 0 var(--space-section);
}

main > section {
  margin: 0;
  padding-top: var(--space-section);
}

main > section > h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

/* The intro paragraph under a heading: readable width, then a fixed gap. */
main > section > h2 + p {
  max-width: var(--measure);
  margin-bottom: var(--space-block);
  font-size: 1.0625rem;
  color: var(--pico-muted-color);
}

main > section > h3 {
  margin-block: var(--space-block) 0.75rem;
}

main > section p {
  max-width: var(--measure);
}

/* The link from a section to its guide page. */
.more {
  margin-top: var(--space-gap);
  font-weight: 500;
}

/* Cards in a grid space by the grid gap, not their own margins. */
.grid {
  gap: var(--space-gap);
}

.grid > article,
.grid > pre,
.features article {
  margin: 0;
}

.grid + * {
  margin-top: var(--space-gap);
}

.grid > article > pre:last-child,
.grid > pre {
  margin-bottom: 0;
}

/* Features */
.features {
  display: grid;
  gap: var(--space-gap);
  margin-bottom: var(--space-gap);
}

@media (min-width: 576px) {
  .features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .features {
    grid-template-columns: repeat(4, 1fr);
  }
}

.features article {
  margin: 0;
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: none;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease;
}

.features article:hover {
  border-color: var(--pico-primary-underline);
  transform: translateY(-2px);
}

.features h3 {
  margin-block: 1rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

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

.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--pico-primary);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

  .features article:hover {
    transform: none;
  }
}

/* A row of names, for example the tile servers. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 var(--space-block);
  padding: 0;
}

.chips li {
  margin: 0;
  padding: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  list-style: none;
}

.chips a {
  display: block;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
}

.chips a:hover {
  color: var(--pico-primary);
}

/* Footer */
body > footer {
  border-top: 1px solid var(--pico-muted-border-color);
  padding-block: 2.5rem;
  color: var(--pico-muted-color);
}

body > footer a {
  color: inherit;
}

/* The row of sibling projects under the footer's own links. */
body > footer .family {
  margin: 0.5rem 0 0;
}

body > footer [aria-current='page'] {
  font-weight: 600;
  text-decoration: none;
}

/* Code blocks: one editor-style surface in both schemes. Pico pads the inner
   <code> and Prism pads the <pre>; only the <pre> pads here, so indents don't double. */
pre,
pre[class*='language-'] {
  margin: 0 0 var(--pico-typography-spacing-vertical);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 12px;
  background: #0d1117;
  color: #e2e8f0;
  font-size: clamp(0.75rem, 0.65rem + 0.35vw, 0.8125rem);
  line-height: 1.65;
  tab-size: 2;
}

pre > code,
pre > code[class*='language-'] {
  display: block;
  padding: 0;
  background: none;
  color: inherit;
  font-family: var(--pico-font-family-monospace);
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
  /* Wrap long lines instead of scrolling sideways. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The Prism comment color is too dim on this surface for small text. */
pre .token.comment {
  color: #a3adba;
}

/* Side-by-side code pairs only once each half is wide enough to read. */
@media (max-width: 1099px) {
  .grid:has(> article > pre, > pre) {
    grid-template-columns: 1fr;
  }
}

:root:not([data-theme='dark']) main pre {
  border-color: transparent;
}

.hero code {
  padding: 0.05em 0.3em;
  background: rgb(255 255 255 / 0.08);
  color: inherit;
}

.hero pre code {
  padding: 0;
  background: none;
}

/* A wide table scrolls inside its box, so the page never scrolls sideways on a phone. */
.table-wrap {
  max-width: 100%;
  margin-bottom: var(--pico-typography-spacing-vertical);
  overflow-x: auto;
}

.table-wrap table {
  margin-bottom: 0;
}

/* Only the name column keeps each name on one line. */
.table-wrap th[scope='row'] {
  font-weight: 500;
  white-space: nowrap;
}

/* The adapter grid: one card for each provider. */
.packages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-gap);
}

.packages article {
  margin: 0;
  padding: 1.25rem;
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: none;
}

.packages h4 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-family: var(--pico-font-family-monospace);
  overflow-wrap: anywhere;
}

.packages h4 a {
  text-decoration: none;
}

.packages .peer {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}

.packages dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
  font-size: 0.85rem;
}

.packages dt {
  font-weight: 600;
}

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

/* A short note, for a limit or a trap. */
.note {
  max-width: var(--measure);
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--pico-primary);
  background: var(--pico-card-sectioning-background-color);
  border-radius: 0 8px 8px 0;
}

/* The live examples: each one is a page of the guide in a frame. One column on a phone. */
.examples {
  display: grid;
  gap: var(--space-gap);
}

@media (min-width: 992px) {
  .examples {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.examples figure {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
}

.examples h4 {
  margin-bottom: 0.25rem;
}

/* The texts have the same space, so the frames of a row start on one line. */
.examples figure > p {
  flex: 1;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--pico-muted-color);
}

/* A fixed height, so the page does not move when the example loads. */
.examples iframe {
  display: block;
  width: 100%;
  height: 460px;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 12px;
  background: var(--pico-card-background-color);
}

.examples figcaption {
  margin-top: 0.5rem;
  padding: 0;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}
