/*
Theme Name: Madrasa Demo
Theme URI: https://example.com/madrasa
Description: A simple, modern front end for a supplementary school running Madrasa LMS. Bilingual and right-to-left aware, with pages for registration, trial bookings and re-enrolment. Designed to be recoloured by a school in one place.
Version: 1.3.0
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Author: PrimaTree
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: madrasa-demo
Tags: education, school, rtl-language-support, translation-ready, custom-colors
*/

/*
 * Everything a school will want to change lives in these six values.
 * Recolouring the whole site is one edit, not a hunt through a stylesheet.
 */
:root {
	--md-accent: #176b5c;
	--md-accent-dark: #0f4d42;
	--md-gold: #b8862b;
	--md-ink: #16211f;
	--md-sand: #f7f4ef;
	--md-paper: #ffffff;

	--md-accent-ink: #ffffff;
	--md-footer-bg: #16211f;
	--md-footer-ink: #d8e0de;
	--md-hero-art: url("assets/img/hero2.jpg");

	--md-muted: #5f6b68;
	--md-line: #e3ded6;
	--md-radius: 10px;
	--md-shadow: 0 1px 2px rgba(22, 33, 31, .05), 0 8px 24px rgba(22, 33, 31, .06);

	/*
	 * Both faces carry Arabic and Latin, which is the point: the same
	 * stylesheet has to look deliberate in either language rather than
	 * falling back to a system font the moment the site switches.
	 */
	--md-display: "Amiri", "Times New Roman", Georgia, serif;
	--md-body: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

	--md-measure: 68ch;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: var(--md-body);
	font-size: 17px;
	line-height: 1.65;
	color: var(--md-ink);
	background: var(--md-paper);
	-webkit-font-smoothing: antialiased;
}

img {
	max-inline-size: 100%;
	block-size: auto;
}

a {
	color: var(--md-accent-dark);
	text-underline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
	outline: 3px solid var(--md-gold);
	outline-offset: 2px;
}

h1, h2, h3 {
	font-family: var(--md-display);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -.01em;
	text-wrap: balance;
	margin-block: 0 .5em;
}

h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.2rem; }

p { margin-block: 0 1em; max-inline-size: var(--md-measure); }

.md-shell {
	inline-size: min(1120px, 100% - 3rem);
	margin-inline: auto;
}

.md-skip {
	position: absolute;
	inset-inline-start: -9999px;
}

.md-skip:focus {
	inset-inline-start: 1rem;
	inset-block-start: 1rem;
	z-index: 100;
	background: var(--md-paper);
	padding: .75rem 1.25rem;
	border-radius: var(--md-radius);
	box-shadow: var(--md-shadow);
}

/* ── Header ───────────────────────────────────────── */

.md-header {
	position: sticky;
	inset-block-start: 0;
	z-index: 50;
	background: rgba(255, 255, 255, .92);
	backdrop-filter: saturate(160%) blur(10px);
	border-block-end: 1px solid var(--md-line);
}

.md-header-inner {
	display: flex;
	align-items: center;
	gap: 1.5rem;
	min-block-size: 74px;
}

.md-brand {
	display: inline-flex;
	align-items: center;
	gap: .7rem;
	text-decoration: none;
	color: inherit;
	font-family: var(--md-display);
	font-weight: 700;
	font-size: 1.25rem;
	line-height: 1.1;
}

.md-mark {
	display: block;
	inline-size: 40px;
	block-size: 40px;
	flex: 0 0 auto;
}

.md-brand-sub {
	display: block;
	font-family: var(--md-body);
	font-size: .72rem;
	font-weight: 400;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--md-muted);
}

.md-nav {
	margin-inline-start: auto;
	display: flex;
	align-items: center;
	gap: .35rem;
	flex-wrap: wrap;
}

.md-nav a {
	text-decoration: none;
	color: var(--md-ink);
	padding: .5rem .85rem;
	border-radius: 8px;
	font-size: .95rem;
}

.md-nav a:hover { background: var(--md-sand); }
.md-nav a[aria-current="page"] { background: var(--md-sand); font-weight: 600; }

.md-nav .md-cta {
	background: var(--md-accent);
	color: var(--md-accent-ink);
	font-weight: 600;
}

.md-nav .md-cta:hover { background: var(--md-accent-dark); }

/* A real WordPress menu renders as a list; give it the same row. */
.md-nav-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: .35rem;
	flex-wrap: wrap;
}

