/*
 * Gallery chrome.
 *
 * This file used to be deliberately plain, on the theory that a reader copying a
 * demo should copy map code and not page styling. That was the right call for a
 * reference and the wrong one for a showcase: a page that looks like a test
 * fixture tells a visitor the library produces test fixtures. So the chrome now
 * does one job, loudly: it makes the map look published.
 *
 * The rules it follows:
 *
 *   1. The figure is the hero. Chrome recedes to hairlines, space and type.
 *      Nothing gets a heavy border, because a border around a map competes with
 *      the map's own edges.
 *   2. Brand colour lives in the chrome, never in the data. The ApexCharts
 *      accents are for links, focus and the logotype; map fills come from
 *      cartographic ramps. A map coloured in brand colours is decoration.
 *   3. Editorial type for what the map says, interface type for what the reader
 *      operates. Serif titles and a source line under every figure, because that
 *      is the grammar readers already associate with a published map.
 *   4. Still deterministic. Light for everyone rather than following the OS, so a
 *      screenshot, a copied snippet and a bug report describe the same page.
 *      Dark surfaces here are authored, never inherited from a system setting.
 */

:root {
  color-scheme: light;

  /* Ink. Cool near-black rather than pure black: pure black on white vibrates,
     and every reference gallery worth copying avoids it. */
  --ink: #0c1118;
  --ink-2: #333d4c;
  --ink-3: #667283;
  --ink-4: #98a2b3;

  --paper: #ffffff;
  --page: #f4f6f9;
  --page-2: #eceff4;
  --night: #0b0f16;
  --night-2: #121824;

  --line: rgba(12, 17, 24, 0.09);
  --line-2: rgba(12, 17, 24, 0.16);
  --line-night: rgba(255, 255, 255, 0.1);

  /* ApexCharts accents. Chrome only. */
  --accent: #0077d9;
  --accent-bright: #008ffb;
  --accent-mint: #00e396;
  --accent-amber: #feb019;

  --sans:
    -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, 'New York', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --shadow-1: 0 1px 2px rgba(12, 17, 24, 0.04), 0 1px 3px rgba(12, 17, 24, 0.03);
  --shadow-2: 0 1px 2px rgba(12, 17, 24, 0.05), 0 12px 28px -14px rgba(12, 17, 24, 0.16);
  --shadow-3: 0 2px 4px rgba(12, 17, 24, 0.06), 0 26px 60px -24px rgba(12, 17, 24, 0.28);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;

  /* Legend and tooltip type, so the map's own furniture matches the page. */
  --apexmaps-font-size: 12px;
  --apexmaps-radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 0 96px;
  font:
    15px/1.6 var(--sans);
  letter-spacing: -0.005em;
  color: var(--ink-2);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

/* --- type ------------------------------------------------------------------ */

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.021em;
  text-wrap: balance;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 640;
  margin: 0 0 8px;
}

h2 {
  font-size: 19px;
  line-height: 1.3;
  font-weight: 620;
  margin: 0 0 6px;
}

h3 {
  font-size: 15px;
  font-weight: 620;
  margin: 0 0 4px;
}

/* Editorial voice: the title of a figure, not of a page section. Serif because
   that is the type a reader has seen on every published map they trust. */
.title {
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.011em;
  color: var(--ink);
  margin: 0 0 6px;
}

.title--lg {
  font-size: 31px;
}

/* Standfirst. One idea, wide measure, never the whole API. */
.dek {
  font-size: 15.5px;
  line-height: 1.62;
  color: var(--ink-3);
  max-width: 68ch;
  margin: 0 0 18px;
}

.kicker {
  font-size: 11px;
  font-weight: 660;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 0 0 10px;
}

.kicker--accent {
  color: var(--accent);
}

.note {
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.62;
  max-width: 72ch;
  margin: 0 0 16px;
}

.label {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.002em;
  margin-bottom: 8px;
}

.sub {
  color: var(--ink-3);
  font-size: 15.5px;
  line-height: 1.62;
  max-width: 72ch;
  margin: 0 0 24px;
}

/* The line that makes a map look like journalism rather than output: what the
   number is, where it came from, and when. Present on every figure, and it says
   "illustrative" out loud whenever the data is synthetic. */
.source {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-4);
}

