/* =========================================
   Curious Ape — Earthy natural color scheme
   Less dark, warm olive/forest tones. More grounded and organic.
   ========================================= */

/* Self-hosted Exo 2 — more distinct, geometric, futuristic/cyberpunk-adjacent
   while remaining highly legible for UI text.
   Files live in assets/fonts/ (embedded for prod, served from disk in dev).
   Using font-display: swap to avoid invisible text while loading.
*/
@font-face {
	font-family: "Exo 2";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("/static/assets/fonts/Exo2-Regular.woff2") format("woff2");
}

@font-face {
	font-family: "Exo 2";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("/static/assets/fonts/Exo2-Medium.woff2") format("woff2");
}

@font-face {
	font-family: "Exo 2";
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url("/static/assets/fonts/Exo2-SemiBold.woff2") format("woff2");
}

@font-face {
	font-family: "Exo 2";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("/static/assets/fonts/Exo2-Bold.woff2") format("woff2");
}

/* Fun monospace: Fira Code — clean, modern, with programming ligatures
   (arrows, comparisons etc. render nicely for a playful tech/cyber feel
   on scores, durations, grid data, etc.). Still very legible.
*/
@font-face {
	font-family: "Fira Code";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("/static/assets/fonts/FiraCode-Regular.woff2") format("woff2");
}

@font-face {
	font-family: "Fira Code";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("/static/assets/fonts/FiraCode-Medium.woff2") format("woff2");
}

@font-face {
	font-family: "Fira Code";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("/static/assets/fonts/FiraCode-Bold.woff2") format("woff2");
}

:root {
	/* Earthy base (natural, less stark) */
	--bg-base: #111c18;
	--bg-surface: #1a2a24;
	--bg-elevated: #22372f;
	--bg-header: #0f1916;

	/* Foreground - warm muted olive */
	--fg-base: #c1c497;
	--fg-muted: #8a9578;
	--fg-inverse: #111c18;

	/* Earthy sage green accent */
	--accent: #7d8f5e;
	--accent-hover: #96a97a;
	--accent-dim: #374a33;
	--accent-weak: #2c3c2a;

	/* Borders + separators - stronger for better definition */
	--border: #32433c;
	--border-strong: #45544d;

	/* Refined surfaces / elevation */
	--shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.03), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
	--shadow-elevated: 0 2px 4px rgba(0, 0, 0, 0.15);

	/* Semantic earthy tones */
	--success: #6b8a58; /* moss green - better contrast */
	--warning: #9c8a5e; /* warm earth */
	--danger: #8b6355; /* clay / terracotta */

	/* Typography scale (kept close to original) */
	--fs-400: 1.125rem;
	--fs-500: 1.3125rem;
	--fs-600: 1.5rem;
	--fs-700: 2.25rem;
	--fs-800: 3rem;

	/* Fonts: Exo 2 (self-hosted, geometric cyberpunk-adjacent) + strong system fallbacks.
	   Mono kept separate for data, scores, grids, etc. */
	--ff-base: "Exo 2", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--ff-mono:
		"Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
		"Courier New", monospace;

	/* Spacing */
	--space-2: 0.5rem;
	--space-3: 0.75rem;
	--space-4: 1rem;

	/* Polish: radius for machine feel */
	--radius: 2px;
}

/* Base reset */
* {
	box-sizing: border-box;
	margin: 0;
}

html {
	background: var(--bg-base);
}

body {
	color: var(--fg-base);
	font-size: var(--fs-400);
	font-family: var(--ff-base);
	line-height: 1.55;
	background-color: var(--bg-base);
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
	/* Subtle tightening that shines with Inter (and is safe with the system fallback) */
	letter-spacing: -0.01em;
}

/* Headings — clean, green accent, mostly sans for unity */
h1,
h2,
h3,
h4 {
	line-height: 1.1;
	text-overflow: clip;
	font-family: var(--ff-base);
}

h1 {
	font-size: var(--fs-800);
	color: var(--accent);
	padding-left: var(--space-2);
	white-space: nowrap;
	letter-spacing: -0.02em;
	position: relative;
}

/* Subtle top green accent line under h1 (console polish) */
h1::after {
	content: "";
	position: absolute;
	bottom: -2px;
	left: var(--space-2);
	right: 0;
	height: 1px;
	background: linear-gradient(to right, var(--accent), transparent);
}

h2 {
	font-size: var(--fs-700);
	color: var(--fg-base);
	padding: 10px 0;
	letter-spacing: -0.015em;
}

h3 {
	font-size: var(--fs-600);
	color: var(--accent);
	font-weight: 600;
}

h4 {
	font-size: var(--fs-500);
	color: var(--fg-base);
	font-weight: 600;
}

/* Links */
a {
	color: var(--accent);
	text-decoration: none;
}

