/* Pico CSS dark theme overrides and custom styles */

:root {
	--pico-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--tooltip-delay: 1200ms;
}

/* Tooltip delay - override Pico */
[data-tooltip]::before,
[data-tooltip]::after {
	opacity: 0 !important;
	visibility: hidden !important;
	transition: opacity 0.2s ease, visibility 0.2s ease !important;
	transition-delay: 0ms !important;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
	opacity: 1 !important;
	visibility: visible !important;
	transition-delay: var(--tooltip-delay) !important;
}

/* Prevent tooltips from showing on focused elements (prevents sticky tooltips after click) */
[data-tooltip]:focus::before,
[data-tooltip]:focus::after,
[data-tooltip]:focus-within::before,
[data-tooltip]:focus-within::after {
	opacity: 0 !important;
	visibility: hidden !important;
	transition-delay: 0ms !important;
}

/* Force dark theme */
html {
	color-scheme: dark;
}

/* Card grid for groups */
.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 1.5rem;
	padding: 1rem 0;
}

/* Group card */
.group-card {
	position: relative;
	background: var(--pico-card-background-color);
	border: 1px solid rgba(245, 245, 240, 0.15);
	border-radius: var(--pico-border-radius);
	padding: 1.5rem;
	transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.group-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	border-color: var(--pico-primary);
}

[data-theme="light"] .group-card {
	border-color: rgba(30, 30, 30, 0.15);
}

[data-theme="light"] .group-card p {
	color: #4a4a4a;
}

[data-theme="light"] .card-meta {
	color: #666666;
	opacity: 0.9;
}

[data-theme="light"] .subtitle {
	color: #555555;
}

[data-theme="light"] .brand {
	color: var(--pico-primary);
}

.group-card-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

.group-card h3 {
	margin: 0 0 0.5rem 0;
	color: var(--pico-primary);
	padding-right: 2rem;
	font-size: 0.95rem;
}

.group-card p {
	margin: 0 0 0.5rem 0;
	color: var(--pico-muted-color);
	font-size: 0.875rem;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.card-meta {
	display: block;
	font-size: 0.8rem;
	color: var(--pico-muted-color);
	opacity: 0.6;
	margin-top: 0.5rem;
}

/* Header nav */
header.container {
	padding-top: 2rem;
	padding-bottom: 1rem;
	margin-bottom: 1rem;
}

header nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

header .brand-container {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	text-decoration: none;
	border-bottom: none;
}

header .brand-container[data-tooltip] {
	border-bottom: none !important;
	text-decoration: none !important;
}

header .brand-logo {
	width: 68px;
	height: 68px;
	color: var(--pico-primary);
}

header .brand {
	font-weight: 600;
	font-size: 2rem;
	color: #e0e0e0;
	text-decoration: none;
}

header .version {
	font-size: 0.8rem;
	color: var(--pico-muted-color);
	opacity: 0.7;
}

header .pubhub-link {
	color: var(--pico-muted-color);
	opacity: 0.7;
	transition: color 0.2s, opacity 0.2s;
	display: flex;
	align-items: center;
}

header .pubhub-link:hover {
	color: var(--pico-primary);
	opacity: 1;
}

header .nav-links {
	display: flex;
	gap: 1rem;
	align-items: center;
}


header .nav-links a {
	color: var(--pico-muted-color);
	text-decoration: none;
}

header .nav-links a:hover {
	color: var(--pico-primary);
}

/* Theme toggle button */
.theme-toggle {
	background: transparent;
	border: 1px solid var(--pico-muted-border-color);
	color: var(--pico-muted-color);
	padding: 0.25rem 0.5rem;
	border-radius: var(--pico-border-radius);
	cursor: pointer;
	font-size: 1rem;
	line-height: 1;
}

.theme-toggle:hover {
	color: var(--pico-primary);
	border-color: var(--pico-primary);
}

/* Markdown content */
.markdown-content {
	font-size: 1rem;
	line-height: 1.6;
}

.markdown-content h1 {
	font-size: 1.25rem;
	margin-top: 1.5rem;
	margin-bottom: 0.75rem;
}

.markdown-content h2 {
	font-size: 1.1rem;
	margin-top: 1.25rem;
	margin-bottom: 0.5rem;
}

.markdown-content h3 {
	font-size: 1rem;
	margin-top: 1rem;
	margin-bottom: 0.5rem;
}

.markdown-content code {
	background: var(--pico-code-background-color);
	padding: 0.2em 0.4em;
	border-radius: 3px;
	font-size: 0.9em;
}

.markdown-content pre {
	background: var(--pico-code-background-color);
	padding: 1rem;
	border-radius: var(--pico-border-radius);
	overflow-x: auto;
}

.markdown-content pre code {
	background: none;
	padding: 0;
}

.markdown-content ul,
.markdown-content ol {
	padding-left: 1.5rem;
}

.markdown-content blockquote {
	border-left: 3px solid var(--pico-primary);
	padding-left: 1rem;
	margin-left: 0;
	color: var(--pico-muted-color);
}

/* Login form */
.login-container {
	max-width: 400px;
	margin: 0 auto;
	padding-top: 33vh;
}

.login-container article header {
	text-align: center;
	margin-bottom: 1.5rem;
}

.login-logo {
	width: 77px;
	height: 77px;
	color: var(--pico-primary);
	margin-bottom: 1rem;
}

.login-container article header h1 {
	margin-bottom: 0.25rem;
}

.login-container article header p {
	color: var(--pico-muted-color);
	margin: 0;
}

/* Editor */
.editor-container textarea {
	font-family: monospace;
	min-height: 400px;
	resize: vertical;
}

/* Breadcrumb */
.breadcrumb {
	margin-bottom: 1rem;
	font-size: 0.875rem;
	color: var(--pico-muted-color);
	padding: 0;
	background: none;
	border: none;
}

.breadcrumb a {
	color: var(--pico-muted-color);
	text-decoration: none;
}

.breadcrumb a:hover {
	color: var(--pico-primary);
}

/* Action buttons */
.actions {
	display: flex;
	gap: 0.5rem;
	margin-top: 1rem;
	align-items: stretch;
}

.actions button,
.actions a[role="button"] {
	margin: 0;
	padding: 0.5rem 1rem;
	line-height: 1.5;
}

.actions .secondary {
	--pico-background-color: transparent;
	--pico-border-color: var(--pico-muted-border-color);
	--pico-color: var(--pico-muted-color);
}

/* Page header with add button */
.page-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
}

