/* Hatnotes — a standalone page in Wikipedia's visual vocabulary:
   their grays and link colors, serif headings over sans body. */

:root {
	--paper: #f8f9fa;
	--sheet: #ffffff;
	--border: #a2a9b1;
	--border-soft: #c8ccd1;
	--hairline: #eaecf0;
	--ink: #202122;
	--muted: #54595d;
	--faint: #72777d;
	--link: #3366cc;
	--visited: #795cb2;
	--blue-soft: #eaf3ff;
	--src: #3366cc;
	--serif: "Linux Libertine", "Libertinus Serif", Georgia, "Times New Roman", serif;
	--sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	padding: 24px 16px 48px;
	background: var(--paper);
	color: var(--ink);
	font: 14px/1.6 var(--sans);
}

.sheet {
	max-width: 1060px;
	margin: 0 auto;
	background: var(--sheet);
	border: 1px solid var(--border-soft);
	padding: 28px 36px 32px;
}

a { color: var(--link); text-decoration: none; }
a:visited { color: var(--visited); }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible {
	outline: 2px solid var(--link);
	outline-offset: 1px;
}

h1 {
	font-family: var(--serif);
	font-weight: normal;
	font-size: 30px;
	line-height: 1.25;
	margin: 0 0 8px;
	padding-bottom: 4px;
	border-bottom: 1px solid var(--border);
}

/* intro, styled the way Wikipedia styles the hatnotes themselves */
.intro {
	font-style: italic;
	color: var(--muted);
	font-size: 13.5px;
	padding-left: 1.6em;
}
.intro p { margin: 0 0 8px; }

/* ---------- toolbar: sort, filter, search ---------- */

.toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin: 16px 0 6px;
}

.dd { position: relative; }

.dd-btn {
	background: var(--sheet);
	color: var(--ink);
	border: 1px solid var(--border);
	border-radius: 2px;
	font: 600 13.5px var(--sans);
	padding: 6px 12px;
	cursor: pointer;
}
.dd-btn:hover { background: var(--blue-soft); }
#sort-val { font-weight: 400; }
.caret { margin-left: 6px; color: var(--muted); font-size: 11px; }

.dd-panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 40;
	background: var(--sheet);
	border: 1px solid var(--border);
	border-radius: 2px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	min-width: max-content;
	padding: 6px;
}
#filter-panel { min-width: 300px; }

.sec {
	font-size: 11px;
	font-weight: 700;
	color: var(--muted);
	padding: 4px 8px 2px;
}

.opt {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 8px;
	border-radius: 2px;
}
.opt:hover { background: var(--blue-soft); }
.opt label {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1;
	cursor: pointer;
	font-size: 13px;
}
.opt label input { accent-color: var(--link); margin: 0; }
.opt-n { margin-left: auto; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }

.opt-btn {
	flex: 1;
	text-align: left;
	background: none;
	border: 0;
	font: 13.5px var(--sans);
	color: var(--ink);
	padding: 3px 0;
	cursor: pointer;
}
.opt.sel .opt-btn { font-weight: 700; color: var(--link); }

.opt-num label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
#f-minviews {
	width: 72px;
	background: var(--sheet);
	color: var(--ink);
	border: 1px solid var(--border);
	border-radius: 2px;
	padding: 3px 6px;
	font: 13px var(--sans);
}
#f-minviews:focus-visible { outline: none; border-color: var(--link); }

.dd-links { display: flex; gap: 12px; padding: 3px 8px 5px; }
.dd-hr { border: 0; border-top: 1px solid var(--hairline); margin: 5px 0; }

.linkish {
	background: none;
	border: 0;
	color: var(--link);
	cursor: pointer;
	font: 12.5px var(--sans);
	padding: 0;
}
.linkish:hover { text-decoration: underline; }

/* info icon + tooltip */
.info {
	position: relative;
	display: inline-flex;
	color: var(--faint);
	cursor: help;
	flex: none;
}
.info:hover, .info:focus-visible { color: var(--link); outline: none; }
.tipbox {
	display: none;
	position: absolute;
	top: calc(100% + 6px);
	right: -6px;
	width: 260px;
	background: var(--ink);
	color: #fff;
	font: 12px/1.45 var(--sans);
	padding: 7px 9px;
	border-radius: 2px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
	white-space: normal;
	z-index: 60;
}
.info:hover .tipbox, .info:focus-visible .tipbox { display: block; }