a:hover,
a:focus-visible {
	color: var(--accent-hover);
	text-decoration: underline;
}

/* Form elements base */
input,
button,
textarea,
select {
	font-family: inherit;
	font-size: inherit;
}

button {
	cursor: pointer;
}

/* =========================================
   Layout (grid structure unchanged)
   ========================================= */

.layout {
	margin: 0 auto;
	max-width: 1800px;
	display: grid;
	gap: var(--fs-400);
	grid-template-columns: 1fr 5fr;
	grid-template-rows: var(--fs-800) 1fr var(--fs-600);
	grid-template-areas:
		"header main"
		"aside  main"
		"footer main";
}

.layout main {
	grid-area: main;
	padding: var(--space-4);
}

.layout header {
	grid-area: header;
	background: var(--bg-header);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
}

.layout aside {
	grid-area: aside;
	background: var(--bg-surface);
	border-right: 1px solid var(--border);
	padding-top: var(--space-2);
}

.layout footer {
	grid-area: footer;
	position: fixed;
	bottom: 0;
	font-size: 0.75rem;
	color: var(--fg-muted);
	padding: 0.25rem 0.5rem;
	background: var(--bg-base);
	border-top: 1px solid var(--border);
}

/* Sidebar nav */
.layout nav {
	display: grid;
}

.layout nav > a {
	padding: 0.55rem 0.75rem 0.55rem 0.75rem;
	text-decoration: none;
	display: flex;
	align-items: center;
	color: var(--fg-base);
	border-left: 3px solid transparent;
	transition: all 80ms ease;
}

.layout nav > a > svg {
	margin-right: 0.6rem;
	width: 1.25rem;
	height: 1.25rem;
	opacity: 0.85;
}

.layout nav > a:hover,
.layout nav > a:focus-visible {
	background: var(--bg-elevated);
	color: var(--accent);
	border-left-color: var(--accent);
}

.layout nav > a:hover svg,
.layout nav > a:focus-visible svg {
	opacity: 1;
}

/* Active (current page) nav item */
.layout nav > a.active {
	background: var(--bg-elevated);
	color: var(--accent);
	border-left-color: var(--accent);
}

.layout nav > a.active svg {
	opacity: 1;
}

/* =========================================
   Buttons (unified, green accent primary)
   ========================================= */

.button,
.btn {
	font: inherit;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	border: 1px solid var(--accent);
	background: var(--accent);
	color: var(--fg-inverse);
	padding: 0.55em 1.1em;
	border-radius: var(--radius);
	transition: all 80ms ease;
}

.button:hover,
.button:focus-visible,
.btn:hover,
.btn:focus-visible {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: var(--fg-inverse);
}

.btn-secondary,
.button-secondary {
	background: transparent;
	color: var(--accent);
	border-color: var(--border-strong);
}

.btn-secondary:hover,
.btn-secondary:focus-visible,
.button-secondary:hover,
.button-secondary:focus-visible {
	background: var(--bg-elevated);
	border-color: var(--accent);
	color: var(--accent);
}

.btn-nav,
.button-nav {
	background: var(--bg-surface);
	color: var(--fg-base);
	border-color: var(--border);
	text-transform: none;
	font-weight: 500;
}

.btn-nav:hover,
.btn-nav:focus-visible,
.button-nav:hover,
.button-nav:focus-visible {
	background: var(--bg-elevated);
	border-color: var(--accent);
	color: var(--accent);
}

.btn-sync {
	font-size: 0.8rem;
	padding: 0.3em 0.65em;
	text-transform: uppercase;
}

/* =========================================
   Forms
   ========================================= */

form {
	margin-block: var(--space-4);
}

label {
	display: block;
	margin-bottom: 0.35rem;
	color: var(--fg-muted);
	font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="checkbox"] {
	background: var(--bg-base);
	color: var(--fg-base);
	border: 1px solid var(--border);
	padding: 0.45rem 0.6rem;
	border-radius: var(--radius);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 2px var(--accent-dim);
}

input[type="checkbox"] {
	accent-color: var(--accent);
}

fieldset {
	border: 1px solid var(--border);
	padding: var(--space-4);
	margin-bottom: var(--space-4);
}

legend {
	padding: 0 0.5rem;
	color: var(--accent);
	font-weight: 600;
}

/* Error callouts */
.error,
p.error {
	color: var(--danger);
	background: rgba(139, 99, 85, 0.12);
	border: 1px solid rgba(139, 99, 85, 0.35);
	padding: 0.5rem 0.75rem;
	border-radius: var(--radius);
}

/* =========================================
   Surfaces / cards (unifying treatment)
   ========================================= */

.surface,
.card,
.panel {
	background: var(--bg-elevated);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	padding: calc(var(--space-4) + 4px) var(--space-4) var(--space-4);
	margin-bottom: var(--space-4);
	box-shadow: var(--shadow-inner), var(--shadow-elevated);
	border-left: 3px solid var(--accent);
	position: relative;
}