.source b {
  font-weight: 600;
  color: var(--ink-3);
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in oklab, var(--accent) 32%, transparent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

strong {
  color: var(--ink);
  font-weight: 620;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  letter-spacing: 0;
  padding: 0.1em 0.36em;
  border-radius: 5px;
  background: var(--page-2);
  color: var(--ink);
}

/* Code blocks are dark on a light page on purpose: it separates "what you read"
   from "what you paste", and it is the one place a showcase can be emphatic
   without shouting. */
pre {
  margin: 0;
  padding: 16px 18px;
  background: var(--night);
  color: #ccd6e3;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* --- layout ---------------------------------------------------------------- */

.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 28px;
}

/* Figures may break out of the text measure. A map is not a paragraph. */
.wrap--wide {
  max-width: 1320px;
}

.grid {
  display: grid;
  /* minmax(0, 1fr), not the default auto: an `auto` track sizes to its widest
     child, so one demo with a wide or resizable box stretches every card on the
     page, and every map then measures itself against that stretched width. */
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 28px 0;
}

.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.stack-lg {
  display: grid;
  gap: 40px;
}

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

  .wrap,
  .grid {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* --- surfaces -------------------------------------------------------------- */

.card,
.figure {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-2);
}

.card > h1:first-child,
.card > h2:first-child,
.figure > h1:first-child {
  margin-top: 0;
}

/* A figure whose plot bleeds to the card edge. Padding above for the editorial
   block, none below, so the map meets its own frame the way a printed one does. */
.figure--bleed {
  padding: 26px 0 0;
}

.figure--bleed > *:not(.plot) {
  padding-left: 28px;
  padding-right: 28px;
}

.figure--bleed .plot {
  margin-bottom: 0;
}

/* Night figure, for the maps that belong on black: routes, arcs, orthographic
   globes. Authored per figure, never inherited from the OS. */
.figure--night {
  background: var(--night);
  color: #aab6c6;
  box-shadow: var(--shadow-3);
}

.figure--night .title,
.figure--night h1,
.figure--night h2,
.figure--night strong {
  color: #f2f5f9;
}

.figure--night .dek,
.figure--night .note,
.figure--night .label {
  color: #8f9cae;
}

.figure--night .source {
  border-top-color: var(--line-night);
  color: #6f7d90;
}

.figure--night .source b {
  color: #8f9cae;
}

.figure--night .stat__value {
  color: #f2f5f9;
}

.figure--night .stat__label {
  color: #77839a;
}

.figure--night .kicker {
  color: #7d8ca1;
}

.figure--night pre {
  background: #060a10;
}

.figure--night button,
.figure--night select {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-night);
  color: #dbe2ec;
}

.figure--night button:hover,
.figure--night select:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.2);
}

.figure--night .seg {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-night);
}

.figure--night .seg button[aria-pressed='true'] {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.plot {
  position: relative;
}

/* Editorial block above a figure: the standfirst on the left at a readable
   measure, the numbers that frame the map on the right. Two columns because a
   single left-aligned column under a wide figure leaves half the header empty,
   and empty is not the same as spacious. */
.figure__head {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 48px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}

.figure__head > *:first-child {
  flex: 1 1 44ch;
  min-width: 0;
}

.figure__head .dek {
  margin-bottom: 0;
}

.figure__head .stats {
  margin: 4px 0 0;
  gap: 28px;
}

/* A map answers "where"; a ranked list answers "which one is biggest". Pairing
   them is better information design than labelling twenty marks, and it gives a
   point map the one thing it always lacks: a readable order. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 28px;
  align-items: start;
}

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

.ranked {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}

.ranked li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  position: relative;
  font-size: 13px;
  transition: background 120ms ease;
}

/* The bar is a background rather than an element, so the row stays one hit
   target and the label always sits on top of its own value. */
.ranked li::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w, 0%);
  border-radius: 7px;
  /* Faint on purpose. Ten bars at a readable tint stop being a scale and become
     a block of colour that outshouts the map they are annotating. */
  background: color-mix(in oklab, var(--bar, var(--accent-bright)) 9%, transparent);
}

.figure--night .ranked li::before {
  background: color-mix(in oklab, var(--bar, var(--accent-bright)) 17%, transparent);
}

.ranked li:hover {
  background: var(--page-2);
}

.ranked li > * {
  position: relative;
}

