/*
 * «منظومة النمو» — services wheel + cards (components/services-system/,
 * D-46). Shared by the home page and the services index (/services/).
 *
 * Baseline: a grid of seven cards. Enhanced (services-system.js sets
 * data-gb-services="wheel" on .gb-services__system): the wheel beside one
 * card at a time.
 */

/* ---------- Grid ---------- */

.gb-services__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
	gap: var(--gb-space-s);
	margin: 0;
	padding: 0;
	list-style: none;
}

.gb-services__item {
	display: grid;
}

/* ---------- Card ---------- */

.gb-service {
	display: grid;
	align-content: start;
	gap: var(--gb-space-2xs);
	padding: var(--gb-space-m);
	border: 1px solid var(--gb-border);
	border-radius: var(--gb-radius-l);
	background-color: var(--gb-bg);
	transition: border-color var(--gb-duration-base) linear;
}

.gb-service:hover {
	border-color: var(--gb-primary);
}

.gb-service__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-block-end: var(--gb-space-2xs);
}

/* Diamond badge: echoes the brand mark's frame. The square is rotated, the icon is not. */
.gb-service__badge {
	position: relative;
	display: grid;
	place-items: center;
	inline-size: 4.25rem;
	block-size: 4.25rem;
	color: var(--gb-color-navy);
	--gb-icon-size: 1.6rem;
}

.gb-service__badge::before {
	content: "";
	position: absolute;
	inset: 0.6rem;
	border: 1.5px solid var(--gb-primary);
	border-radius: 0.55rem;
	background-color: var(--gb-color-turquoise-a10);
	rotate: 45deg;
	transition:
		background-color var(--gb-duration-base) linear,
		rotate var(--gb-duration-slow) var(--gb-ease-out);
}

.gb-service:hover .gb-service__badge::before {
	background-color: var(--gb-primary);
	rotate: 135deg;
}

.gb-service__icon {
	position: relative;
}

.gb-service__number {
	font-size: var(--gb-step--1);
	font-weight: var(--gb-weight-bold);
	color: var(--gb-color-neutral-300);
	font-variant-numeric: tabular-nums;
}

.gb-service__title {
	font-size: var(--gb-step-2);
	color: var(--gb-text);
}

.gb-service__text {
	font-size: var(--gb-step--1);
	color: var(--gb-text-muted);
}

/* Link to the service page (Stage 3). Navy text: turquoise is too light on white. */
.gb-service__more {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	justify-self: start;
	margin-block-start: var(--gb-space-3xs);
	color: var(--gb-color-navy);
	font-size: var(--gb-step--1);
	font-weight: var(--gb-weight-bold);
	text-decoration: none;
	border-block-end: 2px solid var(--gb-primary);
	padding-block-end: 0.1em;
}

.gb-service__more:hover {
	border-block-end-color: var(--gb-accent);
}

.gb-service__more svg {
	inline-size: 1em;
	block-size: 1em;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: translate var(--gb-duration-base) var(--gb-ease-out);
}

.gb-service__more:hover svg {
	translate: calc(var(--gb-dir) * 0.2em) 0;
}

/* The chevron is drawn for RTL (pointing to the reading end); mirror it in LTR. */
[dir="ltr"] .gb-service__more svg {
	scale: -1 1;
}

/* ---------- Small phones: compact row cards (badge beside the text) ---------- */

@media (max-width: 30rem) {
	.gb-service {
		grid-template-columns: auto 1fr;
		column-gap: var(--gb-space-s);
		row-gap: var(--gb-space-3xs);
		padding: var(--gb-space-s);
	}

	.gb-service__top {
		grid-row: span 2;
		margin: 0;
	}

	.gb-service__number {
		display: none;
	}

	.gb-service__title {
		align-self: end;
		font-size: var(--gb-step-1);
	}
}

/* The "/ ٠٨" total only belongs to the wheel's single card. */
.gb-service__of {
	display: none;
}

/* =================================================================
 * «منظومة النمو» — the services wheel (PROPOSAL, D-46).
 * Active only when services.js sets data-gb-services="wheel".
 * ================================================================= */

/* Animatable angle: the whole wheel (branches + nodes) turns from one value. */
@property --gb-wheel-rot {
	syntax: "<angle>";
	inherits: true;
	initial-value: 0deg;
}

