/* Connectors: the overview (scoped to connectors-overview, the way member-pulse scopes itself), and each connector's
   setup page and delivery log. Custom elements are inline by default, so every one used for layout states its display. */

/* #region Overview */

connectors-overview {
	/* Logos are drawn for white paper. They sit on a light plate in both themes rather than being recoloured, which
	   would mean altering other companies' marks; in dark mode the plate is toned down so it does not glare. */
	--logo-plate: #fdfcf9;
	--logo-plate-ink: #4d4636;
	--logo-plate-shadow: 0 1px 2px rgb(77 70 54 / 14%), 0 4px 14px rgb(77 70 54 / 12%);
	/* Status words drawn as text are mixed toward the ink, so they keep 4.5:1 on both papers; the raw greens and
	   reds are lighter than small text allows. */
	--status-ink-attention: color-mix(in srgb, var(--darker-danger-red) 75%, var(--global-font-color));
	--hub-soon: color-mix(in srgb, var(--darker-primary-green) 85%, var(--global-font-color));
	/* The app's secondary ink falls under 4.5:1 for small text on dark paper; pulled toward the main ink, it passes on
	   both papers and still reads as secondary. */
	--quiet-ink: color-mix(in srgb, var(--light-global-font-color) 60%, var(--global-font-color));

	display: flex;
	flex-direction: column;
	gap: 2rem;
	padding: 1rem 1.5rem 2.5rem;

	h2,
	h3,
	h4,
	p {
		margin: 0;
	}

	h3 {
		font-size: var(--font-size-large);
		font-weight: 700;
	}

	h4 {
		font-size: var(--font-size-large);
		font-weight: 700;
		letter-spacing: -0.01em;
	}
}

[data-theme="dark"] connectors-overview {
	--logo-plate: #e9e5db;
	--logo-plate-shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 6px 18px rgb(0 0 0 / 35%);
}

/* #region Intro and hub */

connectors-intro {
	display: grid;
	grid-template-columns: minmax(16rem, 30rem) minmax(0, 1fr);
	align-items: center;
	gap: 2rem 3rem;
	padding: 1.75rem 2.25rem;
	border-radius: 1.5rem;
	background: var(--blue-gray);
	box-shadow: var(--soft-continer-outer-shadow);
}

connectors-title {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;

	h2 {
		font-size: 2rem;
		font-weight: 800;
		letter-spacing: -0.02em;
		line-height: 1.1;
	}

	p {
		max-width: 34rem;
		font-size: var(--font-size-medium);
		line-height: 1.55;
		color: var(--quiet-ink);
		text-wrap: pretty;
	}
}

connectors-hub {
	position: relative;
	display: block;
	width: 100%;
	max-width: 44rem;
	justify-self: center;
	/* Twice as wide as tall, like the SVG's 200 by 100 viewBox, so a node at x% and the end of its line meet. */
	aspect-ratio: 2 / 1;
}

.hub-lines {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
}

/* Line widths and dashes are in viewBox units: one unit is roughly 2.5 to 3.2 px across the hub's widths. */
.hub-line {
	fill: none;
	stroke-width: 0.6;
	stroke-linecap: round;

	&.sending {
		stroke: var(--success-green);
		stroke-opacity: 0.45;
	}

	&.paused {
		stroke: var(--light-blue-gray);
	}

	&.attention {
		stroke: var(--danger-red);
		stroke-dasharray: 2 2;
	}

	&.not-set-up {
		stroke: var(--light-blue-gray);
		stroke-opacity: 0.55;
		stroke-dasharray: 2 2;
	}

	&.not-installed {
		stroke: var(--light-blue-gray);
		stroke-opacity: 0.4;
		stroke-dasharray: 0.01 2.4;
	}

	/* Round caps on near-zero dashes draw dots: a line that is promised, not yet laid. */
	&.soon {
		stroke: var(--hub-soon);
		stroke-width: 0.9;
		stroke-dasharray: 0.01 2.4;
	}
}

