/* shared.css — Common styles for keef.id */

/* Ensure text is visible while web fonts load */
@font-face {
	font-family: 'Geist';
	font-display: swap;
	src: local('Geist');
}

@font-face {
	font-family: 'Geist Mono';
	font-display: swap;
	src: local('Geist Mono');
}

/* Reset */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* Core design tokens */
:root {
	--bg: #0c0c0c;
	--bg-elevated: #111111;
	--text: #ffffff;
	--text-secondary: #888888;
	--text-tertiary: #7a7a7a;
	--border: #1a1a1a;
	--border-hover: #2a2a2a;
}

html {
	scroll-behavior: smooth;
}

/* Base body */
body {
	font-family:
		'Geist',
		-apple-system,
		BlinkMacSystemFont,
		sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	overflow-x: hidden;
	line-height: 1.6;
}

/* Grain texture overlay */
body::before {
	content: '';
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	opacity: 0.02;
	z-index: 1000;
	background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Text selection */
::selection {
	background: rgba(255, 255, 255, 0.15);
}

/* Entrance animations */
@keyframes fadeSlideUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.animate-in {
	opacity: 0;
	animation: fadeSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade {
	opacity: 0;
	animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 {
	animation-delay: 0.1s;
}
.delay-2 {
	animation-delay: 0.25s;
}
.delay-3 {
	animation-delay: 0.4s;
}
.delay-4 {
	animation-delay: 0.55s;
}
.delay-5 {
	animation-delay: 0.7s;
}
.delay-6 {
	animation-delay: 0.85s;
}
.delay-7 {
	animation-delay: 1s;
}

/* ============================================
   Navigation (injected by nav.js)
   ============================================ */

body.has-nav {
	padding-top: 80px;
}

.site-nav {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	padding: 20px 40px;
	display: flex;
	align-items: center;
	gap: 32px;
	z-index: 100;
	background: transparent;
	backdrop-filter: blur(0px);
	-webkit-backdrop-filter: blur(0px);
	transition: background 0.4s ease, backdrop-filter 0.4s ease, -webkit-backdrop-filter 0.4s ease;
}

.site-nav.scrolled {
	background: rgba(12, 12, 12, 0.8);
	backdrop-filter: blur(20px);
	-webkit-backdrop-filter: blur(20px);
}

.site-nav .nav-logo {
	font-family: 'Geist Mono', monospace;
	font-size: 1rem;
	font-weight: 700;
	text-decoration: none;
	color: var(--text);
	letter-spacing: 2px;
	transition: opacity 0.3s ease;
}

.site-nav .nav-logo:hover {
	opacity: 0.6;
}

.site-nav .nav-links {
	display: flex;
	align-items: center;
	gap: 32px;
	list-style: none;
	margin-left: auto;
}

.site-nav .nav-links > li {
	position: relative;
	display: flex;
	align-items: center;
}

.site-nav .nav-links a,
.site-nav .nav-links .nav-dropdown-trigger {
	font-size: 0.85rem;
	line-height: 1;
	font-weight: 400;
	color: var(--text-secondary);
	text-decoration: none;
	transition: color 0.3s ease;
	letter-spacing: 0.5px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: none;
	font-family: inherit;
}

.site-nav .nav-links a:hover,
.site-nav .nav-links .nav-dropdown-trigger:hover,
.site-nav .nav-links a.active {
	color: var(--text);
}

.site-nav .nav-dropdown-trigger .arrow {
	font-size: 0.6rem;
	transition: transform 0.2s ease;
}

.site-nav .nav-item:hover .arrow,
.site-nav .nav-item.dropdown-open .arrow {
	transform: rotate(180deg);
}

/* Dropdown menu */
.site-nav .nav-dropdown {
	position: absolute;
	top: calc(100% + 12px);
	left: -16px;
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 8px 0;
	min-width: 180px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: all 0.2s ease;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.site-nav .nav-item:last-child .nav-dropdown {
	left: auto;
	right: -16px;
}

.site-nav .nav-item:hover .nav-dropdown,
.site-nav .nav-item.dropdown-open .nav-dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.site-nav .nav-dropdown a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	color: var(--text-secondary);
	font-size: 0.85rem;
	transition: all 0.2s ease;
}

.site-nav .nav-dropdown a:hover,
.site-nav .nav-dropdown a.dropdown-focused {
	background: var(--bg);
	color: var(--text);
}

.site-nav .nav-dropdown .icon {
	font-size: 1rem;
	width: 20px;
	text-align: center;
}

/* Mobile menu button (hidden on desktop) */
.site-nav .menu-btn {
	display: none;
	flex-direction: column;
	gap: 5px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 12px;
	margin-left: auto;
}

.site-nav .menu-btn span {
	display: block;
	width: 20px;
	height: 1px;
	background: var(--text);
	transition: all 0.3s ease;
}

.site-nav .menu-btn.open span:first-child {
	transform: rotate(45deg) translate(4px, 4px);
}

.site-nav .menu-btn.open span:last-child {
	transform: rotate(-45deg) translate(4px, -4px);
}

/* Mobile menu overlay */
.site-mobile-menu {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--bg);
	z-index: 99;
	padding: 100px 30px 30px;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
}

.site-mobile-menu.open {
	display: flex;
}

.site-mobile-menu a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	color: var(--text-secondary);
	text-decoration: none;
	font-size: 1rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg-elevated);
	transition: all 0.2s ease;
}

.site-mobile-menu a:hover {
	border-color: var(--border-hover);
	color: var(--text);
}

.site-mobile-menu .section-title {
	font-size: 0.75rem;
	color: var(--text-tertiary);
	text-transform: uppercase;
	letter-spacing: 1px;
	padding: 20px 0 8px;
	margin-top: 10px;
	border-top: 1px solid var(--border);
}

