/* Colors follow nautical charts: white deep water, blue shallows, buff land
   and magenta for routes and anything you can act on. */

:root {
    --paper: #fafcfc;
    --paper-raised: #ffffff;
    --ink: #13253a;
    --ink-muted: #4a5d72;
    --rule: #d7e2e8;
    --shallows: #e6f1f6;
    --shallows-strong: #d3e8f1;
    --land: #ebddb2;
    --land-edge: #c3ad72;
    --contour: #2e6c99;
    --graticule: rgba(46, 108, 153, 0.22);
    --magenta: #b0186f;
    --magenta-hover: #8e1159;
    --magenta-soft: #f8e1ee;
    --error: #b3261e;
    --error-soft: #fbe9e7;

    --syntax-keyword: #2e6c99;
    --syntax-string: #7a5410;
    --syntax-number: #b0186f;
    --syntax-function: #13253a;
    --syntax-property: #3d5166;
    --syntax-comment: #6b7d8f;

    --font-sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --step--1: 0.875rem;
    --step-0: 1.0625rem;
    --step-1: 1.25rem;
    --step-2: 1.625rem;
    --step-3: 2.125rem;

    --radius-small: 4px;
    --radius: 8px;
    --gutter: clamp(16px, 4vw, 40px);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --paper: #0e1a26;
        --paper-raised: #132332;
        --ink: #e3ebf1;
        --ink-muted: #9fb2c3;
        --rule: #243a4d;
        --shallows: #13283a;
        --shallows-strong: #173349;
        --land: #5a5139;
        --land-edge: #8a7b50;
        --contour: #7fb4da;
        --graticule: rgba(127, 180, 218, 0.2);
        --magenta: #f07dbd;
        --magenta-hover: #f7a3d1;
        --magenta-soft: #3b1a2f;
        --error: #ff8f84;
        --error-soft: #3a1d1d;

        --syntax-keyword: #7fb4da;
        --syntax-string: #e2c27c;
        --syntax-number: #f07dbd;
        --syntax-function: #e3ebf1;
        --syntax-property: #bccbd8;
        --syntax-comment: #8095a8;

        color-scheme: dark;
    }
}

:root[data-theme='dark'] {
    --paper: #0e1a26;
    --paper-raised: #132332;
    --ink: #e3ebf1;
    --ink-muted: #9fb2c3;
    --rule: #243a4d;
    --shallows: #13283a;
    --shallows-strong: #173349;
    --land: #5a5139;
    --land-edge: #8a7b50;
    --contour: #7fb4da;
    --graticule: rgba(127, 180, 218, 0.2);
    --magenta: #f07dbd;
    --magenta-hover: #f7a3d1;
    --magenta-soft: #3b1a2f;
    --error: #ff8f84;
    --error-soft: #3a1d1d;

    --syntax-keyword: #7fb4da;
    --syntax-string: #e2c27c;
    --syntax-number: #f07dbd;
    --syntax-function: #e3ebf1;
    --syntax-property: #bccbd8;
    --syntax-comment: #8095a8;

    color-scheme: dark;
}

/* Base */

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 24px;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--step-0);
    font-stretch: 100%;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    text-wrap: balance;
}

p,
ul {
    margin: 0 0 1em;
}

p {
    text-wrap: pretty;
}

a {
    color: var(--magenta);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--magenta-hover);
}

code,
pre,
kbd,
textarea {
    font-family: var(--font-mono);
    font-size: 0.875em;
    font-variant-ligatures: none;
}

:not(pre) > code {
    padding: 0.1em 0.3em;
    border-radius: var(--radius-small);
    background: var(--shallows);
    white-space: nowrap;
}

a code {
    color: inherit;
}

pre {
    margin: 0;
}

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

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -100px;
    z-index: 10;
    padding: 8px 12px;
    border-radius: var(--radius-small);
    background: var(--magenta);
    color: var(--paper);
}

.skip-link:focus {
    top: 12px;
}

.container {
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-inline: var(--gutter);
}

/* Header */

