/* Ported from the Next.js app's calibration.module.css. */
.calibration__wrap {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
}

.calibration__line {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding: var(--space-4) var(--space-5);
	border: var(--border-1) solid var(--border-default);
	border-radius: var(--radius-xl);
	background: var(--background-surface);
}

.calibration__line[data-gap] {
	border-color: var(--feedback-warning-border);
}

/*
 * Done scrolls the next line to the top of the window, so every card that can be landed
 * on keeps a hand's breadth above it rather than sitting flush against the edge.
 */
.calibration__line,
.calibration__folded,
.calibration__narrative {
	scroll-margin-top: var(--space-4);
}

/*
 * A card is not a control, but it is where focus lands after a Done, and a keyboard
 * reader who cannot see that has been moved somewhere has just been lost. Outside the
 * border rather than inside it: the card already owns its edge, including the warning
 * colour a gap paints there.
 */
.calibration__line:focus-visible,
.calibration__narrative:focus-visible {
	outline: var(--border-2) solid var(--border-focus);
	outline-offset: var(--border-2);
}

/*
 * ── what the keyboard can do here, said only while the keyboard is here ──────
 *
 * Both of these answer the same question — you have just been put on a card, now what —
 * and both disappear for a mouse, which is what :focus-visible is for. They cost the card
 * nothing when nobody is looking at it that way.
 *
 * The numerals are the first half: they are already on screen, in the right place, so
 * they only have to look like the keys they are. A raised edge does it, and a moment's
 * transition keeps them from snapping.
 */
.calibration__line:focus-visible .calibration__rung-score {
	border-color: var(--gray-300);
	box-shadow: 0 2px 0 var(--gray-400);
	color: var(--text-primary);
}

/* The second half, in words, sitting with the rest of the card's small print. Held in the
   layout at all times so the foot does not jump when it appears. */
.calibration__hint {
	font-size: var(--font-size-xs);
	color: var(--text-tertiary);
	opacity: 0;
	transition: opacity 120ms ease-out;
}

.calibration__line:focus-visible .calibration__hint {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.calibration__hint,
	.calibration__rung-score {
		transition: none;
	}
}

.calibration__line-head {
	display: flex;
	align-items: center;
	gap: var(--space-3);
}

.calibration__line-name {
	margin: 0;
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-semibold);
	color: var(--text-primary);
}

/* The aggregate and the way out, at the end of the line they belong to. */
.calibration__line-foot {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	flex-wrap: wrap;
}

.calibration__narrative {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding: var(--space-5);
	border: var(--border-1) solid var(--border-default);
	border-radius: var(--radius-xl);
	background: var(--background-surface);
}

.calibration__narrative-read {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.calibration__narrative-label {
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	color: var(--text-primary);
}

.calibration__narrative-text {
	margin: 0;
	font-size: var(--font-size-lg);
	line-height: var(--font-line-height-lg);
	color: var(--text-primary);
	white-space: pre-wrap;
}

.calibration__release-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-4);
	flex-wrap: wrap;
}

.calibration__released-note {
	font-size: var(--font-size-sm);
	color: var(--text-tertiary);
}

/* ── the ladder ──────────────────────────────────────────────────────────────── */
.calibration__ladder {
	display: flex;
	flex-direction: column;
	border: var(--border-1) solid var(--app-rule);
	border-radius: var(--radius-lg);
	background: var(--background-surface);
}

.calibration__rung {
	display: grid;
	grid-template-columns: 28px minmax(0, 1fr);
	gap: var(--space-3);
	align-items: start;
	padding: var(--space-3) var(--space-4);
	cursor: pointer;
	transition: background-color 120ms ease-out;
}

.calibration__rung + .calibration__rung {
	border-top: var(--border-1) solid var(--app-hairline);
}

/*
 * The selected rung is outlined from the inside, so the end rungs have to carry the
 * group's own corners or the ring gets sliced off where it meets the rounded edge.
 * One pixel in from the group, because the group's border is a pixel wide.
 */