/* ── The small-screen menu ────────────────────────── */

/*
 * Hidden by default and shown only under the media query below, so a laptop
 * renders exactly what it did before this existed.
 */
.md-burger {
	display: none;
	margin-inline-start: auto;
	align-items: center;
	justify-content: center;
	inline-size: 44px;
	block-size: 44px;
	padding: 0;
	border: 1px solid var(--md-line);
	border-radius: 10px;
	background: var(--md-paper);
	color: var(--md-ink);
	cursor: pointer;
	flex: 0 0 auto;
}

.md-burger:hover { background: var(--md-sand); }

/* Three bars, drawn rather than fetched. */
.md-burger-bars,
.md-burger-bars::before,
.md-burger-bars::after {
	display: block;
	inline-size: 20px;
	block-size: 2px;
	border-radius: 2px;
	background: currentColor;
	transition: transform .18s ease, opacity .18s ease;
}

.md-burger-bars {
	position: relative;
}

.md-burger-bars::before,
.md-burger-bars::after {
	content: "";
	position: absolute;
	inset-inline-start: 0;
}

.md-burger-bars::before { inset-block-start: -6px; }
.md-burger-bars::after  { inset-block-start: 6px; }

/* Open, the bars become a cross. */
.md-burger[aria-expanded="true"] .md-burger-bars { background: transparent; }
.md-burger[aria-expanded="true"] .md-burger-bars::before { transform: translateY(6px) rotate(45deg); }
.md-burger[aria-expanded="true"] .md-burger-bars::after  { transform: translateY(-6px) rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
	.md-burger-bars,
	.md-burger-bars::before,
	.md-burger-bars::after { transition: none; }
}

@media (max-width: 760px) {

	/*
	 * Only once the script has marked the header. Without JavaScript the links
	 * stay where they are, which is worse looking and still usable, rather
	 * than a button that opens nothing.
	 */
	.md-header.md-has-js .md-burger { display: inline-flex; }

	.md-header.md-has-js .md-nav { display: none; }

	.md-header.md-has-js .md-nav[data-open="true"] {
		display: flex;
		position: absolute;
		inset-inline: 0;
		inset-block-start: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: .1rem;
		margin: 0;
		padding: .6rem 1.5rem 1rem;
		background: var(--md-paper);
		border-block-end: 1px solid var(--md-line);
		box-shadow: var(--md-shadow);
	}

	.md-header.md-has-js .md-nav[data-open="true"] .md-nav-list {
		flex-direction: column;
		align-items: stretch;
		inline-size: 100%;
		gap: .1rem;
	}

	/* Full width rows are easier to hit with a thumb than inline pills. */
	.md-header.md-has-js .md-nav[data-open="true"] a {
		display: block;
		padding: .8rem .6rem;
		border-radius: 8px;
	}

	.md-header.md-has-js .md-nav[data-open="true"] .md-cta {
		margin-block-start: .4rem;
		text-align: center;
	}
}

/*
 * The call to action stays a call to action on its own page. Without this it
 * picks up the current-page background from the rule above while keeping the
 * white text from the rule below it, and reads as white on near-white.
 */
.md-nav a.md-cta[aria-current="page"] {
	background: var(--md-accent-dark);
	color: var(--md-accent-ink);
}

/* ── Hero ─────────────────────────────────────────── */

.md-hero {
	position: relative;
	overflow: hidden;
	background: var(--md-sand);
	padding-block: clamp(3.5rem, 9vw, 7rem);
	border-block-end: 1px solid var(--md-line);
}

/*
 * A geometric motif rather than a stock photograph: it carries the right
 * feeling for an Arabic school, needs no licence, and cannot show the wrong
 * children's faces. The artwork fades to nothing on one side, so the headline
 * always sits on plain ground and the pattern fills the space beyond it.
 */
.md-hero::before {
	content: "";
	position: absolute;
	inset: 0;

	/*
	 * Anchored to the far edge at its own aspect ratio rather than stretched to
	 * cover: cover crops the blank half away on a short, wide hero and drops
	 * the pattern straight behind the headline. The artwork's ground is the
	 * same #f7f4ef as --md-sand, so the uncovered side is seamless.
	 */
	background-image: var(--md-hero-art);
	background-repeat: no-repeat;
	background-position: 100% 50%;
	background-size: auto 100%;

	/*
	 * A second guarantee for narrow screens, where even the anchored image
	 * reaches under the text. The mask is what keeps the words on clear ground
	 * at every width.
	 */
	-webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, .35) 45%, #000 75%);
	mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, .35) 45%, #000 75%);

	pointer-events: none;
}

