/**
 * AAED AL-REDHA — theme layer.
 *
 * The design itself lives in assets/css/app.css (the compiled stylesheet from
 * the original build), and the blocks carry its class names, so the site
 * renders exactly as it always has. theme.json supplies the same colours,
 * fonts and spacing to the editor's native controls.
 *
 * This file only holds what is specific to running that design inside
 * WordPress: styling the core Navigation block to look like the original menu,
 * sizing the Site Logo block, and a couple of editor/admin-bar fixes.
 */

/* -------------------------------------------------------------------------
 * The palette bridge
 *
 * app.css (the original build) reads its colours from --aaed-* variables —
 * see tools/recolor-app-css.py. Mapping them onto the theme.json palette is
 * what makes Appearance → Editor → Styles → Colours, and every style
 * variation, recolour the whole site: the original sections and anything
 * built later from core blocks alike.
 * ---------------------------------------------------------------------- */
:root {
	--aaed-background: var(--wp--preset--color--background);
	--aaed-foreground: var(--wp--preset--color--foreground);
	--aaed-card: var(--wp--preset--color--card);
	--aaed-card-foreground: var(--wp--preset--color--foreground);
	--aaed-popover: var(--wp--preset--color--card);
	--aaed-popover-foreground: var(--wp--preset--color--foreground);
	--aaed-primary: var(--wp--preset--color--primary);
	--aaed-primary-foreground: var(--wp--preset--color--primary-foreground);
	--aaed-secondary: var(--wp--preset--color--secondary);
	--aaed-secondary-foreground: var(--wp--preset--color--foreground);
	--aaed-muted: var(--wp--preset--color--muted);
	--aaed-muted-foreground: var(--wp--preset--color--muted-foreground);
	--aaed-accent: var(--wp--preset--color--primary);
	--aaed-accent-foreground: var(--wp--preset--color--primary-foreground);
	--aaed-border: var(--wp--preset--color--border);
	--aaed-input: var(--wp--preset--color--border);
	--aaed-ring: var(--wp--preset--color--primary);
	--aaed-destructive: #e5484d;
	--aaed-destructive-foreground: #ffffff;
	--aaed-sidebar-background: var(--wp--preset--color--card);
	--aaed-sidebar-foreground: var(--wp--preset--color--foreground);
	--aaed-sidebar-border: var(--wp--preset--color--border);
	--aaed-sidebar-accent: var(--wp--preset--color--secondary);
	--aaed-sidebar-accent-foreground: var(--wp--preset--color--foreground);
	--aaed-sidebar-ring: var(--wp--preset--color--primary);

	--gradient-primary: var(--wp--preset--gradient--gold);
	--gradient-dark: var(--wp--preset--gradient--dark);
	--gradient-card: var(--wp--preset--gradient--card);
	--shadow-elegant: 0 10px 40px -10px color-mix(in srgb, var(--aaed-primary) 20%, transparent);
	--shadow-glow: 0 0 30px color-mix(in srgb, var(--aaed-primary) 30%, transparent);
	--radius: var(--wp--custom--radius, .75rem);
}