.calibration__rung:first-child {
	border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.calibration__rung:last-child {
	border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
}

.calibration__rung:hover {
	background: var(--app-ground);
}

.calibration__rung[data-final] {
	background: var(--background-accent-subtle);
	box-shadow: inset 0 0 0 var(--border-2) var(--turquoise-600);
}

.calibration__rung:has(input:focus-visible) {
	position: relative;
	z-index: var(--z-focus);
	box-shadow: var(--focus-ring);
}

.calibration__rung:has(input:disabled) {
	cursor: default;
}

.calibration__rung input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

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

.calibration__rung-score {
	display: grid;
	place-items: center;
	height: 26px;
	border-radius: var(--radius-sm);
	border: var(--border-1) solid var(--app-rule);
	background: var(--background-page);
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	font-variant-numeric: tabular-nums;
	color: var(--text-tertiary);
	transition:
		box-shadow 120ms ease-out,
		border-color 120ms ease-out,
		color 120ms ease-out;
}

.calibration__rung[data-final] .calibration__rung-score {
	background: var(--turquoise-600);
	border-color: var(--turquoise-600);
	color: var(--base-white);
}

.calibration__rung-body {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	min-width: 0;
}

.calibration__rung-top {
	display: flex;
	align-items: baseline;
	gap: var(--space-3);
	flex-wrap: wrap;
}

/*
 * The scale's own wording. It is the thing being chosen between, so it reads at body size
 * and upright, and it is deliberately not styled like the quotations under it.
 */
.calibration__anchor {
	flex: 1;
	min-width: 14rem;
	font-size: var(--font-size-base);
	line-height: var(--font-line-height-base);
	color: var(--text-secondary);
}

.calibration__rung[data-final] .calibration__anchor {
	color: var(--text-primary);
}

.calibration__chose {
	display: flex;
	gap: var(--space-2);
	flex-wrap: wrap;
}

.calibration__chose-name {
	font-size: var(--font-size-xs);
	font-weight: var(--font-weight-semibold);
	color: var(--text-primary);
	background: var(--app-ground);
	border-radius: var(--radius-full);
	padding: 2px var(--space-3);
	white-space: nowrap;
}

.calibration__chose-name[data-self] {
	background: var(--score-4-bg);
	color: var(--score-4-fg);
}

.calibration__chose-name[data-flagged] {
	background: var(--note-owed-bg);
	color: var(--note-owed-fg);
}

/*
 * A colleague speaking, set apart from the scale's wording by kind rather than by
 * position: smaller, italic, with the speaker named above in upright semibold. Italic
 * because it is the one convention every reader already has for reported speech, and
 * because it survives greyscale where a colour would not.
 */
.calibration__said {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.calibration__summary {
	margin-left: auto;
	font-size: var(--font-size-xs);
	font-variant-numeric: tabular-nums;
	color: var(--text-tertiary);
}

/* ── a decision already taken ────────────────────────────────────────────────── */
/*
 * One line: the score, what it is about, the gap if there was one, and the first words of
 * what you wrote. Mirrors the collapsed indicator on the review form, because it is the
 * same idea — this one is finished, the open ones are the work.
 */
.calibration__folded {
	display: grid;
	grid-template-columns: 28px auto auto minmax(0, 1fr) auto;
	gap: var(--space-3);
	align-items: center;
	width: 100%;
	padding: var(--space-3) var(--space-5);
	border: var(--border-1) solid var(--app-rule);
	border-radius: var(--radius-lg);
	background: var(--background-surface);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: background-color 120ms ease-out;
}

.calibration__folded:hover {
	background: var(--app-ground);
}

.calibration__folded:focus-visible {
	outline: var(--border-2) solid var(--border-focus);
	outline-offset: calc(var(--border-2) * -1);
}

.calibration__folded:has(> [data-gap]) {
	border-color: var(--note-owed-border);
}

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

.calibration__folded-name {
	font-size: var(--font-size-base);
	font-weight: var(--font-weight-medium);
	color: var(--text-primary);
	white-space: nowrap;
}

.calibration__folded-tags {
	display: inline-flex;
	gap: var(--space-2);
}

/*
 * On the agenda. Said in words, not a dot: the gap tag beside it already owns the amber,
 * and a second coloured mark would be a state carried by hue alone.
 */
.calibration__folded-agenda {
	font-size: var(--font-size-xs);
	font-weight: var(--font-weight-semibold);
	color: var(--text-secondary);
	white-space: nowrap;
}

.calibration__folded-gap {
	font-size: var(--font-size-xs);
	font-weight: var(--font-weight-semibold);
	color: var(--note-owed-fg);
	white-space: nowrap;
}

/* Your own sentence, quoted the same way everyone else's is. */
.calibration__folded-note {
	font-size: var(--font-size-sm);
	font-style: italic;
	color: var(--text-tertiary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

.calibration__folded-action {
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-medium);
	color: var(--text-link);
	white-space: nowrap;
}

@media (max-width: 46rem) {
	.calibration__folded {
		grid-template-columns: 28px minmax(0, 1fr) auto;
	}

	.calibration__folded-tags,
	.calibration__folded-note {
		grid-column: 2 / -1;
	}

	.calibration__folded-tags:empty {
		display: none;
	}
}

/* ── the general comments ────────────────────────────────────────────────────── */
.calibration__general {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding: var(--space-5);
	border: var(--border-1) solid var(--app-rule);
	border-radius: var(--app-sheet-radius);
	background: var(--background-surface);
}

.calibration__general-title {
	margin: 0;
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	color: var(--text-tertiary);
}

/* The line's contents, which a save replaces: laid out by the button's own grid. */
.calibration__folded-content {
	display: contents;
}

/* On a phone a line is its score, its name and its action, as in the review form. */
@media (max-width: 767.98px) {
	.calibration__folded {
		grid-template-columns: 28px minmax(0, 1fr) auto;
	}

	.calibration__folded-name {
		white-space: normal;
	}

	.calibration__folded-tags,
	.calibration__folded-note {
		display: none;
	}
}
