/*
 * Last Design — W2-T1 LOCAL TEST trial: project and service pages, cards, gallery layouts and section styles.
 *
 * Loaded only on the trial's pages (body.ld-trial) and on its editor screens (inside .editor-styles-wrapper). Values
 * come from the approved foundation tokens in last-design.css.
 */

/* Presets of the trial's closed editor options (blocks reference them as CSS variables and classes). */
:root {
	--wp--preset--spacing--ld-s: 2rem;
	--wp--preset--spacing--ld-m: clamp(3rem, 2rem + 4.444vw, 6rem);
	--wp--preset--spacing--ld-l: clamp(4rem, 3rem + 4.444vw, 8rem);
}

:where(.ld-trial, .editor-styles-wrapper) .has-ld-small-font-size { font-size: var(--ld-text-small) !important; }
:where(.ld-trial, .editor-styles-wrapper) .has-ld-base-font-size { font-size: var(--ld-text-base) !important; }
:where(.ld-trial, .editor-styles-wrapper) .has-ld-lead-font-size { font-size: var(--ld-text-lead) !important; }
:where(.ld-trial, .editor-styles-wrapper) .has-ld-h3-font-size { font-size: var(--ld-h3) !important; }
:where(.ld-trial, .editor-styles-wrapper) .has-ld-h2-font-size { font-size: var(--ld-h2) !important; }

/* Project and service templates */

.ldp {
	font-family: var(--ld-font-ar);
	font-size: var(--ld-text-base);
	font-weight: var(--ld-weight-body);
	line-height: var(--ld-leading-body);
	color: var(--ld-text);
	background: var(--ld-surface);
}

.ldp *,
.ldp *::before,
.ldp *::after {
	box-sizing: border-box;
	letter-spacing: 0;
}

.ldp :lang(en) {
	font-family: var(--ld-font-en-functional);
}

.ldp-container {
	width: 100%;
	max-width: calc(var(--ld-container) + 2 * var(--ld-gutter));
	margin-inline: auto;
	padding-inline: var(--ld-gutter);
}

.ldp a {
	color: var(--ld-link);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.35em;
}

.ldp a:hover {
	text-decoration-thickness: 2px;
}

.ldp :focus-visible {
	outline: var(--ld-focus-width) solid var(--ld-focus);
	outline-offset: var(--ld-focus-offset);
}

.ldp-trialbar {
	padding-block: var(--ld-space-4);
	font-size: var(--ld-text-small);
	line-height: 1.7;
	background: var(--ld-warm);
}

.ldp-trialbar p,
.ldp-trialbar ul {
	margin: 0;
}

.ldp-trialbar ul {
	margin-block-start: var(--ld-space-2);
	padding-inline-start: 1.25em;
}

.ldp-trialbar__warning::before {
	content: "تنبيه: ";
	font-weight: var(--ld-weight-strong);
}

.ldp-trialbar__info::before {
	content: "ملاحظة: ";
	font-weight: var(--ld-weight-medium);
}

.ldp-hero {
	padding-block-start: var(--ld-space-8);
}

.ldp-hero__text {
	display: grid;
	justify-items: start;
	gap: var(--ld-space-4);
	padding-block-end: var(--ld-space-7);
}

/* Gold as a limited accent: one short rule above the main heading. */
.ldp-hero__text::before,
.ldp-service__head::before {
	content: "";
	display: block;
	width: 2.5rem;
	height: 2px;
	background: var(--ld-accent);
}

.ldp-kicker,
.ldp-note {
	margin: 0;
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
}

.ldp-note {
	font-weight: var(--ld-weight-body);
}

.ldp-title {
	margin: 0;
	font-family: var(--ld-font-ar);
	font-size: var(--ld-h1);
	font-weight: var(--ld-weight-display);
	line-height: var(--ld-leading-display);
	color: inherit;
}