/* The page's one moving thing: sales travelling out along a live connection. Dash and gap sum to 50 on a path whose
   pathLength is 100, so two packets ride each line and the loop has no seam. */
.hub-flow {
	fill: none;
	stroke: var(--success-green);
	stroke-width: 1.2;
	stroke-linecap: round;
	stroke-dasharray: 5 45;
	animation: hub-flow 2.6s linear infinite;
}

@keyframes hub-flow {
	from {
		stroke-dashoffset: 0;
	}

	to {
		stroke-dashoffset: -100;
	}
}

hub-plate {
	display: grid;
	place-items: center;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	background: var(--logo-plate);
	box-shadow: var(--logo-plate-shadow);

	img {
		width: 62%;
		height: 62%;
		object-fit: contain;
	}
}

hub-centre {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);

	hub-plate {
		width: 5rem;
		height: 5rem;
	}

	svg {
		width: 64%;
		height: 64%;
	}
}

/* A zero-size anchor at the node's point: the plate centres on it, the label hangs off the outer side, so labels
   never cross the lines running in towards FarmOps. */
hub-node {
	position: absolute;
	left: var(--x);
	top: var(--y);
	width: 0;
	height: 0;

	> a,
	> hub-plate {
		position: absolute;
		transform: translate(-50%, -50%);
	}

	> a {
		display: block;
		border-radius: 50%;
		transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
	}

	> a:hover {
		transform: translate(-50%, -50%) scale(1.07);
	}
}

hub-label {
	position: absolute;
	top: 0;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	transform: translateY(-50%);
	white-space: nowrap;

	b {
		font-size: var(--font-size-small);
		font-weight: 700;
	}

	span {
		display: inline-flex;
		align-items: center;
		gap: 0.35rem;
		font-size: var(--font-size-tiny);
		font-weight: 600;
		color: var(--quiet-ink);
	}

	/* The dot repeats the line's colour beside the words, which stay in the readable secondary ink. */
	span::before {
		content: "";
		width: 0.45rem;
		height: 0.45rem;
		border-radius: 50%;
		background: var(--light-blue-gray);
	}
}

hub-node[side="left"] hub-label {
	right: 2.5rem;
	align-items: flex-end;
	text-align: right;
}

hub-node[side="right"] hub-label {
	left: 2.5rem;
	align-items: flex-start;
}

hub-node.sending hub-label span::before {
	background: var(--success-green);
}

hub-node.attention hub-label span::before {
	background: var(--danger-red);
}

hub-node.soon hub-label span::before {
	background: var(--darker-primary-green);
}

/* #endregion */

/* #region Pricing */

/* Tinted with the brand gold so it reads as an announcement from FarmOps rather than as one more card. */
connectors-pricing {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(18rem, 32rem);
	align-items: center;
	gap: 1.5rem 3rem;
	padding: 1.5rem 2.25rem;
	border: 1px solid color-mix(in srgb, var(--darker-primary-green) 35%, transparent);
	border-radius: 1.5rem;
	background: color-mix(in srgb, var(--primary-green) 14%, var(--blue-gray));
	box-shadow: var(--soft-continer-outer-shadow);
}

connectors-pricing-text {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;

	h3 {
		font-size: var(--font-size-xlarge);
		font-weight: 800;
		letter-spacing: -0.015em;
	}

	p {
		max-width: 38rem;
		font-size: var(--font-size-medium);
		line-height: 1.55;
		color: var(--quiet-ink);
		text-wrap: pretty;
	}

	small {
		font-size: var(--font-size-small);
		font-weight: 600;
		color: var(--quiet-ink);
	}
}

/* Bars to scale with the days, so the gap between pay-as-you-go and a 3-year agreement is seen, not worked out. */
trial-ladder {
	display: grid;
	grid-template-columns: auto minmax(4rem, 1fr) auto;
	align-items: center;
	gap: 0.85rem 1rem;
}

trial-tier {
	display: contents;

	> span {
		font-size: var(--font-size-normal);
		font-weight: 600;
	}

	> b {
		font-size: var(--font-size-medium);
		font-weight: 800;
		font-variant-numeric: tabular-nums;
		text-align: right;
		white-space: nowrap;
	}
}

