/**
 * Case Results -- the table ([case_results_table]) and the optional .cw-crs section wrapper.
 *
 * Master copy from the clixsy-case-results-table skill. The layout (one semantic table,
 * sticky header, proxy scrollbars, phone transposition) is shared by every site; the look
 * is per site. Restyle a site through the custom properties below, overridden in the
 * theme's own stylesheet, rather than by editing this file -- the module stays identical
 * everywhere, so the next fix can be copied in without a merge.
 *
 * Defaults are the Edward A Smith (J302) design, the first fully measured one.
 *
 * Every rule is scoped two classes deep (.cw-cr .cw-cr__x) so the component beats the
 * theme's global table, link and heading selectors.
 */

.cw-cr,
.cw-crs {
	--cw-cr-font-main: "Roboto", system-ui, sans-serif;
	--cw-cr-font-serif: "DM Serif Display", Georgia, serif;
	--cw-cr-ink: #1f1e1e;
	--cw-cr-muted: #8a8f9c;
	--cw-cr-navy: #2b3f6a;
	--cw-cr-red: #dc0043;
	--cw-cr-line: #e5e6ea;
	--cw-cr-smoky: #f6f6f6;
}

.cw-cr {
	/*
	 * Set per instance by the shortcode's styling attributes, which write them inline on
	 * this wrapper. Declared here so the table has sane defaults when nothing is passed,
	 * and so there is one place to look for what is configurable.
	 *
	 * An inline value beats everything below, including the responsive overrides -- a
	 * padding chosen on the page applies at every screen size, by design.
	 */
	--cw-cr-cell-pad: 14px 10px;
	--cw-cr-margin: 0;
	--cw-cr-max-width: none;
	--cw-cr-min-width: 1600px;

	box-sizing: border-box;

	margin: var( --cw-cr-margin, 0 );
	max-width: var( --cw-cr-max-width, none );
}

.cw-cr *,
.cw-cr *::before,
.cw-cr *::after {
	box-sizing: inherit;
}

/* ---------------------------------------------------------------- heading */

.cw-cr .cw-cr__intro {
	max-width: 900px;
	margin: 0 auto 56px;
	text-align: center;
}

.cw-cr .cw-cr__title {
	margin: 0;
	font-family: var(--cw-cr-font-serif);
	font-size: 44px;
	line-height: 1.2;
	font-weight: 400;
	color: var(--cw-cr-navy);
	text-wrap: pretty;
}

/* --------------------------------------- count, filter chips, arrows (opt-in) */

.cw-cr .cw-cr__count {
	margin: 0 0 20px;
	font-family: var(--cw-cr-font-main);
	font-size: 14px;
	font-weight: 700;
	color: var(--cw-cr-navy);
}

.cw-cr .cw-cr__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 14px 24px;
	margin: 0 0 16px;
}

.cw-cr .cw-cr__toolbar:not(:has(> :not([hidden]))) {
	display: none;
}

