/* Quick Reorder and local Activity. */

.am-reorder,
.am-activity {
	/* Rows size to content; the main stretches to the viewport, so without this
	the grid distributes the leftover height between the header and panels. */
	align-content: start;
	display: grid;
	gap: var(--am-space-5);
	grid-template-columns: minmax(0, 1fr);
}

.am-reorder > *,
.am-activity > * {
	min-width: 0;
}

.am-reorder .am-page-heading,
.am-activity .am-page-heading,
.am-reorder > .am-notice,
.am-activity > .am-notice,
.am-reorder .am-section,
.am-activity .am-section {
	margin-inline: auto;
	max-width: var(--am-content-max);
	position: relative;
	width: 100%;
}

.am-reorder .am-section,
.am-activity .am-section {
	background: var(--am-white);
	border: 1px solid var(--am-border-strong);
	border-radius: var(--am-radius-card);
	margin-bottom: 0;
	padding: var(--am-space-5);
}

.am-reorder .am-notice h2 {
	font-size: var(--am-text-md);
	margin-bottom: var(--am-space-1);
}

.am-reorder .am-section__heading,
.am-activity .am-section__heading {
	align-items: center;
	border-bottom: 1px solid var(--am-border);
	gap: var(--am-space-4);
	grid-template-columns: minmax(0, 1fr) auto;
	margin-bottom: var(--am-space-4);
	padding-bottom: var(--am-space-3);
}

.am-reorder .am-section__heading h2,
.am-activity .am-section__heading h2 {
	font-size: var(--am-text-md);
}

.am-reorder .am-section__heading p,
.am-activity .am-section__heading p {
	color: var(--am-text-subtle);
	font-size: var(--am-text-sm);
	margin: var(--am-space-1) 0 0;
}

.am-reorder-list,
.am-reorder-orders,
.am-activity-list {
	display: grid;
	gap: var(--am-space-3);
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Reorder preview line ------------------------------------------------------- */

.am-reorder-line {
	align-items: center;
	background: var(--am-white);
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius-card);
	display: grid;
	gap: var(--am-space-4);
	grid-template-columns: 3rem minmax(10rem, 1fr) minmax(14rem, 0.8fr);
	min-width: 0;
	padding: var(--am-space-4);
}

.am-reorder-line.is-unavailable {
	background: var(--am-status-warning-bg);
	border-color: var(--am-warning);
}

.am-reorder-line__product-mark {
	align-items: center;
	background: var(--am-surface);
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius-control);
	color: var(--am-silver-500);
	display: flex;
	height: 3rem;
	justify-content: center;
	width: 3rem;
}

.am-reorder-line h3 {
	font-size: var(--am-text-base);
	margin: 0;
	overflow-wrap: anywhere;
}

.am-reorder-line__identity p {
	color: var(--am-text-subtle);
	font-size: var(--am-text-xs);
	font-variant-numeric: var(--am-tnum);
	margin: var(--am-space-1) 0 0;
	overflow-wrap: anywhere;
}

.am-reorder-line dl {
	display: grid;
	gap: var(--am-space-4);
	grid-template-columns: 1fr 1fr;
	margin: 0;
	min-width: 0;
}

.am-reorder-line dl div {
	display: grid;
	gap: 0;
	min-width: 0;
}

.am-reorder-line dt {
	color: var(--am-text-subtle);
	font-size: var(--am-text-xs);
}

.am-reorder-line dd {
	font-variant-numeric: var(--am-tnum);
	font-weight: 700;
	margin: 0;
	overflow-wrap: anywhere;
}

.am-reorder-line dd.is-changed {
	color: var(--am-warning);
}

.am-reorder-line__state {
	display: flex;
	flex-wrap: wrap;
	gap: var(--am-space-2);
	grid-column: 2 / -1;
	margin: 0;
}

/* Submission panel ------------------------------------------------------------ */

.am-reorder-actions {
	align-items: center;
	background: var(--am-surface);
	border: 1px solid var(--am-border-strong);
	border-radius: var(--am-radius-card);
	display: flex;
	gap: var(--am-space-5);
	justify-content: space-between;
	margin-top: var(--am-space-4);
	padding: var(--am-space-4) var(--am-space-5);
}

.am-reorder-actions p {
	margin: 0;
}

.am-reorder-actions strong {
	display: block;
	font-size: var(--am-text-sm);
}

.am-reorder-actions p:not(:has(strong)),
.am-reorder-actions br + * {
	color: var(--am-text-muted);
}

/* Order chooser --------------------------------------------------------------- */

.am-reorder-orders li {
	align-items: center;
	background: var(--am-white);
	border: 1px solid var(--am-border);
	border-radius: var(--am-radius-card);
	display: grid;
	gap: var(--am-space-4);
	grid-template-columns: 2.5rem minmax(0, 1fr) auto;
	min-width: 0;
	padding: var(--am-space-3) var(--am-space-4);
	transition: border-color var(--am-duration) var(--am-ease);
}

.am-reorder-orders li:hover {
	border-color: var(--am-silver-500);
}

