/*!
 * @Rank – JSON, CSV & YAML Formatter: the tool's own rules.
 *
 * The palette, the header, the cards, the buttons, the notices and the toast
 * all come from assets/css/atrank-core.css. Only what is specific to this tool
 * is here.
 *
 * Every rule is anchored on .atrank-df, the tool's own root class. A bare
 * .atrank-something would reach the host page's markup — the harness fails on
 * it, which is how twelve of them were caught during the merge.
 *
 * Two rules here are function rather than decoration:
 *   · the two boxes are the same height and scroll themselves, so the page does
 *     not grow to the size of whatever somebody pasted;
 *   · both are wrap="off" with a horizontal scrollbar, because a formatter's
 *     whole output is its line structure and soft-wrapping destroys it.
 */

/* ── The controls strip ────────────────────────────────────────────────────
   One row that wraps, rather than a stack: these are five short settings and a
   column of them would be most of a laptop screen before any data appeared. */
.atrank-df .atrank-df-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 18px;
}

.atrank-df .atrank-df-group {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.atrank-df .atrank-df-glabel {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--dim);
	white-space: nowrap;
}

.atrank-df .atrank-df-select {
	font: inherit;
	font-size: 12.5px;
	padding: 5px 8px;
	border-radius: var(--r);
	border: 1px solid var(--line2);
	background: var(--panel);
	color: var(--txt);
	max-width: 100%;
}
.atrank-df .atrank-df-select:focus-visible {
	outline: none;
	box-shadow: var(--ring);
	border-color: var(--accent);
}

/* The format picker: radio buttons drawn as one segmented control, because the
   four options are exclusive and a dropdown would hide three of them. */
.atrank-df .atrank-df-seg {
	display: inline-flex;
	border: 1px solid var(--line2);
	border-radius: var(--r);
	overflow: hidden;
}
.atrank-df .atrank-df-seg label {
	position: relative;
	display: inline-flex;
}
.atrank-df .atrank-df-seg input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}
.atrank-df .atrank-df-seg span {
	display: block;
	padding: 5px 11px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	white-space: nowrap;
	border-left: 1px solid var(--line);
}
.atrank-df .atrank-df-seg label:first-child span {
	border-left: 0;
}
.atrank-df .atrank-df-seg input:checked + span {
	background: var(--accent);
	color: var(--on-accent);
}
.atrank-df .atrank-df-seg input:focus-visible + span {
	box-shadow: var(--ring);
}

.atrank-df .atrank-df-check {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 12.5px;
	color: var(--muted);
	cursor: pointer;
	white-space: nowrap;
}
.atrank-df .atrank-df-check input {
	width: 15px;
	height: 15px;
	accent-color: var(--accent);
	flex-shrink: 0;
}

.atrank-df .atrank-df-csvopts {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 14px;
	padding-left: 18px;
	border-left: 1px solid var(--line);
}

/* ── In and out ────────────────────────────────────────────────────────────
   Side by side past a breakpoint. Below it they stack, because two 300 px
   columns of code are two columns nobody can read. */
.atrank-df .atrank-df-panes {
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
	margin-top: 10px;
	align-items: start;
}
@media (min-width: 900px) {
	.atrank-df .atrank-df-panes {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.atrank-df .atrank-df-pane {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.atrank-df .atrank-cardhead {
	justify-content: space-between;
	flex-wrap: wrap;
}
.atrank-df .atrank-cardhead h2 {
	margin: 0;
	font-size: 13px;
	font-weight: 700;
	color: var(--accent);
	display: flex;
	align-items: center;
	gap: 7px;
}

.atrank-df .atrank-df-head-actions {
	display: inline-flex;
	gap: 6px;
}

/* A file input cannot be styled, so the button is its label. */
.atrank-df .atrank-df-filebtn {
	cursor: pointer;
}

.atrank-df .atrank-df-badge {
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.04em;
	padding: 2px 7px;
	border-radius: var(--r);
	background: var(--accent-soft);
	color: var(--accent);
}

/* wrap="off": the line structure IS the output of a formatter. */
.atrank-df .atrank-df-area {
	display: block;
	width: 100%;
	min-width: 0;
	min-height: var(--area-min);
	max-height: 60vh;
	resize: vertical;
	padding: 9px 11px;
	border: 1px solid var(--line2);
	border-radius: var(--r);
	background: var(--inset);
	color: var(--txt);
	font-family: var(--mono);
	font-size: var(--area-size);
	line-height: var(--area-line);
	tab-size: 2;
	overflow: auto;
	white-space: pre;
}
.atrank-df .atrank-df-area:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: var(--ring);
}
.atrank-df .atrank-df-area::placeholder {
	color: var(--dim);
	font-family: var(--font);
	white-space: normal;
}
.atrank-df .atrank-df-area[readonly] {
	background: var(--panel2);
}

.atrank-df .atrank-hint {
	margin: 7px 0 0;
}

/* ── The one action ───────────────────────────────────────────────────────
   Centred as a pair, so neither moves when the other one's label changes. */
.atrank-df .atrank-df-actions {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 12px;
}

/* ── What it found ────────────────────────────────────────────────────────
   A stack, deliberately not two columns: halving the width turns a one-line
   finding into two and the block gets TALLER, which is measured and recorded
   in the registry's density note. */
.atrank-df .atrank-df-tail {
	margin-top: 12px;
	display: grid;
	gap: 7px;
}

/* The offending line, with a caret under the column. Focusable, so a long line
   can be scrolled from the keyboard. */
.atrank-df .atrank-df-excerpt {
	margin: 6px 0 0;
	padding: 7px 9px;
	border-radius: var(--r);
	background: var(--inset);
	color: var(--txt);
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.45;
	white-space: pre;
	overflow-x: auto;
}
.atrank-df .atrank-df-excerpt:focus-visible {
	outline: none;
	box-shadow: var(--ring);
}

@media (max-width: 600px) {
	.atrank-df .atrank-df-csvopts {
		padding-left: 0;
		border-left: 0;
	}
	.atrank-df .atrank-df-actions > * {
		flex: 1 1 auto;
		justify-content: center;
	}
}
