/*
 *	style.css | Finn Le Var
 */

*
{
	margin:		0;
	padding:	0;
	box-sizing:	border-box;
}

/* monogram extended, a pixel font, self hosted so the page makes no outside requests
   it is drawn on a 16px grid so every size here is a multiple of 16 to stay crisp */
@font-face
{
	font-family:	"Monogram";
	src:			url(../../fonts/monogram-extended.ttf) format("truetype");
	font-display:	swap;
}

html, body
{
	min-height:	100%;
}

/* the scrollbar a long logged in list brings takes room on both sides, so the centre doesnt move when it shows */
html
{
	scrollbar-gutter:	stable both-edges;
}

body
{
	background-color:	black;
	color:				#8c8c8c;
	font-family:		"Monogram", monospace;
	font-size:			32px;
	line-height:		1.125;
	-webkit-font-smoothing:	none;
}

/*
 *	background
 */

/* sits behind everything and never scrolls */
#bg
{
	position:	fixed;
	inset:		0;
	z-index:	-1;
}

.layer
{
	position:			absolute;
	inset:				0;
	image-rendering:	pixelated;
}

/* each layer drifts twice as fast as the one behind it, so we get parallax */
.bg01 { background-image: url(../../img/bg01.png); animation: drift_y 120s infinite linear, sway_x 60s infinite ease-in-out; }
.bg02 { background-image: url(../../img/bg02.png); animation: drift_y 60s infinite linear, sway_x 30s infinite ease-in-out; }
.bg03 { background-image: url(../../img/bg03.png); animation: drift_y 30s infinite linear, sway_x 15s infinite ease-in-out; }

/* darkens the edges so the text in the middle stays readable */
.vignette
{
	background: radial-gradient(circle, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 1) 100%);
}

/* scrolls exactly two tiles so the loop has no seam */
@keyframes drift_y
{
	0%		{ background-position-y: 1024px;	}
	100%	{ background-position-y: -1024px;	}
}

@keyframes sway_x
{
	0%		{ background-position-x: 0px;	}
	50%		{ background-position-x: 50px;	}
	100%	{ background-position-x: 0px;	}
}

/* just in case someone has motion turned off */
@media (prefers-reduced-motion: reduce)
{
	.layer { animation: none; }
}

/*
 *	content
 */

/* the name column and how far a groups links step in, the children get the column minus the step
   so every description starts at the same x */
:root
{
	--name:	192px;
	--step:	32px;
}

/* one block as wide as its longest row, centred both ways, svh so the ios bars dont push it off */
main
{
	width:			fit-content;
	max-width:		100%;
	min-height:		100vh;
	min-height:		100svh;
	margin:			0 auto;
	padding:		48px 32px;
	display:		flex;
	flex-direction:	column;
	justify-content:center;
	gap:			32px;
	text-shadow:	0 0 8px black, 0 0 16px black;
}

h1
{
	font-size:		32px;
	font-weight:	normal;
	color:			#d2738a;
}

ul
{
	list-style:	none;
}

/* the gated rows, safety in case a li ever gets a display */
[hidden]	{ display: none; }

/* one row per link, name then description, no boxes, the type does the work. the gap is the same at both
   levels so the descriptions still line up, rounded to a whole pixel where round() is in, plain 5vw where not */
a, .row
{
	position:			relative;
	display:			grid;
	grid-template-columns:	var(--col, var(--name)) 1fr;
	column-gap:			max(16px, 5vw);
	column-gap:			round(max(16px, 5vw), 1px);
	align-items:		baseline;
	text-decoration:	none;
	color:				inherit;
}

/* only once dragging is on, logged in, so everyone else keeps the normal long press and selection. nav only, the
   new group form is a row too and safari wont type into an input that cant be selected */
.editable nav a, .editable nav .row
{
	user-select:		none;
	-webkit-user-select:	none;
	-webkit-touch-callout:	none;
}

