/*
 *	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 with edit on, 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 */
.editing nav a, .editing 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 click anywhere on a header folds it, not only on the arrow */
nav .group > .row	{ cursor: pointer; }

/* 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; }

/* edit on a link is something to pick up, a click on it doesnt go anywhere */
.editing nav a	{ cursor: grab; }

/* while dragging the rows under the pointer stay quiet, the slot line is the only thing that should light up */
.sorting, .sorting nav a, .sorting nav .row	{ 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 two buttons on a group header, the full height of the row so theyre easy to hit, flex so the glyph sits on
   the first line of a wrapped header not in the middle of it */
.drop, .fold
{
	position:			absolute;
	top:				0;
	bottom:				0;
	width:				32px;
	display:			flex;
	align-items:		flex-start;
	font:				inherit;
	color:				#5c5c5c;
	background:			none;
	border:				none;
	border-radius:		0;
	-webkit-appearance:	none;
	appearance:			none;
	cursor:				pointer;
}

/* the fold, in the gutter left of the header where a link has its marker, so the label doesnt move */
.fold
{
	left:	-32px;
}

/* its ^ turned upside down while open, the glyph not the button, flex would move a turned button. turned about
   the middle of the ^ not of its line box, so it stays on the first line */
.fold span
{
	display:			block;
	transform-origin:	50% 50%;
}

.fold[aria-expanded="true"] span	{ transform: rotate(180deg); }

/* the x that takes a group off, at the right end of the header, edit on only */
.drop
{
	right:				0;
	display:			none;
	justify-content:	flex-end;
}

.editing .drop	{ display: flex; }

/* a header description can wrap, it keeps clear of the x */
nav .group > .row	{ padding-right: 32px; }

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

.folded > ul	{ display: none; }

/* edit on a header description types over, an empty one still needs something to click */
.editing nav .row .desc
{
	min-width:	64px;
	cursor:		text;
}

/* 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. a
   description being typed over looks the same */
#new[hidden]	{ display: none; }

#new input, nav .row 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, the edit button always and the rest only while edit is on */
#tools
{
	align-self:	flex-start;
}

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

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

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

/* login or logout, dressed like the tools buttons but small, up in the pages corner. the line height is 1 so the
   top is about where the letters start and the two margins read the same. a link, so the row look and its marker
   come off */
#auth
{
	position:		absolute;
	top:			16px;
	right:			16px;
	display:		block;
	padding:		0;
	font-size:		24px;
	line-height:	1;
	color:			#5c5c5c;
}

#auth[hidden]	{ display: none; }
#auth::before	{ content: none; }

/* a group headers description doesnt size the block, it runs on past the links instead, contained so the header
   counts for nothing. 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 .group > .row
	{
		grid-template-columns:	var(--col, var(--name)) max-content max-content;
		padding-right:			0;
		contain:				inline-size;
	}

	/* the x runs on after the description, 32px past it rather than a whole column gap */
	.drop
	{
		position:			static;
		margin-left:		calc(32px - max(16px, 5vw));
		margin-left:		calc(32px - round(max(16px, 5vw), 1px));
		justify-content:	flex-start;
	}

	/* an open one is as long as a description can be */
	nav .row input	{ width: 36ch; }
}

/* phone, 36px in on the left and 16px on the right where the text is ragged anyway. names and descriptions are
   one size, picked so each font pixel lands on whole screen pixels, 24px is 3 a font pixel on a 2x screen, the
   rows padded to about 32px so theyre still easy to tap and hold */
@media (max-width: 800px)
{
	:root
	{
		--name:	80px;
		--step:	16px;
	}

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

	a, .row
	{
		padding:	4px 0;
		font-size:	24px;
		column-gap:	26px;
	}

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

	/* both clear the rows padding, the fold takes the whole gutter so its easy to hit, its v sits where a link has
	   its marker */
	.drop, .fold	{ padding-top: 4px; }

	.fold
	{
		left:			-36px;
		width:			36px;
		padding-left:	20px;
	}

	#tools button	{ font-size: 16px; }
	#auth			{ font-size: 20px; }

}

/* a 3x screen, most iphones, 21.33px is 4 screen pixels a font pixel where 24 would be an uneven 4.5. the gap
   is 26px above as thats about all a 375px 2x phone has room for next to its longest description, the smaller
   text here leaves room for 32 */
@media (max-width: 800px) and (-webkit-min-device-pixel-ratio: 3), (max-width: 800px) and (min-resolution: 3dppx)
{
	a, .row
	{
		font-size:	calc(64px / 3);
		column-gap:	32px;
	}

	#auth	{ font-size: calc(56px / 3); }
}

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