/* Shared styles for the F1 Circuits API examples: one file, light and dark. */

:root {
  color-scheme: light dark;
  --bg: #f4f4f7;
  --card: #ffffff;
  --text: #15151e;
  --muted: #5d5d6c;
  --line: #dcdce4;
  --accent: #e10600;
  --accent-text: #ffffff;
  --code-bg: #f0f0f4;
  --ok: #1a7f37;
  --warn: #9a6700;
  --error: #c62828;
  --tile: #ffffff;
  --json-key: #0b5cad;
  --json-string: #1a7f37;
  --json-number: #a3480b;
  --json-literal: #8250df;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111116;
    --card: #1b1b23;
    --text: #e9e9ef;
    --muted: #a3a3b3;
    --line: #2e2e3a;
    --accent: #ff3b30;
    --code-bg: #24242e;
    --ok: #4ac26b;
    --warn: #d29922;
    --error: #ff6b6b;
    --tile: #1b1b23;
    --json-key: #79b8ff;
    --json-string: #85e89d;
    --json-number: #ffab70;
    --json-literal: #d2a8ff;
  }
}

* { box-sizing: border-box; }

/* An element hidden by the page stays hidden, whatever display its class gives it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }

/* ---- header and navigation ---- */

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 3px solid var(--accent);
}

header.site .brand {
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}
header.site .brand span { color: var(--accent); }

header.site nav { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; }
header.site nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}
header.site nav a:hover { color: var(--text); background: var(--code-bg); }
header.site nav a[aria-current="page"] { color: var(--accent-text); background: var(--accent); }

.api-switch { font-size: 0.85rem; color: var(--muted); }
.api-switch summary { cursor: pointer; }
.api-switch summary code { color: var(--text); }
.api-switch form { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.api-switch input { width: 18rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

h1 { margin: 0.25rem 0 0.5rem; font-size: 1.9rem; }
h2 { margin: 2rem 0 0.5rem; font-size: 1.35rem; }
h3 { margin: 1.25rem 0 0.4rem; font-size: 1.1rem; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 60rem; }

footer.pager {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 1rem 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  border-top: 1px solid var(--line);
}
footer.pager a { text-decoration: none; font-weight: 600; }
footer.pager [rel="next"] { justify-self: end; }
footer.pager .home { justify-self: center; }

/* ---- cards, calls and results ---- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.grid-2 > .card { margin: 0; }

/* The request bar: the exact URL a call sends, with Copy and Open. */
.request {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  min-height: 2.4rem;
}
.request .verb {
  font: 700 0.75rem var(--mono);
  color: var(--accent-text);
  background: var(--ok);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}
.request .url {
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.85rem;
  scrollbar-width: thin;
}
.request .label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.request:empty { display: none; }
/* In a narrow card: the buttons on the first row, the whole URL wrapped below them. */
.request.compact { flex-wrap: wrap; }
.request.compact .url { order: 9; flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 0.75rem; }
.request button, .request a.open { font-size: 0.8rem; padding: 0.2rem 0.55rem; }
.request a.open {
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
}

.status { font-size: 0.85rem; margin: 0.4rem 0 0.6rem; color: var(--muted); min-height: 1.3em; }
.status.ok::before { content: "● "; color: var(--ok); }
.status.pending::before { content: "◌ "; color: var(--warn); }
.status.error { color: var(--error); }
.status.error::before { content: "✕ "; }
.status.idle::before { content: "○ "; }

.result:empty { display: none; }

.hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; }
.hint.error { color: var(--error); }

pre.code {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  overflow: auto;
  max-height: 32rem;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.code.tall { max-height: 70vh; }
.j-key { color: var(--json-key); }
.j-str { color: var(--json-string); }
.j-num { color: var(--json-number); }
.j-lit { color: var(--json-literal); }

.notice {
  border-left: 4px solid var(--warn);
  background: var(--code-bg);
  padding: 0.6rem 0.8rem;
  border-radius: 0 8px 8px 0;
  margin: 0.6rem 0;
}
.notice.error { border-left-color: var(--error); }
.notice.info { border-left-color: var(--json-key); }

/* ---- forms ---- */

.controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: end; margin: 0.5rem 0 0.75rem; }
.controls label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--muted); }
.controls label.inline { flex-direction: row; align-items: center; gap: 0.35rem; color: var(--text); font-size: 0.9rem; }
.controls fieldset { border: none; padding: 0; margin: 0; display: flex; gap: 0.75rem; align-items: center; }
.controls legend { font-size: 0.8rem; color: var(--muted); padding: 0; margin-bottom: 0.2rem; }

