\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{preamble}[2026/05/10 Deez Training Handbook preamble]

% Engine: lualatex preferred (also compiles under pdflatex with this stack).

% ------- Encoding & geometry -------
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=2.4cm, top=2.6cm, bottom=2.6cm, headheight=14pt]{geometry}

% ------- Math packages -------
\usepackage{amsmath, amsthm, amssymb}
\usepackage{mathtools}
\usepackage{bm}

% ------- Fonts (IBM Plex trio + newtxmath defaults) -------
% Plex Serif body + Plex Sans headers + Plex Mono code.
% newtxmath without the baskervaldx tuning gives clean math glyphs that
% sit well next to Plex Serif.
\usepackage[scale=0.96]{plex-serif}
\usepackage[scale=0.92]{plex-sans}
\usepackage[scale=0.86]{plex-mono}
\usepackage{newtxmath}
\linespread{1.08}
\usepackage{microtype}

\let\emptyset\varnothing

% ------- Graphics & TikZ -------
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes.geometric, shapes.misc,
                shapes.symbols, calc, fit,
                decorations.pathreplacing, decorations.pathmorphing,
                decorations.markings, backgrounds, patterns}

% tikzlings -- pre-drawn cute cartoon critters used for the Hugs mascot
\usepackage{tikzlings}
\usepackage{caption}
\captionsetup{font=small, labelfont={sf,bf}, labelsep=period, justification=centering}
\graphicspath{{./figures/}}

% ------- Layout -------
\usepackage{titlesec}
\usepackage{titling}
\usepackage[bottom]{footmisc}
\usepackage{enumitem}
\usepackage{booktabs}
\setlist{itemsep=2pt, topsep=4pt}
\setlength{\parskip}{4pt plus 1pt minus 0pt}
\setlength{\parindent}{0pt}

% ------- Colour palette: drawn from the Deez Hops/Hucks/Hugs kits.
% Winter kit (royal blue / violet / lime) supplies structural colours.
% Summer kit (hot pink / cyan) supplies sparing accents -- pink in
% particular is reserved for emphasis only because it does not read at
% body sizes.
\usepackage{xcolor}
\definecolor{deezblue}{HTML}{2E2FB1}        % winter-kit royal blue (primary)
\definecolor{deeznavy}{HTML}{1B1F4E}        % deeper navy for headings
\definecolor{deezviolet}{HTML}{6A4FE0}      % violet bridge between blue and pink
\definecolor{deezlime}{HTML}{6FA80F}        % darker lime for body text/lines
\definecolor{kitlime}{HTML}{C7E844}         % bright spray-paint lime, matched to the team kits
\definecolor{deezlimebg}{HTML}{F1F6E1}      % pale lime body background
\definecolor{deezcyan}{HTML}{1FB7D6}        % cyan (number colour on summer kit)
\definecolor{deezpink}{HTML}{EC1D85}        % hot pink (use sparingly!)
\definecolor{deezpinkbg}{HTML}{FCD9E4}      % pale pink background tint
\definecolor{deezsand}{HTML}{F4F1E4}        % cream
\definecolor{notegray}{HTML}{4A4A4A}

% Drill-box tints
\definecolor{setupheaderbg}{HTML}{1B1F4E}   % navy header
\definecolor{setupbodybg}{HTML}{E6E8F4}     % pale blue body
\definecolor{procheaderbg}{HTML}{2E2FB1}    % royal blue header
\definecolor{procbodybg}{HTML}{ECEDF8}      % pale lavender-blue body
\definecolor{varheaderbg}{HTML}{4A6E12}     % dark lime header
\definecolor{varbodybg}{HTML}{F1F6E1}       % pale lime body

% ------- Hyperlinks & cross-refs -------
\usepackage[colorlinks=true,linkcolor=deezblue,citecolor=deezblue,urlcolor=deezblue]{hyperref}
\usepackage[capitalise,noabbrev]{cleveref}

% ------- Section title styling -------
\titleformat{\section}
  {\sffamily\Large\bfseries\color{deeznavy}}
  {\thesection}{0.6em}{}
\titleformat{\subsection}
  {\sffamily\large\bfseries\color{deezblue}}
  {\thesubsection}{0.5em}{}
\titleformat{\subsubsection}
  {\sffamily\normalsize\bfseries\color{deezblue}}
  {\thesubsubsection}{0.4em}{}

% ------- Coloured drill boxes (tcolorbox) -------
\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems, breakable, skins}

