@import "theme.css";

:root {
	--content-width: 900px;
	--thumbnail-width: 300px;
	--thumbnail-height: 100px;

	/*
	--colorize: invert(10%) sepia(61%) saturate(5017%) hue-rotate(323deg) brightness(90%) contrast(109%);
	*/
	--colorize: invert(59%) sepia(71%) saturate(3270%) hue-rotate(327deg) brightness(100%) contrast(99%);

	--line-color: #ccc;
	--tree-expander: 0px;
	--functions-width: 150px;
}

html {
	background-color: #fff;
}

.colorize {
	filter: var(--colorize);
}

/* ------------------------------------- *
* Default application grid in wide mode *
* ------------------------------------- */
#notes2 {
	min-height: 100vh;

	display: grid;
	grid-template-areas:
		"tree-expander tree pad1 crumbs  crumbs    pad2"
		"tree-expander tree pad1 name    functions pad2"
		"tree-expander tree pad1 content content   pad2"
	;

	grid-template-columns:
		/* Tree-expander */
		var(--tree-expander)
		/* Tree */
		min-content minmax(32px, 1fr)
		/* Sync */
		minmax(min-content, calc(var(--content-width) - var(--functions-width)))
		/* Functions */
		var(--functions-width)
		/* Content */
		minmax(32px, 1fr);

	grid-template-rows:
		/* Crumbs */
		min-content
		/* Name */
		min-content
		/* Content */
		1fr;

	/* Tree expander is collapsed as default */
	--tree-expander: 0px;

	&.hide-tree {
		--tree-expander: 32px;

		#tree {
			border-right: none;
		}

		n2-tree {
			display: none;

		}
	}
}

/* ------------------------------- *
 * Application grid in narrow mode *
 * ------------------------------- */
@media only screen and (max-width: 800px) {
	#notes2 {
		grid-template-areas:
			"tree-expander pad1 crumbs    crumbs    pad2"
			"tree-expander pad1 name      functions pad2"
			"tree-expander pad1 content   content   pad2"
		;
		grid-template-columns: 32px 16px 1fr var(--functions-width) 16px;

		&.show-tree {
			grid-template-areas: "tree";
			grid-template-columns: 100%;
			grid-template-rows: 1fr;

			#tree {
				display: grid;
				width: 100%;
			}

			#main-page,
			#show-tree {
				display: none;
			}
		}

		#tree {
			display: none;
		}
	}
}

#tree-expander {
	grid-area: tree-expander;
	color: #333;
	background-color: #eee;
	font-weight: bold;
	border-right: 1px solid var(--line-color);

	display: grid;
	justify-items: center;
	align-items: start;

	padding-top: 8px;
	font-size: 1.25em;

	div div {
		display: inline-block;
		writing-mode: vertical-rl;
		transform: rotate(180deg);
	}
}


#tree {
	grid-area: tree;
	display: grid;
	background-color: #ffffff;
	color: #444;
	z-index: 100;

	border-right: 1px solid var(--line-color);

	n2-tree {
		.el-treenodes {
			margin: 24px 32px 32px 32px;
		}
	}

	.node {
		display: grid;
		grid-template-columns: 40px min-content;
		grid-template-rows:
			min-content 1fr;
		margin-top: 12px;
		align-items: center;

		.expand-toggle {
			user-select: none;
			cursor: pointer;
			justify-self: center;

			img {
				width: auto;
				height: 18px;
			}
		}

		.name {
			white-space: nowrap;
			cursor: pointer;
			user-select: none;

			&:hover {
				color: var(--color1);
			}

			&.selected {
				color: var(--color1);
				font-weight: bold;
			}

		}

		.children {
			padding-left: 24px;
			margin-left: 18px;
			border-left: 1px solid #ddd;
			grid-column: 1 / -1;

			&.collapsed {
				display: none;
			}
		}
	}
}

[id^="page-"] {
	display: none;
}

#main-page {
	display: contents;

	&:focus-within {
		background-color: #faf;
	}

	&.node {
		#page-node {
			display: contents;
		}
	}

	&.storage {
		#page-storage {
			display: contents;

			n2-pagestorage {
				grid-area: content;
			}
		}
	}

	&.history {
		#page-history {
			display: contents;

			n2-pagehistory {
				grid-area: content;
			}
		}
	}
}

#crumbs {
	grid-area: crumbs;
	display: grid;
	align-items: start;
	justify-items: start;
	height: min-content;
	margin: 0 16px 16px 0px;

	n2-crumbs {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		padding: 16px 0px;
		color: #333;
		border-bottom-left-radius: 5px;
		border-bottom-right-radius: 5px;

		n2-crumb {
			margin-right: 8px;
			cursor: pointer;
			user-select: none;
			-webkit-tap-highlight-color: transparent;

			a {
				text-decoration: none;
				color: inherit;
			}
		}


		n2-crumb:before {
			content: ">";
			font-weight: bold;
			color: var(--color1)
		}


		n2-crumb.home {
			&:before {
				content: '';
				margin-left: 0px;
			}

			img {
				height: 24px;
			}
		}
	}

}