.ldp-tag {
	display: inline-block;
	margin: 0;
	padding: var(--ld-space-1) var(--ld-space-3);
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
	color: var(--ld-ink);
	background: var(--ld-warm);
	border-inline-start: 3px solid var(--ld-accent);
}

.ldp-intro {
	max-width: var(--ld-container-text);
	margin: 0;
	font-size: var(--ld-text-lead);
	line-height: 1.75;
}

.ldp-hero__media {
	margin: 0;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--ld-warm);
}

.ldp-hero__media picture,
.ldp-hero__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ldp-facts {
	padding-block-start: var(--ld-space-7);
}

.ldp-facts dl {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
	gap: var(--ld-space-5);
	margin: 0;
}

.ldp-facts dt {
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
}

.ldp-facts dd {
	margin: 0;
}

.ldp-content {
	padding-block: var(--ld-space-6);
}

.ldp-content .ld-stage {
	padding-block: var(--ld-space-6);
}

/* The group of the two design sections adds no space of its own: the sections read as siblings of the others. */
.ldp-content .ld-stage-group {
	margin: 0;
	padding: 0;
}

/* «النتيجة النهائية»: what Last Design did in this project (from the services chosen). */
.ldp-content .ld-stage__role {
	max-width: var(--ld-container-text);
	margin: 0 0 var(--ld-space-4);
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
}

.ldp-content .ld-stage > .wp-block-heading,
.ldp-related__title,
.ldp-preview__title {
	margin: 0 0 var(--ld-space-4);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-h2);
	font-weight: var(--ld-weight-heading);
	line-height: var(--ld-leading-heading);
	color: inherit;
}

.ldp-content p,
.ldp-content ul,
.ldp-content ol {
	max-width: var(--ld-container-text);
	margin: 0 0 var(--ld-space-4);
}

.ldp-service__head,
.ldp-projects__head {
	display: grid;
	justify-items: start;
	gap: var(--ld-space-4);
	padding-block: var(--ld-space-8) var(--ld-space-4);
}

/* Service page: the single «استعرض جميع المشاريع» button under the text (button styles come from .ld-hp). */
.ldp-service__more.ld-hp {
	margin-block: 0;
	padding-block: var(--ld-space-5) var(--ld-space-8);
	background: transparent;
}

/* «جميع المشاريع» (page-projects.php): the home page's project cards (.ld-hp-projects) under the page title. */
.ldp-projects__list.ld-hp {
	padding-block: var(--ld-space-5) var(--ld-space-9);
	background: transparent;
}

.ldp-related,
.ldp-preview {
	padding-block: var(--ld-space-6) var(--ld-space-8);
}

.ldp-preview__title {
	font-size: var(--ld-h3);
}

.ldp-preview__help {
	max-width: var(--ld-container-text);
	margin: 0 0 var(--ld-space-5);
	font-size: var(--ld-text-small);
}

.ldp-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
	gap: var(--ld-space-6);
}

.ldp-card__link {
	display: grid;
	gap: var(--ld-space-3);
	color: inherit;
	text-decoration: none;
}

.ldp .ldp-card__link {
	color: inherit;
	text-decoration: none;
}

.ldp-card__media {
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--ld-warm);
}

.ldp-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ldp-card__title {
	margin: 0;
	font-family: var(--ld-font-ar);
	font-size: var(--ld-h4);
	font-weight: var(--ld-weight-heading);
	line-height: var(--ld-leading-heading);
	color: inherit;
}