select, input, button {
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
input[type="number"] { width: 6.5rem; }
input.wide { min-width: 16rem; }
select { max-width: 30rem; }
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.55; cursor: progress; }

/* ---- lists of choices (circuit browser) ---- */

.choices { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.choices button { font-size: 0.88rem; }
.choices button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.choices button small { color: inherit; opacity: 0.7; }

/* ---- images ---- */

.track-tile {
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  min-height: 9rem;
}
.track-tile img { width: 100%; max-width: 480px; max-height: 320px; object-fit: contain; }
@media (prefers-color-scheme: dark) {
  /* The service's track images are a black line on a transparent ground. */
  .track-tile img { filter: invert(1); }
}

.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.layout-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.layout-card h3 { margin: 0; }
.layout-card p { margin: 0; font-size: 0.88rem; color: var(--muted); }
.layout-card .links { font-size: 0.85rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.layout-card .track-tile { min-height: 7rem; }
.layout-card .track-tile img { max-height: 160px; }
.layout-card code.small { font-size: 0.72rem; word-break: break-all; }

.poster { display: block; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.poster.portrait { max-height: 640px; }
.preview { margin-top: 0.75rem; }

/* ---- tables ---- */

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td code { white-space: nowrap; }
table.kv th { width: 12rem; }

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

#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); }
.leaflet-container { font: inherit; }

/* ---- index ---- */

.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.pages a.page {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text);
  text-decoration: none;
}
.pages a.page:hover { border-color: var(--accent); }
.pages a.page h3 { margin: 0 0 0.3rem; color: var(--accent); }
.pages a.page p { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.92rem; }
.pages a.page ul { margin: 0; padding-left: 1.1rem; font-size: 0.78rem; }
.pages a.page li code { background: none; padding: 0; overflow-wrap: anywhere; }

/* ---- library ---- */

.status.warn::before { content: "! "; color: var(--warn); }
.status.warn { color: var(--warn); }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 1.3rem; margin: 1.5rem 0 0.25rem; }
.crumbs a { text-decoration: none; font-weight: 600; }
.crumbs [aria-current="page"] { font-weight: 700; }
.crumbs .sep { color: var(--muted); }

.level-head { display: flex; gap: 1.25rem; align-items: flex-start; margin: 0.75rem 0 1rem; }
.level-head .tile { width: 180px; flex: none; }
.level-head h2 { margin-top: 0.25rem; }
.level-head p { margin: 0.3rem 0; color: var(--muted); }

.tiles { display: grid; gap: 1.25rem 1rem; }
.tiles.posters { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.tiles.thumbs { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.tile { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.tile-link { color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 0.3rem; }
a.tile-link:hover .tile-frame { outline: 3px solid var(--accent); }
.tile-frame {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.tile-frame.poster { aspect-ratio: 2 / 3; }
.tile-frame.thumb { aspect-ratio: 16 / 9; }
.tile-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-frame .tile-note { font-size: 0.8rem; color: var(--muted); text-align: center; padding: 0.5rem; }
.tile-frame.plain { background: var(--card); padding: 0.75rem; text-align: center; }
.tile-frame.plain strong { display: block; font-size: 1rem; margin-bottom: 0.4rem; }
.tile-frame.plain span { font-size: 0.8rem; color: var(--muted); }
.tile-title { font-weight: 650; line-height: 1.3; }
.tile-sub { font-size: 0.82rem; color: var(--muted); }
.tile .request.compact { padding: 0.25rem 0.35rem; min-height: 0; gap: 0.3rem; }
.tile .request.compact .url { font-size: 0.66rem; }
.tile .request .verb { font-size: 0.62rem; }
.tile .request button, .tile .request a.open { font-size: 0.7rem; padding: 0.1rem 0.4rem; }
.tile .status { font-size: 0.72rem; margin: 0; }

.spinner {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 1s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 4s; } }
.waiting { display: flex; gap: 1rem; align-items: center; }
.waiting p { margin: 0.2rem 0; }

/* ---- the Formula 1 disclaimer, at the foot of every page ---- */

footer.disclaimer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}
footer.disclaimer p { margin: 0.3rem 0; max-width: 60rem; }

/* ---- segmented toggles (picker, builder) ---- */

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* ---- photo picker ---- */

.photos { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.photos.thumb { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.photo-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  background: var(--card);
}
.photo-card.chosen { outline: 3px solid var(--accent); }
.photo-card.picked { border-color: var(--ok); border-width: 2px; }
.photo-frame { background: #000; border-radius: 6px; overflow: hidden; aspect-ratio: 2 / 3; }
.photos.thumb .photo-frame { aspect-ratio: 16 / 9; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.treat-bw .photo-frame img { filter: url(#bw); }
.photo-card .name { font-weight: 650; font-size: 0.85rem; line-height: 1.3; overflow-wrap: anywhere; }
.photo-card .meta { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.photo-card .meta b { color: var(--text); font-weight: 600; }
.photo-card .tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tag { font-size: 0.7rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; color: var(--muted); }
.tag.mark { border-color: var(--ok); color: var(--ok); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.photo-card .actions { display: flex; gap: 0.5rem; align-items: center; margin-top: auto; font-size: 0.8rem; }
.photo-card .actions button { font-size: 0.8rem; padding: 0.2rem 0.6rem; }
.photos.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.copy-block { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.6rem 0; }
.copy-block .head { display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; }
.copy-block .head span { font-size: 0.85rem; color: var(--muted); }

/* ---- poster builder ---- */

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem 1.25rem; }
.option { border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem; display: flex; flex-direction: column; gap: 0.35rem; }
.option .opt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.option .opt-head code { font-weight: 700; }
.option .opt-head small { color: var(--muted); font-size: 0.75rem; text-align: right; }
.option .opt-body { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: center; font-size: 0.88rem; }
.option .opt-body label { display: inline-flex; align-items: center; gap: 0.3rem; }
.option.set { border-color: var(--accent); }
.option select { max-width: 100%; min-width: 0; }
.option .opt-body > select { flex: 1; }
.option input[type="color"] { padding: 0.1rem; width: 3rem; height: 2rem; }
.option input[type="range"] { flex: 1; min-width: 8rem; }
.credits { margin-top: 0.75rem; }
.credits table th { width: 9rem; }
.credits td code { white-space: normal; overflow-wrap: anywhere; }
details.result-raw { margin-top: 0.75rem; }
details.result-raw summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; margin-bottom: 0.5rem; }
table.sources td code { white-space: normal; overflow-wrap: anywhere; }
table.sources th:nth-child(3), table.sources td:nth-child(3) { min-width: 9rem; }
table.sources th:nth-child(4), table.sources td:nth-child(4) { width: 34%; }
.card > div + p.hint { margin-top: 0.75rem; }

/* ---- the picker's satellite frames ---- */

.map-frame { position: relative; background: #111; border-radius: 6px; overflow: hidden; aspect-ratio: 2 / 3; }
.photos.thumb .map-frame { aspect-ratio: 16 / 9; }
.map-frame .map-box { position: absolute; inset: 0; }
.map-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.map-frame.plain { display: grid; place-items: center; padding: 0.75rem; text-align: center; color: #c8c8d2; background: #1d1d24; font-size: 0.82rem; }
.photo-card .request.compact { padding: 0.25rem 0.35rem; min-height: 0; gap: 0.3rem; }
.photo-card .request.compact .url { font-size: 0.66rem; }
.photo-card .status { font-size: 0.75rem; margin: 0; }
#sat .choices { margin: 0.75rem 0 0.25rem; }

/* ---- guides (guides/): numbered steps, boxes to copy, example pictures ---- */

ol.steps { padding-left: 1.6rem; max-width: 60rem; }
ol.steps > li { margin: 0.55rem 0; padding-left: 0.2rem; }
ol.steps > li::marker { font-weight: 700; color: var(--accent); }
.see { color: var(--ok); font-weight: 600; }

.copy {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  margin: 0.5rem 0;
  max-width: 60rem;
}
.copy code { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.88rem; }
.copy button { flex: none; font-size: 0.8rem; padding: 0.2rem 0.6rem; }

.examples-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; margin: 0.75rem 0; }
.examples-row figure { margin: 0; }
.examples-row img { display: block; border-radius: 8px; border: 1px solid var(--line); height: 240px; width: auto; }
.examples-row figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; max-width: 22rem; }

.guide-step { max-width: 62rem; }
.guide-step h2 .num { color: var(--accent); }
details.more { margin: 0.6rem 0; max-width: 60rem; }
details.more summary { cursor: pointer; font-weight: 600; }
/* In a guide, an address or file name in a table wraps, so the table fits a phone. */
.guide-step td code { white-space: normal; overflow-wrap: anywhere; }