.ranked__name {
  color: var(--ink);
  font-weight: 540;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranked__value {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.figure--night .ranked li:hover {
  background: rgba(255, 255, 255, 0.06);
}

.figure--night .ranked__name {
  color: #e9eef5;
}

.figure--night .ranked__value {
  color: #8f9cae;
}

/* --- controls -------------------------------------------------------------- */

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.row .label {
  margin-bottom: 0;
}

button,
select {
  font:
    inherit;
  font-size: 13px;
  font-weight: 520;
  letter-spacing: -0.003em;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease;
}

button:hover,
select:hover {
  border-color: var(--ink-4);
  box-shadow: var(--shadow-1);
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* Segmented control. Mutually exclusive options read better as one object than
   as a row of buttons that all look pressable at once. */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--page-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.seg button {
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 8px;
  padding: 5px 12px;
  color: var(--ink-3);
  font-weight: 540;
}

.seg button:hover {
  background: rgba(12, 17, 24, 0.05);
  box-shadow: none;
}

.seg button[aria-pressed='true'] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* Live readout next to the controls. Tabular figures so the text does not
   shuffle sideways every time a count changes. */
.readout {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--page-2);
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 560;
  color: var(--ink-3);
  letter-spacing: 0.002em;
}

.chip--free {
  background: color-mix(in oklab, var(--accent-mint) 16%, white);
  border-color: color-mix(in oklab, var(--accent-mint) 32%, white);
  color: #056f4a;
}

.chip--licensed {
  background: color-mix(in oklab, var(--accent-amber) 18%, white);
  border-color: color-mix(in oklab, var(--accent-amber) 36%, white);
  color: #8a5300;
}

/* Numbers that carry the point, sized to be read across a room. */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin: 0 0 18px;
}

.stat__value {
  font-size: 27px;
  line-height: 1.1;
  font-weight: 620;
  letter-spacing: -0.024em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-4);
  margin-top: 4px;
}

/* --- navigation ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(140%) blur(12px);
  background: color-mix(in oklab, var(--page) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 640;
  font-size: 14.5px;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

.brand__mark {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: linear-gradient(140deg, var(--accent-bright), #6a5cff);
}

.crumb {
  font-size: 13px;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb a {
  color: var(--ink-3);
  text-decoration: none;
  font-weight: 520;
}

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

.spacer {
  flex: 1;
}

/* --- hero ------------------------------------------------------------------ */

.hero {
  background:
    radial-gradient(90ch 60ch at 12% -20%, rgba(0, 143, 251, 0.2), transparent 62%),
    radial-gradient(70ch 50ch at 88% 0%, rgba(120, 92, 255, 0.18), transparent 60%),
    var(--night);
  color: #b9c4d3;
  padding: 84px 0 96px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hero__title {
  font-family: var(--serif);
  font-size: clamp(38px, 5.4vw, 62px);
  line-height: 1.04;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: #fff;
  margin: 0 0 18px;
  max-width: 22ch;
  text-wrap: balance;
}

.hero__dek {
  font-size: 18px;
  line-height: 1.55;
  color: #96a3b6;
  max-width: 58ch;
  margin: 0 0 28px;
}

.hero__dek strong {
  color: #dde5ef;
  font-weight: 560;
}

.hero .kicker {
  color: #7d8ca1;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero pre {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cfd9e6;
  font-size: 12.5px;
  padding: 11px 15px;
  white-space: pre;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 17px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 580;
  letter-spacing: -0.006em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: #fff;
  color: var(--night);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e6ecf4;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* --- section headers ------------------------------------------------------- */

.section {
  padding-top: 56px;
}

.section__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section__head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.024em;
}

.section__head p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-3);
  max-width: 62ch;
}

/* --- gallery cards --------------------------------------------------------- */

.demo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.demo-list a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: inherit;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.demo-list a:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
}

/* The preview is the whole pitch. A card without one is a table of contents
   row, and a visitor decides whether to click on the strength of the image. */
.demo-list .thumb {
  aspect-ratio: 16 / 9;
  background: var(--page-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.demo-list .thumb > * {
  position: absolute;
  inset: 0;
}

.demo-list .body {
  padding: 15px 17px 17px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.demo-list strong {
  display: block;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.012em;
}

.demo-list span {
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.demo-list a:hover strong {
  color: var(--accent);
}

/* Compact variant for the reference half of the gallery, where a visitor is
   looking something up rather than browsing for inspiration. */
.demo-list--compact {
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 10px;
}

.demo-list--compact a {
  padding: 13px 15px;
  box-shadow: none;
  border: 1px solid var(--line);
  background: transparent;
}

.demo-list--compact a:hover {
  transform: none;
  background: var(--paper);
  border-color: var(--line-2);
  box-shadow: var(--shadow-1);
}

.demo-list--compact strong {
  font-size: 13.5px;
}

.demo-list--compact span {
  font-size: 12.5px;
}

/* --- failure banner -------------------------------------------------------- */

.demo-error {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid #dc2626;
  border-radius: var(--r-sm);
  background: #fef2f2;
  color: #991b1b;
  white-space: pre-wrap;
  font-size: 12.5px;
  font-family: var(--mono);
}

/* --- map furniture --------------------------------------------------------- */

/* The legend is part of the graphic, so it gets graphic type: slightly tighter,
   tabular figures so class breaks line up in a column. */
.apexmaps-legend {
  font-variant-numeric: tabular-nums;
}

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