.cw-cr .cw-cr__chips,
.cw-cr .cw-cr__arrows {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.cw-cr .cw-cr__arrows {
	gap: 8px;
	margin-left: auto;
}

.cw-cr .cw-cr__chips[hidden],
.cw-cr .cw-cr__arrows[hidden],
.cw-cr .cw-cr__cols-note[hidden],
.cw-cr .cw-cr__tr[hidden] {
	display: none !important;
}

.cw-cr .cw-cr__chip {
	min-height: 44px;
	margin: 0;
	padding: 0 18px;
	border: 2px solid var(--cw-cr-chip-border, var(--cw-cr-line));
	border-radius: 9999px;
	background: #fff;
	color: var(--cw-cr-navy);
	font-family: var(--cw-cr-font-main);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.cw-cr .cw-cr__chip:hover {
	border-color: var(--cw-cr-navy);
}

.cw-cr .cw-cr__chip[aria-pressed="true"] {
	border-color: var(--cw-cr-navy);
	background: var(--cw-cr-navy);
	color: #fff;
}

.cw-cr .cw-cr__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 2px solid var(--cw-cr-navy);
	border-radius: 50%;
	background: #fff;
	color: var(--cw-cr-navy);
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s, opacity 0.2s;
}

.cw-cr .cw-cr__arrow:hover:not(:disabled) {
	background: var(--cw-cr-navy);
	color: #fff;
}

.cw-cr .cw-cr__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.cw-cr .cw-cr__chip:focus-visible,
.cw-cr .cw-cr__arrow:focus-visible {
	outline: 3px solid var(--cw-cr-focus, #ffbf00);
	outline-offset: 2px;
}

.cw-cr .cw-cr__cols-note {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 14px 0 0;
	font-family: var(--cw-cr-font-main);
	font-size: 14px;
	color: #4b5563;
}

.cw-cr .cw-cr__cols-note svg {
	flex: none;
	color: var(--cw-cr-navy);
}

/* ------------------------------------------------------------ table frame */

.cw-cr .cw-cr__frame {
	position: relative;
	background: #fff;
	box-shadow: 0 4px 20px 5px rgba(0, 0, 0, 0.12);
}

/*
 * The table names itself with a real <caption>, which is what a parser reads as the
 * table's title. It is taken out of flow rather than given a 1px box: a *sized* caption
 * makes the fixed-layout algorithm discard the first row's column widths and every column
 * collapses to an equal share.
 */
.cw-cr .cw-cr__caption {
	position: absolute;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/*
 * position: relative is load-bearing. The caption above is absolutely positioned, and
 * without a positioned ancestor here it escapes this scroller's clipping and widens the
 * whole page -- on a phone that was 900px of sideways page scroll.
 */
.cw-cr .cw-cr__scroll {
	position: relative;
	overflow-x: auto;
	scrollbar-width: none;
}

.cw-cr .cw-cr__scroll::-webkit-scrollbar {
	display: none;
}

.cw-cr .cw-cr__table {
	width: 100%;
	min-width: var( --cw-cr-min-width, 1600px );
	table-layout: fixed;
	border-collapse: collapse;
	text-align: left;
	margin: 0;
}

/*
 * Visible proxy scrollbars, as in the design: one directly under the header and one at
 * the bottom of the table (on phones, one above the grid). The table's real bar sits below
 * every row and is hidden anyway. Hidden until the script measures the table and finds it
 * actually overflows -- a bar that cannot be dragged is worse than no bar.
 */
.cw-cr .cw-cr__bar {
	display: none;
	overflow-x: auto;
	overflow-y: hidden;
	background: var(--cw-cr-smoky);
	border-bottom: 1px solid var(--cw-cr-line);
	scrollbar-width: thin;
	scrollbar-color: var(--cw-cr-navy) var(--cw-cr-line);
}

.cw-cr .cw-cr__bar::-webkit-scrollbar {
	height: 10px;
}

.cw-cr .cw-cr__bar::-webkit-scrollbar-track {
	background: var(--cw-cr-line);
}

.cw-cr .cw-cr__bar::-webkit-scrollbar-thumb {
	background: var(--cw-cr-navy);
	border-radius: 10px;
}

.cw-cr .cw-cr__bar-spacer {
	height: 1px;
}

.cw-cr .cw-cr__bar--bottom {
	border-bottom: 0;
	border-top: 1px solid var(--cw-cr-line);
}

/*
 * One table cannot hold a scrollbar between its header and its rows, so on wide screens
 * the top bar is laid over a gap opened at the top of tbody, exactly the bar's height.
 * The script publishes both measurements and adds .is-scrollable only while the table
 * overflows, so a table that fits has neither bar nor gap.
 */
@media (min-width: 768px) {

	.cw-cr .cw-cr__bar--top {
		position: absolute;
		top: var(--cw-cr-head-h, 0px);
		right: 0;
		left: 0;
		z-index: 3;
	}

	.cw-cr.is-scrollable .cw-cr__table tbody::before {
		content: "";
		display: block;
		height: var(--cw-cr-bar-h, 13px);
	}

}

/* ----------------------------------------------------------------- header */

/*
 * Fractional column widths leave sub-pixel seams between header cells that show as thin
 * white lines (the design file has them too). Row backgrounds are painted per cell, so
 * they do not reach the seams; a 1px shadow from each cell covers its right-hand edge.
 */
.cw-cr .cw-cr__table thead tr {
	background: var(--cw-cr-navy);
}

.cw-cr .cw-cr__th {
	box-shadow: 1px 0 0 0 var(--cw-cr-navy);
}

.cw-cr .cw-cr__th {
	padding: var( --cw-cr-cell-pad, 14px 10px );
	background: var(--cw-cr-navy);
	font-family: var(--cw-cr-font-main);
	font-size: 12px;
	font-weight: 700;
	line-height: 1.17; /* the design's "normal" for Roboto; the theme's own Roboto files run taller */
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #fff;
	text-align: left;
	vertical-align: bottom;
	border: 0;
}

/* ------------------------------------------------------------------ cells */

.cw-cr .cw-cr__td {
	padding: var( --cw-cr-cell-pad, 14px 10px );
	vertical-align: top;
	font-family: var(--cw-cr-font-main);
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--cw-cr-ink);
	background: #fff;
	border: 0;
	border-bottom: 1px solid var(--cw-cr-line);
}

/* Zebra rows, as designed. On phones the same rule shades alternate case columns. */
.cw-cr .cw-cr__tr--alt .cw-cr__td {
	background: var(--cw-cr-smoky);
}

.cw-cr .cw-cr__td--result {
	font-family: var(--cw-cr-font-serif);
	font-size: 20px;
	line-height: 1.3;
	color: var(--cw-cr-red);
	white-space: nowrap;
}

/* The uplift is a supporting figure, so it reads quieter than the result it derives from. */
.cw-cr .cw-cr__td--pct-increase {
	font-size: 16px;
	font-weight: 700;
	color: var(--cw-cr-navy);
	white-space: nowrap;
}

.cw-cr .cw-cr__dash {
	font-family: var(--cw-cr-font-main);
	font-size: 14px;
	font-weight: 400;
	color: var(--cw-cr-muted);
}


.cw-cr .cw-cr__link {
	color: var(--cw-cr-red);
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cw-cr .cw-cr__link:hover,
.cw-cr .cw-cr__link:focus {
	color: var(--cw-cr-navy);
}

/* ------------------------------------------------------- scroll affordance */

/*
 * Sticky against the page scroll, not the table's own scroller. Its natural position is
 * the bottom of the frame, pulled back up over the last rows, so while you read the middle
 * of a long table it rides along the bottom of the viewport and settles into place as the
 * end of the table arrives.
 */
.cw-cr .cw-cr__hint {
	position: sticky;
	bottom: 20px;
	z-index: 4;
	width: fit-content;
	margin: -64px 16px 16px auto;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 16px;
	border-radius: 999px;
	background: rgba(43, 63, 106, 0.94);
	color: #fff;
	font-family: var(--cw-cr-font-main);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1;
	white-space: nowrap;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
	pointer-events: none;
	opacity: 1;
	transition: opacity 320ms ease;
}

.cw-cr .cw-cr__hint[hidden] {
	display: none;
}

.cw-cr .cw-cr__hint.is-done {
	opacity: 0;
}

.cw-cr .cw-cr__hint-arrow {
	display: block;
	flex: none;
	color: var(--cw-cr-red);
}

@media (prefers-reduced-motion: no-preference) {

	.cw-cr .cw-cr__hint-arrow {
		animation: cw-cr-nudge 1.6s ease-in-out infinite;
	}

}

@keyframes cw-cr-nudge {

	0%,
	100% {
		transform: translateX(0);
	}

	50% {
		transform: translateX(5px);
	}

}

/* ------------------------------------------------------------------- note */

.cw-cr .cw-cr__note {
	max-width: 900px;
	margin: 56px auto 0;
	padding: 28px 36px;
	background: var(--cw-cr-smoky);
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.cw-cr .cw-cr__note-text {
	margin: 0;
	font-family: var(--cw-cr-font-serif);
	font-size: 22px;
	line-height: 1.5;
	color: var(--cw-cr-navy);
	text-wrap: pretty;
}

.cw-cr .cw-cr__note-extra {
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-family: var(--cw-cr-font-main);
	font-size: 15px;
	line-height: 1.7;
	color: var(--cw-cr-ink);
}

.cw-cr .cw-cr__note-extra p {
	margin: 0;
	text-wrap: pretty;
}

.cw-cr .cw-cr__note-extra a {
	color: var(--cw-cr-red);
	text-decoration: underline;
}

/* ------------------------------------------------- per-page modifiers */

/*
 * Density presets, for editors who want "tighter" without picking a number. An explicit
 * padding attribute writes the same property inline and therefore wins over these, which
 * is the precedence you would expect: the specific beats the preset.
 */
.cw-cr--compact {
	--cw-cr-cell-pad: 8px;
}

.cw-cr--roomy {
	--cw-cr-cell-pad: 18px;
}

.cw-cr--align-center {
	margin-left: auto;
	margin-right: auto;
}

.cw-cr--align-left {
	margin-left: 0;
	margin-right: auto;
}

/*
 * The first column is a <th scope="row">, so a screen reader can announce which case a
 * figure belongs to. Browsers centre and embolden th by default; it should read as a
 * slightly stronger cell, not as a heading in the middle of the table.
 */
.cw-cr .cw-cr__td--row {
	text-align: left;
	font-weight: 400;
}

/* ======================================================================
 * "Our Case Results" section: heading, intro and Key Takeaways above the
 * table (blocks/block-case-results-table).
 * ==================================================================== */

.cw-crs {
	padding: 90px 0 40px;
}

/* The design's section is 90% of the viewport wide, wider than the theme's container. */
.cw-crs > .container {
	width: 90%;
	max-width: none;
	padding-right: 0;
	padding-left: 0;
}

.cw-crs .cw-crs__head {
	max-width: 900px;
	margin: 0 auto 56px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
	text-align: center;
}

.cw-crs .cw-crs__title {
	margin: 0;
	font-family: var(--cw-cr-font-serif);
	font-size: 44px;
	line-height: 1.2;
	font-weight: 400;
	color: var(--cw-cr-navy);
	text-wrap: pretty;
}

.cw-crs .cw-crs__body {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 32px;
}

.cw-crs .cw-crs__intro {
	font-family: var(--cw-cr-font-main);
	font-size: 18px;
	line-height: 1.65;
	color: var(--cw-cr-ink);
	text-align: center;
}

.cw-crs .cw-crs__intro p {
	margin: 0;
	font-size: inherit;
	line-height: inherit;
	text-wrap: pretty;
}

.cw-crs .cw-crs__intro p + p {
	margin-top: 1em;
}

.cw-crs .cw-crs__takeaways {
	background: var(--cw-cr-smoky);
	padding: 28px 36px;
	display: flex;
	flex-direction: column;
	gap: 18px;
	text-align: left;
}

.cw-crs .cw-crs__takeaways-title {
	margin: 0;
	font-family: var(--cw-cr-font-serif);
	font-size: 26px;
	line-height: 1.2;
	font-weight: 400;
	color: var(--cw-cr-navy);
}

.cw-crs .cw-crs__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px 36px;
}

.cw-crs .cw-crs__item {
	margin: 0;
	padding: 0;
	display: flex;
	gap: 14px;
	align-items: flex-start;
	font-family: var(--cw-cr-font-main);
	font-size: 15px;
	line-height: 1.55;
	color: var(--cw-cr-ink);
}

.cw-crs .cw-crs__item::before {
	content: none;
}

.cw-crs .cw-crs__bullet {
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	margin-top: 8px;
	background: var(--cw-cr-red);
}

.cw-crs .cw-crs__label {
	color: var(--cw-cr-navy);
	font-weight: 700;
}

.cw-crs .cw-crs__disclaimer {
	max-width: 900px;
	margin: 28px auto 0;
	font-family: var(--cw-cr-font-main);
	font-size: 14px;
	line-height: 1.7;
	color: #535253;
	text-align: center;
	text-wrap: pretty;
}

/* ------------------------------------------------------------ breakpoints */

@media (max-width: 767px) {

	.cw-cr .cw-cr__title,
	.cw-crs .cw-crs__title {
		font-size: 30px;
	}

	.cw-cr .cw-cr__intro {
		margin-bottom: 32px;
	}

	.cw-cr .cw-cr__note {
		margin-top: 32px;
		padding: 24px;
	}

	.cw-cr .cw-cr__hint {
		bottom: 14px;
		margin: -56px 12px 12px auto;
		padding: 8px 14px;
		font-size: 12px;
	}

	.cw-crs {
		padding: 48px 0 24px;
	}

	.cw-crs .cw-crs__head {
		margin-bottom: 32px;
	}

	.cw-crs .cw-crs__intro {
		font-size: 16px;
	}

	.cw-crs .cw-crs__takeaways {
		padding: 24px 20px;
	}

	.cw-crs .cw-crs__list {
		grid-template-columns: minmax(0, 1fr);
	}

	/*
	 * Phones: the design turns the table on its side -- field labels down a sticky left
	 * column, one 200px column per case, scrolling sideways. Done in CSS alone, so the
	 * markup is still the one table desktop uses: the table becomes a grid, rows and row
	 * groups dissolve (display: contents), and the cells flow column by column into
	 * --cw-cr-cols grid rows. Each grid row is one field, so its height is shared by every
	 * case and the labels line up. The ARIA roles in the markup keep the table semantics
	 * that display: contents would otherwise strip in some browsers.
	 */
	.cw-cr .cw-cr__bar--bottom {
		display: none !important;
	}

	.cw-cr .cw-cr__table {
		display: grid;
		grid-auto-flow: column;
		grid-template-rows: repeat(var(--cw-cr-cols, 14), auto);
		grid-template-columns: 132px;
		grid-auto-columns: 200px;
		width: max-content;
		min-width: 0;
	}

	.cw-cr .cw-cr__table thead,
	.cw-cr .cw-cr__table tbody,
	.cw-cr .cw-cr__table tr {
		display: contents;
	}

	.cw-cr .cw-cr__th {
		position: sticky;
		left: 0;
		z-index: 2;
		width: auto !important;
		padding: 16px 14px;
		align-content: center;
		font-size: 13px;
		letter-spacing: 0.03em;
		border-bottom: 1px solid rgba(255, 255, 255, 0.18);
	}

	.cw-cr .cw-cr__td {
		padding: 16px 14px;
		align-content: center;
		font-size: 15px;
		line-height: 1.5;
		border-right: 1px solid var(--cw-cr-line);
	}

	.cw-cr .cw-cr__td--result {
		font-size: 19px;
	}

	.cw-cr .cw-cr__dash {
		font-size: 15px;
	}

}