.gb-services__system {
	/*
	 * Focus = the direction (from the hub) where the chosen service comes to
	 * rest: straight UP, where the logo's arrow points (2026-10-05: the arrow
	 * aims at the chosen service and the logo still ends upright, as the
	 * identity is). Same in both directions and on every screen size.
	 * --gb-wheel-fx / -fy: the same direction as a unit vector, for the seed.
	 * --gb-wheel-aim: how long the arrow takes to aim at a newly chosen service.
	 */
	--gb-wheel-focus: -90deg;
	--gb-wheel-fx: 0;
	--gb-wheel-fy: -1;
	--gb-wheel-aim: 380ms;
	--gb-wheel-turn: 800ms;
	--gb-wheel-reach: 700ms;
}

@media (prefers-reduced-motion: reduce) {
	.gb-services__system {
		--gb-wheel-aim: 0ms;
		--gb-wheel-turn: 0ms;
		--gb-wheel-reach: 0ms;
	}
}

.gb-wheel[hidden],
.gb-services__steps[hidden] {
	display: none;
}

.gb-services__system[data-gb-services="wheel"] {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
	align-items: center;
	gap: var(--gb-space-xl);
}

/* Reading order is tabs → panel; on screen the panel sits at the reading start. */
.gb-services__system[data-gb-services="wheel"] .gb-wheel {
	grid-column: 2;
	grid-row: 1;
}

.gb-services__system[data-gb-services="wheel"] .gb-services__panel {
	grid-column: 1;
	grid-row: 1;
}

/* ---------- The wheel ---------- */

.gb-wheel {
	/* Size of a node's diamond badge. */
	--gb-node-size: clamp(2.75rem, 11cqi, 4rem);

	position: relative;
	justify-self: center;
	inline-size: min(100%, 34rem);
	aspect-ratio: 1;
	/* cqi = 1% of the wheel's width: the SVG box (-100…100) maps 1 unit to 0.5cqi. */
	container-type: inline-size;
	transition: --gb-wheel-rot var(--gb-wheel-turn) var(--gb-ease-in-out);
}

.gb-wheel__art {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	overflow: visible;
}

.gb-wheel__orbit {
	fill: none;
	stroke: var(--gb-color-turquoise-a35);
	stroke-width: 0.6;
	stroke-dasharray: 1.5 2.5;
}

/* The seven branches turn with the wheel (origin = the hub, user 0,0). */
.gb-wheel__branches {
	transform-origin: 0 0;
	rotate: calc(var(--gb-wheel-focus) + var(--gb-wheel-rot));
}

.gb-wheel__branch {
	stroke: var(--gb-color-turquoise-a35);
	stroke-width: 0.8;
	stroke-linecap: round;
	transition: stroke var(--gb-duration-base) linear, stroke-width var(--gb-duration-base) linear;
}

/*
 * The ray (fixed, along the focus direction): drawn in the seed's colour
 * behind the seed when it leaves for the chosen service, erased while the
 * wheel turns (owner, 2026-10-05: «الخط دا يتغير، هيبقى اشيك» — it was orange).
 */
.gb-wheel__focus {
	transform-origin: 0 0;
	rotate: var(--gb-wheel-focus);
}

.gb-wheel__ray {
	stroke: var(--gb-seed);
	stroke-width: 1.6;
	filter: drop-shadow(0 0 1.5px var(--gb-seed-glow));
	stroke-linecap: round;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	transition: stroke-dashoffset 200ms ease-in;
}

.gb-wheel[data-gb-phase="reach"] .gb-wheel__ray {
	stroke-dashoffset: 0;
	transition: stroke-dashoffset calc(var(--gb-wheel-reach) * 0.78) var(--gb-ease-organic) calc(var(--gb-wheel-reach) * 0.22);
}

/* Hub: the brand mark, where every branch starts. */
.gb-wheel__hub {
	position: absolute;
	inset-block-start: 50%;
	left: 50%;
	display: grid;
	place-items: center;
	inline-size: 17cqi;
	block-size: 17cqi;
	border: 1px solid var(--gb-color-turquoise-a35);
	border-radius: 50%;
	background-color: var(--gb-bg);
	box-shadow: 0 0 0 0.6rem var(--gb-color-turquoise-a10);
	translate: -50% -50%;
}

.gb-wheel__mark {
	inline-size: 70%;
	block-size: 70%;
	/* On the light surface: no glass sheen (the dash and seed use the logo's colours everywhere). */
	--gb-mark-sheen: transparent;
	/* Heartbeat flash: navy on the white hub (brand-mark.css). */
	--gb-mark-flash: var(--gb-color-navy);
}