.am-reorder-orders__icon {
	align-items: center;
	background: var(--am-surface-2);
	border-radius: var(--am-radius-control);
	color: var(--am-navy-900);
	display: flex;
	height: 2.5rem;
	justify-content: center;
	width: 2.5rem;
}

.am-reorder-orders li > div {
	display: grid;
	gap: 0;
	min-width: 0;
}

.am-reorder-orders strong {
	font-variant-numeric: var(--am-tnum);
	overflow-wrap: anywhere;
}

.am-reorder-orders span,
.am-reorder-orders small,
.am-activity-list small {
	color: var(--am-text-subtle);
	font-size: var(--am-text-xs);
	font-variant-numeric: var(--am-tnum);
}

.am-reorder-orders .am-button {
	white-space: nowrap;
}

/* Activity timeline ------------------------------------------------------------ */

.am-activity-list {
	gap: 0;
}

.am-activity-list li {
	display: grid;
	gap: var(--am-space-4);
	grid-template-columns: 2rem minmax(0, 1fr);
	min-width: 0;
	padding-bottom: var(--am-space-5);
	position: relative;
}

.am-activity-list li:last-child {
	padding-bottom: 0;
}

/* Connector between markers; stops before the last entry. */
.am-activity-list li:not(:last-child)::before {
	background: var(--am-border-strong);
	content: "";
	inset: 2.25rem auto 0 0.9375rem;
	position: absolute;
	width: 1px;
}

.am-activity-list__mark {
	align-items: center;
	background: var(--am-white);
	border: 1px solid var(--am-border-strong);
	border-radius: 50%;
	display: flex;
	height: 2rem;
	justify-content: center;
	position: relative;
	width: 2rem;
	z-index: 1;
}

.am-activity-list__mark::before {
	background: var(--am-brand);
	border-radius: 50%;
	content: "";
	/* Size pinned by tests/e2e/milestone-nine.visual.spec.mjs. */
	height: 0.45rem;
	width: 0.45rem;
}

.am-activity-list li > div {
	display: grid;
	gap: var(--am-space-1);
	justify-items: start;
	min-width: 0;
	padding-top: var(--am-space-1);
}

.am-activity-list strong {
	font-size: var(--am-text-base);
	font-weight: 600;
	overflow-wrap: anywhere;
}

.am-activity-list a {
	font-size: var(--am-text-sm);
	font-weight: 600;
}

/* Empty and error blocks -------------------------------------------------------- */

.am-reorder .am-empty-state .am-icon,
.am-activity .am-empty-state .am-icon {
	color: var(--am-text-subtle);
	margin: 0 auto var(--am-space-3);
}

.am-empty-state--error {
	background: var(--am-status-danger-bg);
	border-color: var(--am-danger);
	border-style: solid;
}

.am-empty-state--error .am-icon {
	color: var(--am-danger);
}

/* Responsive --------------------------------------------------------------------- */

@media (max-width: 64rem) {
	.am-reorder-line {
		grid-template-columns: 3rem minmax(0, 1fr);
	}

	.am-reorder-line dl,
	.am-reorder-line__state {
		grid-column: 2;
	}
}

@media (max-width: 48rem) {
	.am-reorder .am-section,
	.am-activity .am-section {
		padding: var(--am-space-4);
	}

	.am-reorder .am-section__heading,
	.am-activity .am-section__heading {
		grid-template-columns: 1fr;
	}

	.am-reorder-line {
		align-items: start;
		grid-template-columns: 2.75rem minmax(0, 1fr);
	}

	.am-reorder-line__product-mark {
		height: 2.75rem;
		width: 2.75rem;
	}

	.am-reorder-actions {
		align-items: stretch;
		flex-direction: column;
	}

	.am-reorder-actions .am-button {
		width: 100%;
	}

	.am-reorder-orders li {
		grid-template-columns: 2.5rem minmax(0, 1fr);
	}

	.am-reorder-orders .am-button {
		grid-column: 1 / -1;
		justify-content: center;
		white-space: normal;
	}

	.am-reorder .am-section__heading .am-button,
	.am-activity .am-section__heading .am-button {
		justify-self: start;
	}
}

/*
 * Previous and current unit price stay side by side through tablet widths so
 * the comparison the panel exists for survives; they stack only once the card
 * is too narrow to hold two readable columns.
 */
@media (max-width: 30rem) {
	.am-reorder-line dl {
		gap: var(--am-space-2);
		grid-template-columns: 1fr;
	}
}

@media (max-width: 24rem) {
	.am-reorder-line,
	.am-reorder-orders li {
		grid-template-columns: 1fr;
	}

	.am-reorder-line__product-mark,
	.am-reorder-orders__icon {
		display: none;
	}

	.am-reorder-line dl,
	.am-reorder-line__state {
		grid-column: 1;
	}

	.am-topbar__activity span:last-child {
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		height: 1px;
		overflow: hidden;
		position: absolute;
		white-space: nowrap;
		width: 1px;
	}

	.am-topbar__activity {
		min-width: 2.75rem;
		padding-inline: var(--am-space-3);
	}
}