.ldp-card__link:hover .ldp-card__title {
	text-decoration: underline;
	text-decoration-color: var(--ld-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.4em;
}

.ldp-card__meta {
	margin: var(--ld-space-2) 0 0;
	font-size: var(--ld-text-small);
}

.ldp-card .ldp-tag {
	margin-block-start: var(--ld-space-2);
}

/* Gallery layouts (closed list): "شبكة" — two even columns; "تحريري" — a full-width image, then two, repeating.
   The :not(#ld) keeps these above WordPress's own gallery widths. One column on phones. */

:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-grid figure.wp-block-image:not(#ld),
:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-editorial figure.wp-block-image:not(#ld) {
	width: calc(50% - var(--wp--style--unstable-gallery-gap, 16px) / 2);
}

:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-editorial figure.wp-block-image:not(#ld):nth-child(3n+1) {
	width: 100%;
}

/* "شبكة" keeps an image left alone on its row at half width too (WordPress lets it grow to the full row). */
:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-grid figure.wp-block-image:not(#ld) {
	flex-grow: 0;
}

/* "شبكة": equal frames, 4:3 by default, cropped for display only (the image files are untouched); each image's focal
   point places it in its frame. "تحريري" keeps every image's natural proportions. */
:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-grid figure.wp-block-image:not(#ld) img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

@media (max-width: 47.99rem) {
	:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-grid figure.wp-block-image:not(#ld),
	:where(.ld-trial, .editor-styles-wrapper) .wp-block-gallery.has-nested-images.is-style-ld-editorial figure.wp-block-image:not(#ld) {
		width: 100%;
	}
}

/* Sections of the section-control test page (closed background styles; text colour follows the background). */

:where(.ld-trial, .editor-styles-wrapper) .ld-section {
	padding-block: var(--ld-section-space);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-text-base);
	line-height: var(--ld-leading-body);
	color: var(--ld-text);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section.is-style-ld-bg-paper {
	background: var(--ld-paper);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section.is-style-ld-bg-warm {
	background: var(--ld-warm);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section.is-style-ld-bg-ink {
	color: var(--ld-paper);
	background: var(--ld-ink);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section .wp-block-heading {
	font-family: var(--ld-font-ar);
	font-weight: var(--ld-weight-heading);
	line-height: var(--ld-leading-heading);
	color: inherit;
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section h2.wp-block-heading {
	font-size: var(--ld-h2);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section h3.wp-block-heading {
	font-size: var(--ld-h3);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section p {
	max-width: var(--ld-container-text);
	color: inherit;
}

/* Editor, section page: with no width choice offered, WordPress drops the full-width class from the preview; the
   section still spans the canvas, as on the page (where its stored full width applies) — Blocksy's own full-width
   rule in the editor. */
.editor-styles-wrapper .is-root-container > .wp-block-group.ld-section:not(.alignfull) {
	max-width: none !important;
	margin-inline: var(--has-wide, -20px) !important;
}

/* A section's text area takes the heading's width and edge; its paragraphs keep the reading width from that edge. */
:where(.ld-trial, .editor-styles-wrapper) .ld-section .ld-section__text > p {
	max-width: var(--ld-container-text);
	margin-inline-start: 0;
	margin-inline-end: auto;
}

/* Older section markup (a paragraph directly in the section), same edge as the heading. The constrained layout centres
   every child with !important auto margins: the heading fills the content width, the paragraph would sit in the middle.
   Its start margin is the heading's: half of what the container has beyond the block width (Blocksy's
   --theme-block-width within the content size). */
:where(.ld-trial, .editor-styles-wrapper) .ld-section .ld-section__inner > p {
	margin-inline-start: max(0px, (100% - min(var(--theme-block-width, 100%), var(--wp--style--global--content-size, 100%))) / 2) !important;
	margin-inline-end: auto !important;
}

/* .wp-block-button in the selector: Blocksy's button rule has the same weight (0,2,0) and comes later in the editor. */
:where(.ld-trial, .editor-styles-wrapper) .ld-section .wp-block-button .wp-block-button__link {
	padding: var(--ld-space-3) var(--ld-space-5);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-text-base);
	font-weight: var(--ld-weight-medium);
	color: var(--ld-paper);
	background: var(--ld-ink);
	border: var(--ld-field-border-width) solid var(--ld-ink);
	border-radius: var(--ld-radius);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section .is-style-outline > .wp-block-button__link {
	color: var(--ld-ink);
	background: transparent;
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section.is-style-ld-bg-ink .wp-block-button__link {
	color: var(--ld-ink);
	background: var(--ld-paper);
	border-color: var(--ld-paper);
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section.is-style-ld-bg-ink .is-style-outline > .wp-block-button__link {
	color: var(--ld-paper);
	background: transparent;
}

:where(.ld-trial, .editor-styles-wrapper) .ld-section .wp-block-button .wp-block-button__link:hover {
	box-shadow: inset 0 -3px 0 var(--ld-accent);
}

.ld-trial .ld-section a:not(.wp-block-button__link) {
	color: var(--ld-link);
	text-decoration: underline;
}

.ld-trial .ld-section.is-style-ld-bg-ink a:not(.wp-block-button__link) {
	color: var(--ld-paper);
	text-decoration-color: var(--ld-accent);
}

.ld-trial .ld-section :focus-visible {
	outline: var(--ld-focus-width) solid var(--ld-focus);
	outline-offset: var(--ld-focus-offset);
}

.ld-trial .ld-section.is-style-ld-bg-ink :focus-visible {
	outline-color: var(--ld-focus-on-dark);
}

/* Image sets (W2-T1-R4): a named group of images inside a project section. The name is a level-3 heading, the kind of
   images («صور تصميم تصورية» / «صور فعلية») sits under it, then the description and the gallery. */

.ldp-content .ld-set {
	margin-block: var(--ld-space-7) 0;
	scroll-margin-block-start: var(--ld-space-6);
}

.ldp-content .ld-stage > .wp-block-heading + .ld-set,
.ldp-content .ld-stage__role + .ld-set {
	margin-block-start: var(--ld-space-5);
}

.ldp-content .ld-set > .wp-block-heading {
	margin: 0 0 var(--ld-space-2);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-h3);
	font-weight: var(--ld-weight-heading);
	line-height: var(--ld-leading-heading);
	color: inherit;
}

.ldp-content .ld-set__kind {
	display: inline-block;
	margin: 0 0 var(--ld-space-4);
	padding: var(--ld-space-1) var(--ld-space-3);
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
	line-height: var(--ld-leading-ui);
	background: var(--ld-warm);
	border-inline-start: 3px solid var(--ld-accent);
}

/* A set arrived at from a link (#set-…) is marked briefly by its accent rule, nothing more. */
.ldp-content .ld-set:target > .wp-block-heading {
	text-decoration: underline;
	text-decoration-color: var(--ld-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.4em;
}

/* With scripts on, a set shows its first images (6 in «شبكة», 4 in «تحريري»); the rest are not drawn — so not
   loaded — until «عرض كل الصور». Without scripts every image is shown and the button stays hidden. */
.ld-js .ld-set--more.ld-set--grid:not(.is-expanded) .wp-block-gallery > figure.wp-block-image:nth-of-type(n+7),
.ld-js .ld-set--more.ld-set--editorial:not(.is-expanded) .wp-block-gallery > figure.wp-block-image:nth-of-type(n+5) {
	display: none !important;
}

/* WordPress's enlarge buttons do nothing without scripts: not offered then (the images are shown in full anyway). */
html:not(.ld-js) .ld-set .lightbox-trigger {
	display: none !important;
}

.ldp-content .ld-set__more-wrap {
	display: none;
	margin: var(--ld-space-4) 0 0;
}

.ld-js .ldp-content .ld-set__more-wrap {
	display: block;
}

.ldp .ld-set__more,
.ldp .lds-more {
	min-height: 2.75rem;
	padding: var(--ld-space-2) var(--ld-space-5);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
	line-height: var(--ld-leading-ui);
	color: var(--ld-ink);
	background: transparent;
	border: var(--ld-border-width) solid var(--ld-ink);
	border-radius: var(--ld-radius);
	cursor: pointer;
}

.ldp .ld-set__more:hover,
.ldp .lds-more:hover {
	color: var(--ld-paper);
	background: var(--ld-ink);
}

.ldp .lds-more:disabled {
	cursor: progress;
	opacity: 0.6;
}

/* Editor: a set is outlined and labelled so its place and settings are clear. */
.editor-styles-wrapper .ld-set-editor {
	margin-block: var(--ld-space-5);
	padding: var(--ld-space-3);
	border: 1px dashed var(--ld-stone-deep);
}

.editor-styles-wrapper .ld-set-editor__label {
	margin: 0 0 var(--ld-space-2);
	font-family: var(--ld-font-ar);
	font-size: var(--ld-text-caption);
	color: var(--ld-ink);
}

.editor-styles-wrapper .ld-set-editor h3.wp-block-heading {
	margin-block: 0 var(--ld-space-2);
	font-size: var(--ld-h3);
	font-weight: var(--ld-weight-heading);
}

/* Spaces gallery (W2-T1-R4) */

.lds-head {
	padding-block-start: var(--ld-space-6);
}

.lds-crumbs {
	padding-block-start: var(--ld-space-6);
	font-size: var(--ld-text-small);
}

.lds-total {
	margin: 0;
	font-size: var(--ld-text-small);
	font-weight: var(--ld-weight-medium);
}

.lds-types,
.lds-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
	gap: var(--ld-space-6) var(--ld-space-5);
	margin: 0;
	padding: 0;
	list-style: none;
}

.lds-types-wrap,
.lds-body {
	padding-block-end: var(--ld-space-8);
}

.ldp .lds-type__link,
.ldp .lds-card__link {
	display: grid;
	gap: var(--ld-space-3);
	color: inherit;
	text-decoration: none;
}

.lds-type,
.lds-type__link {
	display: grid;
	gap: var(--ld-space-2);
}

.lds-type__media,
.lds-card__media {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--ld-warm);
}

.lds-type__media img,
.lds-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.lds-type__name,
.lds-card__title {
	margin: 0;
	font-family: var(--ld-font-ar);
	font-size: var(--ld-h4);
	font-weight: var(--ld-weight-heading);
	line-height: var(--ld-leading-heading);
	color: inherit;
}

.lds-type__count,
.lds-card__project,
.lds-card__kind,
.lds-card__count {
	margin: 0;
	font-size: var(--ld-text-small);
}

.lds-card__project {
	margin-block-start: var(--ld-space-2);
	font-weight: var(--ld-weight-medium);
}

.lds-type.is-empty .lds-type__name,
.lds-type.is-empty .lds-type__count {
	color: var(--ld-ink);
}

.lds-type__link:hover .lds-type__name,
.lds-card__link:hover .lds-card__title {
	text-decoration: underline;
	text-decoration-color: var(--ld-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.4em;
}

.lds-pager {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ld-space-5);
	align-items: center;
	margin-block-start: var(--ld-space-7);
	font-size: var(--ld-text-small);
}

.lds-more-wrap {
	display: none;
	margin: var(--ld-space-7) 0 0;
}

.lds-js .lds-more-wrap {
	display: block;
}

.lds-js .lds-pager {
	display: none;
}

.lds-status {
	margin: var(--ld-space-3) 0 0;
	font-size: var(--ld-text-small);
}

.lds-status:empty {
	display: none;
}

/* A section that takes images: its text area first, then its sets area (W2-T1-R4 refinements). The areas add no
   space of their own; the sets keep theirs. */
.ldp-content .ld-stage__text,
.ldp-content .ld-stage__sets {
	margin: 0;
	padding: 0;
}

.ldp-content .ld-stage__text > p:last-child {
	margin-block-end: 0;
}

/* Editor: the sets area is marked, and ends with «إضافة مجموعة صور». */
.editor-styles-wrapper .ld-stage__sets {
	margin-block-start: var(--ld-space-4);
	padding-block-start: var(--ld-space-2);
	border-block-start: 1px dashed var(--ld-stone-deep);
}

.editor-styles-wrapper .ld-sets-add {
	margin-block: var(--ld-space-3) var(--ld-space-5);
}