/* Subtle console-style header bar on refined surfaces */
.surface::before,
.card::before,
.panel::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: var(--accent-weak);
	border-radius: var(--radius) var(--radius) 0 0;
}

.log-entry,
.deadline-item,
.integration {
	background: var(--bg-elevated);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	padding: calc(var(--space-3) + 3px) var(--space-3) var(--space-3);
	margin-bottom: var(--space-3);
	box-shadow: var(--shadow-inner), var(--shadow-elevated);
	border-left: 3px solid var(--accent);
	position: relative;
}

.log-entry:hover,
.deadline-item:hover,
.integration:hover {
	transform: translateY(-1px);
	box-shadow:
		var(--shadow-inner),
		0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Subtle console-style header bar on log entries / cards too */
.log-entry::before,
.deadline-item::before,
.integration::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: var(--accent-weak);
	border-radius: var(--radius) var(--radius) 0 0;
}

.log-entry h3,
.log-entry h4 {
	margin-bottom: 0.25rem;
}

/* =========================================
   Home / Days (bujo) view
   ========================================= */

.days-container {
	margin-bottom: 2rem;
}

.days-list {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.day {
	/* date | score | habits (grow, right-aligned) | sync */
	display: grid;
	grid-template-columns: auto auto 1fr auto;
	align-items: center;
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-left: 4px solid var(--accent);
	margin-bottom: 1px;
	padding: 0.35rem 0.5rem;
	font-size: 0.95rem;
	transition: border-color 80ms ease;
}

/* Stronger mono on dates, durations, etc. */
.day > span:first-child,
.log-entry p,
.log-entry span,
.day-score,
.month-score,
.grid-header {
	font-family: var(--ff-mono);
}

.day:hover {
	border-color: var(--border-strong);
	transform: translateY(-1px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.day > button {
	justify-self: end;
}

.day-score {
	font-weight: 700;
	font-family: var(--ff-mono);
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-left: 1rem;
}

/* Score color states (earthy natural progression - higher contrast on cards) */
.score-0 {
	color: #c48d7e;
} /* warm clay */
.score-1 {
	color: #b88f72;
} /* clay */
.score-2 {
	color: #b5a16e;
} /* warm earth */
.score-3 {
	color: #8fa36d;
} /* sage */
.score-4 {
	color: #8c5fa3;
} /* regal purple */

.day-habits {
	display: flex;
	align-items: center;
	justify-self: end;
	gap: 0.25rem;
	margin-right: 1rem;
}

.habit-spot {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0.25rem;
	border-radius: 2px;
	transition:
		background 80ms ease,
		color 80ms ease;
}

.habit-spot > svg {
	width: 1.5rem;
	height: 1.5rem;
	flex-shrink: 0;
}

.habit-spot:hover {
	background: var(--accent-dim);
	color: var(--accent-hover);
}

.habit-spot-done {
	color: var(--success);
}

.habit-spot-not-done {
	color: var(--danger);
}

/* =========================================
   Habits grid (year matrix)
   ========================================= */

.habits-grid {
	display: grid;
	gap: 1px;
	margin: var(--space-4) 0;
	max-width: min-content;
	background: var(--border);
	border: 1px solid var(--border);
	/* Allow hovered cells to scale outside their track without clipping */
	overflow: visible;
}

.grid-header {
	background: var(--accent-dim);
	color: var(--fg-base);
	padding: 0.45rem 0.5rem;
	text-align: center;
	font-weight: 600;
	font-size: 0.9rem;
	font-family: var(--ff-mono);
	cursor: default;
	user-select: none;
	transition: background-color 120ms ease;
}

.grid-header:hover {
	background: var(--accent);
}

/* Day number headers: show full weekday + day on hover */
.habit-grid-item.grid-header {
	position: relative;
}

.habit-header-tooltip {
	position: absolute;
	bottom: calc(100% + 0.35rem);
	left: 50%;
	transform: translateX(-50%);
	white-space: nowrap;
	padding: 0.35rem 0.6rem;
	background: var(--bg-elevated);
	border: 1px solid var(--border-strong);
	color: var(--fg-base);
	font-size: 1rem; /* ~30% larger than 0.75rem */
	font-weight: 500;
	font-family: var(--ff-mono);
	border-radius: var(--radius);
	box-shadow: var(--shadow-elevated);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	z-index: 20;
	transition: opacity 80ms ease, visibility 80ms ease;
}

.habit-grid-item.grid-header:hover .habit-header-tooltip {
	opacity: 1;
	visibility: visible;
}
.habit-grid-item:hover .habit-header-tooltip {
	opacity: 1;
	visibility: visible;
}

.habit-category {
	background: var(--bg-elevated);
	color: var(--fg-base);
	padding: 0.45rem 0.5rem;
	text-align: center;
	font-weight: 500;
}

.habit-cell {
	aspect-ratio: 1;
	background: var(--bg-base);
	border: 1px solid var(--border);
	cursor: pointer;
	position: relative;
	z-index: 0;
	transform-origin: center center;
	transition:
		transform 120ms ease,
		box-shadow 120ms ease,
		border-color 120ms ease,
		filter 120ms ease;
}

/* Dim type icon watermark — contrast tuned per cell state */
.habit-cell-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.habit-cell-icon > svg {
	width: 60%;
	height: 60%;
}

/* Colored cells (done / not_done): dark dim icon */
.habit-done .habit-cell-icon,
.habit-not_done .habit-cell-icon {
	color: var(--fg-inverse);
	opacity: 0.28;
}

/* Dark empty cells: muted light dim icon */
.habit-no_info .habit-cell-icon {
	color: var(--fg-muted);
	opacity: 0.35;
}

/* Pop out of the grid on hover */
.habit-cell:hover {
	z-index: 2;
	transform: scale(1.1);
	border-color: var(--accent-hover);
	box-shadow:
		0 0 0 1px var(--accent-dim),
		0 4px 12px rgba(0, 0, 0, 0.45);
	filter: brightness(1.12);
}

/* Press feedback on click */
.habit-cell:active {
	z-index: 2;
	transform: scale(1.1);
	border-color: var(--accent);
	box-shadow:
		0 0 0 2px var(--accent),
		0 1px 4px rgba(0, 0, 0, 0.35);
	filter: brightness(1.25);
	transition-duration: 60ms;
}

.habit-cell:focus-visible {
	z-index: 2;
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.habit-grid-item {
	max-width: 2.75rem;
	max-height: 2.75rem;
}

.habit-done {
	background: var(--success);
}

.habit-not_done {
	background: var(--danger);
}

.habit-no_info {
	background: var(--bg-surface);
}

/* Month header on habits page */
.habits-grid + h2,
h2:has(+ .habits-grid) {
	display: inline-block;
}

/* =========================================
   Month navigation
   ========================================= */

.month-navigation {
	display: flex;
	gap: var(--space-3);
	margin: var(--space-4) 0;
}

.month-score {
	font-weight: 700;
	font-family: var(--ff-mono);
	margin-left: var(--space-3);
	color: var(--accent);
}

/* =========================================
   Integrations
   ========================================= */

.integration h3 {
	margin-bottom: 0.25rem;
	display: flex;
	align-items: center;
}

.integration-icon {
	width: 1.25rem;
	height: 1.25rem;
	margin-right: 0.5rem;
	vertical-align: middle;
	/* Full color from the SVG itself; no currentColor tint */
}

.integration ul {
	margin-top: 0.5rem;
	padding-left: 1.1rem;
	color: var(--fg-muted);
	font-size: 0.95rem;
}

/* Integration status badges (colored pills) */
.status-badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border: 1px solid currentColor;
	background: var(--bg-elevated);
}

.status-connected {
	color: var(--success);
	border-color: var(--success);
}

.status-disconnected {
	color: var(--fg-muted);
	border-color: var(--border-strong);
}

.status-unknown {
	color: var(--warning);
	border-color: var(--warning);
}

.status-not-implemented {
	color: var(--border-strong);
	border-color: var(--border);
}

/* =========================================
   Utilities (kept + new)
   ========================================= */

.text-center {
	text-align: center;
}

.flex {
	display: flex;
	align-items: center;
}

.muted {
	color: var(--fg-muted);
}

.mono {
	font-family: var(--ff-mono);
}

/* Fun ligatures + contextual alternates on monospace data
   (Fira Code turns things like ->, <=, != into nicer glyphs when they appear
   in durations, comparisons, or any symbolic data — playful cyber/tech touch
   without hurting legibility).
*/
.mono,
.day-score,
.month-score,
.grid-header {
	font-feature-settings: "liga" "calt";
}

/* Small presentational helper used by a few labels */
.block {
	display: block;
}

/* Footer version */
.layout footer p {
	margin: 0;
}

.version {
	/* Make the version text bigger than the rest of the small footer */
	font-size: 0.95rem;
}

/* Skeleton / loading states for datastar in-flight (e.g. integrations, sync) */
.skeleton {
	background: linear-gradient(
		90deg,
		var(--bg-elevated) 25%,
		var(--bg-surface) 50%,
		var(--bg-elevated) 75%
	);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
	border-radius: var(--radius);
}

@keyframes skeleton-loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* Example: apply .skeleton to content during load, or to .integration, .day during datastar */
.integration.skeleton,
.day.skeleton {
	min-height: 2rem;
}