trial-bar {
	display: block;
	height: 0.65rem;
	border-radius: 1rem;
	background: color-mix(in srgb, var(--global-font-color) 10%, transparent);

	i {
		display: block;
		width: var(--share);
		height: 100%;
		border-radius: inherit;
		background: var(--primary-green);
	}
}

/* #endregion */

/* #region Cards */

.connectors-section {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* The Installed heading, with the toggle at the far end of the same line. */
connectors-section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem 1rem;

	sl-switch {
		font-size: var(--font-size-small);
		font-weight: 600;
		color: var(--quiet-ink);
	}
}

connectors-section-title {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;

	p {
		font-size: var(--font-size-normal);
		color: var(--quiet-ink);
	}
}

connectors-available {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* A wrapping row rather than a grid: tiles grow to share the row, so a full set fills it, but stop at a tile's width,
   so a lone tile does not stretch its logo plate across the page. A grid with a capped track counts its columns at
   the cap and wraps a set that would have fitted. */
connectors-tiles {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;

	> * {
		flex: 1 1 15rem;
		max-width: 32rem;
	}
}

.connector-card,
.connector-tile {
	border-radius: 1.5rem;
	background: var(--blue-gray);
	box-shadow: var(--soft-continer-outer-shadow);
}

.connector-card {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto auto;
	grid-template-areas: "logo body stats aside";
	align-items: center;
	gap: 1rem 2.5rem;
	padding: 1.25rem 1.75rem 1.25rem 1.25rem;
	color: inherit;
	text-decoration: none;
	transition: box-shadow 200ms ease-out, transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1);

	&:hover {
		box-shadow: var(--soft-hover-continer-outer-shadow);
		transform: translateY(-2px);
	}

	&:hover connector-open svg {
		transform: translateX(3px);
	}

	&:focus-visible {
		outline: 2px solid var(--darker-primary-green);
		outline-offset: 3px;
	}

	connector-logo {
		grid-area: logo;
		width: 5.5rem;
		height: 5.5rem;
	}

	connector-logo[shape="wide"] {
		width: 9rem;
	}

	connector-body {
		grid-area: body;
	}
}

connector-price {
	font-size: var(--font-size-small);
	color: var(--quiet-ink);

	b {
		font-size: var(--font-size-medium);
		font-weight: 800;
		color: var(--global-font-color);
	}
}

connector-stats {
	grid-area: stats;
	display: flex;
	align-items: center;
	gap: 2rem;
	font-size: var(--font-size-small);
	color: var(--quiet-ink);
}

connector-stat {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;

	b {
		font-size: var(--font-size-xlarge);
		font-weight: 800;
		letter-spacing: -0.02em;
		line-height: 1.1;
		font-variant-numeric: tabular-nums;
		color: var(--global-font-color);
	}

	span {
		font-size: var(--font-size-tiny);
		font-weight: 600;
	}

	&.failed b,
	&.failed span {
		color: var(--status-ink-attention);
	}
}

connector-aside {
	grid-area: aside;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.75rem;
}

.connector-tile {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding: 0.75rem 0.75rem 1.25rem;

	connector-logo {
		height: 6.5rem;
	}

	connector-body {
		flex: 1;
		padding: 0 0.5rem;
	}

	/* Pinned to the bottom, so the category and pill line up across a row whatever the pitch's length. */
	connector-facts {
		margin-top: auto;
		justify-content: space-between;
	}
}

connector-logo {
	display: grid;
	flex: none;
	place-items: center;
	border-radius: 1rem;
	background: var(--logo-plate);
	box-shadow: var(--logo-plate-shadow);

	/* Square app icons are drawn larger than their share of a wordmark's box, so both read as the same size. */
	&[shape="square"] img {
		width: 3.25rem;
		height: 3.25rem;
		object-fit: contain;
	}

	&[shape="wide"] img {
		max-width: 76%;
		max-height: 2.6rem;
		object-fit: contain;
	}

	span {
		font-size: 2rem;
		font-weight: 800;
		color: var(--logo-plate-ink);
	}
}

