/* ==========================================================================
   SUDAIR PHARMA — LOCALIZATION INFOGRAPHIC

   The right half of the Localization Overview: a dotted map of the Kingdom
   inside a thin ring, with seven pillars orbiting it.

   Scoped under .sud-loc, which exists on one section of one page. The left-hand
   copy in that section is untouched by every rule in this file.

   BUILT AS LAYOUT, NOT AS A PICTURE
   Grid, absolute positioning and one inline SVG — so the labels are real text
   (selectable, translatable, readable to a screen reader) and everything stays
   sharp at any zoom. A flattened export would have been quicker and none of
   that would be true.
   ========================================================================== */

.sud-loc {
	--lo-green: var(--sud-green-700, #006344);
	--lo-bright: var(--sud-green-500, #43B649);
	--lo-ink: #16362E;                 /* dark green-navy, for the labels */
	--lo-line: #CFE2D9;
	--lo-ease: cubic-bezier(.22, 1, .36, 1);

	--lo-disc: clamp(52px, 4.4vw, 66px);
	--lo-core: 42%;                    /* ring diameter, as % of this box */
	--lo-pillar: 28%;                  /* width of one icon + label */

	/*
	 * 42 + 2x28 = 98, leaving 2% of clearance between each middle pillar and the
	 * circle. At 43/29 the two middle labels — the longest of the six — ran into
	 * the ring by a few pixels, because those are the only pillars sitting at the
	 * circle's widest point.
	 */

	position: relative;
	inline-size: 100%;

	/*
	 * A fixed ratio, because the seven pillars are placed as percentages of this
	 * box. Without it the box would take its height from whichever label wrapped
	 * longest, and the orbit would drift as the text reflowed.
	 */
	aspect-ratio: 15 / 10;

	color: var(--lo-ink);
	font-family: var(--sud-font-body, Roboto, Arial, sans-serif);
}

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

/* --------------------------------------------------------------------------
   THE CENTRE

   Sized as a percentage of the box and centred on it, so ring, map and emblem
   scale together as one object.
   -------------------------------------------------------------------------- */

.sud-loc__core {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	transform: translate(-50%, -50%);
	inline-size: var(--lo-core);
	aspect-ratio: 1;
	display: grid;
	place-items: center;
}

/*
 * Ring and dots are one SVG rather than a bordered div plus seven positioned
 * spans. Inside a viewBox the dots sit exactly on the circle at any size, which
 * pixel offsets cannot promise once the container is fluid.
 */
.sud-loc__ring {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	overflow: visible;
	pointer-events: none;
}

.sud-loc__ring circle.sud-loc__ringline {
	fill: none;
	stroke: var(--lo-line);
	stroke-width: 1;
	vector-effect: non-scaling-stroke;
}

.sud-loc__ring circle.sud-loc__node { fill: var(--lo-green); }

/* The map fills most of the ring — it is the subject, not a detail inside it. */
.sud-loc__map {
	position: relative;
	inline-size: 84%;
	color: #BCDFCD;                 /* halftone dot colour, via currentColor */
	display: grid;
	place-items: center;
}

.sud-loc__map svg {
	inline-size: 100%;
	block-size: auto;
	display: block;
}

.sud-loc__emblem {
	position: absolute;
	inline-size: 32%;
	aspect-ratio: 1;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	transform: translate(-50%, -50%);
	z-index: 2;
}

/*
 * RTL: pull the ring and the logo back the other way.
 *
 * Both are centred with a LOGICAL inset and a PHYSICAL transform. In Arabic the
 * inset flips to `right: 50%` — putting each one's right edge on the centre line
 * — but translate(-50%) is not direction-aware and still pulls left, so each
 * overshoots by its own width. Measured at 1440px: the ring 294.2px left of its
 * box's centre (its width is 294.3px), which put its left edge 31px past the
 * edge of the page; and the logo 94.2px left of the ring's centre (its width).
 *
 * Only the horizontal pull is reversed; the vertical centring is unchanged. The
 * labels need nothing — they are placed with inset-inline-start/end, which
 * mirror on their own — and the map is a map, so it rightly does not flip.
 *
 * The ring's rule is desktop-only: from 1200px down it is taken out of absolute
 * positioning (transform: none, margin-inline: auto) and centres correctly in
 * both directions. The query is the exact complement of that one, so on a
 * scaled display there is no fractional width where neither applies. The logo
 * stays absolutely centred inside the ring at every width, so its rule is not
 * limited.
 */
@media not all and (max-width: 1200px) {
	[dir="rtl"] .sud-loc .sud-loc__core { transform: translate(50%, -50%); }
}

[dir="rtl"] .sud-loc .sud-loc__emblem { transform: translate(50%, -50%); }

.sud-loc__emblem img,
.sud-loc__emblem svg {
	inline-size: 100%;
	block-size: 100%;
	display: block;
}

/* --------------------------------------------------------------------------
   THE ORBIT

   The pillars are placed absolutely rather than in two flex columns, and
   that is what lets the circle grow.

   A circle leaves the corners of its bounding box empty. In a column layout
   those corners are wasted: the map can only ever be as wide as the gap left
   between two text columns. Positioned absolutely, the four corner pillars sit
   IN that empty space, so the ring takes 43% of the width instead of a third.

   The two middle pillars sit flush to the edges and the four corners are inset,
   which is what makes the group read as orbiting the map rather than as two
   lists either side of it.
   -------------------------------------------------------------------------- */

.sud-loc__col {
	list-style: none;
	margin: 0;
	padding: 0;

	/* The <ul> stops being a box, so its items position against .sud-loc. */
	display: contents;
}

.sud-loc__pillar {
	position: absolute;
	inline-size: var(--lo-pillar);
	display: flex;
	align-items: center;
	gap: clamp(.7rem, 1.05vw, 1rem);
}

/* Left: top corner, middle (flush to the edge), bottom corner. */
.sud-loc__col--left .sud-loc__pillar:nth-child(1) { inset-inline-start: 7%; inset-block-start: 4%; }
.sud-loc__col--left .sud-loc__pillar:nth-child(2) { inset-inline-start: 0; inset-block-start: 50%; transform: translateY(-50%); }
.sud-loc__col--left .sud-loc__pillar:nth-child(3) { inset-inline-start: 7%; inset-block-end: 4%; }

/* Right mirrors it. */
.sud-loc__col--right .sud-loc__pillar:nth-child(1) { inset-inline-end: 7%; inset-block-start: 4%; }
.sud-loc__col--right .sud-loc__pillar:nth-child(2) { inset-inline-end: 0; inset-block-start: 50%; transform: translateY(-50%); }
.sud-loc__col--right .sud-loc__pillar:nth-child(3) { inset-inline-end: 7%; inset-block-end: 4%; }

/*
 * The seventh goes top centre, in the one gap the six-pillar composition leaves.
 * The top corners occupy 7-35% and 65-93%, so 36% starts it clear of both; and
 * 36 + 28 = 64 makes it symmetrical, which is why it needs no RTL counterpart —
 * inset-inline-start flips to `right: 36%` and lands on the same band.
 *
 * Block-start 0 rather than the corners' 4%: the ring's top reaches 18.5% of the
 * height, and a pillar is ~16% tall, so at 4% its bottom edge would graze the ring.
 *
 * This placement is only ever painted in the hairline case the RTL note below
 * describes — a fractional viewport width between the 1024 and 1025 queries,
 * where neither the orbit nor the stacked layout applies. It exists so the
 * seventh pillar behaves there exactly like the other six, which all have one.
 */
.sud-loc__col--right .sud-loc__pillar:nth-child(4) { inset-inline-start: 36%; inset-block-start: 0; }

.sud-loc__disc {
	inline-size: var(--lo-disc);
	block-size: var(--lo-disc);
	flex: 0 0 auto;
	border-radius: 50%;
	background: #fff;
	display: grid;
	place-items: center;
	color: var(--lo-green);

	box-shadow:
		0 1px 2px rgba(11, 31, 23, .05),
		0 8px 22px rgba(11, 31, 23, .09);
}

/* One proportion and one stroke weight across all seven. */
.sud-loc__disc svg {
	inline-size: 50%;
	block-size: 50%;
	display: block;
	stroke-width: 1.5;
}

.sud-loc .sud-loc__label {
	margin: 0;
	font-family: var(--sud-font-display, Roboto, Arial, sans-serif);
	font-size: clamp(.8125rem, .95vw, .9375rem);
	font-weight: 600;                  /* lighter than the 700 it started at */
	line-height: 1.38;
	letter-spacing: -.002em;
	color: var(--lo-ink);
	text-wrap: balance;
}

/* --------------------------------------------------------------------------
   THE ORBIT, IN MOTION

   The seven pillars travel round the map instead of sitting still beside it.

   AN ELLIPSE, DRAWN WITH TRANSFORMS
   `offset-path: ellipse()` looks like the tool for this and is not: a basic
   shape there resolves against the ELEMENT's own box, so each pillar orbited a
   70x26 ellipse of its own, on the spot. The path has to come from the section,
   so it is built out of transforms instead:

     scaleY(k) rotate(a) translateX(rx) rotate(-a) scaleY(1/k)

   Read right to left, as transforms apply. The inner scaleY squashes the
   pillar, the two rotations are equal and opposite, and the outer scaleY
   stretches it back: the pillar itself comes out unrotated and unsquashed,
   exactly as drawn, which is what keeps the labels upright and readable. What
   does not cancel is the translate in the middle — it is carried round by the
   rotation and then scaled, turning a circle of radius rx into an ellipse of
   rx by k.rx. That is the orbit.

   THE RADII ARE THE LARGEST THAT KEEP EVERY PILLAR INSIDE THE SECTION
   A pillar is 28% of the section wide and about 16% tall, so its centre can
   travel at most 36% of the width across and 42% of the height down. The first
   of those is exactly where the two middle pillars already sit, so the path
   runs through the composition it replaces rather than beside it.

   rx is written as a share of the PILLAR, because a percentage inside
   translateX() is a share of the element — and the pillar is itself a fixed
   share of the section, so 36% of the section is 36/28 = 128.6% of a pillar and
   the orbit rescales with the box. Container units would have been the obvious
   alternative and cost more than they gave: `container-type: size` brings size
   containment with it, which took the pillars off their 28% width entirely.

   k is ry/rx as a plain number. The section holds a fixed aspect ratio, so it
   is one: .42H / .36W with H = W/1.5 comes to .778.

   They start clockwise from three o'clock, in the order the static design
   reads. They are spaced by starting each one further through the same loop
   with a negative delay: one animation, --lo-n phases, nothing to keep in step
   and so nothing to drift, snap or flicker. Adding a pillar is therefore a
   change to that one number, not to the path.

   Desktop only. Below 1201px the section drops the orbit for a stacked list and
   there is no path to travel. That floor is measured, not chosen: see the note
   on the stacked layout for the clearances it comes from. Reduced motion is honoured by the rule at the end
   of this file, which stops every animation inside .sud-loc.
   -------------------------------------------------------------------------- */

@media (min-width: 1201px) {
	.sud-loc {
		--lo-spin: 72s;            /* one unhurried circuit */
		--lo-rx: 128.6%;           /* 36% of the section, as a share of a pillar */
		--lo-k: .778;              /* ry/rx: .42H / .36W at the 15/10 box */
		--lo-n: 7;                 /* phases on the loop: one per pillar */
	}

	/*
	 * At (0,3,0) to match — and follow — the seven placement rules above, which are
	 * that specific. A plain `.sud-loc__pillar` rule is (0,1,0) and would lose to
	 * them, leaving the corner insets and the middle pillars' translateY(-50%)
	 * fighting the orbit.
	 *
	 * Physical `left`/`top`, not the logical pair: the anchor is the centre of
	 * the box either way, and inset-inline-start flips to `right` in Arabic,
	 * which would put the pillar half its own width off centre.
	 */
	.sud-loc__col--left .sud-loc__pillar:nth-child(n),
	.sud-loc__col--right .sud-loc__pillar:nth-child(n) {
		inset: 50% auto auto 50%;

		/*
		 * In front of the ring. The path is the widest ellipse the section can
		 * hold — 36% by 42%, any larger and a pillar leaves the box — and at the
		 * diagonals that line passes a few pixels inside the ring, which a
		 * two-column layout never had to deal with. Painted underneath, the ring
		 * would draw a stroke across a white disc; painted over it, the pillar
		 * simply passes in front, which is what going round a circle looks like.
		 * The map itself is never reached: it is 47px of radius and the nearest
		 * pillar stays 82px clear.
		 */
		z-index: 1;

		animation: sud-loc-orbit var(--lo-spin) linear infinite;
		animation-delay: calc(var(--lo-i) * var(--lo-spin) / var(--lo-n) * -1);
	}

	/*
	 * Clockwise from three o'clock, in the order the static design reads.
	 *
	 * The phases are 360/--lo-n apart, so adding the seventh re-spaced the
	 * existing six rather than squeezing a gap: 51.429 degrees now, 10.286s of
	 * delay between neighbours instead of 12. Their ORDER round the loop is
	 * unchanged, which is why the composition still reads the same way.
	 *
	 * The seventh takes the last phase, 308.6 degrees, between the shield at the
	 * top and the factory at three o'clock.
	 */
	.sud-loc__col--right .sud-loc__pillar:nth-child(2) { --lo-i: 0; }
	.sud-loc__col--right .sud-loc__pillar:nth-child(3) { --lo-i: 1; }
	.sud-loc__col--left  .sud-loc__pillar:nth-child(3) { --lo-i: 2; }
	.sud-loc__col--left  .sud-loc__pillar:nth-child(2) { --lo-i: 3; }
	.sud-loc__col--left  .sud-loc__pillar:nth-child(1) { --lo-i: 4; }
	.sud-loc__col--right .sud-loc__pillar:nth-child(1) { --lo-i: 5; }
	.sud-loc__col--right .sud-loc__pillar:nth-child(4) { --lo-i: 6; }
}

/*
 * The 1025-1100 band used to run the arc on a tightened path (--lo-rx: 120.7%,
 * --lo-k: .857, for 29% pillars). It has been dropped along with the arc in that
 * band; see the note on the stacked layout below for why.
 */

@keyframes sud-loc-orbit {
	from {
		transform:
			translate(-50%, -50%)
			scaleY(var(--lo-k)) rotate(0deg)
			translateX(var(--lo-rx))
			rotate(0deg) scaleY(calc(1 / var(--lo-k)));
	}
	to {
		transform:
			translate(-50%, -50%)
			scaleY(var(--lo-k)) rotate(360deg)
			translateX(var(--lo-rx))
			rotate(-360deg) scaleY(calc(1 / var(--lo-k)));
	}
}


/* --------------------------------------------------------------------------
   RESPONSIVE

   Desktop is the priority composition. Below it the arrangement changes shape
   rather than shrinking — the orbit needs width, and at phone size it would put
   four-word labels in a 90px column.
   -------------------------------------------------------------------------- */

/*
 * Below the arc's floor since that moved to 1201, so every value here is now
 * superseded by the stacked block that follows. Kept as the record of how the
 * arc was tuned for narrow widths, should it ever return to them.
 */
@media (max-width: 1100px) {
	/*
	 * core + 2 x pillar must stay under 100, or the two middle pillars run into
	 * the ring. 31% here against a 42% core came to 104 and did exactly that.
	 * 40 + 2 x 29 = 98 keeps the same 2% clearance as the desktop rule while
	 * giving the labels slightly more width than desktop, which is what this
	 * breakpoint is for.
	 */
	.sud-loc {
		--lo-disc: clamp(44px, 5vw, 56px);
		--lo-core: 40%;
		--lo-pillar: 29%;
		aspect-ratio: 14 / 10;
	}

	.sud-loc .sud-loc__label { font-size: clamp(.75rem, 1.25vw, .875rem); }
}

@media (max-width: 1200px) {
	/*
	 * Raised from 860 to 1024, and now from 1024 to 1200 — the same judgement
	 * made twice, and the second time forced by the seventh pillar.
	 *
	 * Seven boxes do not fit this path at every width six did. Measured as the
	 * smallest gap between any two pillars' INK — disc circle and text line
	 * boxes, not the 28% layout box — over 144 phases of the full circuit:
	 *
	 *     viewport   six      seven
	 *     1040      0.4px    -17.2px   (123 of 144 phases overlapping)
	 *     1150     15.3px     -2.4px
	 *     1180                 0.5px
	 *     1200     21.1px      3.9px
	 *     1280     30.4px      7.9px
	 *     1440     34.4px     11.4px
	 *     1920     48.3px     21.6px
	 *
	 * Seven first clears at about 1180, so the floor is 1201 with a little room
	 * to spare. Note the six were ALREADY down to 0.4px at 1040: that band was
	 * on the edge before anything was added, and raising the floor retires the
	 * near-touch along with the overlap.
	 *
	 * Narrowing the pillars does not buy this back — swept from 22% to 28% at
	 * 1280 the gap stays at 10.2px either way, because what binds is vertical,
	 * and the orbit's vertical radius is already the largest the box can hold.
	 * The levers that would work all break the approved design: a taller visual
	 * box, smaller labels, or smaller discs.
	 *
	 * This query is deliberately a second `max-width` block, after the one that
	 * tightens the arc's own variables: where the two overlap, this one is later
	 * and wins, exactly as it did at 1024.
	 *
	 * Everything returns to normal flow: the map goes on top at a size that keeps
	 * it recognisable, the pillars become a list beneath it. The absolute
	 * placement above is switched off wholesale rather than adjusted.
	 */
	.sud-loc {
		--lo-disc: 50px;
		position: static;
		aspect-ratio: auto;
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: clamp(1.5rem, 4vw, 2.25rem);
	}

	.sud-loc__core {
		position: relative;
		inset: auto;
		transform: none;
		inline-size: min(74%, 330px);
		margin-inline: auto;
	}

	.sud-loc__col {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: clamp(1rem, 3vw, 1.5rem);
	}

	/*
	 * Written at (0,3,0) to match the desktop placement rules above.
	 *
	 * A plain `.sud-loc__pillar` reset is (0,1,0) and loses to
	 * `.sud-loc__col--left .sud-loc__pillar:nth-child(2)`, which is (0,3,0).
	 * `position` and `inset` stopped mattering once the pillar went static, but
	 * `transform: translateY(-50%)` kept applying — so the second pillar of each
	 * column was dragged 25px up into its neighbour. The six items measured
	 * -9, 41, 273, -9, 41 apart instead of an even 16.
	 *
	 * :nth-child(n) matches every item and costs the same specificity as the
	 * rule it has to beat.
	 */
	.sud-loc__col--left .sud-loc__pillar:nth-child(n),
	.sud-loc__col--right .sud-loc__pillar:nth-child(n) {
		position: static;
		inline-size: auto;
		inset: auto;
		transform: none;
	}

	.sud-loc .sud-loc__label { font-size: .8125rem; }
}

@media (max-width: 560px) {
	.sud-loc__core { inline-size: min(88%, 300px); }
	.sud-loc__col { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
	.sud-loc .sud-loc__label { font-size: .875rem; }
}

@media (prefers-reduced-motion: reduce) {
	.sud-loc * { transition: none !important; animation: none !important; }

	/*
	 * ...which on its own left every pillar in a heap.
	 *
	 * The orbit rule moves each pillar's anchor to the centre of the box and
	 * relies on the keyframes for the rest: the translate that carries it out to
	 * the path lives in `from`/`to`, not in the rule. Cancel the animation and
	 * nothing is left to place them, so all of them render on the centre point —
	 * measured at 1440: one position for seven pillars, 21 of 21 pairs
	 * overlapping. It did the same with six; the seventh only makes the heap
	 * taller.
	 *
	 * So hold each pillar at its OWN phase instead: the keyframes' `from`
	 * transform with the rotation it would have had after a negative delay of
	 * --lo-i steps. That is the composition exactly as drawn, standing still,
	 * which is what reduced motion should give.
	 *
	 * Same (0,3,0) as the rule it has to beat, and later in the file, so it wins
	 * on order. Nested inside the orbit's own width so it never reaches the
	 * stacked layout, where the pillars are static and need no transform.
	 */
	@media (min-width: 1201px) {
		.sud-loc__col--left .sud-loc__pillar:nth-child(n),
		.sud-loc__col--right .sud-loc__pillar:nth-child(n) {
			transform:
				translate(-50%, -50%)
				scaleY(var(--lo-k)) rotate(calc(var(--lo-i) * 360deg / var(--lo-n)))
				translateX(var(--lo-rx))
				rotate(calc(var(--lo-i) * -360deg / var(--lo-n))) scaleY(calc(1 / var(--lo-k)));
		}
	}
}