n2-syncprogress {
	--radius: 8px;

	display: grid;
	grid-area: sync;
	display: grid;
	justify-items: center;
	align-items: center;

	position: relative;

	opacity: 0;
	transition: height 0s 500ms, opacity 500ms linear, visibility 0s 500ms;

	&.show {
		opacity: 1;
		transition: visibility, height 0s, opacity 500ms linear;
	}

	progress {
		width: 100%;
		height: 24px;
		border-radius: 8px;
	}

	.count {
		position: absolute;
		top: 16px;
		width: 100%;
		white-space: nowrap;
		color: #888;
		text-align: center;
		font-size: 12pt;
		font-weight: bold;
	}

	progress[value]::-webkit-progress-bar {
		background-color: #eee;
		box-shadow: 0 2px var(--radius) rgba(0, 0, 0, 0.25) inset;
		border-radius: var(--radius);
	}

	progress[value]::-moz-progress-bar {
		background-color: #eee;
		box-shadow: 0 2px var(--radius) rgba(0, 0, 0, 0.25) inset;
		border-radius: var(--radius);
	}

	progress[value]::-webkit-progress-value {
		background: rgb(186, 95, 89);
		background: linear-gradient(180deg, rgba(186, 95, 89, 1) 0%, rgba(254, 95, 85, 1) 50%, rgba(186, 95, 89, 1) 100%);
		border-radius: var(--radius);
	}

	progress[value]::-moz-progress-value {
		background: rgb(186, 95, 89);
		background: linear-gradient(180deg, rgba(186, 95, 89, 1) 0%, rgba(254, 95, 85, 1) 50%, rgba(186, 95, 89, 1) 100%);
		border-radius: var(--radius);
	}

}

/* ============================================================= */

n2-nodeui {
	margin-bottom: 32px;

	&.node-modified:before {
		content: 'h';
		z-index: 8192;
		position: fixed;
		top: 0px;
		left: 0px;
		right: 0px;
		height: 4px;

		background-color: var(--color1);
		color: var(--color2);
	}

	.el-name {
		grid-area: name;
		color: #333;
		font-weight: bold;
		font-size: 1.75em;
		margin-top: 8px;
		margin-bottom: 0px;
	}

	.el-functions {
		grid-area: functions;
		justify-self: end;
		align-self: end;
		margin-bottom: 6px;
	}

	.el-node-content {
		grid-area: content;
		justify-self: center;
		word-wrap: break-word;
		font-family: monospace;
		font-size: 1em;
		color: #333;

		width: 100%;
		max-width: var(--content-width);
		field-sizing: content;

		resize: none;
		outline: none;

		padding: 32px 0;
		border-left: none;
		border-right: none;
		border-top: 1px solid #e0e0e0;
		border-bottom: none;
		margin-top: 8px;
		margin-bottom: 32px;
	}

	.el-node-markdown {
		grid-area: content;
		display: none;

		border-top: 1px solid #e0e0e0;
		margin-top: 8px;
		margin-bottom: 32px;

		overflow-wrap: anywhere;
	}

	&.show-markdown {
		.el-node-content {
			display: none;
		}

		.el-node-markdown {
			display: block;
		}
	}
}

#blank {
	grid-area: blank;
	height: 32px;
}

dialog.op {
	&::backdrop {
		background: rgba(0, 0, 0, 0.5);
	}

	.header {
		font-weight: bold;
		margin-top: 16px;

		&:first-child {
			margin-top: 0px;
		}
	}

}

#op-search {
	.results {
		display: grid;
		grid-template-columns: min-content min-content;
		grid-gap: 6px 16px;

		div {
			white-space: nowrap;
		}


		.ancestors {
			display: flex;

			.ancestor::after {
				content: ">";
				margin: 0px 8px;
				color: #a00;
			}

			.ancestor:last-child::after {
				content: "";
			}
		}
	}
}


/* ------------------------------------------- *
 * Whole page is 100vh with scrolling sections *
 * ------------------------------------------- */
#app.full-height {
	#notes2 {
		height: 100vh;


	}

	#tree {
		n2-tree {
			.el-treenodes {
				height: calc(100vh - 64px - 64px);
				margin: 0px;
				padding: 12px 32px 32px 32px;
				overflow-y: auto;

				&::-webkit-scrollbar {
					display: none;
				}

				-ms-overflow-style: none;
				scrollbar-width: none;
			}
		}
	}

	n2-nodeui {
		.el-node-markdown {
			overflow-y: scroll;

			&::-webkit-scrollbar {
				display: none;
			}

			-ms-overflow-style: none;
			scrollbar-width: none;
		}
	}
}





n2-pagehistory {
	.layout {
		display: grid;
		grid-template-columns: min-content 1fr;
		grid-gap: 8px;
		align-items: center;

		.el-back-image,
		.el-back-text {
			cursor: pointer;
		}

		.el-node-name {
			margin-left: 8px;
		}

		.el-nodes {
			grid-column: 1 / -1;

			display: grid;
			grid-template-columns: min-content 1fr;
			grid-gap: 4px 8px;

			.history-node {
				display: contents;
			}
		}

		.pagination {
			grid-column: 1 / -1;
			margin-top: 16px;

			display: grid;
			grid-template-columns: repeat(3, min-content);
			grid-gap: 32px;
			white-space: nowrap;
			user-select: none;

			.el-prev {
				font-weight: bold;
				cursor: pointer;
			}

			.el-next {
				font-weight: bold;
				cursor: pointer;
			}
		}
	}
}
