@import "theme.css";

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

	--colorize: invert(59%) sepia(71%) saturate(3270%) hue-rotate(327deg) brightness(100%) contrast(99%);

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

	--menu-color: #fff;
	--menu-item-hover-color: #f4f4f4;

	--font-monospace: "Liberation Mono", monospace;

	--markdown-copy-border: 1px solid #0a0;
	--markdown-copy-background: #e3f4d7;
}

html {
	background-color: #fff;
}

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

textarea {
	font-family: var(--font-monospace);
}

button {
	font-size: 1em;
	padding: 4px 8px;
}

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

	display: grid;

	&.page-node {
		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;
	}

	/* The other pages just gets the whole page without dividing it up. */
	&:not(.page-node) {
		grid-template-areas:
			"tree-expander tree pad1 n2-page pad2"
		;

		grid-template-columns:
			/* Tree-expander */
			var(--tree-expander)
			/* Tree */
			min-content
			/* pad1 */
			32px
			/* Content */
			1fr
			/* pad2 */
			32px;

		grid-template-rows: 1fr;
	}


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

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

		#tree {
			border-right: none;
		}

		n2-sidebar {
			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-sidebar {
		display: grid;
		grid-template-rows: min-content min-content min-content 1fr;

		.el-sync-status {
			display: grid;
			grid-template-columns: min-content 1fr;
			grid-gap: 0px 8px;
			align-items: center;
			padding: 8px 16px 8px 16px;
			border-bottom: 1px solid var(--line-color);

			.el-sync-icon {
				grid-column: 1;
				grid-row: 1 / 3;
			}

			.el-sync-label {
				grid-column: 2;
				grid-row: 1;
			}

			progress {
				grid-column: 2;
				grid-row: 2;
				width: 100%;
			}
		}

		.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;

				&.deleted {
					height: 24px;
					transform: translateX(3px) translateY(3px);
				}
			}
		}

		.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;
			}
		}
	}
}


/* =============== *
 * PAGE MANAGEMENT *
 * =============== */
[id^="page-"] {
	display: none;
}

#notes2 {
	&.page-node {
		#page-root {
			display: none;
		}

		#page-node {
			display: contents;
		}
	}

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

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

	&.page-history {
		#page-history {
			display: grid;
			grid-area: n2-page;
		}
	}

	&.page-preferences {
		#page-preferences {
			display: block;
			grid-area: n2-page;
		}
	}

	&.root-node-override {
		[id^="page-"] {
			display: none !important;
		}

		#page-root {
			display: contents !important;
		}
	}

}

#main-page {
	display: contents;

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

}

#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 {
	display: grid;
	position: fixed;
	top: 8px;
	right: 8px;
	padding: 8px 16px;
	z-index: 16384;
	border-radius: 6px;
	font-weight: bold;
	background-color: var(--color1);
	color: #fff;
	box-shadow: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;

	opacity: 0;
	transition: opacity 250ms;

	&.show {
		opacity: 1;
	}

	&.ok {
		background-color: #5aa02c;
	}

	grid-template-columns: min-content repeat(3, min-content);
	grid-gap: 8px 8px;
	white-space: nowrap;
	align-items: center;
	justify-items: end;

	img {
		grid-row: 1/3;
		height: 34px;
		margin-right: 8px;
	}
}

#page-root {
	&>div {
		grid-area: content;
		align-self: start;
		margin-top: 64px;

		display: grid;
		justify-items: center;

		/* logo */
		img {
			margin-bottom: 16px;
			height: 32px;
		}

		.create {
			border: 2px solid #529b00;
			padding: 16px 32px;
			margin-top: 64px;
			background-color: #d9ffc9;
			cursor: pointer;

		}
	}
}

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

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;
		white-space: nowrap;
		width: min-content;
	}

	.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-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;

		font-family: var(--font-monospace);
		font-size: 1em;
		font-weight: 400;

		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-sidebar {
			.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;
		}
	}
}
