@font-face { font-family: CMMain; src: url(fonts/katex-main-regular.woff2) format("woff2"); font-weight: 400; font-style: normal; }
@font-face { font-family: CMMain; src: url(fonts/katex-main-bold.woff2) format("woff2"); font-weight: 700; font-style: normal; }
@font-face { font-family: CMMain; src: url(fonts/katex-main-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; }
@font-face { font-family: CMMain; src: url(fonts/katex-main-bolditalic.woff2) format("woff2"); font-weight: 700; font-style: italic; }
@font-face { font-family: CMMath; src: url(fonts/katex-math-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; }
@font-face { font-family: CMMath; src: url(fonts/katex-math-bolditalic.woff2) format("woff2"); font-weight: 700; font-style: italic; }
@font-face { font-family: CMAMS; src: url(fonts/katex-ams-regular.woff2) format("woff2"); }
@font-face { font-family: Grotesk; src: url(fonts/bricolage-grotesque-latin-500-normal.woff2) format("woff2"); font-weight: 500; }
@font-face { font-family: Grotesk; src: url(fonts/bricolage-grotesque-latin-700-normal.woff2) format("woff2"); font-weight: 700; }
@font-face { font-family: Grotesk; src: url(fonts/bricolage-grotesque-latin-800-normal.woff2) format("woff2"); font-weight: 800; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); font-weight: 400; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); font-weight: 500; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); font-weight: 600; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Plex; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); font-weight: 700; unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --c1: #5a3fc0; --c1-tint: #efebfb;
  --c2: #0b7a75; --c2-tint: #e2f3f1;
  --c3: #c2570c; --c3-tint: #fdf0e4;
  --c5: #1f5fae; --c5-tint: #e7effa;
  --c6: #a3337f; --c6-tint: #f8e9f3;
  --pen: #c8243d; --c4-tint: #fdf0f2;
  --ink: #161a2b; --soft: #4d5468; --rule: #d9dce6;
  --band: #241a5c; --band-accent: #ffcd4a; --foot: #1a1345;
}
.k1 { --c: var(--c1); --t: var(--c1-tint); }
.k2 { --c: var(--c2); --t: var(--c2-tint); }
.k3 { --c: var(--c3); --t: var(--c3-tint); }
.k4 { --c: var(--c5); --t: var(--c5-tint); }
.k5 { --c: var(--pen); --t: var(--c4-tint); }
.k6 { --c: var(--c6); --t: var(--c6-tint); }
.col > .unit { color: var(--c); }
.unit > span { white-space: nowrap; }
.lesson h3 { color: var(--c); }
.lesson > * + * { margin-top: 1.6mm; }
.col > .lesson + .lesson { border-top: 0.4mm dashed color-mix(in srgb, var(--c) 45%, transparent); padding-top: 2.6mm; }