/*
 * The seed IS the logo's seed: services.js parks it exactly on the dash of
 * the hub's mark (the mark's own circle is hidden here) and moves it out to
 * the chosen node with translate/scale. Anchored at the wheel's centre.
 * While the logo turns to aim its arrow ("aim", "turn") the logo's own seed
 * is shown instead, so it turns with the logo; they swap on the dash, where
 * both are in the same place.
 */
.gb-wheel__mark .gb-mark__point {
	visibility: hidden;
}

.gb-wheel:is([data-gb-phase="aim"], [data-gb-phase="turn"]) .gb-wheel__mark .gb-mark__point {
	visibility: visible;
}

.gb-wheel:is([data-gb-phase="aim"], [data-gb-phase="turn"]) .gb-wheel__seed {
	visibility: hidden;
}

.gb-wheel__seed {
	position: absolute;
	inset-block-start: 50%;
	left: 50%;
	z-index: 2;
	inline-size: 0.9rem;
	block-size: 0.9rem;
	margin: -0.45rem 0 0 -0.45rem;
	border-radius: 50%;
	background-color: var(--gb-seed);
	pointer-events: none;
}

/* The glow only once it is out on the branch (on the dash it is just the logo's seed). */
.gb-wheel__seed::after {
	content: "";
	position: absolute;
	inset: -0.25rem;
	border-radius: 50%;
	background-color: var(--gb-seed-glow);
	opacity: 0;
	transition: opacity var(--gb-duration-base) linear;
}

.gb-wheel[data-gb-phase="reach"] .gb-wheel__seed::after {
	opacity: 1;
	transition-delay: calc(var(--gb-wheel-reach) * 0.3);
}

/* ---------- Nodes ---------- */

.gb-wheel__nodes {
	position: absolute;
	inset: 0;
}

/*
 * Each node is placed by angle on the ring (radius 38cqi) and turned back
 * by the same angle, so icons and labels always stay upright. Physical
 * left/top on purpose: this is geometry around a centre, not text flow.
 */
.gb-wheel__node {
	--gb-a: calc(var(--gb-wheel-focus) + var(--gb-node-a) + var(--gb-wheel-rot));

	position: absolute;
	inset-block-start: 50%;
	left: 50%;
	display: grid;
	place-items: center;
	inline-size: var(--gb-node-size);
	block-size: var(--gb-node-size);
	padding: 0;
	border: 0;
	background: none;
	color: var(--gb-color-navy);
	font: inherit;
	cursor: pointer;
	translate: -50% -50%;
	transform: rotate(var(--gb-a)) translateX(38cqi) rotate(calc(var(--gb-a) * -1));
}

/* Diamond badge (the brand frame), like the cards. */
.gb-wheel__badge {
	--gb-icon-size: 42%;

	position: relative;
	display: grid;
	place-items: center;
	inline-size: 100%;
	block-size: 100%;
}

.gb-wheel__badge::before {
	content: "";
	position: absolute;
	inset: 14%;
	border: 1.5px solid var(--gb-primary);
	border-radius: 22%;
	background-color: var(--gb-bg);
	rotate: 45deg;
	transition:
		background-color var(--gb-duration-base) linear,
		scale var(--gb-duration-slow) var(--gb-ease-out),
		box-shadow var(--gb-duration-slow) var(--gb-ease-out);
}

.gb-wheel__icon {
	position: relative;
	inline-size: var(--gb-icon-size);
	block-size: var(--gb-icon-size);
}

.gb-wheel__node:hover .gb-wheel__badge::before {
	background-color: var(--gb-color-turquoise-a20);
}

/*
 * Keyboard focus follows the diamond, not the button's square box (the
 * site-wide ring + halo would draw a square around it).
 */
.gb-wheel__node:focus-visible {
	outline: none;
	box-shadow: none;
}

.gb-wheel__node:focus-visible .gb-wheel__badge::before {
	box-shadow: 0 0 0 2px var(--gb-bg), 0 0 0 4px var(--gb-focus), 0 0 0 8px var(--gb-focus-halo);
}

/* The chosen node: filled, larger, and it "receives" the seed (phase reach). */
.gb-wheel__node[aria-selected="true"] .gb-wheel__badge::before {
	background-color: var(--gb-primary);
	scale: 1.14;
}

