/* FlashMap project page. The accent is the paper figures' teal. */

:root {
  --bg-body: #f4f5f6;
  --bg-card: #ffffff;
  --bg-soft: #f3f5f6;
  --bg-code: #f6f8f9;
  --bg-paper: #ffffff;
  --text: #2d3236;
  --text-strong: #15191c;
  --text-muted: #5c656c;
  --border: #e0e4e7;
  --accent: #207488;
  --accent-hover: #185f70;
  --accent-soft: rgba(32, 116, 136, 0.1);
  --accent-on: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.04), 0 4px 14px rgba(16, 24, 32, 0.06);
  --ok: #2f7d4f;

  --tok-keyword: #9b3a5a;
  --tok-string: #2f6f3e;
  --tok-flag: #207488;
  --tok-comment: #6b7379;
  --tok-number: #96560f;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-sans: 'Alegreya Sans', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Alegreya', Georgia, serif;
  --font-sc: 'Alegreya SC', 'Alegreya', Georgia, serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0e1113;
    --bg-card: #161a1d;
    --bg-soft: #1d2226;
    --bg-code: #111518;
    --bg-paper: #f3f5f6;
    --text: #d6dce0;
    --text-strong: #f1f4f6;
    --text-muted: #9ba5ac;
    --border: #2a3136;
    --accent: #6cc0d2;
    --accent-hover: #93d4e2;
    --accent-soft: rgba(108, 192, 210, 0.12);
    --accent-on: #0b1416;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
    --ok: #7ccf9b;

    --tok-keyword: #e597ae;
    --tok-string: #a6d189;
    --tok-flag: #6cc0d2;
    --tok-comment: #808a91;
    --tok-number: #e5b071;
  }
}

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

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

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

body {
  margin: 0;
  padding: 2rem 1rem;
  background: var(--bg-body);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.15rem;
  line-height: 1.6;
  font-variant-numeric: lining-nums;
}

.container {
  width: 90%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 2.5rem 2.75rem 2rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

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

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

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

p {
  margin: 0 0 1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.8em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.paper-title {
  margin: 0 0 0.6rem;
  color: var(--text-strong);
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4.6vw, 2.6rem);
  font-weight: 450;
  line-height: 1.2;
  text-wrap: balance;
}

.sc {
  font-family: var(--font-sc);
  font-weight: 500;
}

.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15rem 1.1rem;
  margin: 0 0 0.45rem;
  color: var(--text-strong);
  font-size: 1.1em;
}

.affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.1rem 1rem;
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.92em;
}

.authors sup,
.affiliations sup {
  margin-left: 0.1em;
  font-size: 0.68em;
}

.affiliations sup {
  margin: 0 0.15em 0 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.link-button svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: currentColor;
}

a.link-button:hover,
a.link-button:focus-visible {
  background: var(--accent);
  color: var(--accent-on);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.link-button.is-disabled {
  background: transparent;
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: default;
}

/* TL;DR */
.tldr {
  margin: 0 0 1.75rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--accent-soft);
  color: var(--text-strong);
}

.tldr strong {
  margin-right: 0.35em;
  color: var(--accent);
}

/* Sections */
.section-heading {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.25;
}

/* Figures */
figure {
  margin: 1.5rem 0;
}

figcaption {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.88em;
  line-height: 1.5;
}

.paper {
  display: block;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-paper);
  box-shadow: var(--shadow);
}

.paper img {
  display: block;
  width: 100%;
  height: auto;
}

/* Video */
.video-figure {
  margin-top: 0;
}

.video-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.1rem 0;
  text-align: center;
}

.video-footer span + span::before {
  content: "\00b7";
  margin: 0 0.55em;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

.video-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-pending {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  color: var(--text-muted);
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%, var(--accent-soft), transparent 60%),
    var(--bg-soft);
}

.video-pending svg {
  width: 3.2rem;
  height: 3.2rem;
  padding: 0.8rem;
  border-radius: 50%;
  background: var(--bg-card);
  fill: var(--accent);
  box-shadow: var(--shadow);
}

/* With JS, the video stays hidden until it loads; a missing file shows the placeholder instead. */
.js .video-frame video {
  visibility: hidden;
}

.js .video-frame.ready video {
  visibility: visible;
}

.video-frame.missing video {
  display: none;
}

.video-frame.missing .video-pending {
  display: flex;
}

