/*
 * Commit Mono - Neutral programming typeface
 * Licensed under SIL Open Font License 1.1
 * https://commitmono.com/
 */

@font-face {
	font-family: 'CommitMono';
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/CommitMono-450-Regular.woff2") format('woff2');
}

@font-face {
	font-family: 'CommitMono';
	font-style: italic;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/CommitMono-450-Italic.woff2") format('woff2');
}

@font-face {
	font-family: 'CommitMono';
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("../fonts/CommitMono-700-Regular.woff2") format('woff2');
}

@font-face {
	font-family: 'CommitMono';
	font-style: italic;
	font-weight: 700;
	font-display: swap;
	src: url("../fonts/CommitMono-700-Italic.woff2") format('woff2');
}

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

/* Base */
:root {
	--bg: #fff;
	--fg: #000;
	--gray-1: #f5f5f5;
	--gray-2: #e5e5e5;
	--gray-3: #888;
	--font: 'CommitMono', ui-monospace, 'SF Mono', Menlo, monospace;
}

html {
	font-size: 14px;
}

body {
	font-family: var(--font);
	background: var(--bg);
	color: var(--fg);
	line-height: 1.5;
	min-height: 100vh;
}

a {
	color: inherit;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

img, video {
	max-width: 100%;
	height: auto;
	display: block;
}

button, input, textarea, select {
	font: inherit;
	color: inherit;
}

/* Header */
.header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem 2rem;
	border-bottom: 1px solid var(--gray-2);
}

.logo {
	font-weight: 700;
	font-size: 1rem;
	letter-spacing: 0.1em;
}

.nav {
	display: flex;
	gap: 1.5rem;
}

.nav a {
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

/* Main */
.main {
	max-width: 1600px;
	margin: 0 auto;
	padding: 2rem;
}

/* Admin Bar */
.admin-bar {
	margin-bottom: 1.5rem;
	display: flex;
	gap: 1rem;
}

/* Tags Bar */
.tags-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 2rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--gray-2);
}

.tag {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--gray-2);
	background: var(--bg);
	transition: all 0.15s ease;
}

.tag:hover, .tag.active {
	background: var(--fg);
	color: var(--bg);
	border-color: var(--fg);
	text-decoration: none;
}

/* Grid */
.grid {
	column-count: 4;
	column-gap: 1rem;
}

.grid-item {
	display: block;
	break-inside: avoid;
	margin-bottom: 1rem;
	background: var(--gray-1);
	border: 1px solid var(--gray-2);
	overflow: hidden;
	position: relative;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.grid-item:hover {
	text-decoration: none;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.grid-item img {
	width: 100%;
	display: block;
}

/* Quote Card */
.quote-card {
	padding: 1.5rem;
	min-height: 150px;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.quote-card blockquote {
	font-size: 1.1rem;
	font-style: italic;
	line-height: 1.6;
	margin-bottom: 0.75rem;
	white-space: pre-wrap;
}

.quote-card blockquote::before {
	content: '"';
}

.quote-card blockquote::after {
	content: '"';
}

.quote-card cite {
	font-size: 0.85rem;
	color: var(--gray-3);
	font-style: normal;
}

/* Link Card */
.link-card {
	padding: 1.5rem;
	min-height: 100px;
}

.link-title {
	font-weight: 700;
	margin-bottom: 0.5rem;
}

.link-url {
	font-size: 0.75rem;
	color: var(--gray-3);
	word-break: break-all;
}

/* Embed Placeholder */
.embed-placeholder {
	aspect-ratio: 16/9;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--fg);
	color: var(--bg);
	font-size: 2rem;
}

/* Play Indicator */
.play-indicator {
	position: absolute;
	bottom: 0.5rem;
	right: 0.5rem;
	width: 2rem;
	height: 2rem;
	background: rgba(0,0,0,0.7);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.75rem;
	pointer-events: none;
}

/* Item Overlay */
.item-overlay {
	position: absolute;
	inset: auto 0 0 0;
	padding: 0.75rem;
	background: rgba(255, 255, 255, 0.9);
	border-top: 1px solid var(--gray-2);
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.grid-item:hover .item-overlay {
	opacity: 1;
	transform: translateY(0);
}

.item-title {
	font-weight: 700;
	font-size: 0.9rem;
}

/* Item Tags */
.item-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.item-tag {
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	padding: 0.15rem 0.35rem;
	background: var(--gray-1);
	border: 1px solid var(--gray-2);
}

/* Item Page */
.item-page {
	max-width: 900px;
	margin: 0 auto;
}

.back-link {
	display: inline-block;
	font-size: 0.85rem;
	margin-bottom: 2rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.item-detail {
	border: 1px solid var(--gray-2);
}

.image-container img,
.video-container video {
	width: 100%;
}

.video-container {
	position: relative;
}

.video-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.3);
	cursor: pointer;
	transition: background 0.15s ease;
}

.video-overlay:hover {
	background: rgba(0, 0, 0, 0.4);
}

.video-overlay .play-button {
	width: 4rem;
	height: 4rem;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	padding-left: 0.25rem;
}



.embed-container {
	position: relative;
}

/* YouTube/Vimeo iframe embeds */
.embed-container iframe {
	max-width: 100%;
}

/* Twitter embeds */
.embed-container .twitter-tweet {
	margin: 1rem auto !important;
}

.quote-detail {
	padding: 3rem;
	text-align: center;
}

.quote-detail blockquote {
	font-size: 1.5rem;
	font-style: italic;
	line-height: 1.6;
	margin-bottom: 1rem;
	white-space: pre-wrap;
}

.quote-detail blockquote::before {
	content: '"';
}

.quote-detail blockquote::after {
	content: '"';
}

.quote-detail cite {
	color: var(--gray-3);
	font-style: normal;
}

.item-meta {
	padding: 1.5rem;
	border-top: 1px solid var(--gray-2);
}

.item-meta h1 {
	font-size: 1.25rem;
	font-weight: 700;
	margin-bottom: 0.75rem;
}

.item-meta .description {
	margin-bottom: 1rem;
	color: var(--gray-3);
	white-space: pre-wrap;
}

.item-meta .source-link {
	display: block;
	font-size: 0.85rem;
	color: var(--gray-3);
	word-break: break-all;
	margin-bottom: 1rem;
}

.item-meta .item-tags {
	background: none;
	border: none;
	padding: 0;
	margin-bottom: 1rem;
	gap: 0.5rem;
}

.item-meta .timestamp {
	display: block;
	font-size: 0.75rem;
	color: var(--gray-3);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.item-actions {
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--gray-2);
	display: flex;
	gap: 0.5rem;
}

/* Buttons */
.btn {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	padding: 0.5rem 1rem;
	border: 1px solid var(--fg);
	background: var(--bg);
	cursor: pointer;
	transition: all 0.15s ease;
}

.btn:hover {
	background: var(--fg);
	color: var(--bg);
}

.btn-danger {
	border-color: #c00;
	color: #c00;
}

.btn-danger:hover {
	background: #c00;
	color: #fff;
}

.btn-close {
	background: none;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	line-height: 1;
}

/* Modal */
.modal {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.5);
	z-index: 1000;
	align-items: center;
	justify-content: center;
}

.modal.active {
	display: flex;
}

.modal-content {
	background: var(--bg);
	width: 90%;
	max-width: 500px;
	max-height: 90vh;
	overflow-y: auto;
	border: 1px solid var(--fg);
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--gray-2);
}

