/*
 * HR Step Counter
 * Mobile-first. Layout responds to the width of the container the shortcode
 * is placed in (container queries), so it adapts to any theme column width.
 * Override the custom properties below in your theme to restyle.
 */

.hrsc {
	--hrsc-accent: #1e6fd9;
	--hrsc-accent-contrast: #fff;
	--hrsc-text: inherit;
	--hrsc-muted: #5f6b7a;
	--hrsc-surface: #fff;
	--hrsc-border: #d9dee5;
	--hrsc-danger: #c62828;
	--hrsc-success: #2e7d32;
	--hrsc-radius: 12px;
	--hrsc-gap: 16px;

	container-type: inline-size;
	box-sizing: border-box;
	width: 100%;
	max-width: 960px;
	margin-inline: auto;
	color: var(--hrsc-text);
	font-size: 1rem;
	line-height: 1.4;
}

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

.hrsc [hidden] {
	display: none !important;
}

.hrsc__grid {
	display: grid;
	gap: var(--hrsc-gap);
	margin-bottom: var(--hrsc-gap);
}

.hrsc-card {
	background: var(--hrsc-surface);
	border: 1px solid var(--hrsc-border);
	border-radius: var(--hrsc-radius);
	padding: 16px;
}

.hrsc .hrsc-card__title {
	margin: 0 0 12px;
	font-size: 1.125rem;
	line-height: 1.3;
}

/* Summary */

.hrsc-total {
	margin: 0 0 16px;
	display: flex;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
}

.hrsc-total__value {
	font-size: clamp(2.5rem, 12cqi, 3.5rem);
	font-weight: 700;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: var(--hrsc-accent);
	overflow-wrap: anywhere;
}

.hrsc-roller {
	display: inline-flex;
	white-space: nowrap;
}

.hrsc-digit {
	display: inline-block;
	height: 1.1em;
	line-height: 1.1;
	overflow: hidden;
}

.hrsc-digit__strip {
	display: flex;
	flex-direction: column;
	transform: translateY(calc(var(--hrsc-digit, 0) * -10%));
	transition: transform 900ms cubic-bezier(0.2, 0.9, 0.25, 1.05);
	transition-delay: var(--hrsc-delay, 0ms);
}

.hrsc-digit__strip > span {
	display: block;
	height: 1.1em;
}

.hrsc-roller__sep {
	line-height: 1.1;
}

@media (prefers-reduced-motion: reduce) {
	.hrsc-digit__strip {
		transition: none;
	}
}

.hrsc-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.hrsc-total__unit {
	color: var(--hrsc-muted);
	font-size: 1.125rem;
}

.hrsc-breakdown {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 0;
}

.hrsc-breakdown__item {
	border: 1px solid var(--hrsc-border);
	border-radius: 8px;
	padding: 8px;
	text-align: center;
	min-width: 0;
}

.hrsc-breakdown dt {
	color: var(--hrsc-muted);
	font-size: 0.8125rem;
}

.hrsc-breakdown dd {
	margin: 2px 0 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

/* Form */

.hrsc-form {
	display: grid;
	gap: 16px;
	margin: 0;
}

.hrsc-field {
	display: grid;
	gap: 6px;
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.hrsc-label {
	font-weight: 600;
	font-size: 0.9375rem;
	padding: 0;
}

/* 16px minimum prevents iOS Safari from zooming in on focus. */
.hrsc .hrsc-input {
	width: 100%;
	min-height: 48px;
	padding: 10px 12px;
	font-size: 16px;
	font-family: inherit;
	color: inherit;
	background: var(--hrsc-surface);
	border: 1px solid var(--hrsc-border);
	border-radius: 8px;
	-webkit-appearance: none;
	appearance: none;
}

.hrsc .hrsc-input:focus-visible {
	outline: 2px solid var(--hrsc-accent);
	outline-offset: 1px;
	border-color: var(--hrsc-accent);
}

.hrsc-segmented {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
}

.hrsc-segmented label {
	position: relative;
	display: block;
	margin: 0;
}

.hrsc-segmented input {
	position: absolute;
	opacity: 0;
	inset: 0;
	margin: 0;
	cursor: pointer;
}

.hrsc-segmented span {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 8px;
	border: 1px solid var(--hrsc-border);
	border-radius: 8px;
	font-weight: 600;
	cursor: pointer;
	user-select: none;
}

.hrsc-segmented input:checked + span {
	background: var(--hrsc-accent);
	border-color: var(--hrsc-accent);
	color: var(--hrsc-accent-contrast);
}

.hrsc-segmented input:focus-visible + span {
	outline: 2px solid var(--hrsc-accent);
	outline-offset: 2px;
}

/* Buttons */

.hrsc .hrsc-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 10px 20px;
	font-size: 1rem;
	font-family: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	color: var(--hrsc-accent-contrast);
	background: var(--hrsc-accent);
	border: 1px solid var(--hrsc-accent);
	border-radius: 8px;
	cursor: pointer;
}

.hrsc .hrsc-button:disabled {
	opacity: 0.6;
	cursor: progress;
}

.hrsc .hrsc-button--secondary {
	margin-top: 12px;
	color: var(--hrsc-accent);
	background: transparent;
}

.hrsc-message {
	margin: 0;
	min-height: 1.4em;
	font-size: 0.9375rem;
}

.hrsc-message.is-error {
	color: var(--hrsc-danger);
}

.hrsc-message.is-success {
	color: var(--hrsc-success);
}

/* History */

.hrsc .hrsc-history {
	list-style: none;
	margin: 0;
	padding: 0;
}

.hrsc-entry {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-top: 1px solid var(--hrsc-border);
	margin: 0;
}

.hrsc-entry:first-child {
	border-top: 0;
}

.hrsc-entry__main {
	flex: 1;
	min-width: 0;
}

.hrsc-entry__distance {
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.hrsc-entry__type {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 8px;
	border-radius: 999px;
	font-size: 0.8125rem;
	background: color-mix(in srgb, var(--hrsc-accent) 12%, transparent);
	color: var(--hrsc-accent);
}

.hrsc-entry__date {
	display: block;
	color: var(--hrsc-muted);
	font-size: 0.875rem;
}

.hrsc .hrsc-entry__delete-form {
	flex: none;
	margin: 0;
}

.hrsc .hrsc-entry__delete {
	flex: none;
	min-width: 44px;
	min-height: 44px;
	padding: 8px 12px;
	font: inherit;
	font-size: 0.875rem;
	color: var(--hrsc-danger);
	background: transparent;
	border: 1px solid transparent;
	border-radius: 8px;
	cursor: pointer;
}

.hrsc .hrsc-entry__delete:hover,
.hrsc .hrsc-entry__delete:focus-visible {
	border-color: currentColor;
}

.hrsc-empty {
	margin: 0;
	color: var(--hrsc-muted);
}

.hrsc--logged-out {
	text-align: center;
}

.hrsc--logged-out .hrsc-button {
	width: auto;
}

/* Wider containers (tablets, desktops): summary and form side by side. */
@container (min-width: 640px) {
	.hrsc-card {
		padding: 24px;
	}

	.hrsc__grid {
		grid-template-columns: 1fr 1fr;
		align-items: start;
	}

	.hrsc .hrsc-button--secondary {
		width: auto;
	}
}