.site-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding-block: 20px;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 1.5rem;
    font-stretch: 75%;
    font-weight: 750;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.wordmark:hover {
    color: var(--ink);
}

.wordmark-icon {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: var(--contour);
    stroke-width: 1.5;
}

.wordmark-icon .wordmark-route {
    stroke: var(--magenta);
    stroke-width: 2.25;
    stroke-linecap: round;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 20px;
    font-size: var(--step--1);
}

.site-nav a {
    color: var(--ink);
    text-decoration: none;
}

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

.version {
    font-family: var(--font-mono);
    color: var(--ink-muted);
    font-size: 0.8125rem;
}

/* Hero */

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    padding-block: clamp(16px, 4vw, 48px) clamp(56px, 8vw, 104px);
}

@media (min-width: 960px) {
    .hero {
        grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
        align-items: center;
        gap: 64px;
    }
}

.hero h1 {
    max-width: 14ch;
    font-size: clamp(2.75rem, 1.6rem + 4.4vw, 5rem);
    font-stretch: 68%;
    font-weight: 800;
    line-height: 0.96;
    letter-spacing: -0.012em;
}

.lede {
    max-width: 34rem;
    margin-top: 24px;
    color: var(--ink-muted);
    font-size: var(--step-1);
    line-height: 1.5;
}

.lede code {
    color: var(--ink);
}

.install {
    display: flex;
    align-items: stretch;
    max-width: 22rem;
    margin-top: 32px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper-raised);
}

.install-command {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
}

.install-command::before {
    content: '$ ';
    color: var(--ink-muted);
}

.install .copy-button {
    border: 0;
    border-left: 1px solid var(--rule);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.copy-button {
    min-width: 5.5em;
    padding: 6px 14px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--ink-muted);
    font-size: var(--step--1);
}

.copy-button:hover {
    color: var(--magenta);
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0 0;
}

.button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    color: var(--ink);
    font-weight: 550;
    text-decoration: none;
}

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

.button-primary {
    border-color: var(--magenta);
    background: var(--magenta);
    color: var(--paper);
}

.button-primary:hover {
    border-color: var(--magenta-hover);
    background: var(--magenta-hover);
    color: var(--paper);
}

/* Route demo */

.route-demo {
    display: grid;
    justify-items: center;
    gap: 20px;
    margin: 0;
}

.globe-frame {
    position: relative;
    width: 100%;
    max-width: 460px;
}

.globe {
    display: block;
    width: 100%;
    height: auto;
    cursor: grab;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    /* Rounds the focus outline. Labels close to the edge may extend
       beyond the globe. */
    border-radius: 50%;
    overflow: visible;
}

.globe.is-dragging {
    cursor: grabbing;
}

.globe:focus-visible {
    outline-offset: 6px;
}

.globe:focus:not(:focus-visible) {
    outline: none;
}

.globe-placeholder,
.globe-sphere {
    fill: var(--shallows-strong);
}

.globe-sphere {
    stroke: var(--contour);
    stroke-width: 1;
}

.globe-graticule {
    fill: none;
    stroke: var(--graticule);
    stroke-width: 0.75;
}

.globe-land {
    fill: var(--land);
    stroke: var(--land-edge);
    stroke-width: 0.6;
    stroke-linejoin: round;
}

.globe-route {
    fill: none;
    stroke: var(--magenta);
    stroke-width: 3;
    stroke-linecap: round;
}

.globe-route.is-drawing {
    stroke-dasharray: 1;
    animation: draw-route 1100ms cubic-bezier(0.65, 0, 0.35, 1) both;
}