/* Paint the brand background before app.css arrives. */
html,
body {
	background-color: var(--wp--preset--color--background, #0f131a);
}

/* -------------------------------------------------------------------------
 * Header
 * ---------------------------------------------------------------------- */

/* The core Navigation block, dressed as the original nav buttons. */
.aaed-nav .wp-block-navigation-item__content {
	padding: .5rem .75rem;
	border-radius: .5rem;
	font-size: .875rem;
	font-weight: 500;
	color: hsl(var(--muted-foreground));
	transition: color .3s ease, background-color .3s ease;
}

.aaed-nav .wp-block-navigation-item__content:hover,
.aaed-nav .current-menu-item > .wp-block-navigation-item__content {
	color: hsl(var(--primary));
	background-color: hsl(var(--primary) / .1);
}

.aaed-header .wp-block-site-logo img {
	width: auto;
	height: auto;
	max-height: 44px;
}

/* -------------------------------------------------------------------------
 * Editor and admin bar
 * ---------------------------------------------------------------------- */

/* The admin bar must not hide the fixed header on the live site. */
body.admin-bar .aaed-header {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .aaed-header {
		top: 46px;
	}
}

/*
 * Inside the editor canvas a fixed header would float over the content and a
 * full-height hero would swallow the viewport, so both are relaxed while
 * editing. The front end is untouched.
 */
.editor-styles-wrapper .aaed-header {
	position: static;
}

.editor-styles-wrapper .min-h-screen {
	min-height: 0;
}

/* -------------------------------------------------------------------------
 * Inner pages
 *
 * The header is fixed, so every template that is not the home page starts
 * its content below it. The home page and the "Sections page" template begin
 * with a full-height hero or a Page banner pattern that handles this itself.
 * ---------------------------------------------------------------------- */
.aaed-main {
	padding-top: calc(var(--wp--custom--header-offset) + 2.5rem);
	padding-bottom: 5rem;
}

/*
 * A page built from sections (it opens with a Page banner or any full-width
 * section) needs no title above it and no gap under the header — the default
 * page template notices that and steps aside, so one template serves both a
 * plain text page and a designed one.
 */
.aaed-main:has(> .wp-block-post-content > .alignfull:first-child) {
	padding-top: 0;
}

.aaed-main:has(> .wp-block-post-content > .alignfull:first-child) > :is(.aaed-page-head, .wp-block-post-featured-image) {
	display: none;
}

.aaed-main:has(> .wp-block-post-content > .alignfull:last-child) {
	padding-bottom: 0;
}

/* Full-width sections inside prose keep their own rhythm. */
.aaed-prose > .alignfull,
.aaed-prose > .alignfull + * {
	margin-block-start: 0;
}

.aaed-page-head {
	margin-bottom: 2.5rem;
}

.aaed-page-head .wp-block-post-title {
	font-size: var(--wp--preset--font-size--xx-large);
	line-height: 1.15;
}

.aaed-page-head::after {
	content: "";
	display: block;
	width: 4rem;
	height: 4px;
	margin-top: 1.25rem;
	border-radius: 2px;
	background: var(--gradient-primary);
}

.has-text-align-center.aaed-page-head::after,
.aaed-page-head.has-text-align-center::after {
	margin-inline: auto;
}

/*
 * Readable defaults for anything typed into a page or post. The site-wide
 * blockGap stays 0 because the original sections space themselves; inside
 * .aaed-prose ordinary writing gets ordinary rhythm.
 */
.aaed-prose > * + * {
	margin-block-start: 1.25em;
}

.aaed-prose > :is(h2, h3, h4) {
	margin-block-start: 2em;
}

.aaed-prose > :is(h2, h3, h4) + * {
	margin-block-start: .75em;
}

.aaed-prose :is(p, li) {
	color: color-mix(in srgb, var(--aaed-foreground) 86%, var(--aaed-background));
	line-height: 1.8;
}

.aaed-prose :is(ul, ol):not(.wp-block-social-links) {
	padding-inline-start: 1.4em;
}

.aaed-prose ul:not(.wp-block-social-links) {
	list-style: disc;
}

.aaed-prose ol {
	list-style: decimal;
}

.aaed-prose li::marker {
	color: var(--aaed-primary);
}

.aaed-prose a:not(.wp-element-button) {
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
}

.aaed-prose img {
	border-radius: var(--radius);
}

.aaed-prose .wp-block-table :is(th, td) {
	border: 1px solid var(--aaed-border);
	padding: .65rem .9rem;
}

.aaed-prose .wp-block-table thead {
	border-bottom: 2px solid var(--aaed-primary);
}

/* -------------------------------------------------------------------------
 * Block styles registered in functions.php
 * ---------------------------------------------------------------------- */
.is-style-aaed-card {
	background: var(--gradient-card);
	border: 1px solid var(--aaed-border);
	border-radius: calc(var(--radius) + .25rem);
	box-shadow: var(--shadow-card);
	padding: clamp(1.25rem, 1rem + 1vw, 2rem);
	transition: transform .4s cubic-bezier(.4, 0, .2, 1), box-shadow .4s cubic-bezier(.4, 0, .2, 1);
}

.is-style-aaed-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow-elegant);
}