.masthead::before {
  inset: 0; width: auto; height: auto; border-radius: 0; top: 0; opacity: 0.13;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M0 .5h40M.5 0v40' fill='none' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E") 0 0 / 7mm 7mm;
  -webkit-mask-image: linear-gradient(to left, #000 0 25%, transparent 70%); mask-image: linear-gradient(to left, #000 0 25%, transparent 70%);
}
.masthead::after { background: linear-gradient(to left, var(--c1) 0 20%, var(--c2) 20% 40%, var(--c3) 40% 60%, var(--c5) 60% 80%, var(--pen) 80% 100%); }
.scope li { grid-template-columns: 24mm 1fr; }
.scope b { color: var(--band-accent); }
.label { font: 700 13pt/1.3 Ruqaa, serif; color: var(--c); }
.label small { font: 500 9.4pt Plex, sans-serif; color: var(--soft); margin-inline-start: 1.6mm; }

/* math typesetting */
.m { direction: ltr; unicode-bidi: isolate; display: inline-block; font: 400 1.14em/1.3 CMMain, CMAMS, serif; white-space: nowrap; }
.m i { font-family: CMMath, CMMain, serif; font-style: italic; }
.m b { font-weight: 700; }
.m.ok { color: var(--c); font-weight: 700; }
.bb { font-family: CMAMS, serif; font-style: normal; }
.ne { position: relative; display: inline-block; }
.ne::after { content: "/"; position: absolute; inset: 0; text-align: center; }
.m sup { font-size: 0.68em; line-height: 0; vertical-align: 0.5em; }
.m sub { font-size: 0.68em; line-height: 0; vertical-align: -0.2em; }
.m .ok { color: var(--c1, #1e6b47); }
.ov { display: inline-block; border-top: 0.25mm solid currentColor; line-height: 1.05; padding-top: 0.15mm; }
.lesson h3 .m i { font: italic 400 1em CMMath, CMMain, serif; color: inherit; padding: 0; background: none; }
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 0.86em; line-height: 1.05; margin-inline: 0.1em; }
.fr > span:first-child { border-bottom: 0.25mm solid currentColor; padding-inline: 0.15em; }
.rt { white-space: nowrap; }
.rt > span { border-top: 0.06em solid currentColor; padding: 0.06em 0.05em 0 0.08em; margin-inline-start: -0.08em; }

.eq { display: block; text-align: center; background: #fff; border-radius: 2.5mm; padding: 1.4mm 3mm; font-size: 14.5pt; }
.eq .m { font-size: 1em; }
/* key formulas sit on squared paper, like a math notebook */
.eq.c {
  color: var(--c); font-weight: 700;
  --grid: color-mix(in srgb, var(--c) 13%, transparent);
  background: linear-gradient(var(--grid) 0.2mm, transparent 0.2mm) center / 3.6mm 3.6mm, linear-gradient(90deg, var(--grid) 0.2mm, transparent 0.2mm) center / 3.6mm 3.6mm, #fff;
  outline: 0.3mm solid color-mix(in srgb, var(--c) 28%, transparent); outline-offset: -0.3mm;
}
.eq small { display: block; font: 500 9.4pt/1.4 Plex, sans-serif; color: var(--soft); }
.eqs { display: grid; grid-template-columns: repeat(var(--n, 2), 1fr); gap: 1.6mm; }
.eqs > .eq { padding-inline: 1.5mm; }

.box { background: #fff; border-radius: 2.5mm; padding: 1.6mm 2.6mm; font-size: 10.2pt; line-height: 1.55; }
.box.rule { background: color-mix(in srgb, var(--c) 10%, white); }
.box > b:first-child { color: var(--c); }
.frs { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 1mm 4mm; margin-block: 0.6mm; }
.frs .fr { font-size: 0.92em; margin-inline: 0.4em; }
.def { font-size: 10.6pt; line-height: 1.55; }
.def > b:first-child { color: var(--c); }

/* worked example: expression then the step that produced it */
.work { display: grid; grid-template-columns: auto 1fr; gap: 0.2mm 3mm; align-items: baseline; background: #fff; border-radius: 2.5mm; padding: 1.4mm 2.6mm; font-size: 9.6pt; line-height: 1.5; }
.work .m { font-size: 12pt; justify-self: end; }
.work > span:not(.m):not(.q) { color: var(--soft); }
.work .q { grid-column: 1 / -1; font-weight: 600; color: var(--ink); }
.work .q .m { justify-self: auto; }
.work .ans .m, .work .ans { color: var(--c); font-weight: 700; }

ol.order { list-style: none; counter-reset: o; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.4mm; }
ol.order li { counter-increment: o; background: #fff; border-top: 1.2mm solid var(--c); padding: 1mm 1.6mm 1.3mm; font-size: 9.4pt; line-height: 1.4; }
ol.order li::before { content: counter(o); display: block; font: 700 18pt/1 CMMain, serif; color: var(--c); }
ol.order li b { display: block; font-size: 10.6pt; }

table.t { width: 100%; border-collapse: collapse; background: #fff; font-size: 9.8pt; line-height: 1.4; text-align: center; border-radius: 2.5mm; overflow: hidden; }
table.t th { background: color-mix(in srgb, var(--c) 14%, white); color: var(--c); font-weight: 700; padding: 0.9mm 1.2mm; }
table.t td { padding: 0.8mm 1.2mm; border-top: 0.25mm solid var(--rule); }
table.t .m { font-size: 11.6pt; }
table.t td.no { color: var(--pen); font-weight: 700; }
table.t td.yes { color: var(--c1); font-weight: 700; }
table.t.row th { text-align: start; white-space: nowrap; width: 1%; }

.fig { display: flex; align-items: center; gap: 2.6mm; background: #fff; border-radius: 2.5mm; padding: 1.4mm 2.4mm; font-size: 9.8pt; line-height: 1.45; }
.fig svg { flex: 0 0 auto; }
.fig:has(> .work) { flex-direction: column; align-items: stretch; gap: 1mm; }
.fig:has(> .work) > svg { align-self: center; }
.fig > .work { padding: 0; background: none; }
.fig.col2 { flex-direction: column; align-items: stretch; text-align: center; }
svg.g { direction: ltr; font-family: CMMath, CMMain, serif; font-style: italic; font-size: 13px; overflow: visible; }
svg.g .s { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
svg.g .a { stroke: var(--c); }
svg.g .p { stroke: var(--pen); }
svg.g .d { stroke-dasharray: 3 3; }
svg.g .f { fill: color-mix(in srgb, var(--c) 16%, white); }
svg.g .fp { fill: color-mix(in srgb, var(--pen) 14%, white); }
svg.g text { fill: var(--ink); }
svg.g text.c { fill: var(--c); font-weight: 700; }
svg.g text.n { font-style: normal; font-family: Plex, sans-serif; font-size: 10px; }
svg.g .dot { fill: var(--c); }
svg.g .hole { fill: #fff; stroke: var(--c); stroke-width: 1.6; }

.cases { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 1.6mm; }
.cases > div { background: #fff; padding: 1.3mm 1.8mm 1.5mm; font-size: 9.3pt; line-height: 1.4; text-align: center; }
.cases .w { display: block; font: 700 15pt/1.15 CMMain, Ruqaa, serif; color: var(--c); letter-spacing: 0.04em; }
.cases svg { display: block; margin: 0.6mm auto; }

.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6mm; font-size: 9.9pt; line-height: 1.45; }
.duo > div { background: #fff; padding: 1.3mm 2mm; }
.duo > div > b:first-child { display: block; font: 700 13.5pt/1.25 Ruqaa, serif; color: var(--c); }
.duo > .no > b:first-child { color: var(--pen); }
.duo .ex { display: block; text-align: center; font-size: 1.12em; }
.duo .ex:first-of-type { margin-top: 1mm; }
.duo svg { display: block; margin: 1.2mm auto 0; }

.chips { display: flex; flex-wrap: wrap; gap: 1.4mm; }
.chips > span { background: #fff; padding: 0.4mm 2.4mm; font-size: 10pt; font-weight: 600; }
.chips .m { font-weight: 400; }

.pen .m { color: var(--pen); }
.wrong { color: var(--pen); text-decoration: line-through; }

[dir="ltr"] .work .m { justify-self: start; }
[lang="en"] .masthead .title, [lang="en"] .unit h2, [lang="en"] .lesson h3, [lang="en"] .label, [lang="en"] .duo > div > b:first-child, [lang="en"] .foot .wish, [lang="en"] .pen::before { font-family: Grotesk, sans-serif; }
[lang="en"] .masthead .title { font-size: 70pt; font-weight: 800; letter-spacing: -0.035em; }
[lang="en"] .unit h2 { font-size: 22pt; font-weight: 800; letter-spacing: -0.02em; }
[lang="en"] .lesson h3 { font-size: 14.6pt; font-weight: 700; letter-spacing: -0.01em; }
[lang="en"] .duo > div > b:first-child { font-size: 12.4pt; font-weight: 700; }
[lang="en"] .label { font-size: 12.4pt; }
[lang="en"] .foot .wish { font-size: 20pt; font-weight: 700; letter-spacing: -0.015em; }
[lang="en"] .pen::before { content: "Watch out"; font-size: 12pt; font-weight: 800; letter-spacing: -0.01em; transform: none; }
[lang="en"] .scope li { grid-template-columns: 26mm 1fr; }