@keyframes draw-route {
    from {
        stroke-dashoffset: 1;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.globe-center {
    fill: var(--paper);
    stroke: var(--contour);
    stroke-width: 2.5;
}

.globe-marker circle {
    fill: var(--magenta);
    stroke: var(--paper);
    stroke-width: 2;
}

.globe-marker.is-from circle {
    fill: var(--paper);
    stroke: var(--magenta);
    stroke-width: 3;
}

.globe-marker text {
    fill: var(--ink);
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 650;
    paint-order: stroke;
    stroke: var(--shallows-strong);
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
}

.globe-error {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 20%;
    color: var(--ink-muted);
    text-align: center;
}

.route-caption {
    max-width: 30rem;
    color: var(--ink-muted);
    font-size: var(--step--1);
    text-align: center;
}

.route-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 560px;
}

.field {
    display: grid;
    gap: 4px;
    flex: 1 1 8rem;
}

.field-label {
    color: var(--ink-muted);
    font-size: var(--step--1);
}

select {
    min-height: 44px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    background: var(--paper-raised)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23b0186f' stroke-width='1.5'/%3E%3C/svg%3E")
        no-repeat right 12px center / 12px 8px;
    appearance: none;
}

.swap-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    background: transparent;
}

.swap-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.unit-toggle {
    display: flex;
    padding: 3px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.unit-toggle button {
    min-width: 44px;
    min-height: 36px;
    border: 0;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--ink-muted);
}

.unit-toggle button[aria-pressed='true'] {
    background: var(--magenta-soft);
    color: var(--magenta);
    font-weight: 600;
}

.route-results {
    display: grid;
    width: 100%;
    max-width: 560px;
    margin: 0;
}

.route-results > div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 16px;
    padding-block: 10px;
    border-top: 1px solid var(--rule);
}

.route-results dt a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    text-decoration: none;
}

.route-results dt a:hover {
    color: var(--magenta);
}

.route-results dd {
    margin: 0;
    font-size: var(--step-1);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

@media (min-width: 560px) {
    .route-results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 32px;
    }

    .route-results > div {
        flex-direction: column;
        align-items: start;
        justify-content: start;
    }

    .route-results dd {
        text-align: left;
    }
}

.swatch {
    flex: none;
    width: 14px;
    height: 3px;
}

.swatch-route {
    border-radius: 2px;
    background: var(--magenta);
}

.swatch-center {
    width: 10px;
    height: 10px;
    margin-inline: 2px;
    border: 2.5px solid var(--contour);
    border-radius: 50%;
}

/* Docs layout */

.docs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-bottom: 96px;
}

@media (min-width: 960px) {
    .docs {
        grid-template-columns: 224px minmax(0, 1fr);
        gap: 64px;
    }
}

.docs-content {
    min-width: 0;
    max-width: 47rem;
}

/* Table of contents */

.toc {
    font-size: var(--step--1);
}