/*
 * The fade runs light-to-dense left-to-right, which is only correct while the
 * text starts on the left. Mirrored, the dense end would sit under the
 * headline.
 */
[dir="rtl"] .md-hero::before {
	transform: scaleX(-1);
}

/* The pattern is decoration; it must never win against the words. */
@media (prefers-contrast: more) {
	.md-hero::before { display: none; }
}

.md-hero-inner { position: relative; }

/*
 * A tinted uppercase pill is the default every template reaches for. This
 * says the same thing in both of the school's languages instead, which is
 * the one detail a generic education theme cannot borrow - and both bundled
 * faces carry Arabic, so it costs nothing to set.
 */
.md-eyebrow {
	display: flex;
	align-items: baseline;
	gap: .75rem;
	margin-block-end: 1.3rem;
}

.md-eyebrow::before {
	/*content: "";*/
	inline-size: 2.25rem;
	block-size: 2px;
	background: var(--md-accent);
	flex: 0 0 auto;
	transform: translateY(-.35em);
}

.md-eyebrow-ar {
	font-family: var(--md-display);
	font-size: 1.15rem;
	line-height: 1;
	color: var(--md-accent-dark);
}

.md-eyebrow-en {
	font-size: .8rem;
	letter-spacing: .1em;
	color: var(--md-muted);
}

.md-hero p.md-lede {
	font-size: clamp(1.05rem, 2vw, 1.25rem);
	color: var(--md-muted);
	max-inline-size: 56ch;
}

/* ── Action cards ─────────────────────────────────── */

.md-actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 1rem;
	margin-block-start: 2.5rem;
}

.md-action {
	display: flex;
	flex-direction: column;
	gap: .5rem;
	background: var(--md-paper);
	border: 1px solid var(--md-line);
	border-radius: var(--md-radius);
	padding: 1.6rem;
	text-decoration: none;
	color: inherit;
	box-shadow: var(--md-shadow);
	transition: transform .16s ease, border-color .16s ease;
}

.md-action:hover {
	transform: translateY(-2px);
	border-color: var(--md-accent);
}

.md-action-icon {
	inline-size: 42px;
	block-size: 42px;
	display: grid;
	place-items: center;
	border-radius: 10px;
	background: var(--md-sand);
	color: var(--md-accent-dark);
	margin-block-end: .3rem;
}

.md-action h3 { margin: 0; font-size: 1.25rem; }
.md-action p { color: var(--md-muted); font-size: .95rem; margin: 0; }

.md-action-go {
	margin-block-start: .5rem;
	font-weight: 600;
	color: var(--md-accent-dark);
	font-size: .95rem;
}

.md-action-go::after {
	content: "→";
	margin-inline-start: .35rem;
	display: inline-block;
}

/* The arrow has to point the way the language runs. */
[dir="rtl"] .md-action-go::after { content: "←"; }

/* ── Strip of facts ───────────────────────────────── */

/*
 * Four equal cells with a big number in each treats "Saturday", a date and
 * two counts as though they matter equally. They do not: the next session is
 * the only one a parent acts on. So it leads, and the rest run quietly
 * alongside it.
 */
.md-facts {
	background: var(--md-sand);
	border-block: 1px solid var(--md-line);
	margin-block-start: 2rem;
	padding-block: 1.5rem;
}

.md-facts-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: .75rem 2.5rem;
}

.md-facts-lead {
	margin: 0;
	max-inline-size: none;
	display: flex;
	align-items: baseline;
	gap: .65rem;
	flex-wrap: wrap;
}

.md-facts-label {
	font-size: .7rem;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--md-muted);
	white-space: nowrap;
}

.md-facts-lead strong {
	font-family: var(--md-display);
	font-size: clamp(1.25rem, 2.4vw, 1.65rem);
	font-weight: 700;
	line-height: 1.1;
	color: var(--md-footer-bg);
	unicode-bidi: plaintext;
}

.md-facts-rest {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: .3rem 1.4rem;
	font-size: .93rem;
	color: var(--md-muted);
}

.md-facts-rest li {
	position: relative;
	unicode-bidi: plaintext;
}

/* The separator sits in the gap, so it never doubles the spacing. */
.md-facts-rest li + li::before {
	content: "·";
	position: absolute;
	inset-inline-start: -.8rem;
	opacity: .55;
}

