/* Ported from the Next.js app's review.module.css. */
/* ── the ladder ──────────────────────────────────────────────────────────────── */
.review__ladder {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.review__instruction {
	margin: 0 0 var(--space-1);
	font-size: var(--font-size-sm);
	color: var(--text-secondary);
}

/*
 * One frame around the five, hairlines between.
 *
 * Each rung used to carry its own border and radius, which made the ladder read as a row
 * of controls and put a box around every sentence. The sentences are the product: the set
 * is the control, and all of the emphasis goes to the one that is chosen.
 *
 * The rungs stay uncoloured on purpose. The score meter draws the scale in colour because
 * it reports a finished record; tinting rung 1 red here would make a legitimate
 * assessment look like a fault at the moment somebody is deciding whether it is true.
 */
.review__ladder-group {
	border: var(--border-1) solid var(--app-rule);
	/* The design system documents --radius-lg as the radius for form inputs, selection
	   cards and radio rows. A ladder is a set of radio rows. */
	border-radius: var(--radius-lg);
	background: var(--background-surface);
	overflow: hidden;
}

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

.review__rung + .review__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 is sliced off square where it meets the rounded edge.
 * One pixel in from the group, because the group's border is a pixel wide. The same fix,
 * for the same reason, as the calibration ladder.
 */
.review__rung:first-child {
	border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

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

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

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

/* Visually hidden, never removed: the native input keeps arrow keys, Home/End and
   screen-reader announcement working without a line of JavaScript. */
.review__rung input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Outlined from the inside, so choosing a rung cannot shift the ones under it. */
.review__rung:has(input:checked) {
	background: var(--background-accent-subtle);
	box-shadow: inset 0 0 0 var(--border-2) var(--turquoise-600);
}

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

.review__rung:has(input:disabled) {
	cursor: default;
	opacity: 0.75;
}

/*
 * The score numeral: a square of tabular figures. It is the one shape this app repeats,
 * on a rung and on a finished row, so a 4 is recognisably the same object wherever it
 * turns up.
 */
.review__rung-number {
	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;
}

.review__rung:has(input:checked) .review__rung-number {
	background: var(--turquoise-600);
	border-color: var(--turquoise-600);
	color: var(--base-white);
}

.review__rung-text {
	font-size: var(--font-size-base);
	line-height: var(--font-line-height-base);
	color: var(--text-secondary);
}

.review__rung:has(input:checked) .review__rung-text {
	color: var(--text-primary);
}

/* ── one indicator, open ─────────────────────────────────────────────────────── */
/*
 * Open and collapsed used to be the same object at two heights: both white, both bordered,
 * both rounded. Twenty indicators read as twenty cards, and the one being written in had
 * no more presence than the nineteen already finished.
 *
 * The open one is now recessed, the tinted ground showing through the sheet, which is the
 * oldest convention there is for "this is the part you fill in".
 */
.review__indicator {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding: var(--space-5);
	background: var(--app-ground);
	box-shadow: inset 0 1px 0 var(--app-rule);
}

.review__indicator:has(.review__requirement[data-owes-note]) {
	background: var(--note-owed-bg);
	box-shadow: inset 0 1px 0 var(--note-owed-border);
}

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

/*
 * A row is not a control, but it is where focus lands after a Done, and a keyboard
 * reviewer who cannot see that they have been moved has just been lost. Inset, like the
 * collapsed strip's: these run the full width of the sheet, and an outline outside them
 * would be drawn over its rounded edge.
 */
.review__indicator:focus-visible {
	outline: var(--border-2) solid var(--border-focus);
	outline-offset: calc(var(--border-2) * -1);
}

/*
 * ── 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.
 */
.review__indicator:focus-visible .review__rung-number {
	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. */
.review__hint {
	font-size: var(--font-size-xs);
	color: var(--text-tertiary);
	opacity: 0;
	transition: opacity 120ms ease-out;
}

.review__indicator:focus-visible .review__hint {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.review__hint,
	.review__rung-number {
		transition: none;
	}
}

.review__indicator-head {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
}

.review__indicator-name {
	margin: 0;
	font-size: var(--font-size-xl);
	line-height: var(--font-line-height-xl);
	letter-spacing: -0.018em;
	font-weight: var(--font-weight-semibold);
	color: var(--text-primary);
}

.review__indicator-prompt {
	margin: var(--space-1) 0 0;
	font-size: var(--font-size-sm);
	color: var(--text-tertiary);
}

.review__indicator-foot {
	display: flex;
	align-items: center;
	gap: var(--space-4);
	flex-wrap: wrap;
}

/* Pushed to the end of the row whatever else is in it. */
.review__done-button {
	margin-left: auto;
}

/* ── one indicator, collapsed ────────────────────────────────────────────────── */
/*
 * A finished indicator is a line in a register: score, name, the first words of the note.
 *
 * The whole line is the button. Aiming at "Edit" was asking for a four-character target
 * on a row that is eight hundred pixels wide and does exactly one thing.
 */
.review__collapsed {
	display: grid;
	grid-template-columns: 28px auto minmax(0, 1fr) auto;
	gap: var(--space-3);
	align-items: center;
	width: 100%;
	padding: var(--space-3) var(--space-5);
	border: 0;
	font: inherit;
	text-align: left;
	cursor: pointer;
	background: var(--background-surface);
	box-shadow: inset 0 1px 0 var(--app-hairline);
	transition: background-color 120ms ease-out;
}

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

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

.review__collapsed:has(> [data-owes-note]) {
	background: var(--note-owed-bg);
	box-shadow: inset 0 1px 0 var(--note-owed-border);
}

.review__collapsed:has(> [data-owes-note]):hover {
	background: var(--amber-100);
}

/* Reads as the action without being a second control inside the first. */
.review__collapsed-action {
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-medium);
	color: var(--text-link);
	white-space: nowrap;
}

.review__collapsed:has(> [data-owes-note]) .review__collapsed-action {
	color: var(--note-owed-fg);
}

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

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

.review__collapsed-preview {
	font-size: var(--font-size-sm);
	color: var(--text-tertiary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

/* ── the form shell ──────────────────────────────────────────────────────────── */
.review__form {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding-bottom: var(--space-10);
}

/*
 * Tabs and indicators are one sheet. Indicators are rows in it, separated by their own
 * inset rules, so the eye travels down a single column instead of across twenty boxes.
 */
.review__sheet {
	background: var(--app-sheet);
	border: var(--border-1) solid var(--app-rule);
	border-radius: var(--app-sheet-radius);
	overflow: hidden;
}

/*
 * The tabs sit on the sheet's top edge, so they need the sheet's own padding beside them.
 * Flush into the corner they read as a browser tab strip that someone forgot to finish.
 *
 * The vertical space belongs to the tab rather than the list, so the label is centred in
 * the strip and the active underline still lands on the list's own bottom rule.
 */
.review__tabs-list {
	gap: var(--space-2);
	padding-inline: var(--space-5);
}

.review__tab {
	/* The tab's own bottom border is the active underline and it sits inside the strip, so
	   the top padding carries it to keep the label on the centre line. */
	padding: calc(var(--space-4) + var(--border-2)) var(--space-3) var(--space-4);
	background: transparent;
	color: var(--text-tertiary);
}

.review__tab:hover {
	background: transparent;
	color: var(--text-primary);
}

.review__tab[data-active] {
	color: var(--text-primary);
	font-weight: var(--font-weight-semibold);
}

.review__panel > :first-child {
	box-shadow: none;
}

/* ── category tabs ───────────────────────────────────────────────────────────── */
.review__tab-count {
	color: var(--text-tertiary);
	font-variant-numeric: tabular-nums;
	font-weight: var(--font-weight-regular);
}

/*
 * Says "there is something unfinished in here" without saying how much — a category with
 * one owed note and one with three need the same thing done. If that turns out to matter,
 * this becomes a number.
 */
.review__tab-flag {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-left: var(--space-2);
	border-radius: var(--radius-full);
	background: var(--note-owed-fg);
	vertical-align: middle;
}

.review__submit-bar {
	position: sticky;
	bottom: var(--space-4);
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: var(--space-4);
	flex-wrap: wrap;
	margin-top: var(--space-4);
	padding: var(--space-4) var(--space-5);
	border: var(--border-1) solid var(--app-rule);
	border-radius: var(--radius-lg);
	background: var(--background-surface);
	box-shadow: var(--shadow-md);
}

.review__submit-status {
	font-size: var(--font-size-sm);
	color: var(--text-secondary);
}

.review__save-label {
	color: var(--text-tertiary);
}

/* The general comment: one field, after the twenty, before the submit bar. */
.review__general {
	margin-top: var(--space-2);
}

/* The save's own state, after the progress it belongs to. */
.review__save-label::before {
	content: ' · ';
}

/* The note's requirement, under its label: what it is for, and whether this score owes it. */
.review__requirement {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

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

/* On a phone a line is its score, its name and its action: the name wraps rather than pushing the action off the
   edge, and the note's first words give way to it. */
@media (max-width: 767.98px) {
	.review__collapsed {
		grid-template-columns: 28px minmax(0, 1fr) auto;
	}

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

	.review__collapsed-preview {
		display: none;
	}
}