.site-mobile-menu .section-title:first-child {
	border-top: none;
	margin-top: 0;
	padding-top: 0;
}

/* Theme toggle in nav */
.site-nav .theme-toggle {
	position: relative;
	top: auto;
	right: auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 1px solid var(--border);
	background: none;
	color: var(--text-secondary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 0.3s ease, color 0.3s ease;
	padding: 0;
	flex-shrink: 0;
	z-index: auto;
}

/* Expand touch target to 44px without changing visual size */
.site-nav .theme-toggle::before {
	content: '';
	position: absolute;
	inset: -6px;
}

.site-nav .theme-toggle:hover {
	border-color: var(--text-tertiary);
	color: var(--text);
	transform: none;
}

/* Live clock in nav (homepage) */
.site-nav .time {
	font-family: 'Geist Mono', monospace;
	font-size: 0.8rem;
	color: var(--text-tertiary);
	letter-spacing: 0.5px;
}

/* ============================================
   Reading Progress Bar
   ============================================ */

.reading-progress {
	position: fixed;
	top: 0;
	left: 0;
	width: 0%;
	height: 2px;
	background: var(--text-secondary);
	z-index: 1001;
	pointer-events: none;
	transition: width 0.1s linear;
}

/* ============================================
   Page Transition
   ============================================ */

.page-transition {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: var(--bg);
	z-index: 9999;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.page-transition.active {
	opacity: 1;
	pointer-events: all;
}

/* ============================================
   Footer (enhanced with social links)
   ============================================ */

.footer {
	text-align: center;
	margin-top: 60px;
	padding-top: 40px;
	border-top: 1px solid var(--border);
}

.back-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--text-secondary);
	text-decoration: none;
	padding: 12px 24px;
	border: 1px solid var(--border);
	border-radius: 8px;
	font-size: 0.9rem;
	transition: all 0.3s ease;
}

.back-link:hover {
	color: var(--text);
	border-color: var(--border-hover);
	transform: translateY(-2px);
}

.footer-social {
	display: flex;
	justify-content: center;
	gap: 12px;
	margin-top: 20px;
}

.footer-social a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 1px solid var(--border);
	border-radius: 50%;
	color: var(--text-tertiary);
	text-decoration: none;
	transition: all 0.3s ease;
}

.footer-social a:hover {
	color: var(--text);
	border-color: var(--text-tertiary);
	transform: translateY(-2px);
}

.footer-social svg {
	width: 16px;
	height: 16px;
}

/* ============================================
   Keyboard Shortcuts Modal
   ============================================ */

.shortcuts-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.7);
	backdrop-filter: blur(4px);
	z-index: 2000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.shortcuts-overlay.open {
	display: flex;
}

.shortcuts-modal {
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 28px;
	max-width: 360px;
	width: 100%;
}

.shortcuts-modal h3 {
	font-family: 'Geist Mono', monospace;
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 20px;
	color: var(--text);
}

.shortcuts-modal .shortcut-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 0;
	border-bottom: 1px solid var(--border);
}

.shortcuts-modal .shortcut-row:last-child {
	border-bottom: none;
}

.shortcuts-modal .shortcut-label {
	font-size: 0.85rem;
	color: var(--text-secondary);
}

.shortcuts-modal kbd {
	font-family: 'Geist Mono', monospace;
	font-size: 0.75rem;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 4px;
	padding: 3px 8px;
	color: var(--text-tertiary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
	body.has-nav {
		padding-top: 70px;
	}

	.site-nav {
		padding: 18px 24px;
	}

	.site-nav .nav-links {
		display: none;
	}

	.site-nav .menu-btn {
		display: flex;
		z-index: 101;
	}

	.footer-social {
		gap: 10px;
	}

	.site-nav .time {
		display: none;
	}
}

/* ============================================
   Reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/* ============================================
   Light mode
   ============================================ */

[data-theme='light'] {
	--bg: #f5f5f5;
	--bg-elevated: #ffffff;
	--text: #111111;
	--text-secondary: #555555;
	--text-tertiary: #707070;
	--border: #e0e0e0;
	--border-hover: #cccccc;
}

[data-theme='light'] ::selection {
	background: rgba(0, 0, 0, 0.15);
}

[data-theme='light'] body::before {
	opacity: 0.015;
}

[data-theme='light'] .site-nav.scrolled {
	background: rgba(245, 245, 245, 0.8);
}

[data-theme='light'] .site-nav .nav-dropdown {
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

[data-theme='light'] .shortcuts-overlay {
	background: rgba(0, 0, 0, 0.4);
}

/* Theme toggle (fallback for pages without nav) */
.theme-toggle {
	position: fixed;
	top: 20px;
	right: 20px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var(--border);
	background: var(--bg-elevated);
	color: var(--text-secondary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1001;
	transition: border-color 0.3s ease, transform 0.3s ease, color 0.3s ease;
	padding: 0;
}

.theme-toggle:hover {
	border-color: var(--text-tertiary);
	color: var(--text);
	transform: scale(1.1);
}

/* Theme toast notification */
.theme-toast {
	position: fixed;
	bottom: 24px;
	right: 24px;
	background: var(--bg-elevated);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 10px 18px;
	border-radius: 20px;
	font-size: 0.8rem;
	font-family: inherit;
	z-index: 2000;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.theme-toast.show {
	opacity: 1;
	transform: translateY(0);
}

/* Screen reader only */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Focus */
:focus-visible {
	outline: 2px solid var(--text-secondary);
	outline-offset: 2px;
}

/* Restore focus ring on inputs that remove outline */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: 2px solid var(--text-secondary);
	outline-offset: 2px;
}