.is-style-aaed-accent-line.wp-block-separator {
	width: 5rem;
	height: 4px;
	border: 0;
	border-radius: 2px;
	background: var(--gradient-primary);
	opacity: 1;
}

.is-style-aaed-accent-line.wp-block-separator.aligncenter,
.has-text-align-center > .is-style-aaed-accent-line {
	margin-inline: auto;
}

.is-style-aaed-eyebrow {
	display: inline-block;
	padding: .35rem .85rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--aaed-primary) 12%, transparent);
	color: var(--aaed-primary);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: .04em;
}

.is-style-aaed-rounded img,
.wp-block-image.is-style-aaed-rounded img {
	border-radius: calc(var(--radius) * 2);
	box-shadow: var(--shadow-card);
}

.is-style-aaed-icon-badge {
	display: inline-grid;
	place-items: center;
	width: 3.25rem;
	height: 3.25rem;
	border-radius: 1rem;
	background: color-mix(in srgb, var(--aaed-primary) 14%, transparent);
	color: var(--aaed-primary);
	font-weight: 800;
	font-size: 1.05rem;
}

/* -------------------------------------------------------------------------
 * Pattern helpers
 * ---------------------------------------------------------------------- */
.aaed-banner {
	position: relative;
	overflow: hidden;
	padding-top: calc(var(--wp--custom--header-offset) + 4rem) !important;
	background-image:
		linear-gradient(to top, color-mix(in srgb, var(--aaed-primary) 8%, transparent), transparent 70%),
		linear-gradient(135deg, var(--aaed-background), var(--aaed-card));
	border-bottom: 1px solid var(--aaed-border);
}

.aaed-banner.has-background-image {
	background-image: none;
}

.aaed-stat-number {
	color: var(--aaed-primary);
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.aaed-cta {
	border: 1px solid color-mix(in srgb, var(--aaed-primary) 30%, transparent);
	background:
		radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--aaed-primary) 16%, transparent), transparent 60%),
		var(--gradient-card);
	border-radius: calc(var(--radius) * 2);
}

.aaed-step-number {
	font-size: 2.75rem;
	font-weight: 800;
	line-height: 1;
	color: transparent;
	-webkit-text-stroke: 1.5px var(--aaed-primary);
}

.aaed-logos img {
	filter: grayscale(1);
	opacity: .65;
	transition: filter .3s ease, opacity .3s ease;
}

.aaed-logos img:hover {
	filter: none;
	opacity: 1;
}

/* Post cards in the blog grid and the "Latest news" pattern. */
.aaed-post-card {
	height: 100%;
	overflow: hidden;
}

.aaed-post-card .wp-block-post-featured-image {
	margin: calc(clamp(1.25rem, 1rem + 1vw, 2rem) * -1) calc(clamp(1.25rem, 1rem + 1vw, 2rem) * -1) 1.25rem;
}

.aaed-post-card .wp-block-post-featured-image img {
	aspect-ratio: 16 / 10;
	object-fit: cover;
	border-radius: 0;
}

.wp-block-post-template.is-layout-grid > li {
	margin: 0;
}

/* Native FAQ (core/details). */
.wp-block-details + .wp-block-details {
	margin-top: .75rem;
}

.wp-block-details summary {
	cursor: pointer;
	font-weight: 600;
	list-style: none;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}

.wp-block-details summary::-webkit-details-marker {
	display: none;
}

.wp-block-details summary::after {
	content: "+";
	color: var(--aaed-primary);
	font-size: 1.35rem;
	line-height: 1;
	transition: transform .25s ease;
}

.wp-block-details[open] summary::after {
	transform: rotate(45deg);
}

.wp-block-details[open] > summary {
	margin-bottom: .75rem;
}

