/* ==========================================================================
   SUDAIR PHARMA — OUR MANUFACTURING SITES

   Three site cards between the manufacturing video and Manufacturing
   Expansion on the Manufacture page.

   Scoped under .sud-ms, a class that exists in one HTML widget on one section
   of one page, so this is safe to load site wide alongside the other
   component stylesheets.

   WHAT IT DOES NOT OWN
   Type size and weight come from heading-typography.css — the h2 here is the
   site's h2 (25/400) and the card titles are the site's h3 (20/400), the same
   values the Manufacturing Technologies cards on this page already render at.
   Nothing in this file sets a heading font-size, so the scale stays in one
   place. Colour, spacing and layout are this file's business; the scale is
   not.

   MOTION
   Entirely borrowed. The heading carries data-sud-reveal and the grid carries
   .sud-stagger, both of which motion.js observes and motion.css animates, so
   the reveal, the 70ms stagger, the easing curve and the whole reduced-motion
   fallback are the site's existing ones rather than a second system. This file
   adds only the hover behaviour, which has no JavaScript at all. The finished
   state is the default everywhere: motion.css hides nothing unless the script
   has added .sud-motion.
   ========================================================================== */

.sud-ms {
	--ms-green:  var(--sud-green-700, #006344);
	--ms-accent: var(--sud-green-500, #43B649);
	--ms-ink:    var(--sud-ink, #0B1F17);
	--ms-body:   var(--sud-body, #46574F);
	--ms-line:   #DCE9E2;
	--ms-tint:   #F2F8F4;
	--ms-ease:   var(--sud-ease-soft, cubic-bezier(.22, 1, .36, 1));

	max-inline-size: var(--sud-maxw, 1240px);
	margin-inline: auto;
	box-sizing: border-box;
}

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

/* --------------------------------------------------------------------------
   HEADING
   The decorative rules fade at BOTH ends rather than running from one side.
   A one-directional gradient would have to be mirrored for Arabic; a symmetric
   one is correct in either direction with no RTL rule at all.
   -------------------------------------------------------------------------- */

.sud-ms__head {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(14px, 2.6vw, 38px);
	margin-block-end: clamp(28px, 3.4vw, 46px);
}

.sud-ms__rule {
	flex: 1 1 0;
	min-inline-size: 0;
	max-inline-size: 260px;
	block-size: 1px;
	background: linear-gradient(90deg, rgba(0, 99, 68, 0), rgba(0, 99, 68, .42) 50%, rgba(0, 99, 68, 0));
}

.sud-ms__title {
	margin: 0;
	color: var(--ms-green);
	font-family: var(--sud-font-display);
	line-height: 1.2;
	text-align: center;
	text-wrap: balance;
}

/* The rules are decoration, not structure: below the card breakpoint they
   would be two 14px stubs either side of a wrapped heading, so they go. */
@media (max-width: 560px) {
	.sud-ms__rule { display: none; }
}

/* --------------------------------------------------------------------------
   GRID
   Three up, then two, then one. The third card of a two-column row spans the
   full width and is capped so it reads as a centred card rather than a wide
   one.
   -------------------------------------------------------------------------- */

.sud-ms__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(16px, 2.1vw, 30px);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (max-width: 1024px) {
	.sud-ms__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

	/*
	 * inline-size, NOT max-inline-size. The card is a size-containment
	 * container (see DATE BAR), so its contents contribute nothing to its
	 * intrinsic width; a max-width plus auto margins makes the item
	 * shrink-to-fit, and shrink-to-fit of a contained box is zero — measured,
	 * the card collapsed to 49px. A definite width resolves against the grid
	 * area instead of the contents, which containment cannot interfere with.
	 */
	.sud-ms__grid > :last-child:nth-child(odd) {
		grid-column: 1 / -1;
		inline-size: min(100%, 520px);
		margin-inline: auto;
	}
}

@media (max-width: 640px) {
	.sud-ms__grid { grid-template-columns: minmax(0, 1fr); }
	/*
	 * 100%, not auto. `margin-inline: auto` above still applies here, and auto
	 * margins plus an auto width make a grid item shrink-to-fit rather than
	 * stretch — which, for a size-containment container, is again zero: the
	 * card measured 42px at 375. A definite 100% of the grid area sidesteps
	 * the auto margins entirely.
	 */
	.sud-ms__grid > :last-child:nth-child(odd) { inline-size: 100%; }
}

/* --------------------------------------------------------------------------
   CARD

   The cell is the grid item and the reveal target; the card is the surface.
   They are separate because .sud-stagger (motion.css) writes transform and a
   transition onto every direct child of the grid at (0,3,0) — with the card as
   that child, the hover lift was cancelled outright and the shadow snapped.
   One transform each, no specificity contest, no !important.
   -------------------------------------------------------------------------- */

.sud-ms__cell { display: flex; }

.sud-ms__card {
	flex: 1 1 auto;
	min-inline-size: 0;
	/* Named, so the date bar can ask this card's width — see DATE BAR below. */
	container-type: inline-size;
	container-name: sud-ms-card;

	position: relative;
	display: flex;
	flex-direction: column;
	gap: clamp(14px, 1.6vw, 20px);
	padding: clamp(20px, 2.3vw, 30px);
	background: #fff;
	border: 1px solid var(--ms-line);
	border-radius: var(--sud-radius-lg, 24px);
	box-shadow: 0 1px 2px rgba(11, 31, 23, .03), 0 10px 28px rgba(11, 31, 23, .05);
	overflow: hidden;
	transition:
		transform .42s var(--ms-ease),
		box-shadow .42s var(--ms-ease),
		border-color .42s var(--ms-ease);
}

/*
 * The corner wash, in the secondary green. Present at rest and brought up on
 * hover — the reference's diagonal sliver, kept to a tint so it never competes
 * with the copy. 225deg points into the card from the top-INLINE-end corner,
 * so Arabic needs the mirrored angle.
 */
.sud-ms__card::after {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline-end: 0;
	inline-size: 104px;
	block-size: 104px;
	pointer-events: none;
	background: linear-gradient(225deg, rgba(67, 182, 73, .16), rgba(67, 182, 73, 0) 64%);
	opacity: .8;
	transition: opacity .42s var(--ms-ease);
}

[dir="rtl"] .sud-ms__card::after {
	background: linear-gradient(135deg, rgba(67, 182, 73, .16), rgba(67, 182, 73, 0) 64%);
}

/*
 * The thin accent along the top edge. Scaled from zero on hover, which is a
 * transform on a 2px strip — no layout, no repaint of the card.
 */
.sud-ms__card::before {
	content: "";
	position: absolute;
	inset-block-start: 0;
	inset-inline: 0;
	block-size: 2px;
	background: linear-gradient(90deg, var(--ms-green), var(--ms-accent));
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform .5s var(--ms-ease);
	z-index: 1;
}

[dir="rtl"] .sud-ms__card::before { transform-origin: right center; }

@media (hover: hover) {
	.sud-ms__card:hover {
		transform: translate3d(0, -6px, 0);
		border-color: rgba(0, 99, 68, .34);
		box-shadow: 0 4px 10px rgba(11, 31, 23, .05), 0 22px 48px rgba(0, 99, 68, .12);
	}

	.sud-ms__card:hover::before { transform: scaleX(1); }
	.sud-ms__card:hover::after  { opacity: 1; }

	.sud-ms__card:hover .sud-ms__icon {
		transform: scale(1.06);
		background: var(--ms-green);
		border-color: transparent;
		color: #fff;
	}
}

/* --------------------------------------------------------------------------
   TITLE ROW
   -------------------------------------------------------------------------- */

.sud-ms__top {
	display: flex;
	align-items: center;
	gap: clamp(12px, 1.4vw, 18px);
}

.sud-ms__icon {
	flex: none;
	inline-size: 56px;
	block-size: 56px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--sud-surface-3, #EAF2ED);
	border: 1px solid rgba(0, 99, 68, .10);
	color: var(--ms-green);
	transition:
		transform .42s var(--ms-ease),
		background .42s var(--ms-ease),
		border-color .42s var(--ms-ease),
		color .42s var(--ms-ease);
}

.sud-ms__icon svg {
	inline-size: 26px;
	block-size: 26px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.sud-ms__name {
	margin: 0;
	color: var(--ms-green);
	font-family: var(--sud-font-display);
	line-height: 1.25;
	text-wrap: balance;
}

/* --------------------------------------------------------------------------
   DATE BAR

   Stacked by default; one row only where the two lines measurably fit.

   MEASURED, NOT GUESSED. The widest pair — "Constructed 2022" and
   "Manufacturing since 2023" — needs 332px of text and icons, plus an 18px
   column gap and an 18px divider inset: 368px inside the bar. Three cards on
   the site's 1240px grid leave the bar 281px, so a single row is not possible
   at desktop width however the padding is tuned, and the brief's own
   instruction applies: let it wrap cleanly rather than force it.

   The threshold therefore belongs to the CARD, not the viewport — the same
   card is 317px wide at three-up and 423px at two-up. A container query asks
   the real question (is there room in THIS card?) instead of approximating it
   with a breakpoint that would be wrong the moment the grid changes. The
   stacked form above is the default, so a browser without container queries
   gets the correct layout rather than a broken one.
   -------------------------------------------------------------------------- */

.sud-ms__dates {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
	margin: 0;
	padding: clamp(11px, 1.2vw, 14px) clamp(13px, 1.5vw, 18px);
	background: var(--ms-tint);
	border-radius: 14px;
	list-style: none;
}

.sud-ms__date {
	display: flex;
	align-items: center;
	gap: 9px;
	min-inline-size: 0;
	font-size: .8125rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--ms-ink);
}

.sud-ms__date svg {
	flex: none;
	inline-size: 18px;
	block-size: 18px;
	fill: none;
	stroke: var(--ms-green);
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* 420px of card content leaves the bar 389px against the 368px it needs. */
@container sud-ms-card (min-width: 420px) {
	.sud-ms__dates {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		column-gap: 18px;
		row-gap: 10px;
	}

	.sud-ms__date + .sud-ms__date {
		border-inline-start: 1px solid rgba(0, 99, 68, .18);
		padding-inline-start: 18px;
	}
}

/* --------------------------------------------------------------------------
   DESCRIPTION
   -------------------------------------------------------------------------- */

.sud-ms__desc {
	margin: 0;
	color: var(--ms-body);
	font-size: var(--sud-text-base, 1rem);
	line-height: 1.7;
}

/* --------------------------------------------------------------------------
   REDUCED MOTION
   motion.css already neutralises the shared reveal and stagger. These are the
   two behaviours this file adds on its own, so they are switched off here.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.sud-ms__card,
	.sud-ms__card:hover,
	.sud-ms__icon,
	.sud-ms__card:hover .sud-ms__icon {
		transform: none !important;
		transition: none !important;
	}

	.sud-ms__card::before,
	.sud-ms__card:hover::before {
		transform: scaleX(1);
		transition: none !important;
	}

	.sud-ms__card::after,
	.sud-ms__card:hover::after { transition: none !important; }
}
