/*
 * Equilibrium League task ledger.
 *
 * Direction: a scribe's account book kept in a dim room. Warm brown-black
 * ground, aged parchment ink, gold for anything worth points. The display face
 * (IM Fell English) appears only in the masthead and the two player names —
 * every number lives in mono, because this is fundamentally a ledger.
 * The two players are teal and rose throughout; those two colours never mean
 * anything else on this page.
 */

:root {
	--ink: #12100d;
	--ink-2: #191510;
	--panel: #201b14;
	--panel-hi: #292219;
	--line: #3b3125;
	--line-soft: #2a231a;

	--parchment: #ece2cd;
	--muted: #a0917a;
	--faint: #6d6150;

	--gold: #f2a93b;
	--gold-dim: #8a6323;

	--p1: #55c9b3;
	--p2: #e2739f;

	--easy: #8bba60;
	--medium: #5aa3dd;
	--hard: #dd7a4a;
	--elite: #a878d8;
	--master: #ecc84a;

	--display: "IM Fell English", "Iowan Old Style", Georgia, serif;
	--mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

	--gap: 1.25rem;
	--radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
	margin: 0;
	background:
		radial-gradient(120% 80% at 50% -10%, #1d1811 0%, transparent 60%),
		var(--ink);
	color: var(--parchment);
	font-family: var(--mono);
	font-size: 13px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration-color: var(--gold-dim); text-underline-offset: 2px; }

:focus-visible {
	outline: 2px solid var(--gold);
	outline-offset: 2px;
}

main {
	max-width: 1180px;
	margin: 0 auto;
	padding: 0 var(--gap) 4rem;
}

/* ---------- Masthead ---------- */

.masthead {
	max-width: 1180px;
	margin: 0 auto;
	padding: 2.25rem var(--gap) 1.5rem;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: flex-end;
	justify-content: space-between;
	border-bottom: 1px solid var(--line);
}

.masthead h1 {
	font-family: var(--display);
	font-weight: 400;
	font-size: clamp(2.4rem, 6vw, 3.6rem);
	line-height: 0.95;
	margin: 0;
	letter-spacing: 0.01em;
	color: var(--parchment);
}

.masthead-sub {
	margin: 0.5rem 0 0;
	color: var(--muted);
	font-size: 11px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.masthead-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.synced {
	margin: 0;
	color: var(--faint);
	font-size: 11px;
	text-align: right;
}

.synced.stale { color: var(--hard); }

.btn {
	font: inherit;
	font-size: 11px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--parchment);
	background: var(--panel-hi);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 0.6rem 0.9rem;
	cursor: pointer;
	transition: border-color 120ms ease, color 120ms ease;
}

.btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.btn[disabled] { opacity: 0.5; cursor: progress; }

.link-btn {
	font: inherit;
	font-size: 11px;
	background: none;
	border: 0;
	color: var(--muted);
	cursor: pointer;
	padding: 0.2rem 0.35rem;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.link-btn:hover { color: var(--gold); }

/* ---------- Scorecards ---------- */

.scores {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: var(--gap);
	margin: 1.75rem 0;
}

.card {
	background: linear-gradient(180deg, var(--panel) 0%, var(--ink-2) 100%);
	border: 1px solid var(--line);
	border-top: 2px solid var(--accent);
	border-radius: var(--radius);
	padding: 1.1rem 1.25rem 1.25rem;
}

.card-name {
	font-family: var(--display);
	font-size: 1.9rem;
	line-height: 1;
	margin: 0;
	color: var(--accent);
}

.card-meta {
	margin: 0.35rem 0 1rem;
	font-size: 11px;
	color: var(--faint);
}

.card-figures {
	display: flex;
	gap: 1.75rem;
	align-items: baseline;
	margin-bottom: 1rem;
}

.figure-value {
	font-size: 1.6rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--gold);
	display: block;
	line-height: 1.1;
}

.figure-value.plain { color: var(--parchment); }

.figure-label {
	font-size: 10px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.tier-bars { display: grid; gap: 0.3rem; }

.tier-bar {
	display: grid;
	grid-template-columns: 52px 1fr 62px;
	gap: 0.6rem;
	align-items: center;
	font-size: 10px;
	color: var(--muted);
}

.tier-bar-track {
	display: block;
	height: 5px;
	background: var(--line-soft);
	border-radius: 999px;
	overflow: hidden;
}

.tier-bar-fill {
	display: block;
	height: 100%;
	background: var(--tier);
	border-radius: 999px;
	transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tier-bar-count { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Drift ---------- */

.drift {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--ink-2);
	padding: 1.1rem 1.25rem 1.25rem;
	margin-bottom: var(--gap);
}

.drift-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	margin-bottom: 0.85rem;
}

.drift h2 {
	font-family: var(--display);
	font-weight: 400;
	font-size: 1.5rem;
	margin: 0;
	letter-spacing: 0.02em;
}

.drift-hint { margin: 0; color: var(--faint); font-size: 11px; }

.drift-bar {
	display: flex;
	height: 34px;
	border-radius: var(--radius);
	overflow: hidden;
	border: 1px solid var(--line);
	background: var(--panel);
}

.drift-seg {
	border: 0;
	padding: 0;
	cursor: pointer;
	background: var(--seg);
	position: relative;
	transition: flex-grow 400ms cubic-bezier(0.22, 1, 0.36, 1), filter 120ms ease;
	min-width: 2px;
}

.drift-seg + .drift-seg { border-left: 1px solid var(--ink); }
.drift-seg:hover { filter: brightness(1.25); }
.drift-seg[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--parchment); }

.drift-key {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1.1rem;
	margin-top: 0.7rem;
	font-size: 11px;
}

.key-item {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	background: none;
	border: 0;
	color: var(--muted);
	font: inherit;
	cursor: pointer;
	padding: 0.15rem 0;
}

.key-item:hover { color: var(--parchment); }
.key-item[aria-pressed="true"] { color: var(--parchment); }

.key-swatch {
	width: 10px;
	height: 10px;
	border-radius: 2px;
	background: var(--seg);
	flex: none;
}

.key-count { font-variant-numeric: tabular-nums; color: var(--parchment); }

/* ---------- Controls ---------- */

.controls {
	display: grid;
	gap: 0.9rem;
	padding: 1.1rem 1.25rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--ink-2);
	margin-bottom: var(--gap);
}