\tcbset{
  drillbox/.style={
    enhanced, breakable,
    arc=0pt, outer arc=0pt,
    boxrule=0pt, titlerule=0pt,
    left=10pt, right=10pt, top=6pt, bottom=6pt,
    toptitle=4pt, bottomtitle=4pt, lefttitle=10pt,
    fonttitle=\sffamily\bfseries,
    coltitle=white,
    before skip=8pt, after skip=8pt,
  }
}

% Plain (un-numbered) coloured boxes -- "Setup" / "Procedure" /
% "Variations" speak for themselves; numbers would only fight the
% subsection numbering used by drills.
\newtcolorbox{setupbox}{
  drillbox, colback=setupbodybg, colframe=setupbodybg,
  colbacktitle=setupheaderbg, title={Setup},
}
\newtcolorbox{procedurebox}{
  drillbox, colback=procbodybg, colframe=procbodybg,
  colbacktitle=procheaderbg, title={Procedure},
}
\newtcolorbox{variationsbox}{
  drillbox, colback=varbodybg, colframe=varbodybg,
  colbacktitle=varheaderbg, title={Variations},
}

% Equipment is a slim no-counter strip with a cyan left bar
\usepackage{mdframed}
\newmdenv[
  leftline=true, rightline=false, topline=false, bottomline=false,
  linewidth=3pt, linecolor=deezcyan,
  innerleftmargin=10pt, innerrightmargin=0pt,
  innertopmargin=2pt, innerbottommargin=2pt,
  skipabove=4pt, skipbelow=8pt
]{equipmentbox}

\newenvironment{equipment}{%
  \begin{equipmentbox}%
  {\sffamily\bfseries\color{deezcyan}Equipment.}\,\ignorespaces%
}{\end{equipmentbox}}