.name	{ color: #e8e8e8; }

/* a group header is a label not a link, so its name sits dimmer than the links under it */
.row .name	{ color: #5c5c5c; }
.row .desc	{ color: #5c5c5c; }

/* a third of a line either side of a group, enough to read as one block without stretching the list */
.group
{
	margin:	12px 0;
}

.group ul
{
	padding-left:	var(--step);
	--col:			calc(var(--name) - var(--step));
}

/* the marker lives in the gutter left of the name, absolute so showing it shifts nothing */
a::before
{
	content:	">";
	position:	absolute;
	left:		-32px;
	color:		#d2738a;
	visibility:	hidden;
}

a:hover .name, a:focus-visible .name	{ color: #d2738a; }
a:hover::before, a:focus-visible::before	{ visibility: visible; }

/* the marker and the pink are the focus ring */
a:focus-visible
{
	outline:	none;
}

/*
 *	reordering
 */

/* the row being dragged stays where it is and fills pink, square to match the pixels. the shadows push the
   fill out past the text either side without moving anything */
.dragging
{
	background-color:	#d2738a;
	box-shadow:			-8px 0 0 #d2738a, 8px 0 0 #d2738a;
	text-shadow:		none;
}

nav .dragging .name, nav .dragging .desc	{ color: black; }
a.dragging::before							{ visibility: hidden; }

/* while dragging the rows under the pointer stay quiet, the slot line is the only thing that should light up */
.sorting, .sorting a	{ cursor: grabbing; }
.sorting a:hover:not(.dragging) .name		{ color: #e8e8e8; }
.sorting a:hover::before					{ visibility: hidden; }

/* the drop slot, 8px dashes as a gradient so they land on whole pixels, a dashed border wont */
#slot
{
	position:		absolute;
	height:			2px;
	background:		repeating-linear-gradient(90deg, #d2738a 0 8px, transparent 8px 16px);
	pointer-events:	none;
}

/* the label that follows the pointer, the name and a dim line saying where it goes */
#ghost
{
	position:			fixed;
	left:				0;
	top:				0;
	z-index:			10;
	padding:			4px 12px 6px;
	background-color:	#141414;
	border:				2px solid #2e2e2e;
	white-space:		nowrap;
	pointer-events:		none;
}

#ghost .name	{ display: block; }
#ghost .hint	{ display: block; font-size: 16px; color: #6c6c6c; }

/* the x that takes a group off, in the gutter left of its header where a link has its marker, the full height of
   the row so its easy to hit, logged in only */
.drop
{
	position:			absolute;
	left:				-32px;
	top:				0;
	bottom:				0;
	width:				32px;
	display:			none;
	font:				inherit;
	text-align:			left;
	color:				#5c5c5c;
	background:			none;
	border:				none;
	border-radius:		0;
	-webkit-appearance:	none;
	appearance:			none;
	cursor:				pointer;
}

.editable .drop	{ display: block; }

.drop:hover, .drop:focus-visible, .armed .drop
{
	color:		#d2738a;
	outline:	none;
}

/* pressed once, the header goes pink and its description says to press again */
nav .armed .name, nav .armed .desc	{ color: #d2738a; }

/* the new group form, the inputs sit where the header text will, underlined in 8px dashes like the slot line */
#new[hidden]	{ display: none; }

#new input
{
	min-width:			0;
	width:				100%;
	padding:			0;
	font:				inherit;
	color:				#e8e8e8;
	caret-color:		#d2738a;
	background:			repeating-linear-gradient(90deg, #d2738a 0 8px, transparent 8px 16px) bottom / 100% 2px no-repeat;
	border:				none;
	border-radius:		0;
	outline:			none;
	-webkit-appearance:	none;
	appearance:			none;
}

#new input::placeholder
{
	color:		#5c5c5c;
	opacity:	1;
}

/* sits under the list, logged in only, reset only once the page isnt the default */
#tools
{
	align-self:	flex-start;
}

#tools:not([hidden])
{
	display:	flex;
	gap:		32px;
}

#tools button
{
	font:				inherit;
	font-size:			16px;
	color:				#5c5c5c;
	background:			none;
	border:				none;
	border-radius:		0;
	-webkit-appearance:	none;
	appearance:			none;
	cursor:				pointer;
}

#tools button:hover, #tools button:focus-visible
{
	color:		#d2738a;
	outline:	none;
}

/* a group headers description doesnt size the block, it runs on past the links instead. the docs one is the
   longest line on the page, so counting it put the bright text left of centre. wide windows only, a narrower
   one hasnt the room either side for it to run into */
@media (min-width: 1100px)
{
	nav .row .desc
	{
		width:			0;
		white-space:	nowrap;
	}
}

/* phone, a 16px gutter, names and descriptions both 16px so the long ones still fit on one line, the rows padded
   back up to the 32px they were so theyre still easy to tap and hold */
@media (max-width: 800px)
{
	:root
	{
		--name:	96px;
		--step:	16px;
	}

	main
	{
		width:		auto;
		padding:	48px 16px;
	}

	a, .row
	{
		padding:	7px 0;
		font-size:	16px;
	}

	a::before	{ left: -16px; }

	/* the gutter is too thin for it, so it goes to the right end of the header instead */
	.drop
	{
		left:		auto;
		right:		0;
		width:		32px;
		text-align:	right;
	}
}

/* a group everything was dragged out of, kept while dragging is on so it can be dropped back into */
body:not(.editable) .group.bare	{ display: none; }