.wp-block-details > :not(summary) {
	color: var(--aaed-muted-foreground);
}

/* Navigation sub-menus and the mobile overlay follow the palette. */
.wp-block-navigation .wp-block-navigation__submenu-container {
	background: var(--aaed-card) !important;
	border: 1px solid var(--aaed-border) !important;
	border-radius: .75rem;
	padding: .35rem;
	min-width: 13rem;
}

.wp-block-navigation__responsive-container.is-menu-open {
	background: var(--aaed-background) !important;
	color: var(--aaed-foreground) !important;
}

/* Search, comments and the form controls. */
.wp-block-search__input,
.wp-block-post-comments-form :is(input:not([type="submit"]), textarea) {
	width: 100%;
	background: var(--aaed-background);
	color: var(--aaed-foreground);
	border: 1px solid var(--aaed-border);
	border-radius: .65rem;
	padding: .75rem 1rem;
	font: inherit;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.wp-block-search__input:focus:focus,
.wp-block-post-comments-form :is(input, textarea):focus {
	outline: none;
	border-color: var(--aaed-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--aaed-primary) 20%, transparent);
}

.wp-block-post-comments-form input[type="submit"] {
	background: var(--aaed-primary);
	color: var(--aaed-primary-foreground);
	border: 0;
	border-radius: .75rem;
	padding: .85rem 1.75rem;
	font-weight: 600;
	cursor: pointer;
}