.modal-header h2 {
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.1em;
}

.modal-tabs {
	display: flex;
	border-bottom: 1px solid var(--gray-2);
}

.modal-tabs .tab {
	flex: 1;
	padding: 0.75rem;
	background: none;
	border: none;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	cursor: pointer;
	border-bottom: 2px solid transparent;
}

.modal-tabs .tab.active {
	border-bottom-color: var(--fg);
}

.modal-body {
	padding: 1.5rem;
}

.tab-content {
	display: none;
}

.tab-content.active {
	display: block;
}

/* Forms */
form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

input, textarea {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid var(--gray-2);
	background: var(--bg);
}

input:focus, textarea:focus {
	outline: none;
	border-color: var(--fg);
}

textarea {
	resize: vertical;
	min-height: 80px;
}

input[type="file"] {
	padding: 0.5rem;
}

/* Preview */
.preview {
	padding: 1rem;
	background: var(--gray-1);
	border: 1px solid var(--gray-2);
	display: none;
}

.preview.active {
	display: block;
}

.preview img {
	max-width: 200px;
	margin-bottom: 0.5rem;
}

.preview-title {
	font-weight: 700;
	margin-bottom: 0.25rem;
}

.preview-description {
	font-size: 0.85rem;
	color: var(--gray-3);
	white-space: pre-wrap;
}

/* Image Gallery (detail page) */
.image-gallery {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 2px;
}

.image-gallery img {
	width: 100%;
	height: auto;
	display: block;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.image-gallery img:hover {
	opacity: 0.9;
}

/* Single image when odd count - make last one full width */
.image-gallery img:last-child:nth-child(odd) {
	grid-column: span 2;
}

/* Gallery Cycling (home grid) */
.grid-item-images {
	position: relative;
	width: 100%;
}

.grid-item-images img {
	width: 100%;
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	opacity: 0;
	transition: opacity 0.4s ease;
}

.grid-item-images img:first-child {
	position: relative;
}

.grid-item-images img.active {
	opacity: 1;
}

/* Gallery Indicator */
.gallery-indicator {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 0.7rem;
	padding: 0.2rem 0.4rem;
	pointer-events: none;
}

/* Responsive */
@media (max-width: 1200px) {
	.grid {
		column-count: 3;
	}
}

@media (max-width: 900px) {
	.grid {
		column-count: 2;
	}
	
	.main {
		padding: 1rem;
	}
}

@media (max-width: 600px) {
	.grid {
		column-count: 1;
	}
	
	.header {
		padding: 1rem;
	}
	
	.quote-detail {
		padding: 2rem 1rem;
	}
	
	.quote-detail blockquote {
		font-size: 1.25rem;
	}
}