.page-header h1 {
	margin: 0;
}

.subtitle {
	color: var(--pico-muted-color);
	margin: 0 0 1rem 0;
	font-size: 1rem;
}

/* Filter */
.filter-container {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1rem;
}

.filter-wrapper {
	position: relative;
	max-width: 400px;
	flex: 1;
}

.filter-wrapper input {
	width: 100%;
	padding-right: 2.5rem;
	margin: 0;
}

.filter-clear {
	position: absolute;
	right: 0.5rem;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: var(--pico-muted-color);
	font-size: 1.25rem;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	line-height: 1;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s, color 0.2s;
}

.filter-clear:hover {
	color: var(--pico-color);
}

.filter-wrapper.has-value .filter-clear {
	opacity: 1;
	visibility: visible;
}

.filter-count {
	color: var(--pico-muted-color);
	font-size: 0.875rem;
	white-space: nowrap;
}

.add-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	color: var(--pico-primary);
	text-decoration: none;
	font-size: 3rem;
	font-weight: bold;
	transition: transform 0.2s;
}

.add-btn:hover {
	transform: scale(1.1);
}

/* Delete button inside card */
.delete-btn {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	background: transparent;
	border: none;
	padding: 0.25rem;
	cursor: pointer;
	z-index: 1;
	outline: none;
}

.delete-btn:focus {
	outline: none;
	box-shadow: none;
}

.trash-icon {
	width: 33px;
	height: 33px;
	fill: #dc3545;
	opacity: 0.6;
	transition: opacity 0.2s, fill 0.2s;
}

.delete-btn:hover .trash-icon {
	opacity: 1;
	fill: #ff4d5a;
}

/* Dialog modal */
dialog article footer {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
}

dialog article footer form {
	margin: 0;
}

dialog article footer button {
	margin: 0;
	border: 1px solid transparent;
	transition: border-color 0.2s;
}

dialog article footer button:hover {
	border-color: var(--pico-primary);
}

dialog article footer button.contrast:hover {
	border-color: #dc3545;
}

/* See Also section */
.see-also-section {
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--pico-muted-border-color);
}

.see-also-header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

.see-also-header strong {
	color: var(--pico-muted-color);
	font-size: 0.875rem;
}

.see-also-add {
	background: transparent;
	border: 1px solid var(--pico-muted-border-color);
	color: var(--pico-primary);
	width: 24px;
	height: 24px;
	border-radius: 50%;
	padding: 0;
	font-size: 1rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.see-also-add:hover {
	background: var(--pico-primary);
	color: var(--pico-primary-inverse);
	border-color: var(--pico-primary);
}

.see-also-empty {
	color: var(--pico-muted-color);
	font-size: 0.875rem;
	font-style: italic;
	margin: 0;
}

.see-also-list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.see-also-list li {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	background: var(--pico-card-background-color);
	border: 1px solid var(--pico-muted-border-color);
	border-radius: var(--pico-border-radius);
	padding: 0.25rem 0.5rem;
}

.see-also-list a {
	color: var(--pico-primary);
	text-decoration: none;
	font-size: 0.875rem;
}

.see-also-list a:hover {
	text-decoration: underline;
}

.see-also-remove {
	background: transparent;
	border: none;
	color: var(--pico-muted-color);
	padding: 0 0.25rem;
	font-size: 1rem;
	cursor: pointer;
	opacity: 0.6;
	line-height: 1;
}

.see-also-remove:hover {
	color: #dc3545;
	opacity: 1;
}

/* Loading view - centered logo with slow blink */
.loading-view {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--pico-background-color);
}

.loading-logo {
	width: 80px;
	height: 80px;
	color: var(--pico-primary);
	animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.3; }
}

/* Line count indicator */
.line-count {
	font-size: 0.8rem;
	color: var(--pico-muted-color);
	margin-top: 0.25rem;
	margin-bottom: 1rem;
}

.line-count .warning {
	color: orange;
}

.line-count .error {
	color: #dc3545;
	font-weight: bold;
}

/* See-also picker in edit form */
.see-also-picker {
	margin-bottom: 1rem;
}

.see-also-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.see-also-chip {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	background: var(--pico-card-background-color);
	border: 1px solid var(--pico-muted-border-color);
	border-radius: var(--pico-border-radius);
	padding: 0.25rem 0.5rem;
	font-size: 0.875rem;
	color: var(--pico-primary);
}

.see-also-chip button {
	background: transparent;
	border: none;
	color: var(--pico-muted-color);
	padding: 0 0.25rem;
	font-size: 1rem;
	cursor: pointer;
	opacity: 0.6;
	line-height: 1;
}

.see-also-chip button:hover {
	color: #dc3545;
	opacity: 1;
}

.see-also-picker select {
	max-width: 300px;
	margin: 0;
}
