%% ============================================================
%%  Pandoc template for Springer LNCS (llncs.cls)
%%  Drop llncs.cls + splncs04.bst into paper/ alongside this file.
%%  Quarto renders index.qmd → index.tex → index.pdf via pdflatex.
%% ============================================================

\documentclass[$for(classoption)$$classoption$$sep$,$endfor$]{llncs}

%% ── Packages Quarto always needs ────────────────────────────
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage{array}    
\usepackage{calc}

%% ── Pandoc Image Bounding ───────────────────────────────────
\makeatletter
\newcommand*\pandocbounded[1]{% measure and scale image
  \sbox0{#1}%
  \ifdim\wd0>\linewidth
    \resizebox{\linewidth}{!}{\usebox0}%
  \else
    \usebox0%
  \fi
}
\makeatother

\newcounter{none}

%% ── References ──────────────────────────────
$if(natbib)$
\usepackage[$natbiboptions$]{natbib}
$endif$

%% ── Pandoc Syntax Highlighting ──────────────────────────────
$if(highlighting-macros)$
$highlighting-macros$
$endif$

%% ── Listings for Rust / Python code blocks ──────────────────
\usepackage{listings}
\lstset{
  basicstyle=\ttfamily\small,
  breaklines=true,
  frame=single,
  numbers=left,
  numberstyle=\tiny,
  xleftmargin=2em
}

%% ── tikz for architecture diagrams ─────────────────────────
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,shapes.geometric,fit,backgrounds}

%% ── Extra packages from document front matter ───────────────
$for(header-includes)$
$header-includes$
$endfor$

%% ── Hyperref config (keep LNCS-friendly) ────────────────────
\hypersetup{
  colorlinks=true,
  linkcolor=black,
  citecolor=black,
  urlcolor=blue,
  pdfauthor={$author-running$},
  pdftitle={$title$}
}

%% ── Bibliography ────────────────────────────────────────────
$if(bibliography)$
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$splncs04$endif$}
$endif$

%% ============================================================
\begin{document}

\title{$title$}
$if(subtitle)$
\subtitle{$subtitle$}
$endif$

%% Running head (short title, author list)
\titlerunning{$if(title-running)$$title-running$$else$$title$$endif$}
\authorrunning{$if(author-running)$$author-running$$else$$for(author)$$author.name$$sep$ \and $endfor$$endif$}

\author{$author$}

\institute{$institute$}

\maketitle

\begin{abstract}
$abstract$
\end{abstract}

$if(keywords)$
\keywords{$for(keywords)$$keywords$$sep$ \and $endfor$}
$endif$

%% ── Body ────────────────────────────────────────────────────
$body$

%% ── Bibliography ────────────────────────────────────────────
$if(bibliography)$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$endif$

\end{document}