.gb-wheel[data-gb-phase="reach"] .gb-wheel__node[aria-selected="true"] .gb-wheel__badge::before {
	box-shadow: 0 0 0 0.45rem var(--gb-color-turquoise-a20);
}

/* Focus ring stays visible on the chosen node too (it wins over the glow above). */
.gb-wheel[data-gb-phase] .gb-wheel__node:focus-visible .gb-wheel__badge::before {
	box-shadow: 0 0 0 2px var(--gb-bg), 0 0 0 4px var(--gb-focus), 0 0 0 8px var(--gb-focus-halo);
}

/* Label under the badge, outside its box, so the badge stays the node's centre. */
.gb-wheel__label {
	position: absolute;
	inset-block-start: 100%;
	left: 50%;
	padding-block-start: 0.35rem;
	font-size: var(--gb-step--1);
	font-weight: var(--gb-weight-bold);
	line-height: 1.3;
	color: var(--gb-text-muted);
	white-space: nowrap;
	translate: -50% 0;
	transition: color var(--gb-duration-base) linear;
}

.gb-wheel__node:hover .gb-wheel__label,
.gb-wheel__node[aria-selected="true"] .gb-wheel__label {
	color: var(--gb-text);
}

/* The chosen service rests at the top with the ray coming up to it: its label goes above it. */
.gb-wheel__node[aria-selected="true"] .gb-wheel__label {
	inset-block-start: auto;
	inset-block-end: 100%;
	padding-block: 0 0.35rem;
}

/* Entrance (once, when the wheel first comes into view): nodes grow in, in turn. */
.gb-wheel[data-gb-wheel-wait] .gb-wheel__node {
	opacity: 0;
	scale: 0.6;
}

.gb-wheel .gb-wheel__node {
	transition:
		opacity var(--gb-duration-slow) var(--gb-ease-out),
		scale var(--gb-duration-slow) var(--gb-ease-out);
	transition-delay: calc(var(--gb-node-i) * 60ms);
}

@media (prefers-reduced-motion: reduce) {
	.gb-wheel .gb-wheel__node {
		transition: none;
	}
}

/* ---------- The panel (one card at a time) ---------- */

.gb-services__system[data-gb-services="wheel"] .gb-services__grid {
	display: block;
}

.gb-services__system[data-gb-services="wheel"] .gb-services__item[hidden] {
	display: none;
}

/* The new card arrives with the seed (after the turn). */
.gb-services__system[data-gb-services="wheel"] .gb-services__item[data-gb-entering] {
	animation: gb-service-in var(--gb-wheel-reach) var(--gb-ease-out) both;
	animation-delay: var(--gb-wheel-delay, 0ms);
}

@keyframes gb-service-in {
	from {
		opacity: 0;
		translate: 0 0.75rem;
	}
}

.gb-services__system[data-gb-services="wheel"] .gb-service {
	gap: var(--gb-space-xs);
	padding: var(--gb-space-l);
	border-color: var(--gb-color-turquoise-a35);
	border-inline-start: 4px solid var(--gb-primary);
	min-block-size: 16rem;
}

.gb-services__system[data-gb-services="wheel"] .gb-service__title {
	font-family: var(--gb-font-display);
	font-size: var(--gb-step-4);
}

.gb-services__system[data-gb-services="wheel"] .gb-service__text {
	font-size: var(--gb-step-1);
}

.gb-services__system[data-gb-services="wheel"] .gb-service__number {
	font-size: var(--gb-step-0);
	color: var(--gb-text-muted);
}

.gb-services__system[data-gb-services="wheel"] .gb-service__of {
	display: inline;
	color: var(--gb-color-neutral-300);
}

.gb-services__steps {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gb-space-s);
	margin-block-start: var(--gb-space-s);
}

.gb-services__hint {
	font-size: var(--gb-step--1);
	color: var(--gb-text-muted);
	text-align: center;
}

.gb-services__step {
	display: grid;
	flex: none;
	place-items: center;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	padding: 0;
	border: 1px solid var(--gb-border);
	border-radius: 50%;
	background-color: var(--gb-bg);
	color: var(--gb-text);
	cursor: pointer;
	transition: border-color var(--gb-duration-fast) linear;
}

.gb-services__step:hover {
	border-color: var(--gb-primary);
}