/* 404 */
.aaed-404-code {
	font-size: clamp(6rem, 4rem + 10vw, 11rem);
	font-weight: 900;
	line-height: 1;
	background: var(--gradient-primary);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* Visible keyboard focus everywhere. */
:where(a, button, input, textarea, select, summary):focus-visible {
	outline: 2px solid var(--aaed-primary);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.is-style-aaed-card,
	.is-style-aaed-card:hover {
		transition: none;
		transform: none;
	}
}

/* -------------------------------------------------------------------------
 * Headings in new content
 *
 * app.css carries Tailwind's reset (h1–h6 inherit size and weight), which the
 * original sections depend on — every one of their headings carries
 * .english-text / .arabic-text and sizes itself with utility classes. Any
 * other heading is new content, so it gets the brand scale from theme.json.
 * ---------------------------------------------------------------------- */
:is(h1, h2, h3, h4, h5, h6):not(.english-text):not(.arabic-text):not(.member-name) {
	font-weight: 700;
	line-height: 1.25;
	color: var(--aaed-foreground);
}

h1:not(.english-text):not(.arabic-text) { font-size: var(--wp--preset--font-size--xx-large); }
h2:not(.english-text):not(.arabic-text) { font-size: var(--wp--preset--font-size--x-large); }
h3:not(.english-text):not(.arabic-text):not(.member-name) { font-size: clamp(1.35rem, 1.2rem + .6vw, 1.6rem); }
h4:not(.english-text):not(.arabic-text) { font-size: var(--wp--preset--font-size--large); font-weight: 600; }
h5:not(.english-text):not(.arabic-text) { font-size: var(--wp--preset--font-size--medium); font-weight: 600; }
h6:not(.english-text):not(.arabic-text) { font-size: var(--wp--preset--font-size--small); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* A size picked in the editor still wins over the defaults above. */
.has-small-font-size { font-size: var(--wp--preset--font-size--small) !important; }
.has-medium-font-size { font-size: var(--wp--preset--font-size--medium) !important; }
.has-large-font-size { font-size: var(--wp--preset--font-size--large) !important; }
.has-x-large-font-size { font-size: var(--wp--preset--font-size--x-large) !important; }
.has-xx-large-font-size { font-size: var(--wp--preset--font-size--xx-large) !important; }

/* Centre the pill label when its paragraph is centred. */
.is-style-aaed-eyebrow {
	display: block;
	width: fit-content;
}

.is-style-aaed-eyebrow.has-text-align-center {
	margin-inline: auto;
}

.is-style-aaed-eyebrow.has-text-align-right {
	margin-inline-start: auto;
}

/* The FAQ cards' staggered entrance (was an inline style the block could not keep). */
.aaed-faq-item:nth-child(2) { animation-delay: 150ms; }
.aaed-faq-item:nth-child(3) { animation-delay: 300ms; }
.aaed-faq-item:nth-child(4) { animation-delay: 450ms; }
.aaed-faq-item:nth-child(5) { animation-delay: 600ms; }
.aaed-faq-item:nth-child(6) { animation-delay: 750ms; }
.aaed-faq-item:nth-child(7) { animation-delay: 900ms; }

/* The comment form's own markup, given the same rhythm as the contact form. */
.wp-block-post-comments-form .comment-reply-title {
	margin-bottom: .75rem;
	font-size: var(--wp--preset--font-size--large);
}

.wp-block-post-comments-form form > p {
	margin: 0 0 1rem;
	color: var(--aaed-muted-foreground);
	font-size: var(--wp--preset--font-size--small);
}

.wp-block-post-comments-form label {
	display: block;
	margin-bottom: .4rem;
	font-weight: 600;
	color: var(--aaed-foreground);
}

.wp-block-post-navigation-link a {
	color: var(--aaed-foreground);
}

.wp-block-post-navigation-link a:hover {
	color: var(--aaed-primary);
}

/* Numbers: four across on desktop, two by two on a phone. */
@media (max-width: 781px) {
	.wp-block-columns.aaed-stats {
		flex-wrap: wrap !important;
		row-gap: 2rem;
	}

	.wp-block-columns.aaed-stats > .wp-block-column {
		flex-basis: calc(50% - .75rem) !important;
		flex-grow: 0;
	}
}

/* Outlined step numbers: the prose colour rule must not fill them in. */
p.aaed-step-number {
	color: transparent;
	-webkit-text-fill-color: transparent;
}

/*
 * Mobile menu. The header's backdrop blur makes it the containing block for
 * fixed-position children, which trapped the Navigation overlay inside the
 * header bar. While the menu is open the blur is dropped, so the overlay
 * covers the screen as intended.
 */
.aaed-header:has(.wp-block-navigation__responsive-container.is-menu-open) {
	backdrop-filter: none !important;
	-webkit-backdrop-filter: none !important;
}

.wp-block-navigation__responsive-container.is-menu-open {
	padding: 1.5rem 1.5rem 2rem !important;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: 3.5rem;
	align-items: flex-start;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: .25rem !important;
	align-items: flex-start !important;
	width: 100%;
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	font-size: 1.25rem !important;
	padding: .75rem .5rem !important;
}

.wp-block-navigation__responsive-container-close,
.wp-block-navigation__responsive-container-open {
	color: var(--aaed-foreground);
}

/* Anchor jumps (/#about, /#contact) land below the fixed header. */
html {
	scroll-padding-top: var(--wp--custom--header-offset);
}

/* -------------------------------------------------------------------------
 * Site settings (inc/settings.php): logo size, header button, WhatsApp
 * ---------------------------------------------------------------------- */
.aaed-header .wp-block-site-logo img {
	width: var(--aaed-logo-w, 120px) !important;
	max-width: none;
	max-height: none;
	height: auto;
}

@media (max-width: 781px) {
	.aaed-header .wp-block-site-logo img {
		width: var(--aaed-logo-w-mobile, 84px) !important;
	}

	/* Phones have no room for the tagline beside the logo and the menu button. */
	.aaed-header .aaed-tagline {
		display: none !important;
	}

	.aaed-header > .container {
		padding-top: .75rem !important;
		padding-bottom: .75rem !important;
	}
}


.aaed-whatsapp {
	position: fixed;
	inset-inline-end: 1.25rem;
	bottom: 1.25rem;
	z-index: 60;
	display: grid;
	place-items: center;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 999px;
	background: #25d366;
	color: #fff;
	box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5);
	transition: transform .2s ease;
}

.aaed-whatsapp:hover {
	transform: scale(1.06);
	color: #fff;
}