% Drill heading: \drill{Title}{TYPE} renders the title as a numbered
% subsection (so it lands in the TOC) with a TYPE tag floated right
% and a lime rule underneath. Each drill starts on its own page.
\newcommand{\drill}[2]{%
  \clearpage
  \subsection[#1]{#1\hfill{\normalfont\sffamily\bfseries\footnotesize\color{white}%
   \colorbox{deezviolet}{\hspace{4pt}\strut #2\hspace{4pt}}}}%
  \vspace{-6pt}%
  \noindent\textcolor{deezlime}{\rule{\linewidth}{1.2pt}}%
  \par\vspace{2pt}%
}

% Coach's note: italic body, sans-serif gray header (no box)
\newtheoremstyle{notestyle}
  {4pt}{4pt}{\itshape}{}{\sffamily\bfseries\color{notegray}}{.}{ }{}
\theoremstyle{notestyle}
\newtheorem*{coachnote}{Coach's note}

% ------- Headers / footers -------
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\sffamily\small\nouppercase{\leftmark}}
\fancyhead[R]{\sffamily\small\thepage}
\fancyfoot[R]{\sffamily\small\itshape Deez}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}

% ------- The 'aj' signature command (Aj = A with descended J) -------
\newcommand{\aj}{\ensuremath{A\hspace{-0.25em}\raisebox{-.35em}{J}}}

% ------- Reference to Bijl's Ultimate Trainer's Manual.
% \bijl       -- inline gray italic reference; safe inside schedule tables.
% \sourcebijl -- green pill badge for the drill-heading source slot.
% \sourcecoach-- pink pill badge for drills that DON'T match a Bijl figure
%               (the coach's own variants); pink reads as "non-canonical".
\newcommand{\bijl}[2]{%
  {\sffamily\footnotesize\itshape\color{notegray}[Bijl~\S#1, p.~#2]}%
}
\newcommand{\sourcebijl}[2]{%
  \tikz[baseline=-0.6ex]{\node[fill=deezlime, text=white,
       font=\sffamily\bfseries\scriptsize, inner xsep=6pt, inner ysep=2pt,
       rounded corners=2pt]{Bijl~\S#1,\,p.~#2};}%
}
\newcommand{\sourcecoach}{%
  \tikz[baseline=-0.6ex]{\node[fill=deezpink, text=white,
       font=\sffamily\bfseries\scriptsize, inner xsep=6pt, inner ysep=2pt,
       rounded corners=2pt]{Coach's~drill};}%
}

% ------- Silent section for weeks.
% Each week page already announces itself in the running header, so
% repeating the title as a big section heading is redundant. \weekstart
% bumps the section counter, registers the TOC entry, and sets the
% running header -- but renders nothing on the page. Use in place of
% \section{} inside the week files.
\newcommand{\weekstart}[1]{%
  \refstepcounter{section}%
  \phantomsection
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
  \markboth{#1}{}%
}

% ------- Per-session schedule envelope.
% Wraps the standard 5-block timetable. Body is tabular rows of
% `time & item & focus \\`.
\newenvironment{schedule}{%
  \par\addvspace{4pt}%
  \begin{center}\sffamily\small
  \begin{tabular}{r l l}
  \toprule
  $t$~(min) & Item & Focus \\
  \midrule
}{%
  \bottomrule
  \end{tabular}
  \end{center}
  \par\addvspace{4pt}%
}

% ------- TikZ field-diagram styles (Ultimate Frisbee).
% Symbol conventions follow Hildo Bijl's Ultimate Trainer's Manual
% (legend on p.~ii). Playing direction is always UPWARD.
%   offence  -- a cross-out X (Bijl's offensive player), navy
%   thrower  -- a larger X with a small filled disc-circle to its right
%               (\thrower{<name>}{<coord>})
%   defender -- a short diagonal "facing" slash with a perpendicular
%               "movement" tick, gray (\defender{<coord>}{<facing>}{<tick>})
%   disc     -- small filled blue circle
%   discpile -- cluster of three small circles (waiting-disc pile)
%               (\discpile{<coord>})
%   cone     -- small filled lime triangle
%   cut      -- solid arrow (violet)        -- player run
%   throw    -- dotted arrow (pink, sparing) -- disc flight
%   sideline -- dotted gray line
\tikzset{
  cone/.style={regular polygon, regular polygon sides=3, draw=deezlime, fill=deezlime,
               inner sep=0pt, minimum size=5pt},
  offence/.style={cross out, draw=deeznavy, line width=1.0pt,
                  inner sep=0pt, minimum size=9pt},
  throwerx/.style={cross out, draw=deeznavy, line width=1.2pt,
                   inner sep=0pt, minimum size=12pt},
  disc/.style={circle, draw=deezblue, fill=deezblue, inner sep=0pt, minimum size=4pt},
  cut/.style={->, >={Stealth[length=5pt]}, line width=1.1pt, deezviolet},
  cutb/.style={->, >={Stealth[length=5pt]}, line width=1.1pt, deezblue},
  cutg/.style={->, >={Stealth[length=5pt]}, line width=1.1pt, deezlime},
  throw/.style={->, >={Stealth[length=5pt]}, line width=1.0pt, deezpink,
                densely dotted},
  sideline/.style={densely dotted, notegray, line width=0.6pt},
  fieldlabel/.style={font=\sffamily\footnotesize\itshape, color=notegray},
  cuelabel/.style={font=\sffamily\footnotesize, color=deezviolet},
  cuelabelp/.style={font=\sffamily\footnotesize, color=deezpink},
  cuelabelb/.style={font=\sffamily\footnotesize, color=deezblue},
}

% Thrower = larger X with adjacent disc circle.
% \thrower{<name>}{<coord>} -- X is named <name> for later reference.
\newcommand{\thrower}[2]{%
  \node[throwerx] (#1) at #2 {};
  \node[disc] at ($#2+(0.28,0.0)$) {};
}

% Defender mark: short slash + perpendicular tick.
% \defender{<coord>} draws a diagonal facing line (down-right by default)
% with a movement tick at its lower end.
\newcommand{\defender}[1]{%
  \begin{scope}[shift={#1}]
    \draw[notegray, line width=1.0pt] (-0.12,0.18) -- (0.12,-0.18);
    \draw[notegray, line width=1.0pt] (0.04,-0.10) -- (0.20,-0.02);
  \end{scope}%
}

% Pile of three small waiting-discs, centred on <coord>.
\newcommand{\discpile}[1]{%
  \begin{scope}[shift={#1}]
    \node[disc] at (-0.12,-0.06) {};
    \node[disc] at (0.10,-0.10) {};
    \node[disc] at (-0.02,0.10) {};
  \end{scope}%
}

% Numbered cue-tag (filled disc with white digit). Use as
% \cuetag{1} or \cuetag[deezpink]{2a}
\newcommand{\cuetag}[2][deezviolet]{%
  \tikz[baseline=-0.5ex]\node[circle, draw=#1, fill=#1, text=white,
                              font=\sffamily\bfseries\scriptsize,
                              inner sep=1pt, minimum size=12pt]{#2};%
}

\endinput