#search {
	flex: 1;
	min-width: 170px;
	max-width: 320px;
	background: var(--sheet);
	color: var(--ink);
	border: 1px solid var(--border);
	border-radius: 2px;
	padding: 6px 10px;
	font: 13.5px var(--sans);
}
#search:focus-visible { outline: none; border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); }
#search::placeholder { color: var(--faint); }

/* ---------- results ---------- */

.count {
	display: flex;
	justify-content: flex-end;
	margin: 10px 2px 4px;
}
.legend { font-size: 12px; color: var(--faint); }
.legend i { display: inline-block; width: 9px; height: 9px; margin: 0 4px 0 10px; }
.legend .s { background: var(--src); border-radius: 50%; }
.legend .d {
	width: 0;
	height: 0;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	border-right: 8.7px solid var(--src);
}
.legend.dir-right .d {
	border-right: none;
	border-left: 8.7px solid var(--src);
}

.rows { border-top: 1px solid var(--border-soft); }
.row {
	display: grid;
	grid-template-columns: 100px 1fr 200px;
	gap: 4px 20px;
	padding: 13px 2px 12px;
	border-bottom: 1px solid var(--hairline);
	align-items: start;
}
.row > div { min-width: 0; }
.rank { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.ratio {
	font-family: var(--serif);
	font-size: 19px;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	color: var(--src);
}

.pair { font-size: 15px; line-height: 1.7; min-height: 3.4em; }
.pair .sect { color: var(--muted); font-size: 13.5px; }
.pair .v {
	color: var(--muted);
	font-size: 12.5px;
	font-variant-numeric: tabular-nums;
}
.pair .conn { color: var(--faint); font-size: 12px; }
.pill {
	display: inline-block;
	font-size: 11.5px;
	font-style: normal;
	line-height: 1.5;
	padding: 0 9px;
	border-radius: 10px;
	background: var(--blue-soft);
	color: var(--link);
	border: 1px solid var(--link);
	vertical-align: 1px;
	white-space: nowrap;
}

.hat {
	font-family: var(--mono);
	font-size: 11.5px;
	color: var(--muted);
	background: var(--paper);
	border: 1px solid var(--hairline);
	padding: 4px 9px;
	margin-top: 7px;
	border-radius: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.db { margin-top: 5px; }
.db svg { width: 100%; height: 34px; display: block; overflow: visible; }
.db .axis { stroke: var(--border-soft); stroke-width: 1; }
.db .tick { fill: var(--faint); font: 9px var(--sans); }
.db .join { stroke-width: 2; opacity: 0.45; }
.db .ps { fill: var(--src); }
.db .pd { fill: var(--src); }

#more {
	display: block;
	margin: 22px auto 0;
	cursor: pointer;
	background: var(--sheet);
	color: var(--ink);
	border: 1px solid var(--border);
	border-radius: 2px;
	font: 600 13.5px var(--sans);
	padding: 8px 24px;
}
#more:hover { background: var(--blue-soft); }
#more[hidden] { display: none; }

.none {
	padding: 36px 0;
	color: var(--faint);
	text-align: center;
	font-style: italic;
	font-family: var(--serif);
	font-size: 16px;
}

/* article hover preview card */
#preview {
	position: fixed;
	z-index: 100;
	width: 320px;
	background: var(--sheet);
	border: 1px solid var(--border);
	border-radius: 2px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
	overflow: hidden;
}
#preview img {
	display: block;
	width: 100%;
	max-height: 180px;
	object-fit: cover;
	border-bottom: 1px solid var(--hairline);
}
.pv-body { padding: 10px 12px; }
.pv-title { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.pv-desc { font-size: 12px; color: var(--muted); margin-top: 1px; }
.pv-extract {
	font-size: 13px;
	line-height: 1.5;
	margin-top: 6px;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
	max-height: 9.75em;
}

.foot {
	margin-top: 36px;
	border-top: 1px solid var(--hairline);
	padding-top: 10px;
	font-size: 12px;
	color: var(--faint);
}
.foot p { margin: 0 0 6px; }

@media (max-width: 760px) {
	.sheet { padding: 20px 16px 24px; }
	.row { grid-template-columns: 1fr; gap: 3px; }
	.db { max-width: 250px; }
	.count { justify-content: flex-start; }
	/* anchor dropdown panels to the toolbar so they can't overflow the
	   viewport on narrow screens */
	.toolbar { position: relative; }
	.dd { position: static; }
	.dd-panel { left: 0; right: 0; min-width: 0; }
	#filter-panel { min-width: 0; }
	.tipbox { width: 210px; }
}