.control-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem 1.1rem;
}

.field { display: grid; gap: 0.3rem; }
.search-field { flex: 1 1 240px; }

.field-label {
	font-size: 10px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
}

input[type="search"], select {
	font: inherit;
	color: var(--parchment);
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 0.5rem 0.6rem;
	width: 100%;
}

input[type="search"]::placeholder { color: var(--faint); }

.toggle {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	color: var(--muted);
	cursor: pointer;
	font-size: 12px;
	user-select: none;
}

.toggle input { accent-color: var(--gold); }
.toggle:hover { color: var(--parchment); }

.chips-row { align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; flex: 1 1 auto; }

.chip {
	font: inherit;
	font-size: 11px;
	background: var(--panel);
	color: var(--faint);
	border: 1px solid var(--line-soft);
	border-radius: 999px;
	padding: 0.28rem 0.7rem;
	cursor: pointer;
	transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
	white-space: nowrap;
}

.chip:hover { color: var(--parchment); }

/* Tiers carry their own colour; regions stay quiet so the two do not compete. */
.chip[aria-pressed="true"] {
	color: var(--ink);
	background: var(--chip, var(--muted));
	border-color: var(--chip, var(--muted));
	font-weight: 500;
}

/* ---------- Ledger ---------- */

.ledger-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	padding: 0 0.25rem 0.6rem;
	color: var(--muted);
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.result-points { color: var(--gold); font-variant-numeric: tabular-nums; }
.ledger-head p { margin: 0; }

.ledger-hint {
	margin: 0 0 0.7rem;
	padding: 0 0.25rem;
	color: var(--faint);
	font-size: 11px;
}

.rows {
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--ink-2);
}

.row {
	display: grid;
	grid-template-columns: 30px 104px 76px minmax(0, 1fr) 66px 32px;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.75rem;
	border-left: 2px solid transparent;
	border-bottom: 1px solid var(--line-soft);
	cursor: pointer;
	transition: background 100ms ease;
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel); }

/* Divergence is the point of the page, so only divergence gets an edge mark.
   "Neither" is the resting state and stays unmarked; "both" recedes. */
.row.state-p1 { border-left-color: var(--p1); }
.row.state-p2 { border-left-color: var(--p2); }
.row.state-both { opacity: 0.45; }
.row.state-both:hover { opacity: 1; }

/* The sync glyph: top lozenge is player one, bottom is player two.
   Filled means done. Two hollow marks means it is still on the shared list. */
.glyph { display: grid; gap: 3px; justify-items: center; }

.pip {
	width: 14px;
	height: 5px;
	border-radius: 999px;
	border: 1px solid var(--pip);
	background: transparent;
}

.pip.on { background: var(--pip); }

.cell-region {
	font-size: 11px;
	color: var(--muted);
	display: flex;
	align-items: center;
	gap: 0.4rem;
	min-width: 0;
}

