%%
%% Copyright (c) 2022-2023 by Friedemann Bartels
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008/05/04 or later.
%%

\documentclass[
  draft,
  twoside,
  beginright,
  % fanfold,
  import,
  optimize={quality=50, density=72}
]{pagelayout}

\usepackage{lipsum}
\usepackage{tgheros}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\sfdefault}

\pagewidth=200mm
\pageheight=200mm
\margin=20mm
\innermargin=40mm
\gutter=10mm
\bleed=3mm
\safetymargin=5mm
\spinewidth=7mm

\safezone

\newbeforepage{primary}{
  \setgrid[height=\margin, y=0mm]{{{}}}

  \leftpage{
    \text[center]{\thepage}
  }

  \rightpage{
    \text[center]{\hspace*{\fill}\thepage}
  }
}
\setbeforepage{primary}

\begin{document}
  \Large
  \pagenumbering{roman}

  \template[back cover,margin=0mm, inner margin=0mm]{f}{}

  \page[front cover,color=white,page graphic=kopi, inner margin=\margin]{
    \text[bottom]{
      \fontsize{42mm}{46mm}\selectfont
      \centering
      KØPI
    }

    \ifspine{
      \setgrid[width=\spinewidth,x=-\spinewidth]{{{1}}}
      \place{0 0 1 1}
      \tikzgraphic{
        \node[rotate=90] at (0.5\width,0.5\height){
          \fontsize{4mm}{8mm}\selectfont
          KØPI
        };
      }
    }
  }

  \page{
    \text{
      \strut
      \tableofcontents
    }
  }

  \pagenumbering{arabic}

  \setcounter{page}{0}
  \page[before page=]{}

  \page{
    \text{
      \strut
      \section{Introduction}
      \lipsum[1][1-7]
    }
  }

  \newgraphic{kopi wide}{vpos=0.43, file=kopi}
  \page[double, page graphic=kopi wide, before page=, color=white]{
    \rightpage{
      \text[bottom]{
        \lipsum[1][8-10]
      }
    }
  }

\end{document}