/* Phones get the 2x2 video (index.html picks it by width; script.js sets the exact ratio once it loads). */
@media (max-width: 600px) {
  .video-frame {
    aspect-ratio: 1080 / 1344;
  }
}

/* Quickstart */
.quickstart {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.qs-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}

.tablist,
.model-picker,
.client-picker {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--border);
}

.tablist [role='tab'],
.model-picker span,
.client-picker span {
  display: block;
  padding: 0.35rem 0.95rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tablist [role='tab']:hover,
.model-picker label:hover span,
.client-picker label:hover span {
  color: var(--text-strong);
}

.tablist [role='tab'][aria-selected='true'] {
  background: var(--accent);
  color: var(--accent-on);
}

.model-picker {
  margin: 0;
  border: 0;
  min-width: 0;
}

.model-picker label {
  position: relative;
  display: block;
}

.model-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.model-picker span {
  font-size: 0.9em;
  padding: 0.35rem 0.75rem;
}

.model-picker input:checked + span {
  background: var(--accent-soft);
  color: var(--accent);
}

.model-picker input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tab-panel {
  padding: 1.1rem 1.1rem 0.4rem;
}

.tab-panel:focus-visible {
  outline-offset: -3px;
}

.tab-panel + .tab-panel {
  border-top: 1px solid var(--border);
}

.panel-title {
  margin: 0 0 0.75rem;
  color: var(--text-strong);
  font-size: 1.1em;
}

/* Without JS, every framework is shown in turn, and the tabs and model picker (which need JS) are hidden. */
html:not(.js) .qs-bar {
  display: none;
}

.js .panel-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.js .tab-panel + .tab-panel {
  border-top: 0;
}

.tab-panel[hidden] {
  display: none;
}

.hint {
  margin: 0 0 0.9rem;
  color: var(--text-muted);
  font-size: 0.9em;
  line-height: 1.5;
}

/* Code blocks */
.code-block {
  margin: 0 0 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 2.3rem;
  padding: 0.25rem 0.4rem 0.25rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.code-title {
  color: var(--text-muted);
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82em;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.copy-button svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-button:hover {
  border-color: var(--border);
  background: var(--bg-card);
  color: var(--text-strong);
}

.copy-button.copied {
  color: var(--ok);
}

pre {
  margin: 0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  tab-size: 4;
}

pre code {
  font-size: inherit;
  white-space: pre;
}

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

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

.tok-flag {
  color: var(--tok-flag);
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

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

/* Phones */
@media (max-width: 640px) {
  body {
    padding: 0.5rem;
  }

  .container {
    width: auto;
    padding: 1.5rem 1rem 1.25rem;
    border-radius: var(--radius-md);
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .link-button {
    padding: 0.4rem 0.85rem;
    font-size: 0.95em;
  }

  .section-heading {
    margin-top: 2rem;
  }

  .paper {
    padding: 0.5rem;
  }

  .qs-bar {
    padding: 0.5rem;
  }

  .tablist {
    display: flex;
    width: 100%;
  }

  .tablist [role='tab'] {
    flex: 1;
    padding-inline: 0.5rem;
  }

  .tab-panel {
    padding: 0.85rem 0.75rem 0.2rem;
  }

  pre {
    padding: 0.75rem 0.8rem;
    font-size: 0.72rem;
  }
}

/* curl / OpenAI toggle on the request blocks (JS only; without JS both examples are shown). */
.client-picker {
  margin: 0 0 0 auto;
  border: 0;
  min-width: 0;
  padding: 0.15rem;
  border-radius: 8px;
}

.client-picker label {
  position: relative;
  display: block;
}

.client-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.client-picker span {
  padding: 0.15rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8em;
}

.client-picker input:checked + span {
  background: var(--accent-soft);
  color: var(--accent);
}

.client-picker input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

html:not(.js) .client-picker {
  display: none;
}

html:not(.js) pre[data-client='openai'] {
  border-top: 1px solid var(--border);
}

.js .code-block:not(.show-openai) pre[data-client='openai'],
.js .code-block.show-openai pre[data-client='curl'] {
  display: none;
}

.code-title {
  white-space: nowrap;
}

@media (max-width: 420px) {
  .code-head {
    gap: 0.3rem;
  }

  .client-picker span {
    padding: 0.15rem 0.45rem;
  }
}

/* On narrow screens the setup line wraps: drop the separators, which would start lines. */
@media (max-width: 600px) {
  .video-footer {
    gap: 0.15rem 0.9rem;
  }

  .video-footer span + span::before {
    content: none;
  }
}
