% ============================================================
%  Venn Diagram Shading Worksheet  —  MYP Year 9
%  J. Murphy  |  JMaths  |  Sets & Probability
% ============================================================
\documentclass[11pt]{article}

\usepackage[a4paper,top=1.5cm,bottom=1.2cm,left=1cm,right=1cm,
            includeheadfoot,headsep=4pt,footskip=12pt]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usepackage[table]{xcolor}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{mdframed}
\usepackage{array}
\usepackage{multicol}
\usepackage{booktabs}

\usetikzlibrary{calc, intersections}

% ── House colours ──────────────────────────────────────────────────────────
\definecolor{ibblue}{HTML}{0F4C81}
\definecolor{accent}{HTML}{0F766E}
\definecolor{shadegray}{RGB}{210,220,235}
\definecolor{warmgray}{RGB}{245,246,248}

% ── Header / footer ────────────────────────────────────────────────────────
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.6pt}
\renewcommand{\headrule}{\color{ibblue}\hrule width\headwidth height 0.6pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{\footnotesize\color{ibblue}\bfseries MYP Year 9 Mathematics}
\chead{\footnotesize\color{ibblue}\bfseries Venn Diagram Shading}
\rhead{\footnotesize Name: \underline{\hspace{4cm}}}
\cfoot{\footnotesize\color{ibblue}\thepage}
\rfoot{\footnotesize\color{accent} J. Murphy}

% ── Spacing ────────────────────────────────────────────────────────────────
\setlength{\parindent}{0pt}
\setlength{\parskip}{1pt}
\setlist[enumerate]{nosep,leftmargin=*,labelsep=0.5em}
\setlist[itemize]{nosep,leftmargin=*,labelsep=0.4em}

% ── Section style ──────────────────────────────────────────────────────────
\newcommand{\jmsection}[1]{%
  \vspace{4pt}%
  \noindent\colorbox{ibblue}{\parbox{\dimexpr\linewidth-2\fboxsep}{%
    \color{white}\bfseries\large\hspace{4pt}#1\hspace{4pt}}}%
  \vspace{3pt}\par}

% ── Helpers ────────────────────────────────────────────────────────────────
% Blank two-set Venn, scaled to 0.62
% Circles: A centred at (2.15,2), B centred at (3.85,2), radius 1.45
% Rectangle: (0,0)–(6,4)
\newcommand{\blanktwovenn}{%
  \begin{tikzpicture}[scale=0.62,line width=0.9pt]
    \draw[ibblue!60, line width=0.7pt] (0,0) rectangle (6,4);
    \node[ibblue!70, font=\small] at (0.35,0.35) {$U$};
    \draw[ibblue, line width=1.2pt] (2.15,2) circle (1.45);
    \draw[ibblue, line width=1.2pt] (3.85,2) circle (1.45);
    \node[ibblue, font=\bfseries] at (1.1,3.4)  {$A$};
    \node[ibblue, font=\bfseries] at (4.9,3.4)  {$B$};
  \end{tikzpicture}}

% Blank three-set Venn (symmetric)
% A:(2.7,4.3) B:(5.3,4.3) C:(4.0,2.1), all radius 1.85; box (0,0)–(8,7)
\newcommand{\blankthreevenn}{%
  \begin{tikzpicture}[scale=0.66,line width=0.9pt]
    \draw[ibblue!60, line width=0.7pt] (0,0) rectangle (8,7);
    \node[ibblue!70, font=\small] at (0.4,0.4) {$U$};
    \draw[ibblue, line width=1.2pt] (2.7,4.3) circle (1.85);
    \draw[ibblue, line width=1.2pt] (5.3,4.3) circle (1.85);
    \draw[ibblue, line width=1.2pt] (4.0,2.1) circle (1.85);
    \node[ibblue, font=\bfseries] at (1.2,6.5)  {$A$};
    \node[ibblue, font=\bfseries] at (6.8,6.5)  {$B$};
    \node[ibblue, font=\bfseries] at (4.0,0.3)  {$C$};
  \end{tikzpicture}}

% Labelled diagram cell
\newcommand{\vennbox}[2]{%
  \begin{minipage}[t]{0.31\linewidth}
    \centering
    {\color{accent}\bfseries\small #1}\\[2pt]
    #2
  \end{minipage}}

% Large Venn for context question (scale 0.9)
\newcommand{\blanktwovennLG}{%
  \begin{tikzpicture}[scale=0.9,line width=1pt]
    \draw[ibblue!60, line width=0.8pt] (0,0) rectangle (8,5.5);
    \node[ibblue!70] at (0.4,0.4) {$U$};
    \draw[ibblue, line width=1.4pt] (2.8,2.75) circle (2.1);
    \draw[ibblue, line width=1.4pt] (5.2,2.75) circle (2.1);
    \node[ibblue, font=\bfseries\large] at (1.1,5.0)  {$F$};
    \node[ibblue, font=\bfseries\large] at (6.9,5.0)  {$G$};
  \end{tikzpicture}}

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

% ── Title block ──────────────────────────────────────────────
\begin{center}
  {\color{ibblue}\LARGE\bfseries Shading Venn Diagrams}\\[2pt]
  {\color{accent}\small Sets $\cdot$ Complements $\cdot$ Intersections $\cdot$ Unions}\\[3pt]
  {\footnotesize Date: \underline{\hspace{3.5cm}} \quad Class: \underline{\hspace{3cm}}}
\end{center}

\vspace{1pt}
{\color{ibblue}\rule{\linewidth}{0.8pt}}
\vspace{3pt}

% ============================================================
\jmsection{Section A \quad Notation Warm-Up}
% ============================================================

\begin{mdframed}[backgroundcolor=warmgray, linecolor=ibblue, linewidth=0.8pt,
                 innertopmargin=4pt, innerbottommargin=4pt,
                 innerleftmargin=6pt, innerrightmargin=6pt]
{\small
Let $U$ be a \textbf{universal set} and $A$, $B$ be subsets.
\begin{center}
\begin{tabular}{@{}l@{\quad}l@{\quad}p{7cm}@{}}
\toprule
\textbf{Notation} & \textbf{Read as} & \textbf{Meaning} \\
\midrule
$A \cup B$    & ``$A$ union $B$''              & All elements in $A$, in $B$, or in both \\
$A \cap B$    & ``$A$ intersection $B$''       & Elements in \emph{both} $A$ \emph{and} $B$ \\
$A'$          & ``complement of $A$''          & Everything in $U$ \emph{not} in $A$ \\
$(A \cup B)'$ & ``complement of $A$ union $B$'' & Everything \emph{outside} both circles \\
\bottomrule
\end{tabular}
\end{center}
\vspace{2pt}
\textbf{Example.}\;
$U=\{1,\ldots,8\}$, $A=\{1,3,5,7\}$, $B=\{3,5,6,8\}$:\quad
$A\cup B=\{1,3,5,6,7,8\}$,\; $A\cap B=\{3,5\}$,\; $A'=\{2,4,6,8\}$,\; $A\cap B'=\{1,7\}$.
}
\end{mdframed}

\vspace{3pt}

\textbf{A1.} $U=\{1,\ldots,10\}$, $P=\{2,4,6,8,10\}$, $Q=\{1,2,3,4,5\}$. List the elements.

\begin{enumerate}[label=(\alph*), itemsep=2pt]
  \item $P \cup Q = \bigl\{\;\underline{\hspace{6.5cm}}\;\bigr\}$\hfill
        (b)~$P \cap Q = \bigl\{\;\underline{\hspace{5cm}}\;\bigr\}$
  \item[(c)] $P' = \bigl\{\;\underline{\hspace{6.5cm}}\;\bigr\}$\hfill
        (d)~$P' \cap Q = \bigl\{\;\underline{\hspace{4.8cm}}\;\bigr\}$
  \item[(e)] $(P \cup Q)' = \bigl\{\;\underline{\hspace{6.5cm}}\;\bigr\}$
\end{enumerate}

\vspace{4pt}

% ============================================================
\jmsection{Section B \quad Two-Set Shading}
% ============================================================

\textbf{Shade the region} described. The rectangle represents $U$.

\vspace{4pt}

\vennbox{(a)\quad $A \cup B$}{\blanktwovenn}
\hfill
\vennbox{(b)\quad $A \cap B$}{\blanktwovenn}
\hfill
\vennbox{(c)\quad $A'$}{\blanktwovenn}

\vspace{8pt}

\vennbox{(d)\quad $B'$}{\blanktwovenn}
\hfill
\vennbox{(e)\quad $A \cap B'$}{\blanktwovenn}
\hfill
\vennbox{(f)\quad $A' \cap B$}{\blanktwovenn}

\vspace{8pt}

\vennbox{(g)\quad $(A \cup B)'$}{\blanktwovenn}
\hfill
\vennbox{(h)\quad $(A \cap B)'$}{\blanktwovenn}
\hfill
\vennbox{(i)\quad $A' \cup B$}{\blanktwovenn}

\vspace{8pt}

\vennbox{(j)\quad $A' \cap B'$}{\blanktwovenn}
\hfill
\vennbox{(k)\quad $A \cup B'$}{\blanktwovenn}
\hfill
\vennbox{(l)\quad $A' \cup B'$}{\blanktwovenn}

\newpage

% ============================================================
\jmsection{Section C \quad Three-Set Shading}
% ============================================================

Shade the region described. Sets are $A$, $B$, $C$; rectangle is $U$.

\vspace{4pt}

\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (a)\quad $A \cap B \cap C$}\\[2pt]
  \blankthreevenn
\end{minipage}
\hfill
\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (b)\quad $A \cup B \cup C$}\\[2pt]
  \blankthreevenn
\end{minipage}
\hfill
\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (c)\quad $(A \cup B \cup C)'$}\\[2pt]
  \blankthreevenn
\end{minipage}

\vspace{10pt}

\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (d)\quad $A \cap B \cap C'$}\\[2pt]
  \blankthreevenn
\end{minipage}
\hfill
\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (e)\quad $(A \cup B) \cap C'$}\\[2pt]
  \blankthreevenn
\end{minipage}
\hfill
\begin{minipage}[t]{0.31\linewidth}
  \centering
  {\color{accent}\bfseries\small (f)\quad $A \cap B' \cap C'$}\\[2pt]
  \blankthreevenn
\end{minipage}

\vspace{10pt}

\textbf{C7. Identify the eight regions.}\; Write a set expression for each numbered region.

\vspace{4pt}

\begin{minipage}[t]{0.44\linewidth}
\begin{tikzpicture}[scale=0.90, line width=1pt]
  \draw[ibblue!60, line width=0.8pt] (0,0) rectangle (8,7);
  \node[ibblue!70] at (0.4,0.4) {$U$};
  \draw[ibblue, line width=1.3pt] (2.7,4.3) circle (1.85);
  \draw[ibblue, line width=1.3pt] (5.3,4.3) circle (1.85);
  \draw[ibblue, line width=1.3pt] (4.0,2.1) circle (1.85);
  \node[ibblue, font=\bfseries\large] at (1.2,6.5) {$A$};
  \node[ibblue, font=\bfseries\large] at (6.8,6.5) {$B$};
  \node[ibblue, font=\bfseries\large] at (4.0,0.3) {$C$};
  \node[font=\bfseries\large, accent] at (1.8,4.3)  {\textbf{1}};
  \node[font=\bfseries\large, accent] at (4.0,5.1)  {\textbf{2}};
  \node[font=\bfseries\large, accent] at (6.2,4.3)  {\textbf{3}};
  \node[font=\bfseries\large, accent] at (3.0,3.0)  {\textbf{4}};
  \node[font=\bfseries\large, accent] at (4.0,3.6)  {\textbf{5}};
  \node[font=\bfseries\large, accent] at (5.0,3.0)  {\textbf{6}};
  \node[font=\bfseries\large, accent] at (4.0,1.5)  {\textbf{7}};
  \node[font=\bfseries\large, accent] at (0.8,1.0)  {\textbf{8}};
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}[t]{0.52\linewidth}
\begin{enumerate}[label=\textbf{Region \arabic*:}, leftmargin=3.5cm, itemsep=5pt]
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
  \item \underline{\hspace{4cm}}
\end{enumerate}
\end{minipage}

\newpage

% ============================================================
\jmsection{Section D \quad Context Problem}
% ============================================================

\textbf{D1.}\; In a year group of 40 students, each studies at least one language: French ($F$) or German ($G$).
Survey results: 28 study French; 19 study German; 7 study \textbf{both}.

\begin{enumerate}[label=(\alph*), itemsep=6pt]

\item Show this is consistent by verifying the total using inclusion-exclusion.

\vspace{1.2cm}

\item Complete the Venn diagram: write the number of students in each of the four regions.

\vspace{4pt}
\begin{center}
  \blanktwovennLG
\end{center}

\item Find $P(\text{French only})$.

\vspace{1.5cm}

\item Find $P(\text{exactly one language})$.

\vspace{1.5cm}

\item Given a student studies German, find $P(\text{also studies French})$.
{\small (Conditional probability — write as a fraction.)}

\vspace{1.5cm}

\item Shade the region $F' \cap G$ below and state what it represents in context.

\vspace{4pt}
\begin{center}
  \blanktwovennLG
\end{center}

\vspace{0.3cm}
This region represents: \underline{\hspace{9cm}}

\end{enumerate}

\vspace{6pt}

\begin{center}
  {\color{ibblue!50}\rule{0.6\linewidth}{0.5pt}}\\[2pt]
  {\footnotesize\color{ibblue!70} \textit{JMaths} \;$\cdot$\; Sets \& Venn Diagrams \;$\cdot$\; MYP Year 9}
\end{center}

\end{document}
