/* DeRanklizer — one fluid column, no media queries */

/* Lato (SIL Open Font License, see fonts/OFL.txt), self-hosted so visitors' browsers make no requests to Google.
   Latin subset only; any character outside it falls back to the system sans-serif. */
@font-face { font-family: lato; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/lato-400.woff2) format("woff2"); }
@font-face { font-family: lato; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/lato-700.woff2) format("woff2"); }
@font-face { font-family: lato; font-weight: 900; font-style: normal; font-display: swap; src: url(fonts/lato-900.woff2) format("woff2"); }

:root {
	--deep: #353533;
	--dark: #494947;
	--lite: #D5D5CF;
	--soft: #BDBDB7;
	--mid: #959591;
	--gold: #FBB13C;
	--ink: #2B2B29;
	--row: 50px;   /* height of a candidate card */
	--gap: 8px;    /* space between cards; script.js reads --row and --gap */
	--pitch: calc(var(--row) + var(--gap));
}

*, *::before, *::after { box-sizing: border-box; }
body {
	margin: 0;
	background: var(--deep);
	color: var(--lite);
	font: 400 16px/1.4 lato, sans-serif;
	-webkit-text-size-adjust: 100%;
}
h1, h2, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }

/* Shell */
.panel {
	width: min(100% - 16px, 420px);
	margin: 8px auto 0;
	padding: 4px 16px 24px;
	background: var(--dark);
	border-radius: 12px;
}
.site-title {
	display: block;
	padding: 24px 0 14px;
	transform: rotate(-10deg);
}
.site-title img { display: block; width: 250px; max-width: 100%; height: auto; margin: 0 auto; }
.site-title.small { padding: 20px 0 20px; }
.site-title.small img { width: 175px; }

.foot {
	width: min(100% - 32px, 380px);
	margin: 16px auto 28px;
	font-size: 12px;
	text-align: center;
	color: var(--soft);
}
.foot img { display: block; margin: 16px auto 0; }
.foot .fine { padding-top: 10px; }

/* Landing */
.lede { margin-top: 6px; text-align: center; font-size: 17px; }
.steps { margin: 18px 0 0; counter-reset: step; }
.steps li { position: relative; padding: 4px 0 4px 34px; counter-increment: step; }
.steps li::before {
	content: counter(step);
	position: absolute; left: 0; top: 4px;
	width: 24px; height: 24px;
	display: grid; place-items: center;
	border-radius: 50%;
	background: var(--gold); color: var(--ink);
	font-size: 14px; font-weight: 900;
}
.group h2 {
	margin: 24px 0 8px;
	font-size: 12px; font-weight: 700;
	letter-spacing: .1em; text-transform: uppercase;
	color: var(--soft);
}
.subhead {
	margin: 8px 0 8px;
	font-size: 12px; font-weight: 700;
	letter-spacing: .1em; text-transform: uppercase;
	text-align:center;
	color: var(--soft);
}
.race-list a {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	min-height: 60px; margin-bottom: 8px; padding: 10px 8px 10px 16px;
	background: var(--lite); color: var(--ink);
	border-radius: 8px; box-shadow: 1px 2px 4px rgba(0, 0, 0, .35);
	font-weight: 700; text-decoration: none;
}
.race-list small { display: block; font-size: 13px; font-weight: 400; color: #55554F; }
.race-list a.touched small::after { content: " · Ranked ✓"; color: #2F6F2F; font-weight: 700; }
.race-list svg { flex: none; }

/* Race header */
.race-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.race-nav h1 {
	padding: 8px 0;
	border-block: 1px solid #000;
	text-align: center;
	font-size: 24px; line-height: 1.15; font-weight: 900;
	color: var(--lite);
}
.race-nav h1 small {
	display: block; margin-bottom: 2px;
	font-size: 12px; font-weight: 700;
	letter-spacing: .1em; text-transform: uppercase;
	color: var(--soft);
}
.nav-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--gold); }
.hint { margin: 12px 4px 0; text-align: center; font-size: 14px; color: var(--soft); }

/* The ranking board.
   Without JS the <ol> is an ordinary stacked list. Once script.js adds .ready,
   every card is absolutely placed at --i (its index) slots down, so the rank
   numbers and the orange line stay put while cards slide past them. */
.board { position: relative; margin-top: 18px; padding-left: 38px; }
.ballot { position: relative; }
.ballot li {
	display: flex; align-items: center;
	min-height: var(--row); margin-bottom: var(--gap);
	background: var(--lite); color: var(--ink);
	border: 1px solid transparent; border-radius: 6px;
	box-shadow: 1px 2px 4px rgba(0, 0, 0, .35);
	transition: background-color .2s, color .2s;
	-webkit-user-select: none; user-select: none;
	-webkit-touch-callout: none;
}
.ballot .name {
	flex: 1;
	padding: 0 4px 0 14px;
	font-size: 15.5px; line-height: 1.15; font-weight: 700;
}
.grip {
	flex: none; align-self: stretch; width: 52px;
	display: grid; place-items: center;
	padding: 0; border: 0; background: none;
	color: #85857F;
	touch-action: none;          /* the handle drags; the rest of the card scrolls the page */
}
.grip:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; border-radius: 6px; }