@media (min-width: 960px) {
    .toc {
        position: sticky;
        top: 0;
        align-self: start;
        max-height: 100vh;
        padding-top: 24px;
    }

    .toc-details > summary {
        display: none;
    }

    .toc-body {
        max-height: calc(100vh - 48px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: 24px;
        scrollbar-width: thin;
    }
}

@media (max-width: 959px) {
    .toc-details {
        border: 1px solid var(--rule);
        border-radius: var(--radius);
    }

    .toc-details > summary {
        min-height: 44px;
        padding: 10px 16px;
        cursor: pointer;
        font-weight: 600;
    }

    .toc-body {
        max-height: 60vh;
        overflow-y: auto;
        padding: 0 16px 16px;
    }
}

.toc-filter input {
    width: 100%;
    min-height: 40px;
    margin-bottom: 16px;
    padding: 0 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    background: var(--paper-raised);
}

.toc-filter input::placeholder {
    color: var(--ink-muted);
}

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

.toc-group + .toc-group {
    margin-top: 20px;
}

.toc-group-link {
    display: block;
    margin-bottom: 4px;
    color: var(--ink);
    font-weight: 650;
    text-decoration: none;
}

.toc-list ol a {
    display: block;
    padding: 3px 0 3px 12px;
    border-left: 2px solid var(--rule);
    color: var(--ink-muted);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.toc-list ol a.is-code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.toc-list a:hover {
    color: var(--magenta);
}

.toc-list a[aria-current] {
    border-left-color: var(--magenta);
    color: var(--magenta);
}

.toc-empty {
    color: var(--ink-muted);
}

/* Docs content */

.doc-group {
    padding-top: 24px;
}

.doc-group + .doc-group,
[data-api] .doc-group {
    margin-top: 48px;
}

.doc-group h2 {
    margin-bottom: 16px;
    font-size: var(--step-3);
    font-stretch: 82%;
    font-weight: 750;
    line-height: 1.1;
    letter-spacing: -0.005em;
}

.group-intro {
    max-width: 40rem;
    color: var(--ink-muted);
}

.doc-heading {
    margin: 40px 0 12px;
    font-size: var(--step-1);
    font-weight: 650;
    line-height: 1.3;
}

.docs-content ul {
    padding-left: 1.25em;
}

.docs-content li + li {
    margin-top: 0.4em;
}

.fn {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--rule);
}

.fn-title {
    margin-bottom: 12px;
    font-size: var(--step-0);
    font-weight: 400;
    line-height: 1.4;
}

.fn-title a {
    color: var(--ink);
    text-decoration: none;
}

.fn-title a:hover .fn-name {
    color: var(--magenta);
}

.fn-title code {
    padding: 0;
    background: none;
    font-size: 1.0625rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

.fn-name {
    font-weight: 600;
}

.fn-title > a > .fn-name {
    font-family: var(--font-sans);
    font-size: var(--step-1);
}

.fn-params {
    color: var(--ink-muted);
}

.fn-exports code {
    white-space: normal;
}

.fn-description p {
    max-width: 40rem;
}

/* Code snippets and examples */

.snippet {
    position: relative;
    margin-bottom: 16px;
}

.snippet pre,
.example-editor {
    border-radius: var(--radius);
    background: var(--shallows);
}

.snippet pre {
    padding: 14px 16px;
    overflow-x: auto;
    line-height: 1.6;
}

.snippet .copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--paper-raised);
}

.example {
    margin-top: 20px;
}

.example-editor {
    position: relative;
    border: 1px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
}

.example-editor:hover {
    border-color: var(--rule);
}

.example-editor:focus-within {
    border-color: var(--magenta);
}

/* The textarea lies exactly on top of the highlighted copy. Both need the
   same font, size, padding and wrapping. */
.example-highlight,
.example-input {
    margin: 0;
    padding: 16px;
    border: 0;
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    letter-spacing: 0;
}

@media (max-width: 559px) {
    .example-highlight,
    .example-input {
        padding: 12px;
        font-size: 0.8125rem;
    }
}

.example-highlight code {
    font-size: inherit;
}

.example-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    resize: none;
    overflow: hidden;
    background: transparent;
    color: transparent;
    caret-color: var(--ink);
    outline: none;
}

.example-input::selection {
    background: rgba(176, 24, 111, 0.22);
}

.example-output {
    padding: 12px 16px 14px;
    border: 1px solid var(--rule);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--paper-raised);
}

.example-output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
}

.example-output-label {
    color: var(--ink-muted);
    font-size: var(--step--1);
}

.example-reset {
    padding: 2px 10px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--magenta);
    font-size: 0.8125rem;
}

.example-reset:hover {
    border-color: var(--magenta);
}

.example-logs div {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--ink-muted);
    white-space: pre-wrap;
}

.example-result {
    margin-top: 4px;
    font-size: 0.9375rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.example-result code {
    font-size: inherit;
}

.example-output.is-error {
    border-color: var(--error);
    background: var(--error-soft);
}

.example-output.is-error .example-output-label,
.example-output.is-error .example-result {
    color: var(--error);
}

.tok-keyword {
    color: var(--syntax-keyword);
}

.tok-string {
    color: var(--syntax-string);
}

.tok-number,
.tok-literal {
    color: var(--syntax-number);
}

.tok-function {
    color: var(--syntax-function);
    font-weight: 600;
}

.tok-property {
    color: var(--syntax-property);
}

.tok-comment {
    color: var(--syntax-comment);
}

/* Footer */

.site-footer {
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
    font-size: var(--step--1);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 32px;
    padding-block: 32px 40px;
}

.site-footer p {
    margin: 0;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-credit {
    flex-basis: 100%;
}