/* ── Page shell ───────────────────────────────────── */

.md-main { padding-block: clamp(2.5rem, 6vw, 4.5rem); }

/*
 * The home page is built from full-bleed bands that carry their own padding,
 * so the shell's padding would only add dead space above the hero and below
 * the facts strip.
 */
.home .md-main { padding-block: 0; }

.md-page-head {
	max-inline-size: var(--md-measure);
	margin-block-end: 2rem;
}

.md-page-head p {
	color: var(--md-muted);
	font-size: 1.08rem;
}

.md-card {
	background: var(--md-paper);
	border: 1px solid var(--md-line);
	border-radius: var(--md-radius);
	padding: clamp(1.5rem, 4vw, 2.5rem);
	box-shadow: var(--md-shadow);
}

/* ── Footer ───────────────────────────────────────── */

.md-footer {
	background: var(--md-footer-bg);
	color: var(--md-footer-ink);
	margin-block-start: 2rem;
	padding-block: 3rem 2rem;
}

.md-footer a { color: var(--md-accent-ink); }

.md-footer-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 2rem;
}

.md-footer h3 {
	font-family: var(--md-body);
	font-size: .78rem;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: #8ea39e;
	margin-block-end: .6rem;
}

.md-footer p { color: #b9c6c3; font-size: .95rem; }

.md-footer ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.md-footer li { margin-block-end: .35rem; }

.md-footer-base {
	margin-block-start: 2.5rem;
	padding-block-start: 1.5rem;
	border-block-start: 1px solid rgba(255, 255, 255, .12);
	font-size: .85rem;
	color: #8ea39e;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

/* ── The plugin's forms, dressed for this theme ───── */

.md-main .mdrs-form-wrap {
	--mdrs-accent: var(--md-accent);
	--mdrs-ink: var(--md-ink);
	--mdrs-muted: var(--md-muted);
	--mdrs-line: var(--md-line);
	--mdrs-radius: 8px;
	--mdrs-ok-bg: rgba(23, 107, 92, .07);

	max-inline-size: none;
}

.md-main .mdrs-form-wrap .mdrs-step > legend {
	font-family: var(--md-display);
	font-size: 1.5rem;
}

.md-main .mdrs-form-wrap .mdrs-btn {
	font-weight: 600;
	padding: .8rem 1.6rem;
	border-radius: 8px;
}

.md-main .mdrs-form-wrap .mdrs-thanks {
	background: var(--md-sand);
	border-inline-start-width: 4px;
}

.md-main .mdrs-form-wrap .mdrs-thanks h2 {
	font-family: var(--md-display);
}

/* ── Bidi ─────────────────────────────────────────── */

/*
 * A bilingual site will always carry some text in the other direction — an
 * English class name on an Arabic page, a date, a phone number. `plaintext`
 * gives each block its own direction from its first strong character, so a
 * trailing full stop stops jumping to the front of the line.
 */
.md-action h3,
.md-action p,
.md-page-head p,
.md-facts-lead strong,
.md-facts-rest li,
.md-footer p,
.md-footer li,
.md-card p {
	unicode-bidi: plaintext;
}

/*
 * The hero's headline and lede are deliberately NOT in that list. `plaintext`
 * takes a block's direction from its first strong character, so an English
 * school name on an Arabic site resolved left-to-right and aligned itself away
 * from every other element on the page. That is the right behaviour for a
 * quoted class name sitting inside Arabic prose; it is the wrong behaviour for
 * the page's own title, which should follow the page.
 *
 * So: keep plaintext, which is what stops a trailing full stop jumping to the
 * front of the line, and pin the alignment explicitly. `text-align: start`
 * cannot do this job — start/end resolve against the direction plaintext just
 * worked out, which is the very thing being overridden.
 */
.md-hero h1,
.md-lede {
	unicode-bidi: plaintext;
	text-align: left;
}

[dir="rtl"] .md-hero h1,
[dir="rtl"] .md-lede {
	text-align: right;
}

/* ── Small screens ────────────────────────────────── */

@media (max-width: 760px) {
	.md-shell { inline-size: min(1120px, 100% - 2rem); }

	.md-header-inner {
		flex-wrap: wrap;
		gap: .5rem;
		padding-block: .75rem;
	}

	.md-nav {
		margin-inline-start: 0;
		inline-size: 100%;
		justify-content: flex-start;
	}

	.md-footer-base { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: .01ms !important;
		transition-duration: .01ms !important;
	}
}
