%
% fariscovernew — Modern Arabic/English Title Page Generator
% Author: Faris Hameed
% Email: classsec81@gmail.com
% License: LPPL 1.3c
% Requires: XeLaTeX or LuaLaTeX
% ---------------------------------------------------------------

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fariscovernew}[2025/09/09 v1.0 Title page (multi-styles, safe ratios, diamondx layers)]

% ===== Requirements =====
\RequirePackage{iftex}
\ifPDFTeX
  \PackageError{fariscovernew}
    {This package requires XeLaTeX or LuaLaTeX}
    {Run with xelatex or lualatex.}
\fi
\RequirePackage{fontspec}
\RequirePackage{bidi}
\RequirePackage{tikz}
\usetikzlibrary{calc}
\RequirePackage[table,dvipsnames,svgnames,x11names]{xcolor}
\RequirePackage{xparse}

% ===== Default Settings =====
\def\FarisLang{A}% A=Arabic, E=English

% لون الأساس ومشتقاته (لا تراكب ! فوق مخلّط)
\def\FarisBaseColor{ForestGreen}
\def\FarisTitleColor{\FarisBaseColor!85!black}
\def\FarisSubtitleColor{\FarisBaseColor!55!black}
\def\FarisFrameColor{\FarisBaseColor!70!black}
\def\FarisOuterFill{\FarisBaseColor!30}
\def\FarisMiddleFill{\FarisBaseColor!10}
\def\FarisAccentColor{\FarisBaseColor}

\def\FarisPageWidth{18cm}
\def\FarisPageHeight{26.7cm}
\def\FarisCorner{8mm}
\def\FarisStyle{triple}% triple | diagonal | wave | badge | diamond | minimal | ribbon | sidebar | corner | diamondx