.ready { --span: calc(var(--n) * var(--pitch) - var(--gap)); }
.ready .ballot { height: var(--span); }
.ready .ballot li {
	position: absolute; top: 0; left: 0; right: 0;
	height: var(--row); margin: 0;
	transform: translateY(calc(var(--i) * var(--pitch)));
	cursor: grab;
	will-change: transform;
}
.animate .ballot li:not(.dragging) { transition: transform .2s ease, background-color .2s, color .2s; }

/* Cards below the line: still listed, but visibly "not ranked" */
.ballot li.out { background: #5F5F5C; color: var(--lite); border-color: #7A7A76; box-shadow: none; }
.ballot li.out .grip { color: var(--soft); }

.ballot li.dragging {
	z-index: 5;
	box-shadow: 0 12px 24px rgba(0, 0, 0, .5);
}
.is-dragging, .is-dragging * { cursor: grabbing !important; }

.rank {
	position: absolute; left: 0;
	top: calc(var(--i) * var(--pitch));
	width: 30px; height: var(--row);
	display: grid; place-items: center;
	font-size: 22px; font-weight: 900;
	color: var(--soft);
	opacity: 0; transition: opacity .25s;      /* revealed by .ranked, after the voter's first move */
}
.ranked .rank { opacity: 1; }

/* The orange line: fixed between slot 6 and slot 7. Only with more than 6 candidates, and only after the voter's first move. */
.ready.cut::after {
	content: "";
	position: absolute; left: 0; right: 0;
	top: calc(var(--slots) * var(--pitch) - var(--gap) / 2 - 2px);
	height: 4px; border-radius: 2px;
	background: var(--gold);
	pointer-events: none;
	opacity: 0; transition: opacity .25s;
}
.ready.cut.ranked::after { opacity: 1; }

/* Fallback for when script.js hasn't run (JS off or blocked). Nothing changes for the first 1.5s, so there's
   no flash while the script loads; after that the "needs JavaScript" message appears and the controls that
   only work with JS (.needs-js) collapse. script.js removes both the message and the .needs-js class as soon
   as it starts. (<noscript> isn't reliable when a browser toggles JS off.) */
.nojs { max-height: 0; margin: 0; overflow: hidden; opacity: 0; animation: nojs-show 0s 1.5s forwards; }
@keyframes nojs-show { to { max-height: 8em; margin-top: 16px; opacity: 1; } }
.needs-js { animation: needs-js-hide 0s 1.5s forwards; }
@keyframes needs-js-hide { to { max-height: 0; margin: 0; padding: 0; overflow: hidden; opacity: 0; } }

[hidden] { display: none !important; }

/* "Keep this order" (race pages, until the voter has ranked) */
.keep-cta { margin-top: 18px; }
.keep-btn {
	width: 100%; padding: 12px 8px;
	border: 2px solid var(--gold); border-radius: 8px;
	background: none; color: var(--gold);
	font-size: 15px; font-weight: 700; cursor: pointer;
}

/* Below the board */
.tools { margin-top: 20px; text-align: center; }
.linklike {
	padding: 8px; border: 0; background: none;
	font-size: 14px; color: var(--soft);
	text-decoration: underline; cursor: pointer;
}
.pager { display: flex; gap: 12px; margin-top: 8px; }
.pager a {
	flex: 1; padding: 13px 8px;
	border-radius: 8px;
	background: rgba(255, 255, 255, .09);
	text-align: center; font-size: 15px; font-weight: 700; text-decoration: none;
}
.pager a.next { background: var(--gold); color: var(--ink); }

.sr {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip-path: inset(50%); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.animate .ballot li:not(.dragging) { transition: none; }
}

/* Landing page: print button */
.print-cta { margin-top: 24px; text-align: center; }
.print-btn {
	width: 100%; padding: 13px 8px;
	border: 0; border-radius: 8px;
	background: var(--gold); color: var(--ink);
	font-size: 15px; font-weight: 700; cursor: pointer;
}

/* Printing. Only the home page has a printable sheet (built by script.js): logo, date, and each race's
   choices above the line. Everything else is hidden; a race page just points people to the home page. */
#sheet { display: none; }
@media print {
	@page { margin: .7in; }
	body { background: #fff; color: #000; }
	body > * { display: none !important; }
	body::before {
		content: "To print your choices, open the DeRanklizer home page and choose \201CPrint my choices.\201D";
		display: block; font-size: 14pt;
	}
	body.home::before { display: none; }
	body.home > #sheet { display: block !important; }

	#sheet img { display: block; width: 2.6in; height: auto; margin: 0 auto .18in; filter: brightness(.8); }
	#sheet h2 { margin: 0 0 .3in; text-align: center; font-size: 20pt; font-weight: 900; }
	#sheet > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: .4in; align-items: start; }   /* two columns under the logo and heading so it fits one page */
	#sheet .race { margin: 0 0 .26in; padding-top: .1in; border-top: 1.5pt solid #000; break-inside: avoid; }
	#sheet h3 { margin: 0 0 .06in; font-size: 15pt; font-weight: 900; }
	#sheet h3 small {
		display: block; font-size: 9pt; font-weight: 700;
		letter-spacing: .1em; text-transform: uppercase; color: #444;
	}
	#sheet ol { list-style: decimal; padding-left: 1.6em; font-size: 13pt; line-height: 1.5; }
	#sheet .none { font-size: 12pt; font-style: italic; color: #444; }
	#sheet .fine { margin-top: .2in; text-align: center; font-size: 9pt; color: #444; }
}
