/* Foresportia API tutorial — pedagogical "notebook-style" page.
   Loaded in addition to css/api-docs.css, which provides the shared docs
   chrome (layout, sidebar, breadcrumb, pager, code blocks, dark theme). */

.docs-tutorial .docs-summary { max-width: 72ch; }

/* --- Language switch --- */
.tuto-lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  margin: 0 0 12px;
  padding: 4px;
  border: 1px solid var(--docs-line);
  border-radius: 9px;
  background: var(--docs-card);
}
.tuto-lang-switch a,
.tuto-lang-switch span {
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}
.tuto-lang-switch a:hover { background: #eef2ff; }
.tuto-lang-switch span[aria-current="true"] {
  background: var(--docs-blue);
  color: #fff;
}
[data-theme="dark"] .tuto-lang-switch a:hover { background: #1f2d47; }

/* --- Google Colab button --- */
.tuto-colab-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  padding: 10px 15px;
  border: 1px solid #e29a00;
  border-radius: 8px;
  background: #f9ab00;
  color: #202124 !important;
  box-shadow: 0 3px 8px rgba(249, 171, 0, 0.24);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tuto-colab-link:hover {
  background: #f6a000;
  box-shadow: 0 5px 12px rgba(249, 171, 0, 0.3);
  transform: translateY(-1px);
}
.tuto-colab-link:focus-visible { outline: 2px solid #e29a00; outline-offset: 3px; }
.tuto-colab-link img { display: block; object-fit: contain; }

/* --- Table of contents --- */
.tuto-toc {
  margin: 22px 0 8px;
  padding: 18px 20px;
  border: 1px solid var(--docs-line);
  border-radius: 12px;
  background: #f7f8fb;
}
.tuto-toc h2 {
  margin: 0 0 10px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--docs-muted);
}
.tuto-toc ol {
  margin: 0; padding: 0; list-style: none;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px;
  counter-reset: tuto;
}
.tuto-toc li { counter-increment: tuto; }
.tuto-toc a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 6px; border-radius: 7px;
  color: var(--docs-ink); font-size: 0.9rem; text-decoration: none;
}
.tuto-toc a::before {
  content: counter(tuto);
  flex: 0 0 auto;
  min-width: 1.4em;
  color: var(--docs-blue); font-variant-numeric: tabular-nums; font-weight: 800;
}
.tuto-toc a:hover { background: #eef2ff; }
[data-theme="dark"] .tuto-toc { background: #18243a; }
[data-theme="dark"] .tuto-toc a:hover { background: #1f2d47; }

/* --- Steps --- */
.tuto-step { scroll-margin-top: 84px; }
.tuto-step > h2 {
  display: flex; align-items: baseline; gap: 12px;
}
.tuto-step > h2 .tuto-step-num {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9rem; height: 1.9rem; padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--docs-blue); color: #fff;
  font-size: 0.9rem; font-weight: 800; font-variant-numeric: tabular-nums;
}

/* --- Outcome preview list --- */
.tuto-outcome {
  margin: 18px 0 0; padding: 0; list-style: none;
  display: grid; gap: 12px;
}
.tuto-outcome li {
  padding: 14px 16px 14px 44px; position: relative;
  border: 1px solid var(--docs-line); border-radius: 10px;
  background: var(--docs-card);
  line-height: 1.55;
}
.tuto-outcome li::before {
  content: "✓";
  position: absolute; left: 16px; top: 14px;
  color: #177146; font-weight: 800;
}
[data-theme="dark"] .tuto-outcome li::before { color: #5fd39a; }

/* --- Code block with copy button --- */
.tuto-code { position: relative; margin: 16px 0; }
.tuto-code > pre { margin: 0; padding-top: 40px; }
.tuto-copy {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 7px;
  background: rgba(255, 255, 255, 0.08); color: #dbeafe;
  font: 600 0.76rem ui-monospace, SFMono-Regular, Consolas, monospace;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tuto-copy:hover { background: rgba(255, 255, 255, 0.16); }
.tuto-copy:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.tuto-copy.is-copied { border-color: #5fd39a; color: #5fd39a; }
.tuto-copy .tuto-copy-done { display: none; }
.tuto-copy.is-copied .tuto-copy-idle { display: none; }
.tuto-copy.is-copied .tuto-copy-done { display: inline; }

/* --- Chart preview cards (placeholders until real captures are added) --- */
.tuto-chart {
  margin: 16px 0; padding: 0;
  border: 1px solid var(--docs-line); border-radius: 12px; overflow: hidden;
  background: var(--docs-card);
}
/* Real captures are wide: one figure per line, scaled to the column, height
   auto (the width/height attributes keep the intrinsic ratio and avoid CLS). */
.tuto-chart img { display: block; width: 100%; max-width: 100%; height: auto; }
.tuto-chart figcaption {
  padding: 12px 16px; border-top: 1px solid var(--docs-line);
  color: var(--docs-muted); font-size: 0.85rem; line-height: 1.55;
}

/* --- Full code accordion --- */
.tuto-full { margin: 20px 0 0; border: 1px solid var(--docs-line); border-radius: 12px; }
.tuto-full > summary {
  cursor: pointer; list-style: none;
  padding: 14px 18px;
  font-weight: 700; color: var(--docs-ink);
}
.tuto-full > summary::-webkit-details-marker { display: none; }
.tuto-full > summary::before {
  content: "▸"; display: inline-block; margin-right: 10px; color: var(--docs-blue);
  transition: transform 0.15s;
}
.tuto-full[open] > summary::before { transform: rotate(90deg); }
.tuto-full-body { padding: 0 18px 18px; }

/* --- Action buttons (copy all / download) --- */
.tuto-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 12px; }
.tuto-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 9px;
  font: 600 0.9rem inherit; text-decoration: none; cursor: pointer;
  border: 1px solid var(--docs-blue);
}
.tuto-btn-primary { background: var(--docs-blue); color: #fff; }
.tuto-btn-primary:hover { filter: brightness(1.06); }
.tuto-btn-secondary { background: transparent; color: var(--docs-blue); }
.tuto-btn-secondary:hover { background: #eef2ff; }
.tuto-btn:focus-visible { outline: 2px solid var(--docs-blue); outline-offset: 2px; }
[data-theme="dark"] .tuto-btn-secondary:hover { background: #1f2d47; }
.tuto-copy-status { margin: 0; min-height: 1.2em; color: var(--docs-muted); font-size: 0.85rem; }

/* --- Developer CTA --- */
.tuto-cta {
  margin: 40px 0 0; padding: 24px 24px;
  border: 1px solid var(--docs-line); border-radius: 14px;
  background: linear-gradient(180deg, #f2f5ff, #ffffff);
}
.tuto-cta h2 { margin: 0 0 8px; }
.tuto-cta p { margin: 0 0 16px; max-width: 62ch; }
[data-theme="dark"] .tuto-cta { background: linear-gradient(180deg, #18243a, #0f172a); }

/* --- Related links --- */
.tuto-related { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tuto-related a { color: var(--docs-blue); font-weight: 600; }

@media (max-width: 700px) {
  .tuto-lang-switch { width: 100%; }
  .tuto-lang-switch a,
  .tuto-lang-switch span { flex: 1; padding-inline: 8px; }
  .tuto-toc ol { grid-template-columns: 1fr; }
  .tuto-copy { top: 6px; right: 6px; padding: 5px 9px; font-size: 0.72rem; }
}
