/* ============================================================
   TK Expertise Accordion — Plugin CSS
   Horizontal image accordion with a stable height and smooth
   cross-fade between the closed (rotated title) and open
   (media + copy) states. Themed per instance via CSS custom
   properties. Stacks vertically on small screens.
   ============================================================ */

.tk-accordion {
	position: relative;
	display: flex;
	flex-direction: row;
	align-items: stretch;
	width: 100%;
	gap: 0;
	padding-top: var(--tk-acc-pad-top, 0);
	padding-bottom: var(--tk-acc-pad-bottom, 0);
	padding-left: var(--tk-acc-pad-x, 0);
	padding-right: var(--tk-acc-pad-x, 0);
	box-sizing: border-box;
	/* Outer outline + rounded corners on the container so they stay
	   continuous; panels draw only inner dividers. */
	border: 1px solid var(--tk-acc-border-color, #000000);
	border-radius: var(--tk-acc-panel-radius, 15px);
	overflow: hidden;
	/* Query container so headline size can scale with the accordion's own width
	   (via cqw) rather than the viewport — this keeps the headline's proportion
	   to the column constant at every width, matching Figma's wrapping. */
	container-type: inline-size;
	font-family: var(--tk-acc-body-font, 'Montserrat', sans-serif);

	/* Fluid type scale. Heading scales to the accordion width: Figma is a 60px
	   headline in a 1653px-wide accordion (= 3.63% of the width), so at any width
	   the headline holds the same proportion and wraps the same (e.g. "Influencer
	   Relations & Social" stays two lines). We use cqw (physical container width),
	   not cqi: the rotated closed titles use a vertical writing-mode where cqi
	   resolves to the container's block axis instead of its width, which shrank
	   them. cqw is width-based regardless of writing-mode, so open headings and
	   closed rotated titles compute to the same size. */
	--tk-acc-fs-heading: clamp(1.75rem, 3.63cqw, 3.75rem);           /* ~28 -> 60px */
	--tk-acc-fs-body:    clamp(0.95rem, 0.9rem + 0.25vw, 1.125rem);   /* ~15 -> 18px */
	--tk-acc-fs-eyebrow: clamp(0.9rem, 0.86rem + 0.18vw, 1.05rem);    /* ~14 -> 17px */
}

/* ---- Panel base ------------------------------------------------ */
.tk-accordion-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	/* Width distributed by flex-grow ratio (basis 0) so panels always
	   sum to 100% of the container — the open panel is never clipped. */
	flex: var(--tk-acc-collapsed-ratio, 1) 1 0;
	min-width: 0;
	overflow: hidden;
	cursor: pointer;
	border: 0;
	border-left: 1px solid var(--tk-acc-border-color, #000000); /* inner divider */
	background-color: var(--tk-acc-panel-bg, #FFFFFF);
	transition: flex-grow var(--tk-acc-anim, 620ms) cubic-bezier(0.33, 0, 0.2, 1);
}

.tk-accordion-panel--first { border-left: 0; }

/* Closed-state gradient sits on an overlay so it can fade smoothly to the
   open (white) state instead of snapping. */
.tk-accordion-panel::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background-image: linear-gradient(
		var(--tk-acc-closed-angle, 180deg),
		var(--tk-acc-closed-start, #9BB7E9) 0%,
		var(--tk-acc-closed-end, rgba(205, 219, 244, 0)) 55%
	);
	opacity: 1;
	transition: opacity var(--tk-acc-anim, 620ms) cubic-bezier(0.33, 0, 0.2, 1);
}
.tk-accordion-panel.is-active::before { opacity: 0; }

.tk-accordion-panel:focus-visible {
	outline: 2px solid var(--tk-acc-arrow-color, #5887DA);
	outline-offset: -3px;
	z-index: 5;
}

.tk-accordion-panel.is-active {
	flex: var(--tk-acc-active-ratio, 2) 1 0;
	cursor: default;
	z-index: 2;
}

/* ---- Eyebrow: "Service ———— 01" across the TOP ---------------- */
.tk-accordion-eyebrow {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	font-family: var(--tk-acc-body-font, 'Montserrat', sans-serif);
	font-weight: 400;
	font-size: var(--tk-acc-fs-eyebrow);
	line-height: 1.3;
	color: var(--tk-acc-text-color, #000000);
	white-space: nowrap;
}

.tk-accordion-eyebrow .tk-accordion-rule {
	flex: 1 1 auto;
	height: 0;
	border-top: 1px solid var(--tk-acc-text-color, #000000); /* continuous line */
	opacity: 0.55;
	min-width: 16px;
}

.tk-accordion-eyebrow-num { font-variant-numeric: tabular-nums; }

/* ---- Closed layer: in-flow (reserves height so the accordion height
       is stable), eyebrow on top, big title rising from bottom-left --- */
.tk-accordion-collapsed {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
	padding: 22px 22px 26px;
	opacity: 1;
	transition: opacity calc(var(--tk-acc-anim, 620ms) * 0.55) ease;
}
.tk-accordion-panel.is-active .tk-accordion-collapsed {
	opacity: 0;
	pointer-events: none;
}

.tk-accordion-collapsed .tk-accordion-eyebrow { flex: 0 0 auto; }

.tk-accordion-rotate-wrap {
	flex: 1 1 auto;
	display: flex;
	align-items: flex-end;       /* anchor title to the BOTTOM */
	justify-content: flex-start; /* flush LEFT */
	min-height: 0;
	margin-top: 18px;
}

.tk-accordion-rotate {
	/* vertical-rl reserves real vertical space (panel grows to fit the
	   longest title); rotate(180deg) makes it read bottom-to-top. */
	writing-mode: vertical-rl;
	transform: rotate(180deg);
	white-space: normal;
	/* Cap the run length so long titles wrap to two lines and the accordion
	   stays a manageable height, while short titles ("Video & Podcast") stay on
	   one line. 9.5em is tuned so an 18-ish-character line like "Relations &
	   Social" fits on one line (keeping "Influencer Relations & Social" to two
	   lines) while longer titles like "Business Communications" still wrap. */
	max-height: 9.5em;
	font-family: var(--tk-acc-heading-font, 'Montserrat', sans-serif);
	font-weight: 600;
	font-size: var(--tk-acc-fs-heading); /* SAME size as the open heading */
	line-height: 1.15;
	color: var(--tk-acc-text-color, #000000);
	letter-spacing: -0.01em;
	margin: 0;
}

/* ---- Open layer: overlays the panel, cross-fades in ------------ */
.tk-accordion-open {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: auto;
	/* Laid out at the final expanded width (set by JS) so the copy does not
	   re-wrap while the panel animates — it simply fades into place. */
	width: var(--tk-acc-active-w, 100%);
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	text-align: left;
	gap: 14px;
	padding: 22px 34px 40px;
	box-sizing: border-box;
	opacity: 0;
	pointer-events: none;
	transition: opacity calc(var(--tk-acc-anim, 620ms) * 0.55) ease;
}
.tk-accordion-panel.is-active .tk-accordion-open {
	opacity: 1;
	pointer-events: auto;
	/* Fade in once the panel is most of the way open. */
	transition-delay: calc(var(--tk-acc-anim, 620ms) * 0.4);
}

.tk-accordion-media {
	position: relative;
	width: 100%;
	aspect-ratio: 571 / 301;
	border-radius: var(--tk-acc-media-radius, 15px);
	overflow: hidden;
	background-color: #eef1f6;
	flex: 0 0 auto;
}

.tk-accordion-media img,
.tk-accordion-media dotlottie-player,
.tk-accordion-media .tk-accordion-lottie {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.tk-accordion-heading {
	width: 100%;
	font-family: var(--tk-acc-heading-font, 'Montserrat', sans-serif);
	font-weight: 600;
	font-size: var(--tk-acc-fs-heading);
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: var(--tk-acc-text-color, #000000);
	margin: 0;
	text-align: left;
}

.tk-accordion-body {
	width: 100%;
	font-family: var(--tk-acc-body-font, 'Montserrat', sans-serif);
	font-weight: 400;
	font-size: var(--tk-acc-fs-body);
	line-height: 1.5;
	color: var(--tk-acc-text-color, #000000);
	margin: 0;
	text-align: left;
}

.tk-accordion-body p { margin: 0 0 0.6em; }
.tk-accordion-body p:last-child { margin-bottom: 0; }

.tk-accordion-cta {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	align-self: flex-start;
	/* 20px below the body copy: the flex gap (14px) + 6px. Not bottom-anchored,
	   so shorter panels keep the CTA next to the copy instead of dropping it to
	   the frame bottom. */
	margin-top: 6px;
	font-family: var(--tk-acc-body-font, 'Montserrat', sans-serif);
	font-weight: 600;
	font-size: 1rem;
	text-transform: capitalize;
	color: var(--tk-acc-text-color, #000000);
	text-decoration: none;
}

.tk-accordion-cta-arrow {
	display: inline-flex;
	align-items: center;
	color: var(--tk-acc-arrow-color, #5887DA);
	transition: transform 0.25s ease;
}
.tk-accordion-cta-arrow svg { display: block; width: 22px; height: auto; }
.tk-accordion-cta:hover .tk-accordion-cta-arrow { transform: translateX(5px); }

/* ---- Responsive: stack vertically on tablet + mobile ---------- */
@media (max-width: 1024px) {
	.tk-accordion { flex-direction: column; }

	.tk-accordion-panel {
		flex: 0 0 auto !important;
		width: 100%;
		border-left: 0;
		border-top: 1px solid var(--tk-acc-border-color, #000000);
		transition: none;
	}
	.tk-accordion-panel--first { border-top: 0; }

	/* Stacked panels are wide and short, so the gradient reads better running
	   left-to-right: saturated on the left, fading to transparent on the right. */
	.tk-accordion-panel::before {
		background-image: linear-gradient(
			90deg,
			var(--tk-acc-closed-start, #9BB7E9) 0%,
			var(--tk-acc-closed-end, rgba(205, 219, 244, 0)) 90%
		);
	}

	/* Revert to in-flow show/hide so panels expand downward. More padding on
	   the closed toggles so they have room to breathe. */
	.tk-accordion-collapsed { position: static; opacity: 1 !important; padding: 34px 30px; }
	.tk-accordion-panel.is-active .tk-accordion-collapsed { display: none; }
	.tk-accordion-open {
		position: static;
		width: auto;
		opacity: 1 !important;
		pointer-events: auto;
		padding: 32px 30px 36px;
		transition-delay: 0ms;
	}
	.tk-accordion-panel:not(.is-active) .tk-accordion-open { display: none; }

	.tk-accordion-rotate-wrap { align-items: flex-start; margin-top: 12px; }
	.tk-accordion-rotate {
		writing-mode: horizontal-tb;
		transform: none;
		max-height: none;
		font-size: clamp(1.5rem, 5vw, 2.25rem);
		text-align: left;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tk-accordion-panel,
	.tk-accordion-panel::before,
	.tk-accordion-collapsed,
	.tk-accordion-open,
	.tk-accordion-cta-arrow {
		transition: none !important;
	}
}