.gb-services__step svg {
	inline-size: 1.2rem;
	block-size: 1.2rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Chevrons are drawn for RTL (previous points right); mirror them in LTR. */
[dir="ltr"] .gb-services__step svg {
	scale: -1 1;
}

/* ---------- Narrow screens: wheel on top, the card below it ---------- */

@media (max-width: 55.99rem) {
	.gb-services__system[data-gb-services="wheel"] {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--gb-space-l);
	}

	.gb-services__system[data-gb-services="wheel"] .gb-wheel,
	.gb-services__system[data-gb-services="wheel"] .gb-services__panel {
		grid-column: 1;
		grid-row: auto;
	}

	.gb-wheel {
		inline-size: min(100%, 22rem);
	}

	/* Names would collide on a small ring: the card below names the service. */
	.gb-wheel__label {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		padding: 0;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.gb-services__system[data-gb-services="wheel"] .gb-service {
		padding: var(--gb-space-m);
		min-block-size: 0;
	}

	/* One card at a time has the full width: keep it stacked (not the compact row card). */
	.gb-services__system[data-gb-services="wheel"] .gb-service {
		grid-template-columns: minmax(0, 1fr);
	}

	.gb-services__system[data-gb-services="wheel"] .gb-service__top {
		grid-row: auto;
		margin-block-end: var(--gb-space-2xs);
	}

	.gb-services__system[data-gb-services="wheel"] .gb-service__number {
		display: inline;
	}

	.gb-services__system[data-gb-services="wheel"] .gb-service__title {
		align-self: auto;
		font-size: var(--gb-step-3);
	}
}

/* ---------- The service's picture (revisions 4 and 5) ---------- */

/*
 * Owner (2026-10-05): «يميز كل حاجه ف الجمب هنا بصورة», then «الصور محتاجه
 * تتظبط مهم». Each card carries a picture of the company's own work for that
 * service (gb_theme_services_pictures(): 1200 × 675, framed by hand). It sits
 * at the top of the card, as wide as the card: beside the text (revision 4)
 * the text was squeezed into two or three words a line and the tall box cut
 * the pictures in half. In the wheel it changes with the service and
 * settles in as the card arrives with the seed.
 */
.gb-service__picture {
	position: relative;
	order: -1;
	margin: 0 0 var(--gb-space-2xs);
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: calc(var(--gb-radius-l) - 0.25rem);
	background-color: var(--gb-color-navy);
}

.gb-service__picture img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

/* A fine turquoise edge and the seed in the corner: the brand's signature on the photo. */
.gb-service__picture::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 1px solid var(--gb-color-turquoise-a35);
	border-radius: inherit;
	background: radial-gradient(circle at calc(100% - 1.1rem) 1.1rem, var(--gb-seed) 0 0.32rem, transparent 0.36rem);
	pointer-events: none;
}

/* The seed sits at the reading start: top right in Arabic, top left in English. */
[dir="ltr"] .gb-service__picture::after {
	background: radial-gradient(circle at 1.1rem 1.1rem, var(--gb-seed) 0 0.32rem, transparent 0.36rem);
}

/* In the wheel: the picture is the top of the card, almost edge to edge. */
.gb-services__system[data-gb-services="wheel"] .gb-service:has(.gb-service__picture) {
	padding-block-start: var(--gb-space-xs);
}

.gb-services__system[data-gb-services="wheel"] .gb-service > .gb-service__picture {
	margin-inline: calc(var(--gb-space-xs) - var(--gb-space-l));
	margin-block-end: var(--gb-space-3xs);
}

@media (max-width: 55.99rem) {
	.gb-services__system[data-gb-services="wheel"] .gb-service > .gb-service__picture {
		margin-inline: calc(var(--gb-space-xs) - var(--gb-space-m));
	}
}

/* The picture settles in as the card arrives with the seed. */
.gb-services__system[data-gb-services="wheel"] .gb-services__item[data-gb-entering] .gb-service__picture img {
	animation: gb-service-picture-in var(--gb-wheel-reach) var(--gb-ease-out) both;
	animation-delay: var(--gb-wheel-delay, 0ms);
}

@keyframes gb-service-picture-in {
	from {
		scale: 1.08;
	}
}

/* Small phones (compact row cards): no picture, the row stays light. */
@media (max-width: 30rem) {
	.gb-services__system:not([data-gb-services="wheel"]) .gb-service__picture {
		display: none;
	}
}