.cell-region span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.tier-chip {
	font-size: 10px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--tier);
	border: 1px solid color-mix(in srgb, var(--tier) 35%, transparent);
	background: color-mix(in srgb, var(--tier) 10%, transparent);
	border-radius: var(--radius);
	padding: 0.15rem 0.4rem;
	text-align: center;
}

.cell-name { min-width: 0; }

.task-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 12.5px;
}

.row.open .task-name { white-space: normal; }

.badge {
	font-size: 9px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--gold);
	border: 1px solid var(--gold-dim);
	border-radius: 2px;
	padding: 0 0.25rem;
	margin-left: 0.4rem;
	vertical-align: 1px;
}

.badge.clue { color: var(--medium); border-color: color-mix(in srgb, var(--medium) 50%, transparent); }

.cell-points {
	text-align: right;
	font-variant-numeric: tabular-nums;
	color: var(--gold);
	font-size: 12px;
}

.target-btn {
	font: inherit;
	font-size: 15px;
	line-height: 1;
	background: none;
	border: 0;
	color: var(--line);
	cursor: pointer;
	padding: 0.2rem;
	border-radius: var(--radius);
}

.target-btn:hover { color: var(--gold-dim); }
.target-btn[aria-pressed="true"] { color: var(--gold); }

/* Read-only viewers see which tasks are targeted, but cannot change them. */
.target-btn.read-only { color: var(--gold); cursor: default; text-align: center; }

.detail {
	grid-column: 1 / -1;
	display: grid;
	gap: 0.4rem;
	padding: 0.15rem 0 0.5rem 0.25rem;
	border-left: 1px solid var(--line);
	padding-left: 0.9rem;
	margin-left: 0.15rem;
	color: var(--muted);
	font-size: 12px;
}

.detail-line { margin: 0; }
.detail-label { color: var(--faint); letter-spacing: 0.1em; text-transform: uppercase; font-size: 10px; }
.detail-who { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 11px; }
.detail-who b { font-weight: 500; }

.empty {
	padding: 2rem 1rem;
	text-align: center;
	color: var(--faint);
}

/* ---------- Footer ---------- */

footer {
	max-width: 1180px;
	margin: 0 auto;
	padding: 1.5rem var(--gap) 3rem;
	border-top: 1px solid var(--line-soft);
	color: var(--faint);
	font-size: 11px;
}

footer p { margin: 0.3rem 0; }

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

@media (max-width: 720px) {
	.row {
		grid-template-columns: 26px minmax(0, 1fr) 56px 30px;
		row-gap: 0.25rem;
	}
	.cell-region { grid-column: 2 / -1; order: 3; }
	.tier-chip { display: none; }
	.masthead { padding-top: 1.5rem; }
	.masthead-actions { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---------- tabs ---------- */

.tabs {
	display: flex;
	gap: 0.4rem;
	margin: var(--gap) 0 0.8rem;
	border-bottom: 1px solid var(--line-soft);
}

.tab {
	font: inherit;
	font-family: var(--display);
	font-size: 15px;
	background: none;
	color: var(--faint);
	border: 1px solid transparent;
	border-bottom: none;
	border-radius: var(--radius) var(--radius) 0 0;
	padding: 0.35rem 1rem;
	margin-bottom: -1px;
	cursor: pointer;
	transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tab:hover { color: var(--parchment); }

.tab[aria-pressed="true"] {
	color: var(--gold);
	background: var(--panel);
	border-color: var(--line);
	border-bottom: 1px solid var(--panel);
}

/* ---------- goals ---------- */

.badge.approx {
	color: var(--muted);
	border-color: var(--line);
	cursor: help;
}

.goals .ledger-head { align-items: center; }

.goal-row {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) minmax(0, 20rem);
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.75rem;
	border-left: 2px solid transparent;
	border-bottom: 1px solid var(--line-soft);
}

.goal-row:hover { background: var(--panel-hi); }

.goal-short {
	font-variant-numeric: tabular-nums;
	text-align: right;
	color: var(--gold);
	font-size: 13px;
}

.goal-main { min-width: 0; }

.goal-meta {
	display: block;
	color: var(--faint);
	font-size: 11px;
	margin-top: 0.15rem;
}

.goal-reqs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	justify-content: flex-end;
}

.goal-req {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	font-size: 11px;
	background: var(--panel);
	border: 1px solid var(--line-soft);
	border-radius: var(--radius);
	padding: 0.15rem 0.45rem;
	white-space: nowrap;
}

.goal-skill { color: var(--parchment); }
.goal-level { color: var(--faint); font-variant-numeric: tabular-nums; }
.goal-gap { color: var(--gold); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
	.goal-row { grid-template-columns: 40px minmax(0, 1fr); }
	.goal-reqs { grid-column: 2; justify-content: flex-start; }
}
