/* Lykkeskatt — app UI (overview, year timeline, book editor). The printed page itself is in book.css. */

@font-face { font-family: 'Fraunces'; src: url(../fonts/fraunces.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url(../fonts/source-sans-3.woff2) format('woff2'); font-weight: 200 900; font-display: swap; }

:root {
	--bg: #f4f1ec; --card: #fff; --ink: #26231f; --muted: #7d766b; --line: #e2ddd4;
	--accent: #b4541f; --star: #e8a317; --bad: #b3261e; --ok: #2e7d4f;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 'Source Sans 3', system-ui, sans-serif; }
a { color: inherit; }
h1, h2 { font-family: 'Fraunces', Georgia, serif; font-weight: 500; letter-spacing: -0.01em; margin: 0; }
button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn {
	display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
	cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #c9c2b5; }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.btn.off { opacity: .45; }
select, input[type=text], input[type=datetime-local], textarea { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); font-size: .9em; }
.err { color: var(--bad); }
.grow { flex: 1; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }
[hidden] { display: none !important; }

.top {
	position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
	padding: 10px 20px; background: rgba(244, 241, 236, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 24px; }
.top .back { text-decoration: none; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; }
body.login form { display: grid; gap: 12px; width: min(320px, 90vw); text-align: center; }
body.login h1 { font-size: 40px; margin-bottom: 8px; }
body.login input { padding: 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; text-align: center; }
body.login button { background: var(--ink); color: #fff; border-color: var(--ink); padding: 12px; }
body.login .err { margin: 0; }

/* Overview */
.years { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.yr { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.yr .meta { padding: 18px 20px 20px; }
.yr h2 { font-size: 42px; margin-bottom: 6px; }
.yr h2 a { text-decoration: none; }
.yr p { margin: 4px 0 0; color: var(--muted); font-size: .93em; }
.yr .stars { color: var(--ink); font-weight: 600; }
.yr .links { margin-top: 12px; display: flex; gap: 8px; }
.albums { margin-top: 36px; color: var(--muted); }
.albums summary { cursor: pointer; }
.albums table { border-collapse: collapse; margin: 12px 0; color: var(--ink); }
.albums td, .albums th { text-align: left; padding: 4px 18px 4px 0; border-bottom: 1px solid var(--line); }

/* Year timeline */
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters button { padding: 5px 11px; border-radius: 99px; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters i { font-style: normal; opacity: .6; font-size: .85em; margin-left: 2px; }
.months { position: sticky; top: 55px; z-index: 15; display: flex; gap: 2px; padding: 6px 20px; overflow-x: auto;
	background: rgba(244, 241, 236, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.months a { padding: 3px 10px; border-radius: 99px; text-decoration: none; color: var(--muted); font-size: .9em; }
.months a:hover { background: var(--card); color: var(--ink); }
.timeline { padding: 8px 20px 120px; }
.timeline section h2 { font-size: 30px; margin: 28px 0 4px; }
.timeline section h2 small { font: 400 14px 'Source Sans 3', sans-serif; color: var(--muted); letter-spacing: 0; margin-left: 8px; }
.day h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 4px; }
.it { --hgt: 150px; position: relative; display: block; height: var(--hgt); width: calc(var(--hgt) * var(--r)); background: #e6e1d8; overflow: hidden; border-radius: 3px; }
.it img { width: 100%; height: 100%; object-fit: cover; display: block; }
.it .s { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
	background: rgba(0, 0, 0, .35); color: #fff; font-size: 17px; line-height: 30px; opacity: 0; transition: opacity .12s; }
.it:hover .s { opacity: 1; }
.it.st-star .s { opacity: 1; background: var(--star); color: #fff; }
.it.st-star { outline: 3px solid var(--star); outline-offset: -3px; }
.it.st-hidden img { opacity: .25; filter: grayscale(1); }
.it.vid::before { content: '▶'; position: absolute; left: 6px; bottom: 5px; color: #fff; font-size: 13px; text-shadow: 0 0 4px #000; z-index: 1; }
.it.est .s { right: auto; left: 4px; }
.it.est { outline: 2px dashed var(--accent); outline-offset: -2px; }
.lb-side .note { background: #fbe9dc; border-left: 3px solid var(--accent); padding: 8px 10px; font-size: .92em; }
.lb-side .chk { display: block; font-weight: 400; margin: 10px 0 4px; font-size: .92em; }
.it.txt::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--accent); opacity: .85; }
@media (max-width: 700px) { .it { --hgt: 105px; } .top { padding: 8px 12px; } .timeline { padding: 8px 12px 100px; } .months { top: 96px; } }
@media (hover: none) { .it .s { opacity: .85; } }

/* Large view */
body.lbopen { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: 1fr 360px; background: #171513; }
.lb-img { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; }
.lb-img img, .lb-img video { max-width: 100%; max-height: 100vh; width: 100%; height: 100%; object-fit: contain; display: block; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 76px; padding: 0; border: 0; border-radius: 8px;
	background: rgba(255, 255, 255, .08); color: #fff; font-size: 34px; line-height: 1; }
.lb .nav:hover { background: rgba(255, 255, 255, .2); }
.lb .prev { left: 10px; } .lb .next { right: 10px; }
.lb-side { background: var(--bg); padding: 22px 20px; overflow-y: auto; position: relative; }
.lb-side .x { position: absolute; top: 12px; right: 12px; border: 0; background: none; font-size: 18px; padding: 6px 10px; }
.lb-side .when { font: 500 20px/1.25 'Fraunces', serif; margin: 0 40px 4px 0; }
.lb-side .when::first-letter { text-transform: uppercase; }
.lb-side p { margin: 0 0 10px; }
.lb-side .acts { display: flex; gap: 8px; margin: 14px 0 18px; }
.lb-side .acts button { flex: 1; padding: 10px; }
#lb-star.on { background: var(--star); border-color: var(--star); color: #fff; font-weight: 600; }
#lb-hide.on { background: var(--ink); color: #fff; }
.lb-side label { display: block; font-weight: 600; margin-bottom: 4px; }
.lb-side .cap { border-left: 3px solid var(--line); padding-left: 10px; margin: 6px 0 16px; }
.lb-side .cap p { margin: 2px 0 4px; white-space: pre-line; }
.lb-side .datefix { margin: 18px 0; }
.lb-side .datefix summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.lb-side .keys { margin-top: 24px; }
@media (max-width: 900px) {
	.lb { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; }
	.lb-img img, .lb-img video { max-height: 55vh; }
	.lb-side .keys { display: none; }
}

/* ───── Book editor ───── */
body.bookpage { background: #dcd7ce; }
.bookbar input[type=text] { width: 220px; }
.bookbar label { font-size: .92em; color: var(--muted); white-space: nowrap; }
.bookbar .exp { font-size: .92em; }
.bookbar .exp a { color: var(--accent); margin-left: 8px; }
.pages { display: grid; grid-template-columns: repeat(2, minmax(0, 560px)); justify-content: center; gap: 34px 2px; padding: 26px 20px 260px; }
.pages .pw:first-child { grid-column: 2; }
body.single .pages { grid-template-columns: minmax(0, 860px); gap: 34px; }
body.single .pages .pw:first-child { grid-column: 1; }
@media (max-width: 800px) { .pages { grid-template-columns: minmax(0, 1fr); gap: 30px; } .pages .pw:first-child { grid-column: 1; } }
.pw { position: relative; }
.pw .pg { box-shadow: 0 2px 14px rgba(40, 30, 10, .18); }
.ptools { display: flex; align-items: center; gap: 4px; height: 30px; margin-bottom: 4px; font-size: 13px; color: #6b655b; opacity: .55; transition: opacity .12s; }
.pw:hover .ptools, .ptools:focus-within { opacity: 1; }
.ptools .pno { font-weight: 600; min-width: 46px; }
.ptools select, .ptools button { padding: 2px 7px; font-size: 13px; border-radius: 6px; }
.ptools button { min-width: 28px; }

/* Editing aids drawn on top of the page (never printed) */
.pg-in::after { content: ''; position: absolute; inset: calc(3 * var(--mm)); border: 1px dashed rgba(200, 40, 90, .35); pointer-events: none; }
.pg [contenteditable] { outline: none; border-radius: 2px; cursor: text; min-width: 2em; }
.pg [contenteditable]:hover { background: rgba(180, 84, 31, .08); }
.pg [contenteditable]:focus { background: rgba(180, 84, 31, .13); }
.pg [contenteditable]:empty::before { content: attr(data-ph); color: #b9b2a6; }
.pg figcaption .t:empty { display: inline-block; }
/* An empty page heading must not take room in the editor, or the page would look different from the print. */
.pg .pg-in > .hd:empty { position: absolute; top: calc(6.5 * var(--mm)); left: calc(17 * var(--mm)); margin: 0; font-size: calc(4.5 * var(--mm)); z-index: 3; }
.pg .pg-in > .hd:empty:not(:focus) { opacity: 0; }
.pw:hover .pg .pg-in > .hd:empty { opacity: 1; }
.pg .ly-full [contenteditable]:empty::before { color: rgba(255, 255, 255, .7); }
.pg .sl .ph { cursor: grab; }
.pg .sl.empty .ph { cursor: default; border: calc(.5 * var(--mm)) dashed #c9c2b5; background: #f7f5f1; }
.pg .sl.empty .ph::after { content: 'Slipp et bilde her'; position: absolute; inset: 0; display: grid; place-items: center; color: #a39c8f; text-align: center; }
.pg .sl.over .ph { outline: calc(1.2 * var(--mm)) solid var(--accent); outline-offset: calc(-1.2 * var(--mm)); }
.pg .sl.dragging { opacity: .4; }
.pg .ph .tool { position: absolute; z-index: 2; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff;
	font-size: 15px; line-height: 30px; opacity: 0; transition: opacity .12s; }
.pg .sl:hover .tool, .pg .tool.panning { opacity: 1; }
.pg .ph .pan { left: 6px; top: 6px; cursor: move; touch-action: none; }
.pg .ph .rm { right: 6px; top: 6px; }
.pg .ph .dpi { position: absolute; z-index: 2; left: 8px; bottom: 8px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: var(--ok); }
.pg .ph .dpi.mid { background: var(--star); } .pg .ph .dpi.low { background: var(--bad); }
@media (hover: none) { .pg .ph .tool { opacity: .8; } }

.tray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(38, 35, 31, .96); color: #fff; padding: 8px 14px 10px; }
.tray.over { background: #5a2a10; }
.tray .hd { display: flex; gap: 12px; align-items: baseline; font-size: 13px; opacity: .85; margin-bottom: 6px; }
.tray .strip { display: flex; gap: 6px; overflow-x: auto; min-height: 20px; padding-bottom: 2px; }
.tray .ti { flex: none; height: 84px; border-radius: 3px; cursor: grab; display: block; }
.tray.closed .strip { display: none; }
.tray button { padding: 1px 9px; font-size: 12px; background: none; color: #fff; border-color: rgba(255, 255, 255, .35); }
.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; background: var(--bad); color: #fff; padding: 9px 16px; border-radius: 8px; }
