@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Old+Standard+TT:wght@400;700&display=swap");

:root {
	--ink: #000000d9;
	--rule: #000;
	--link-faint: #00000040;
	--link-strong: #00000080;
	--bg: rgb(254, 243, 199);
	--highlight: rgba(255, 230, 0, 0.45);
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #0000000d; }
::-webkit-scrollbar-thumb { background: #0000000d; }
::-webkit-scrollbar-thumb:hover { background: #000; }

html, body, main { height: 100%; }
html, body { background-color: var(--bg); }

@media screen and (min-width: 740px) {
	html, body { overflow: hidden; }
}

html {
	font-family: "IBM Plex Mono", monospace;
	font-size: 14px;
	line-height: 1.2em;
	color: var(--ink);
}

body { margin: 0; }

h1, h2, h3, h4 {
	font-family: "Old Standard TT", serif;
	margin: 0;
	display: inline-block;
}
h1, h2 { font-size: 1.75rem; font-weight: 400; }

a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--link-faint);
	text-decoration-thickness: 1px;
	cursor: pointer;
}
a:hover { text-decoration-color: var(--link-strong); }

p { margin: 0.5rem 0; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 500; }
small { font-size: 0.9rem; }
code {
	font-family: inherit;
	background: #00000010;
	padding: 0 0.25em;
}

ul { margin: 0; padding: 0; }
ul:not(:last-child) { margin-bottom: 1rem; }
li { list-style: none; position: relative; }

button {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

/* Layout */
#page { width: 100%; }
@media screen and (min-width: 740px) {
	#page {
		height: 100vh;
		display: flex;
		flex-direction: column;
	}
}

header#header {
	padding: 2rem 0;
	border-bottom: 1px solid var(--rule);
	z-index: 2;
}
@media screen and (min-width: 740px) {
	header#header { padding: 3rem 0; }
}
header#header .flex { align-items: flex-end; }
header#header .column { padding: 0 2rem; }
@media screen and (min-width: 740px) {
	header#header .column { padding: 0 3rem; }
}

main {
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.flex { display: flex; flex-wrap: wrap; }
main > .flex { flex: 1; overflow-y: auto; }
@media screen and (min-width: 740px) {
	main > .flex { overflow: hidden; }
}

.column { width: 100%; }
@media screen and (min-width: 740px) {
	.column { height: 100%; width: 50%; }
}

@media screen and (min-width: 740px) {
	.scroll {
		overflow-y: scroll;
		-webkit-overflow-scrolling: touch;
	}
	.scroll:not(:last-child) { border-right: 1px solid; }
	#left-col { border-right: 1px solid var(--rule); }
}

section {
	padding: 2rem;
	position: relative;
	overflow: visible;
	border-bottom: 1px solid;
}
@media screen and (min-width: 740px) {
	section { padding: 3rem; }
	section:last-of-type { border-bottom: 0; }
}

section header { margin-bottom: 1rem; }

/* Trælister */
ul.nested li {
	max-width: 32rem;
	padding-left: 1.25em;
	margin-top: 0.5em;
}
ul.nested li:before {
	content: "";
	width: 0.5em;
	height: 0.5em;
	display: block;
	position: absolute;
	left: 0;
	top: 0;
	border: solid var(--rule);
	border-width: 0 0 1px 1px;
}
ul.nested li.empty { padding-left: 0; }
ul.nested li.empty:before { display: none; }
ul.nested > li {
	break-inside: avoid;
	position: relative;
}
ul.nested > li:not(:last-child) { margin-bottom: 1rem; }
ul.nested > li > ul > li:not(:last-child) { margin-bottom: 1em; }
ul.nested > li:before { border-left-width: 0; }
ul.nested > li li:not(:last-child):after {
	content: "";
	width: 1px;
	height: calc(100% + 0.5rem);
	display: block;
	position: absolute;
	left: 0;
	top: 0.5rem;
	background-color: #000;
}

/* Bibliotek-rækker */
.book-row,
.highlight-row {
	display: flex;
	gap: 0.5rem;
	align-items: baseline;
}
.book-row .name { flex: 1; min-width: 0; }
.book-row.active .name strong { text-decoration: underline; text-decoration-color: var(--link-strong); }
.book-row .delete {
	color: inherit;
	opacity: 0.4;
	font-size: 1rem;
}
.book-row .delete:hover { opacity: 1; }

.highlight-row .text {
	flex: 1;
	min-width: 0;
	cursor: pointer;
	display: block;
	background: linear-gradient(transparent 60%, var(--highlight) 60%);
	padding: 0 0.15em;
}
.highlight-row .text:hover { background: linear-gradient(transparent 60%, rgba(255, 200, 0, 0.65) 60%); }
.highlight-row .delete {
	color: inherit;
	opacity: 0.4;
	font-size: 1rem;
	flex: 0 0 auto;
}
.highlight-row .delete:hover { opacity: 1; }

/* Reader-kolonne */
#right-col {
	display: flex;
	flex-direction: column;
}

#reader-section {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 0;
	border-bottom: 0;
	min-height: 0;
}

.reader-header {
	padding: 2rem;
	margin-bottom: 0 !important;
	border-bottom: 1px solid var(--rule);
}
@media screen and (min-width: 740px) {
	.reader-header { padding: 3rem; }
}
.reader-header h2 { display: block; }
.reader-header small {
	display: block;
	margin-top: 0.5rem;
	color: #00000099;
}

#viewer-wrap {
	flex: 1;
	position: relative;
	overflow: hidden;
	min-height: 300px;
}

#viewer {
	width: 100%;
	height: 100%;
}

#viewer-empty {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	color: #00000060;
	font-style: italic;
}

#viewer-empty.hidden { display: none; }

.page-nav {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 4rem;
	font-family: "Old Standard TT", serif;
	font-size: 2rem;
	color: #00000040;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	transition: color 0.15s, background-color 0.15s;
}
.page-nav:hover { color: var(--ink); background: #0000000a; }
.page-nav.prev { left: 0; }
.page-nav.next { right: 0; }
.page-nav.hidden { display: none; }

#reader-controls {
	padding: 1rem 2rem;
	border-top: 1px solid var(--rule);
	display: flex;
	gap: 1rem;
	align-items: center;
	font-size: 0.9rem;
}
@media screen and (min-width: 740px) {
	#reader-controls { padding: 1rem 3rem; }
}
#reader-controls .spacer { flex: 1; }

/* Drop overlay */
#drop-overlay {
	position: fixed;
	inset: 0;
	background: rgba(254, 243, 199, 0.95);
	border: 4px dashed var(--rule);
	display: none;
	align-items: center;
	justify-content: center;
	font-family: "Old Standard TT", serif;
	font-size: 2rem;
	z-index: 100;
	pointer-events: none;
}
body.dragging #drop-overlay { display: flex; }

/* EPUB iframe styling overrides — sker via epub.js themes i app.js */
