% \iffalse meta-comment
%
% Copyright (C) 2026 by NAAM MOHAMED
% -----------------------------------
% الأستاذ ناعم محمد - NAAM MOHAMED
%
% هذا العمل مرخص بموجب رخصة المشاع الإبداعي (نسب المصنف - منع الاشتقاق).
% This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.
%
% حزمة الإطارات المرنة 
% Professional Flexible Borders Package
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{na-pageborder.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{na-pageborder}[2026/05/06 v1.8 Professional Borders by NAAM MOHAMED]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{na-pageborder}
\usepackage{polyglossia}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage[most]{tcolorbox}
\usepackage[xetex, colorlinks=true, urlcolor=teal, pdfpagemode=UseNone, pdfstartview=FitH]{hyperref}

% --- إعدادات اللغة ---
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic]{Arial}

% --- تنسيق أرقام الأقسام داخل إطارات ملونة ---
\renewcommand{\thesection}{\arabic{section}}
\titleformat{\section}
  {\color{blue!70!black}\normalfont\Large\bfseries}
  {\begin{tcolorbox}[
      enhanced, boxrule=0.5pt, colback=blue!5, colframe=blue!70!black,
      size=small, hbox, symptoms, on line, arc=2pt
    ]\thesection\end{tcolorbox}}
  {1em}{}

\titleformat{\subsection}{\color{teal!70!black}\normalfont\large\bfseries}{\thesubsection}{1em}{}

\begin{document}
  \DocInput{na-pageborder.dtx}
\end{document}
%</driver>
% \fi
%
% % --- تصميم عنوان الحزمة بإطار مضاعف ملون ---
% \begin{center}
% \begin{tcolorbox}[
%     enhanced, arc=5pt, boxrule=1.5pt, colframe=blue!80!black, colback=white,
%     title={\large \textbf{حزمة الإطارات المرنة \textsf{na-pageborder}}},
%     center title, fonttitle=\bfseries, drop shadow,
%     borderline={0.7pt}{2pt}{blue!40!white}
% ]
%   \centering
%   \Large \textbf{دليل الاستخدام والتوثيق البرمجي} \\[0.5em]
%   \large \textbf{الأستاذ ناعم محمد \textlatin{(NAAM MOHAMED)}} \\[0.3em]
%   \small \textbf{الإصدار 1.8 --- مايو 2026}
% \end{tcolorbox}
% \end{center}
%
% \begin{abstract}
% \color{gray!80!black}
% تقدم هذه الحزمة ثلاثة أنواع من الإطارات الزخرفية للصفحات، مصممة خصيصاً لتناسب المطبوعات التعليمية والتمارين الرياضية للأستاذ ناعم محمد لعام 2026.
% \end{abstract}
%
% \section{متطلبات التشغيل والخطوط الخارجية}
% لضمان عمل الحزمة، يرجى الالتزام بالشروط التالية وتثبيت الخطوط المطلوبة:
%
% \subsection{المتطلبات البرمجية}
% \begin{itemize}
%     \item \textbf{\color{red!80!black}محرك اللغة:} الحزمة تتطلب حزمة \texttt{polyglossia} حصراً.
%     \item \textbf{\color{red!80!black}المحرك المستخدم:} يجب استخدام محرك \texttt{XeLaTeX}.
% \end{itemize}
%
% \subsection{روابط تحميل الخطوط المطلوبة}
% يرجى زيارة الروابط التالية لتحميل وتثبيت الخطوط على نظامك (Windows Fonts):
% \begin{itemize}
%     \item \textbf{خط Byzantium:} (للإطار الأول) \\
%     \url{https://www.ffonts.net/Byzantium.font}
%     \item \textbf{خط Frames:} (للإطار الثاني) \\
%     \url{https://www.dafont.com/frames.font}
%     \item \textbf{خط Borderbats:} (للإطار الثالث) \\
%     \url{https://www.dafont.com/borderbats.font}
% \end{itemize}
%
% \section{الأوامر المتاحة}
% \subsection{الإطار الأول: \texttt{\textbackslash napageborderone}}
% يستخدم لإدراج إطار بنمط \textlatin{Byzantium}.
%
% \subsection{الإطار الثاني: \texttt{\textbackslash napagebordertwo}}
% يستخدم لإدراج إطار بنمط \textlatin{Frames}.
%
% \subsection{الإطار الثالث: \texttt{\textbackslash napageborderthree}}
% يستخدم لإدراج إطار بنمط \textlatin{Borderbats}.
%
% \section{التراخيص}
% هذا العمل محمي بموجب رخصة المشاع الإبداعي (نسب المصنف - منع الاشتقاق 4.0 الدولية).
%
% \StopEventually{}
%
%<*package>
\RequirePackage{tikz}
\RequirePackage{fontspec}
\RequirePackage{xcolor}

\AtBeginDocument{
  \@ifpackageloaded{polyglossia}{
    \ifcsname arabicfont\endcsname \relax \else \newfontfamily\arabicfont[Script=Arabic]{Arial} \fi
  }{
    \PackageError{na-pageborder}{Package polyglossia is required}{Please load polyglossia in your preamble.}
  }
}

\providefontfamily\nasborderfont[Scale=2.45,Script=Arabic]{Byzantium}
\providefontfamily\nanborderfont[Scale=4,Script=Arabic]{Frames}
\providefontfamily\naaborderfont[Scale=5,Script=Arabic]{Borderbats-Filligree}

\newcommand{\napageborderone}[1][blue!40!black]{{
    \nasborderfont\color{#1}
    \begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-0.15cm,text width=\paperwidth,minimum height=\paperheight ]at (current page.center) {%
    \offinterlineskip\centering 
    IJJJJJJJJJJJJJJJJJK\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    O\hphantom{JJJJJJJJJJJJJJJJJ}P\\
    LJJJJJJJJJJJJJJJJJN\par
    };
    \end{tikzpicture}
}}

\newcommand{\napagebordertwo}[1][red!40!black]{{
    \nanborderfont\color{#1}
    \begin{tikzpicture}[remember picture,overlay]
    \node[text width=\paperwidth,minimum height=\paperheight ]at (current page.center) {%
    \offinterlineskip\centering%
    `aaaaaaaaaab\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    g\hphantom{aaaaaaaaaa}c\\
    feeeeeeeeeed\\
    };
    \end{tikzpicture}
}}

\newcommand{\napageborderthree}[1][green!40!black]{{
    \naaborderfont\color{#1}
    \begin{tikzpicture}[remember picture,overlay]
    \node[text width=\paperwidth,minimum height=\paperheight ]at (current page.center) {%
    \offinterlineskip\centering 
    AeeeeeeeB\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    F\hphantom{eeeeeee}f\\
    CEEEEEEED\par
    };
    \end{tikzpicture}
}}
%</package>
% \Finale
\endinput