/* self-hosted fonts -- no external request, served from Cloudflare CDN */
@font-face {
	font-family: "NerdSymbols";
	src: url("./fonts/NerdSymbols.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
	/* only fetched when a page actually contains these glyphs */
	unicode-range: U+F07B, U+F254;
}

@font-face {
	font-family: "JetBrains Mono";
	src: url("./fonts/JetBrainsMono.woff2") format("woff2");
	font-weight: 100 800;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "JetBrains Mono";
	src: url("./fonts/JetBrainsMono-Italic.woff2") format("woff2");
	font-weight: 100 800;
	font-style: italic;
	font-display: swap;
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
html,
body {
	height: 100%;
}

body {
	background: var(--e-bg-dark);
	color: var(--text);
	font-family: "JetBrains Mono", "NerdSymbols", monospace;
	min-height: 100vh;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 5vh 10vw;
}

.editor {
	width: 100%;
	max-width: none;
	height: 90vh;
	display: flex;
	flex-direction: column;
	background: var(--bg-surface);
	border-radius: 10px;
	border: 1px solid var(--e-green);
	/* shadow matches hyprland: range=8 render_power=4 (tight, focused falloff) */
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
	overflow: hidden;
}

.prompt-chrome {
	background: var(--bg-surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
	padding-top: 5px;
}

.prompt-l1 {
	height: 20px;
	display: flex;
	align-items: stretch;
	justify-content: space-between;
}

.powerline-nav {
	display: flex;
	align-items: stretch;
	padding-left: 18px;
}

.nav-seg {
	position: relative;
	display: inline-flex;
	align-items: center;
	padding: 0 12px 0 10px;
	font-size: 0.78rem;
	font-family: inherit;
	text-decoration: none;
	white-space: nowrap;
	--seg-bg: #80638e;
	background: var(--seg-bg);
	color: #000000;
	transition: color 0.15s;
}

.nav-seg::after {
	content: "";
	position: absolute;
	right: -12px;
	top: 0;
	width: 0;
	height: 0;
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
	border-left: 12px solid var(--seg-bg);
}

/* extra left padding so text clears the previous segment's arrow */
.nav-seg + .nav-seg {
	padding-left: 18px;
}

/* decreasing z-index ensures each segment's arrow paints over the next segment's background */
.powerline-nav .nav-seg:nth-child(1) {
	z-index: 15;
}
.powerline-nav .nav-seg:nth-child(2) {
	z-index: 14;
}
.powerline-nav .nav-seg:nth-child(3) {
	z-index: 13;
}
.powerline-nav .nav-seg:nth-child(4) {
	z-index: 12;
}

.nav-seg-logo {
	--seg-bg: #2d5b58;
	color: #e8f6f5;
	font-weight: 700;
}

/* leading diamond cap matching OMP OS segment leading_diamond */
.nav-seg-logo::before {
	content: "";
	position: absolute;
	left: -12px;
	top: 0;
	width: 0;
	height: 0;
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent;
	border-right: 12px solid #2d5b58;
}

.nav-seg.active {
	--seg-bg: #6cc644;
	background: var(--seg-bg);
	color: #000000;
	font-weight: 500;
}

/* hover turns the whole segment shape (body + trailing arrow) yellow via --seg-bg */
.nav-seg:not(.nav-seg-logo):not(.active):hover {
	--seg-bg: var(--e-yellow);
	background: var(--seg-bg);
	color: #000000;
}

.r-segments {
	display: flex;
	align-items: stretch;
	padding-right: 14px;
}

/* OMP status: background=#6cc644 foreground=#000000 (no eldritch equivalent) */
.r-status {
	display: inline-flex;
	align-items: center;
	padding: 0 10px;
	background: #6cc644;
	color: #000000;
	font-size: 0.78rem;
	font-weight: 700;
	border-radius: 10px 0 0 10px;
}

/* OMP exec time: background=#2d5b58 foreground=#e8f6f5 (no eldritch equivalent) */
.r-exectime {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0 10px;
	background: #2d5b58;
	color: #e8f6f5;
	font-size: 0.78rem;
	border-radius: 0 10px 10px 0;
}

.r-icon {
	font-size: 0.9rem;
}

/* line-height: 1 so box-drawing chars connect across lines */
.prompt-l2,
.prompt-l3 {
	padding: 0 16px;
	font-size: 0.8rem;
	line-height: 1;
	white-space: nowrap;
}

.prompt-l2 {
	padding-top: 5px;
}
.prompt-l3 {
	padding-bottom: 8px;
}

.p-frame {
	color: var(--text-subtle);
}
.p-time {
	color: var(--e-yellow);
}
.p-sep {
	color: var(--text-subtle);
}
.p-date {
	color: var(--e-purple);
}
.p-icon {
	color: var(--e-cyan);
	font-size: 1rem;
	margin-right: 2px;
}
.p-cwd {
	color: var(--e-cyan);
}
/* larger font-weight so ❯ reads clearly at small size */
.p-arrow {
	color: var(--e-green);
	font-weight: 700;
	margin-left: 4px;
}

.content {
	flex: 1;
	min-height: 0;
	padding: 24px 32px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.content-inner {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.panel {
	border: 1px solid var(--border);
	background: var(--bg);
	padding: 24px;
	margin-bottom: 24px;
	position: relative;
}

/* floated label sits in the border top, background must match content area */
.panel-label {
	position: absolute;
	top: -0.65em;
	left: 14px;
	padding: 0 8px;
	background: var(--bg);
	color: var(--e-cyan);
	font-size: 0.72rem;
	letter-spacing: 0.04em;
}

.page-header {
	margin-bottom: 32px;
}

.page-header h1 {
	font-size: 1.4rem;
	color: var(--e-green);
	margin-bottom: 6px;
}

.prompt {
	color: var(--text-subtle);
	font-size: 0.85rem;
}
.prompt .cmd {
	color: var(--e-cyan);
}

p {
	color: var(--text-muted);
	line-height: 1.7;
	font-size: 0.9rem;
	margin-bottom: 12px;
}
p:last-child {
	margin-bottom: 0;
}

a {
	color: var(--link);
	text-decoration: none;
}
a:hover {
	color: var(--link-hover);
}

/* ─── TUI navigation system ─── */

.tui-session {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.tui-prompt-line {
	margin-bottom: 10px;
	font-size: 0.85rem;
}

.tui-workspace {
	display: flex;
	align-items: stretch;
	flex: 1;
	min-height: 0;
}

/* list pane */
.tui-list {
	width: 300px;
	flex-shrink: 0;
	border: 1px solid var(--border);
	background: var(--bg-surface);
	display: flex;
	flex-direction: column;
}

.tui-list-header {
	padding: 5px 12px;
	font-size: 0.72rem;
	color: var(--e-cyan);
	letter-spacing: 0.04em;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.tui-item {
	display: flex;
	align-items: center;
	padding: 5px 12px 5px 10px;
	font-size: 0.85rem;
	color: var(--text-muted);
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

.tui-item::before {
	content: "  ";
	width: 2ch;
	display: inline-block;
	flex-shrink: 0;
}

.tui-item.focused {
	background: var(--bg-elevated);
	color: var(--e-green);
}

.tui-item.focused::before {
	content: "▶ ";
}

.tui-item:hover:not(.focused) {
	background: var(--bg-elevated);
	color: var(--text);
}

.tui-list-hint {
	margin-top: auto;
	padding: 8px 10px;
	font-size: 0.7rem;
	color: var(--text-subtle);
	border-top: 1px solid var(--border);
}

.key {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	color: var(--e-fg-dim);
	padding: 0 4px;
	border-radius: 3px;
	font-size: 0.7rem;
}

/* output pane */
.tui-output-wrap {
	flex: 1;
	border: 1px solid var(--border);
	border-left: none;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.tui-cmd-line {
	padding: 5px 14px;
	font-size: 0.85rem;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
	visibility: hidden;
	background: var(--bg-surface);
}

#tui-output {
	padding: 16px 20px;
	overflow-y: auto;
	flex: 1;
}

.tui-empty-hint {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--text-subtle);
	font-size: 0.8rem;
	user-select: none;
}

/* nushell-style table */
.nu-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--border);
	border-radius: 4px;
	overflow: hidden;
	font-size: 0.82rem;
	margin-bottom: 16px;
}

.nu-table th {
	background: var(--bg-surface);
	color: var(--e-cyan);
	font-weight: 700;
	padding: 4px 14px;
	text-align: left;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.nu-table th.col-idx {
	text-align: right;
}

.nu-table td {
	padding: 3px 14px;
	border-bottom: 1px solid var(--bg-elevated);
	white-space: nowrap;
}

.nu-table tbody tr:last-child td {
	border-bottom: none;
}

.nu-table tbody tr:nth-child(even) td {
	background: var(--bg-elevated);
}

.col-idx {
	color: var(--e-comment);
	text-align: right;
	padding-right: 10px !important;
	width: 3ch;
}

.col-str {
	color: var(--e-fg);
}

.col-num {
	color: var(--e-purple);
}

.col-date {
	color: var(--e-yellow);
}

.col-path {
	color: var(--e-green);
}

/* status tags */
.tag {
	font-size: 0.8em;
}

.tag-playing {
	color: var(--e-green);
}

.tag-finished {
	color: var(--e-cyan);
}

.tag-dropped {
	color: var(--e-red);
}

.tag-paused {
	color: var(--e-yellow);
}

.tag-active {
	color: var(--e-green);
}

.tag-wip {
	color: var(--e-yellow);
}

.tag-done {
	color: var(--e-cyan);
}

.tag-deferred {
	color: var(--e-comment);
}

/* tui content block */
.tui-block {
	border: 1px solid var(--border);
	background: var(--bg-surface);
	margin-bottom: 16px;
	overflow: hidden;
}

.tui-block-title {
	padding: 4px 14px;
	font-size: 0.72rem;
	color: var(--e-cyan);
	letter-spacing: 0.04em;
	border-bottom: 1px solid var(--border);
}

.tui-block-body {
	padding: 14px 16px;
}

.tui-text {
	color: var(--text-muted);
	line-height: 1.7;
	font-size: 0.85rem;
	margin-bottom: 6px;
}

.tui-text:last-child {
	margin-bottom: 0;
}

/* left panel scrolls independently without affecting right pane or page */
.tui-list {
	overflow-y: auto;
}

/* folder +/- sits after the ::before focus cursor, inherits item color */
.tui-item-folder .folder-arrow {
	margin-right: 5px;
	flex-shrink: 0;
}

/* child items: indented, slightly smaller */
.tui-item-child {
	padding-left: 28px;
	font-size: 0.82rem;
}

.child-date {
	color: var(--e-comment);
	font-size: 0.75rem;
	margin-right: 8px;
}

/* ─── Markdown renderer styles ─── */

.md-h1 {
	color: var(--e-cyan);
	font-weight: 700;
	font-size: 0.95rem;
	margin-bottom: 8px;
	margin-top: 14px;
}

.md-h1:first-child {
	margin-top: 0;
}

.md-h2 {
	color: var(--e-green);
	font-weight: 600;
	font-size: 0.9rem;
	margin-bottom: 6px;
	margin-top: 12px;
}

.md-h3 {
	color: var(--e-yellow);
	font-weight: 600;
	font-size: 0.88rem;
	margin-bottom: 4px;
	margin-top: 10px;
}

.md-hash {
	opacity: 0.45;
}

.md-p {
	color: var(--text-muted);
	line-height: 1.7;
	font-size: 0.85rem;
	margin-bottom: 4px;
}

.md-li {
	color: var(--text-muted);
	font-size: 0.85rem;
	margin-bottom: 2px;
	display: flex;
	align-items: baseline;
}

.md-bullet {
	color: var(--e-cyan);
	margin-right: 8px;
	flex-shrink: 0;
}

.md-li-nested {
	padding-left: 20px;
}

.md-codeblock {
	border: 1px solid var(--border);
	background: var(--bg-surface);
	margin: 8px 0;
	overflow-x: auto;
}

.code-lang {
	padding: 2px 12px;
	font-size: 0.72rem;
	color: var(--e-comment);
	border-bottom: 1px solid var(--border);
}

.code-pre {
	margin: 0;
	padding: 10px 14px;
	font-size: 0.82rem;
	color: var(--e-fg);
	white-space: pre;
	overflow-x: auto;
}

.md-code {
	color: var(--e-yellow);
	background: var(--bg-elevated);
	padding: 0 4px;
	border-radius: 2px;
}

.md-spacer {
	height: 6px;
}

.md-hr {
	border: none;
	border-top: 1px solid var(--border);
	margin: 12px 0;
}

.md-loading {
	color: var(--text-subtle);
	font-size: 0.85rem;
	padding: 4px 0;
}

.md-error {
	color: var(--e-red);
	font-size: 0.85rem;
	padding: 4px 0;
}

/* ─── Guestbook ─── */

/* message column: wraps unlike other nu-table cells */
.gb-table .col-msg {
	white-space: pre-wrap;
	word-break: break-word;
	max-width: 380px;
}

.gb-from a {
	color: var(--e-green);
	text-decoration: none;
}

.gb-from a:hover {
	color: var(--e-cyan);
}

.gb-empty {
	color: var(--text-subtle);
	font-style: italic;
	margin-bottom: 16px;
}

.gb-form-wrap {
	margin-top: 20px;
}

.gb-form-header {
	color: var(--text-subtle);
	font-size: 0.82rem;
	margin-bottom: 10px;
}

.gb-hp {
	position: absolute;
	left: -9999px;
	opacity: 0;
	pointer-events: none;
}

.gb-form {
	border: 1px solid var(--border);
	background: var(--bg-surface);
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 9px;
}

.gb-field {
	display: flex;
	align-items: center;
	gap: 14px;
}

.gb-field-msg {
	align-items: flex-start;
}

.gb-label {
	color: var(--e-comment);
	font-size: 0.8rem;
	width: 4ch;
	flex-shrink: 0;
	padding-top: 3px;
}

.gb-input {
	flex: 1;
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--border);
	color: var(--e-fg);
	font-family: inherit;
	font-size: 0.82rem;
	padding: 2px 4px;
	outline: none;
	transition: border-color 0.15s;
}

.gb-input::placeholder {
	color: var(--text-subtle);
}

.gb-input:focus {
	border-bottom-color: var(--e-cyan);
}

.gb-textarea {
	resize: vertical;
	min-height: 62px;
	line-height: 1.5;
}

.gb-actions {
	display: flex;
	align-items: center;
	gap: 16px;
	padding-top: 4px;
	margin-left: calc(4ch + 14px);
}

.gb-btn {
	background: none;
	border: none;
	color: var(--e-green);
	font-family: inherit;
	font-size: 0.82rem;
	cursor: pointer;
	padding: 0;
	transition: color 0.15s;
}

.gb-btn:hover {
	color: var(--e-cyan);
}

.gb-status {
	color: var(--e-red);
	font-size: 0.8rem;
}

/* ─── Nix file viewer ─── */

/* removes output pane padding so nix-view fills edge to edge */
#tui-output.nix-output {
	padding: 0;
}

.nix-view {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--e-bg-dark);
	font-size: 0.82rem;
}

.nix-file-header {
	padding: 4px 16px;
	font-size: 0.75rem;
	color: var(--e-comment);
	border-bottom: 1px solid var(--border);
	background: var(--e-bg-raised);
	flex-shrink: 0;
	position: sticky;
	top: 0;
	z-index: 1;
}

.nix-body {
	overflow-x: auto;
	padding: 10px 0;
}

.nix-line {
	display: flex;
	align-items: baseline;
	line-height: 1.5;
}

.nix-line:hover {
	background: rgba(255, 255, 255, 0.03);
}

.nix-ln {
	min-width: 3ch;
	text-align: right;
	padding: 0 16px 0 12px;
	color: var(--e-comment);
	opacity: 0.5;
	user-select: none;
	flex-shrink: 0;
}

.nix-code {
	white-space: pre;
	color: var(--e-fg);
	padding-right: 24px;
}

/* nix token colors -- eldritch palette */
.nx-kw {
	color: var(--e-purple);
}
.nx-ns {
	color: var(--e-purple);
}
.nx-bool {
	color: var(--e-yellow);
}
.nx-null {
	color: var(--e-red);
}
.nx-str {
	color: var(--e-green);
}
.nx-interp {
	color: var(--e-cyan);
}
.nx-comment {
	color: var(--e-comment);
	font-style: italic;
}
.nx-num {
	color: var(--e-cyan);
}
.nx-path {
	color: var(--e-green-dark);
}

/* mobile: fullscreen window, hide chrome that won't fit */
@media (max-width: 768px) {
	body {
		padding: 0;
	}

	.editor {
		width: 100%;
		height: 100svh;
		border-radius: 0;
		border-left: none;
		border-right: none;
	}

	/* right pill doesn't fit on narrow nav */
	.r-segments {
		display: none;
	}

	.nav-seg {
		font-size: 0.7rem;
	}

	.content {
		padding: 16px 20px;
	}
}

/* responsive: stack tui workspace on narrow screens */
@media (max-width: 620px) {
	.tui-workspace {
		flex-direction: column;
	}

	.tui-list {
		width: 100%;
		flex-shrink: 0;
	}

	.tui-output-wrap {
		border-left: 1px solid var(--border);
		border-top: none;
		flex: 1;
		min-height: 0;
	}

	.content {
		padding: 12px 16px;
	}

	/* keyboard shortcuts don't apply on touch */
	.tui-list-hint {
		display: none;
	}

	/* 44px minimum touch target */
	.tui-item {
		padding: 12px 12px 12px 10px;
	}
}

/* ─── Home page layout ─── */

.home-layout {
	display: flex;
	flex-direction: column;
}

.home-speech {
	position: relative;
	border: 1px solid var(--border);
	background: var(--bg-surface);
	padding: 10px 14px;
	margin-bottom: 20px;
}

/* outer border of speech bubble tail -- points at avatar center (70px from layout left) */
.home-speech::after {
	content: "";
	position: absolute;
	bottom: -10px;
	left: 61px;
	border-left: 9px solid transparent;
	border-right: 9px solid transparent;
	border-top: 9px solid var(--border);
}

/* inner fill of speech bubble tail */
.home-speech::before {
	content: "";
	position: absolute;
	bottom: -8px;
	left: 62px;
	z-index: 1;
	border-left: 8px solid transparent;
	border-right: 8px solid transparent;
	border-top: 8px solid var(--bg-surface);
}

.home-ff {
	display: flex;
	align-items: flex-start;
	gap: 28px;
}

.home-speech-inner .md-p,
.home-speech-inner .md-loading,
.home-speech-inner .md-error {
	font-size: 0.78rem;
	line-height: 1.55;
	margin-bottom: 2px;
}

.home-avatar-wrap {
	position: relative;
	width: 140px;
	height: 140px;
}

.home-avatar {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 100px;
	height: 100px;
	border-radius: 50%;
}

.home-frame {
	position: absolute;
	top: 0;
	left: 0;
	width: 140px;
	height: 140px;
	pointer-events: none;
}

/* info panel */
.home-panel {
	flex: 1;
	min-width: 0;
	font-size: 0.82rem;
	padding-top: 2px;
}

.ff-title {
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--e-fg);
	margin-bottom: 3px;
}

.ff-at {
	color: var(--e-comment);
}

.ff-sep-line {
	color: var(--border);
	margin-bottom: 10px;
	letter-spacing: -0.5px;
}

.ff-map-row {
	display: flex;
	align-items: baseline;
	gap: 6px;
	line-height: 1.75;
}

.ff-tree {
	color: var(--e-comment);
	flex-shrink: 0;
}

.ff-site-link {
	color: var(--e-cyan);
	text-decoration: none;
	font-weight: 500;
	flex-shrink: 0;
}

.ff-site-link:hover {
	color: var(--e-cyan-bright);
}

.ff-comment {
	color: var(--e-comment);
	font-size: 0.78rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ff-section-label {
	color: var(--e-yellow);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	margin-top: 12px;
	margin-bottom: 4px;
}

.ff-label {
	color: var(--e-purple);
	width: 9ch;
	flex-shrink: 0;
}

.ff-contact-link {
	color: var(--e-cyan);
	text-decoration: none;
}

.ff-contact-link:hover {
	color: var(--e-cyan-bright);
}

@media (max-width: 620px) {
	.home-ff {
		flex-direction: column;
		align-items: center;
	}

	.home-panel {
		width: 100%;
	}
}