% مفاتيح ضبط عامة
\newcommand{\FarisSetStyle}[1]{\def\FarisStyle{#1}}
\newcommand{\FarisSetColor}[1]{%
  \def\FarisBaseColor{#1}%
  \def\FarisTitleColor{\FarisBaseColor!85!black}%
  \def\FarisSubtitleColor{\FarisBaseColor!55!black}%
  \def\FarisFrameColor{\FarisBaseColor!70!black}%
  \def\FarisOuterFill{\FarisBaseColor!30}%
  \def\FarisMiddleFill{\FarisBaseColor!10}%
  \def\FarisAccentColor{\FarisBaseColor}%
}
\newcommand{\FarisSetAccentColor}[1]{\def\FarisAccentColor{#1}}
\newcommand{\FarisSetDims}[3]{%
  \def\FarisPageWidth{#1}\def\FarisPageHeight{#2}\def\FarisCorner{#3}%
}

% ===== خطوط (اختياري) =====
\def\FarisMainFontCmd{}% قبل العنوان
\def\FarisSubFontCmd{} % قبل الفرعي

% ===== أبعاد داخلية =====
\newdimen\FarisTSZ \newdimen\FarisTBL
\newdimen\FarisSSZ \newdimen\FarisSBL
\newdimen\FarisBaseDim
\newdimen\FarisTmpDim
\newdimen\FarisTmpBL
\newdimen\FarisTextShiftY \FarisTextShiftY=0pt
\newdimen\FarisRibbonThk   \FarisRibbonThk=14mm
\newdimen\FarisSidebarW    \FarisSidebarW=22mm
\newdimen\FarisInnerPad    \FarisInnerPad=1cm

% ===== أعلام منطقية =====
\newif\iffarisSkip
\newif\iffarisUseDefaultSub
\newif\iffarisHaveTitlePt  \farisHaveTitlePtfalse

% ===== مساعدات =====
\newcommand{\farisCheckSkip}[1]{%
  \farisSkipfalse
  \if\relax\detokenize{#1}\relax
    \farisSkiptrue
  \else
    \def\FarisTmpA{#1}\def\FarisTmpB{-}%
    \ifx\FarisTmpA\FarisTmpB \farisSkiptrue\fi
  \fi
}

% ===== تغليف نص بحسب اللغة =====
\newcommand{\FarisTitleWrap}[2]{%
  \if\FarisLang E
    {\FarisMainFontCmd #1 #2}%
  \else
    \beginR{\FarisMainFontCmd #1 #2}\endR%
  \fi
}
\newcommand{\FarisSubtitleWrap}[2]{%
  \if\FarisLang E
    {\FarisSubFontCmd #1 #2}%
  \else
    \beginR{\FarisSubFontCmd #1 #2}\endR%
  \fi
}

% ==================================================================
% أدوات المتمّم اللوني (بدون expl3) — تعريف عالمي
% ==================================================================
\makeatletter
\def\Faris@splitRGB#1,#2,#3\relax{\def\Faris@r{#1}\def\Faris@g{#2}\def\Faris@b{#3}}
\newcommand{\FarisDefineComplementColor}[2]{%
  \colorlet{Faris@FrontTmp}{#1}%
  \convertcolorspec{named}{Faris@FrontTmp}{rgb}{\Faris@rgb}%
  \expandafter\Faris@splitRGB\Faris@rgb\relax
  \pgfmathparse{1 - \Faris@r}\let\Faris@R\pgfmathresult
  \pgfmathparse{1 - \Faris@g}\let\Faris@G\pgfmathresult
  \pgfmathparse{1 - \Faris@b}\let\Faris@B\pgfmathresult
  \expandafter\definecolor\expandafter{#2compl}{rgb}{\Faris@R,\Faris@G,\Faris@B}%
  \colorlet{#2}{#2compl}%
}
\makeatother
\newif\iffarisDiamondBackComplement
\farisDiamondBackComplementfalse
\newcommand{\FarisDiamondBackComplementOn}{\farisDiamondBackComplementtrue}
\newcommand{\FarisDiamondBackComplementOff}{\farisDiamondBackComplementfalse}

% ===== Triad (HSB) tools — define as RGB to please PGF =====
\makeatletter
% نفصل H,S,B و R,G,B
\def\Faris@splitHSB#1,#2,#3\relax{\def\Faris@H{#1}\def\Faris@S{#2}\def\Faris@B{#3}}
\def\Faris@splitRGB#1,#2,#3\relax{\def\Faris@r{#1}\def\Faris@g{#2}\def\Faris@b{#3}}

% زاوية مثلث الألوان بالدرجات (افتراضي 90°)
\providecommand{\FarisDiamondTriadOffset}{90}
\newcommand{\FarisSetDiamondTriadOffset}[1]{\def\FarisDiamondTriadOffset{#1}}

% يولّد لونًا ثلاثيًّا بالاعتماد على تدوير Hue ثم يعرّفه كنموذج RGB
\newcommand{\FarisDefineTriadFromColor}[2]{%
  % 1) خذ المصدر كاسم لون معروف
  \colorlet{Faris@TriadSrc}{#1}%
  % 2) حوّله إلى HSB
  \convertcolorspec{named}{Faris@TriadSrc}{hsb}{\Faris@hsb}%
  \expandafter\Faris@splitHSB\Faris@hsb\relax
  % 3) احسب الـHue الجديد + تطبيع إلى [0..1]
  \pgfmathparse{\Faris@H + (\FarisDiamondTriadOffset/360)}\let\Faris@Hnew\pgfmathresult
  \pgfmathparse{\Faris@Hnew > 1 ? \Faris@Hnew - 1 : (\Faris@Hnew < 0 ? \Faris@Hnew + 1 : \Faris@Hnew)}%
  \let\Faris@Htriad\pgfmathresult
  % 4) حوّل HSB الجديد إلى RGB نصي
  \edef\Faris@hsbnew{\Faris@Htriad,\Faris@S,\Faris@B}%
  \convertcolorspec{hsb}{\Faris@hsbnew}{rgb}{\Faris@rgbtriad}%
  \expandafter\Faris@splitRGB\Faris@rgbtriad\relax
  % 5) عرّف اللون الناتج كنموذج RGB (PGF-friendly)
  \expandafter\definecolor\expandafter{#2}{rgb}{\Faris@r,\Faris@g,\Faris@b}%
}
\makeatother

% ==================================================================
% تينتات خاصة بـ diamondx (محلية للنمط فقط)
% ==================================================================
\providecommand{\FarisOuterTint}{30}                 % افتراضي عام
\providecommand{\FarisDiamondOuterTint}{\FarisOuterTint}
\providecommand{\FarisDiamondBackTint}{\FarisDiamondOuterTint}
\newcommand{\FarisSetDiamondTints}[2]{%
  \def\FarisDiamondOuterTint{#1}%
  \def\FarisDiamondBackTint{#2}%
}
\providecommand{\FarisDiamondBackTintII}{\FarisDiamondBackTint}
\newcommand{\FarisSetDiamondBackTintII}[1]{\def\FarisDiamondBackTintII{#1}}

% ==================================================================
% تدوير diamondx
% ==================================================================
\def\FarisDiamondBackAngle{-45}
\def\FarisDiamondFrontAngle{45}
\newcommand{\FarisSetDiamondAngles}[2]{%
  \def\FarisDiamondBackAngle{#1}%
  \def\FarisDiamondFrontAngle{#2}%
}
\newcommand{\FarisSetDiamondAnglePair}[1]{%
  \def\FarisDiamondBackAngle{-#1}%
  \def\FarisDiamondFrontAngle{#1}%
}
\providecommand{\FarisDiamondBackDelta}{10}
\newcommand{\FarisSetDiamondBackDelta}[1]{\def\FarisDiamondBackDelta{#1}}

% ==================================================================
% رسامي الأنماط (lower-case)
% ==================================================================
\newcommand{\farisDrawtriple}{%
  \coordinate (C) at (current page.center);
  \node[draw=\FarisFrameColor, ultra thick, fill=\FarisOuterFill,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \node[draw=\FarisFrameColor, line width=1.5pt, fill=\FarisMiddleFill,
        minimum width={\dimexpr\FarisPageWidth-\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-\FarisInnerPad\relax},
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \node[draw=\FarisFrameColor, line width=3.5pt, fill=white,
        minimum width={\dimexpr\FarisPageWidth-2\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-2\FarisInnerPad\relax},
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawdiagonal}{%
  \coordinate (C) at (current page.center);
  \node[fill=white, draw=\FarisFrameColor, line width=2pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \node[fill=\FarisAccentColor, rotate=-18, anchor=center,
        minimum width={\dimexpr\FarisPageWidth*13/10\relax},
        minimum height={\dimexpr\FarisPageHeight/3\relax}] at (C) {};
  \node[fill=\FarisFrameColor, rotate=12, anchor=center,
        minimum width={\dimexpr\FarisPageWidth*9/10\relax},
        minimum height={\dimexpr\FarisPageHeight/5\relax}] at (C) {};
  \node[fill=white, draw=\FarisFrameColor, line width=1.2pt,
        minimum width={\dimexpr\FarisPageWidth-2\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-2\FarisInnerPad\relax},
        rounded corners=5mm, anchor=center] at (C) {};
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawwave}{%
  \coordinate (C) at (current page.center);
  \node[fill=\FarisMiddleFill, draw=\FarisFrameColor, line width=1pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \path[fill=\FarisAccentColor!20]
    ($(C)+(-0.5*\FarisPageWidth, 0.2*\FarisPageHeight)$)
      .. controls ($(C)+(-0.15*\FarisPageWidth, 0.35*\FarisPageHeight)$)
      and       ($(C)+( 0.15*\FarisPageWidth, 0.05*\FarisPageHeight)$)
      ..
    ($(C)+( 0.5*\FarisPageWidth, 0.18*\FarisPageHeight)$)
    -- ($(C)+( 0.5*\FarisPageWidth, 0.5*\FarisPageHeight)$)
    -- ($(C)+(-0.5*\FarisPageWidth, 0.5*\FarisPageHeight)$) -- cycle;
  \path[fill=\FarisBaseColor!80!black]
    ($(C)+(-0.5*\FarisPageWidth,-0.22*\FarisPageHeight)$)
      .. controls ($(C)+(-0.2*\FarisPageWidth,-0.05*\FarisPageHeight)$)
      and       ($(C)+( 0.2*\FarisPageWidth,-0.35*\FarisPageHeight)$)
      ..
    ($(C)+( 0.5*\FarisPageWidth,-0.18*\FarisPageHeight)$)
    -- ($(C)+( 0.5*\FarisPageWidth,-0.5*\FarisPageHeight)$)
    -- ($(C)+(-0.5*\FarisPageWidth,-0.5*\FarisPageHeight)$) -- cycle;
  \node[fill=white, draw=\FarisFrameColor, line width=1.6pt,
        minimum width={\dimexpr\FarisPageWidth-2.2\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-2.2\FarisInnerPad\relax},
        rounded corners=5mm, anchor=center] at (C) {};
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawbadge}{%
  \coordinate (C) at (current page.center);
  \node[fill=white, draw=\FarisFrameColor, line width=1.2pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \fill[\FarisAccentColor!20] (C) circle[radius=5.2cm];
  \draw[\FarisFrameColor, line width=3pt] (C) circle[radius=4.6cm];
  \fill[\FarisOuterFill] (C) circle[radius=4.2cm];
  \draw[\FarisFrameColor, line width=1.2pt, dash pattern=on 3pt off 3pt]
       (C) circle[radius=3.2cm];
  \draw[\FarisFrameColor!60, line width=0.8pt] (C) circle[radius=2.2cm];
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawdiamond}{%
  \coordinate (C) at (current page.center);
  \node[fill=\FarisMiddleFill, draw=\FarisFrameColor, line width=1pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \node[fill=\FarisOuterFill, draw=\FarisFrameColor, line width=2.2pt, rotate=45,
        minimum width={\dimexpr\FarisPageWidth*3/4\relax},
        minimum height={\dimexpr\FarisPageHeight*3/4\relax},
        anchor=center] at (C) {};
  \node[fill=white, draw=\FarisFrameColor, line width=1.2pt, rotate=45,
        minimum width={\dimexpr\FarisPageWidth*5/8\relax},
        minimum height={\dimexpr\FarisPageHeight*5/8\relax},
        anchor=center] at (C) {};
  \FarisTextShiftY=0pt
}

% ===== Helpers for diamondx (A/B) =====
\newcommand{\farisDiamondBackSquareA}[1]{%
  \node[fill=farisdiamondbackfill, draw=farisdiamondbackframe, line width=2.2pt,
        rotate=#1, minimum width={\dimexpr\FarisPageWidth*3/4\relax},
        minimum height={\dimexpr\FarisPageHeight*3/4\relax}, anchor=center] at (C) {};
  \node[fill=white, draw=farisdiamondbackframe, line width=1.2pt,
        rotate=#1, minimum width={\dimexpr\FarisPageWidth*5/8\relax},
        minimum height={\dimexpr\FarisPageHeight*5/8\relax}, anchor=center] at (C) {};
}
\newcommand{\farisDiamondBackSquareB}[1]{%
  \node[fill=farisdiamondback2fill, draw=farisdiamondback2frame, line width=2.2pt,
        rotate=#1, minimum width={\dimexpr\FarisPageWidth*3/4\relax},
        minimum height={\dimexpr\FarisPageHeight*3/4\relax}, anchor=center] at (C) {};
  \node[fill=white, draw=farisdiamondback2frame, line width=1.2pt,
        rotate=#1, minimum width={\dimexpr\FarisPageWidth*5/8\relax},
        minimum height={\dimexpr\FarisPageHeight*5/8\relax}, anchor=center] at (C) {};
}

% ===== diamondx — طبقات خلفية A/B + واجهة =====
\newcommand{\farisDrawdiamondx}{%
  \coordinate (C) at (current page.center);

  % خلفية الصفحة
  \node[fill=\FarisMiddleFill, draw=\FarisFrameColor, line width=1pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};

  % -------- واجهة (من الأساس + تينت محلي) --------
  \colorlet{farisdiamondfrontbase}{\FarisBaseColor}%
  \colorlet{farisdiamondfrontfill}{farisdiamondfrontbase!\FarisDiamondOuterTint}%

  % -------- الخلفي A (متمّم BaseColor) --------
  \colorlet{farisdiamondbackfill}{\FarisBaseColor!\FarisDiamondBackTint}%
  \colorlet{farisdiamondbackframe}{\FarisFrameColor}%
  \iffarisDiamondBackComplement
    \FarisDefineComplementColor{\FarisBaseColor}{farisdiamondback_base_comp}%
    \colorlet{farisdiamondbackfill}{farisdiamondback_base_comp!\FarisDiamondBackTint}%
    \colorlet{farisdiamondbackframe}{farisdiamondback_base_comp!70!black}%
  \fi

  % -------- الخلفي B = لون ثلاثي بين الأساس والمتمّم (Triad من BaseColor) --------
% نولّد لونًا ثلاثيًّا من لون الأساس بدوران hue = \FarisDiamondTriadOffset
\FarisDefineTriadFromColor{\FarisBaseColor}{farisdiamondback2_triad_base}%
% تعبئة/إطار B من هذا اللون (تينت مستقل + تغميق الإطار بنفس المنطق)
\colorlet{farisdiamondback2fill}{farisdiamondback2_triad_base!\FarisDiamondBackTintII}%
\colorlet{farisdiamondback2frame}{farisdiamondback2_triad_base!70!black}%

  % -------- ارسم الخلفيين: B (+Δ) تحت ثم A (الزاوية الأصلية) --------
  \pgfmathsetmacro{\FarisBackAnglePlus}{\FarisDiamondBackAngle + \FarisDiamondBackDelta}
  \farisDiamondBackSquareB{\FarisBackAnglePlus}
  \farisDiamondBackSquareA{\FarisDiamondBackAngle}

  % -------- الواجهة الأمامية --------
  \node[fill=farisdiamondfrontfill, draw=\FarisFrameColor, line width=2.2pt,
        rotate=\FarisDiamondFrontAngle,
        minimum width={\dimexpr\FarisPageWidth*3/4\relax},
        minimum height={\dimexpr\FarisPageHeight*3/4\relax},
        anchor=center] at (C) {};
  \node[fill=white, draw=\FarisFrameColor, line width=1.2pt,
        rotate=\FarisDiamondFrontAngle,
        minimum width={\dimexpr\FarisPageWidth*5/8\relax},
        minimum height={\dimexpr\FarisPageHeight*5/8\relax},
        anchor=center] at (C) {};

  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawminimal}{%
  \coordinate (C) at (current page.center);
  \node[fill=white, draw=\FarisFrameColor!50, line width=0.8pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \draw[\FarisFrameColor, line width=3pt]
    ($(C)+(-0.4*\FarisPageWidth, 0.4*\FarisPageHeight)$) --
    ($(C)+( 0.4*\FarisPageWidth, 0.4*\FarisPageHeight)$);
  \draw[\FarisFrameColor, line width=3pt]
    ($(C)+(-0.4*\FarisPageWidth,-0.4*\FarisPageHeight)$) --
    ($(C)+( 0.4*\FarisPageWidth,-0.4*\FarisPageHeight)$);
  \draw[\FarisAccentColor, line width=2pt]
    ($(C)+(-0.47*\FarisPageWidth, 0.47*\FarisPageHeight)$) --
    ($(C)+(-0.37*\FarisPageWidth, 0.47*\FarisPageHeight)$) --
    ($(C)+(-0.37*\FarisPageWidth, 0.37*\FarisPageHeight)$);
  \draw[\FarisAccentColor, line width=2pt]
    ($(C)+( 0.47*\FarisPageWidth,-0.47*\FarisPageHeight)$) --
    ($(C)+( 0.37*\FarisPageWidth,-0.47*\FarisPageHeight)$) --
    ($(C)+( 0.37*\FarisPageWidth,-0.37*\FarisPageHeight)$);
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawribbon}{%
  \coordinate (C) at (current page.center);
  \node[fill=\FarisMiddleFill, draw=\FarisFrameColor, line width=1.2pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \node[fill=\FarisFrameColor, rotate=6, anchor=center,
        minimum width={\dimexpr\FarisPageWidth+1.5cm\relax},
        minimum height=\FarisRibbonThk] at ($(C)+(0,0.35*\FarisPageHeight)$) {};
  \node[fill=\FarisAccentColor, rotate=-6, anchor=center,
        minimum width={\dimexpr\FarisPageWidth+1.5cm\relax},
        minimum height=\FarisRibbonThk] at ($(C)+ (0,-0.35*\FarisPageHeight)$) {};
  \node[fill=white, draw=\FarisFrameColor, line width=2pt,
        minimum width={\dimexpr\FarisPageWidth-2\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-2\FarisInnerPad\relax},
        rounded corners=5mm, anchor=center] at (C) {};
  \FarisTextShiftY=0pt
}

\newcommand{\farisDrawsidebar}{%
  \coordinate (C) at (current page.center);
  \node[fill=\FarisOuterFill, draw=\FarisFrameColor, line width=1.2pt,
        minimum width=\FarisPageWidth, minimum height=\FarisPageHeight,
        rounded corners=\FarisCorner, anchor=center] at (C) {};
  \path node[fill=\FarisFrameColor, anchor=north west,
             minimum width=\FarisSidebarW,
             minimum height=\FarisPageHeight] at ($ (C) + (-0.5*\FarisPageWidth, 0.5*\FarisPageHeight) $) {};
  \node[fill=white, draw=\FarisFrameColor, line width=2pt,
        minimum width={\dimexpr\FarisPageWidth-\FarisSidebarW-1.2\FarisInnerPad\relax},
        minimum height={\dimexpr\FarisPageHeight-2\FarisInnerPad\relax},
        rounded corners=5mm, anchor=west] at ($ (C) + (-0.5*\FarisPageWidth+\FarisSidebarW+0.6*\FarisInnerPad,0) $) {};
  \FarisTextShiftY=0pt
}

% مصرّف النمط
\newcommand{\farisDrawDispatch}{%
  \expandafter\ifx\csname farisDraw\FarisStyle\endcsname\relax
    \farisDrawtriple
  \else
    \csname farisDraw\FarisStyle\endcsname
  \fi
}

% ==================================================================
% البيئة الرئيسية
% [Lang][TitlePt][SubtitlePt][Color][MainFont][SubFont][SubRatio]{Title}{Subtitle}
% ==================================================================
\NewDocumentEnvironment{FarisTitlePageEnv}{ o o o o o o o m m }{%
  \begingroup
  \def\FARISdash{-}%
  \farisHaveTitlePtfalse

  % (1) اللغة
  \IfNoValueF{#1}{\farisCheckSkip{#1}\iffarisSkip \relax \else \def\FarisLang{#1}\fi}%

  % (4) اللون العام
  \IfNoValueF{#4}{\farisCheckSkip{#4}\iffarisSkip \relax \else \FarisSetColor{#4}\fi}%

  % (2) TitlePt -> مرجع النسبة
  \def\FarisTitleSize{}%
  \IfNoValueF{#2}{%
    \def\TMP{#2}%
    \if\relax\detokenize{#2}\relax\else
      \ifx\TMP\FARISdash\else
        \FarisTSZ=#2pt\relax
        \ifdim\FarisTSZ<1pt \FarisTSZ=12pt\fi
        \FarisTBL=\FarisTSZ \divide\FarisTBL by 5 \advance\FarisTBL by \FarisTSZ
        \edef\FarisTitleSize{\noexpand\fontsize{\the\FarisTSZ}{\the\FarisTBL}\noexpand\selectfont}%
        \farisHaveTitlePttrue
      \fi
    \fi
  }%

  % (7) SubRatio
  \def\FARISratio{}%
  \farisUseDefaultSubfalse
  \IfNoValueTF{#7}{%
    \farisUseDefaultSubtrue
  }{%
    \def\TMP{#7}%
    \if\relax\detokenize{#7}\relax
      \farisUseDefaultSubtrue
    \else
      \ifx\TMP\FARISdash
        \farisUseDefaultSubtrue
      \else
        \dimen0=#7pt\relax
        \ifdim\dimen0=0pt
          \farisUseDefaultSubtrue
        \else
          \edef\FARISratio{#7}%
        \fi
      \fi
    \fi
  }%

  % (3) SubtitlePt / نسبة
  \def\FarisSubtitleSize{}%
  \iffarisUseDefaultSub
    \def\FarisSubtitleSize{}%
  \else
    \ifx\FARISratio\empty
      \IfNoValueF{#3}{%
        \def\TMP{#3}%
        \if\relax\detokenize{#3}\relax\else
          \ifx\TMP\FARISdash\else
            \FarisSSZ=#3pt\relax
            \ifdim\FarisSSZ<1pt \FarisSSZ=9.6pt\fi
            \FarisSBL=\FarisSSZ \divide\FarisSBL by 5 \advance\FarisSBL by \FarisSSZ
            \edef\FarisSubtitleSize{\noexpand\fontsize{\the\FarisSSZ}{\the\FarisSBL}\noexpand\selectfont}%
          \fi
        \fi
      }%
      \ifx\FarisSubtitleSize\empty
        \iffarisHaveTitlePt \FarisBaseDim=\FarisTSZ \else \FarisBaseDim=12pt \fi
        \FarisTmpDim=\dimexpr \FarisBaseDim*4/5\relax
        \FarisTmpBL=\FarisTmpDim \divide\FarisTmpBL by 5 \advance\FarisTmpBL by \FarisTmpDim
        \edef\FarisSubtitleSize{\noexpand\fontsize{\the\FarisTmpDim}{\the\FarisTmpBL}\noexpand\selectfont}%
      \fi
    \else
      \iffarisHaveTitlePt \FarisBaseDim=\FarisTSZ \else \FarisBaseDim=12pt \fi
      \FarisTmpDim=\FARISratio\FarisBaseDim\relax
      \ifdim\FarisTmpDim<1pt \FarisTmpDim=9.6pt\fi
      \FarisTmpBL=\FarisTmpDim \divide\FarisTmpBL by 5 \advance\FarisTmpBL by \FarisTmpDim
      \edef\FarisSubtitleSize{\noexpand\fontsize{\the\FarisTmpDim}{\the\FarisTmpBL}\noexpand\selectfont}%
    \fi
  \fi

  % (5) خط العنوان
  \def\FarisMainFontCmd{}%
  \IfNoValueF{#5}{%
    \farisCheckSkip{#5}%
    \iffarisSkip\relax\else
      \IfFontExistsTF{#5}{%
        \if\FarisLang E \newfontfamily\FarisMainFace{#5}%
        \else            \newfontfamily\FarisMainFace[Script=Arabic]{#5}%
        \fi
        \def\FarisMainFontCmd{\FarisMainFace}%
      }{\PackageWarning{fariscovernew}{Main font '#5' not found; keeping default}}%
    \fi
  }%

  % (6) خط الفرعي
  \def\FarisSubFontCmd{}%
  \IfNoValueF{#6}{%
    \farisCheckSkip{#6}%
    \iffarisSkip\relax\else
      \IfFontExistsTF{#6}{%
        \if\FarisLang E \newfontfamily\FarisSubFace{#6}%
        \else            \newfontfamily\FarisSubFace[Script=Arabic]{#6}%
        \fi
        \def\FarisSubFontCmd{\FarisSubFace}%
      }{\PackageWarning{fariscovernew}{Sub font '#6' not found; keeping default}}%
    \fi
  }%

  % ===== الرسم (LTR أثناء الرسم فقط) =====
  \par\newpage
  \thispagestyle{empty}%
  \begingroup
    \setLTR
    \noindent\makebox[0pt][l]{%
      \begin{tikzpicture}[remember picture, overlay, inner sep=0pt]
        \farisDrawDispatch
        \coordinate (Ctxt) at ($(current page.center)+(0,\FarisTextShiftY)$);
        \node[align=center] at (Ctxt) {%
          {\color{\FarisTitleColor}\FarisTitleWrap{\FarisTitleSize}{#8}}\\[6pt]%
          {\color{\FarisSubtitleColor}\FarisSubtitleWrap{\FarisSubtitleSize}{#9}}%
        };
      \end{tikzpicture}%
    }%
  \endgroup
}{%
  \endgroup\ignorespacesafterend
}

% ===== الأمر المختصر =====
\ProvideDocumentCommand{\FarisTitlePage}{ O{} O{} O{} O{} O{} O{} O{} m m }{%
  \begin{FarisTitlePageEnv}[#1][#2][#3][#4][#5][#6][#7]{#8}{#9}\end{FarisTitlePageEnv}%
}