connector-body {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	flex: 1;
	min-width: 0;

	p {
		max-width: 60ch;
		font-size: var(--font-size-normal);
		line-height: 1.5;
		color: var(--quiet-ink);
	}
}

connector-heading {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
}

connector-facts {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-top: 0.35rem;
}

connector-ask {
	font-size: var(--font-size-small);
	font-weight: 600;
	color: var(--global-font-color);
}

connector-category {
	padding: 0.2rem 0.65rem;
	border-radius: 1rem;
	background: var(--light-gray);
	color: var(--global-font-color);
	font-size: var(--font-size-tiny);
	font-weight: 700;
}

connector-open {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: var(--font-size-small);
	font-weight: 700;
	color: var(--global-font-color);

	svg {
		transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
	}
}

/* #endregion */

@media (max-width: 1100px) {
	connectors-intro,
	connectors-pricing {
		grid-template-columns: 1fr;
	}

	/* The figures drop under the description; status and Open keep the right edge. */
	.connector-card {
		grid-template-columns: auto minmax(0, 1fr) auto;
		grid-template-areas:
			"logo body aside"
			"logo stats aside";
	}
}

/* Below this the hub's side labels run off the edge. The cards say everything it does, so it steps aside. */
@media (max-width: 640px) {
	connectors-overview {
		padding: 0.75rem 1rem 2rem;
	}

	connectors-intro,
	connectors-pricing {
		padding: 1.25rem;
	}

	connectors-hub {
		display: none;
	}

	.connector-card {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "logo" "body" "stats" "aside";
		padding: 1.25rem;
	}

	connector-aside {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hub-flow {
		display: none;
	}

	.hub-line.sending {
		stroke-opacity: 1;
	}

	.connector-card,
	connector-open svg,
	hub-node > a {
		transition: none;
	}
}

/* #endregion */

/* #region Connector page */

.connectors-page {
	padding: 1rem 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.connectors-subtitle,
.connector-hint {
	color: var(--light-global-font-color);
	font-size: var(--font-size-small);
}

.connector-hint {
	margin: 0;
}

.connector-notice {
	padding: 0.6rem 1rem;
	border-radius: 0.75rem;
	font-size: var(--font-size-normal);
}

.connector-notice.success {
	background: var(--soft-success-green);
}

.connector-notice.error {
	background: var(--soft-danger-red);
}

.connector-notice.info {
	background: var(--light-gray);
}

/* Setup beside the log on wide screens, stacked on narrow ones. */
.connector-columns {
	display: grid;
	grid-template-columns: minmax(320px, 2fr) 3fr;
	gap: 1rem;
	align-items: start;
}

@media (max-width: 1100px) {
	.connector-columns {
		grid-template-columns: 1fr;
	}
}

.connector-panel {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1rem 1.25rem;
	border-radius: 1.5rem;
	background: var(--blue-gray);
	box-shadow: var(--soft-continer-outer-shadow);
}

.connector-panel h3,
.connector-panel h4 {
	margin: 0;
}

.connector-panel h4 {
	margin-top: 0.5rem;
}

.connector-callback {
	padding: 0.4rem 0.6rem;
	border-radius: 0.5rem;
	background: var(--plain-white);
	font-size: var(--font-size-small);
	word-break: break-all;
	user-select: all;
}

.connector-counts {
	font-size: var(--font-size-small);
	color: var(--light-global-font-color);
}

.connector-log {
	overflow-x: auto;
}

.delivery-message {
	max-width: 28rem;
	font-size: var(--font-size-small);
}

.delivery-status {
	padding: 0.15rem 0.6rem;
	border-radius: 1rem;
	font-size: var(--font-size-small);
	white-space: nowrap;
	background: var(--light-gray);
}

.delivery-status.delivered {
	background: var(--soft-success-green);
}

.delivery-status.failed {
	background: var(--soft-danger-red);
}

/* #endregion */