/* Rasende2 — hand-written, no build step. Colours come from custom properties
   so dark mode is one @media block rather than a variant on every rule. */

:root {
	--bg: #ffffff;
	--surface: #ffffff;
	--text: #0f172a;
	--text-muted: #64748b;
	--border: #e2e8f0;
	--accent: #1d4ed8;
	--accent-text: #1e3a8a;
	--accent-soft: #dbeafe;
	--up: #16a34a;
	--down: #dc2626;

	--flash-info: #dbeafe;
	--flash-warn: #fef3c7;
	--flash-error: #fee2e2;
	--flash-text: #0f172a;

	--radius: 6px;
	--gap: 1rem;
	--measure: 42rem;

	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f172a;
		--surface: #1e293b;
		--text: #f1f5f9;
		--text-muted: #94a3b8;
		--border: #334155;
		--accent: #93c5fd;
		--accent-text: #1e3a8a;
		--accent-soft: #bfdbfe;
	}
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	line-height: 1.6;
}

a {
	color: var(--accent);
}

a:hover {
	text-decoration: underline;
}

img {
	max-width: 100%;
	height: auto;
}

h1,
h2 {
	line-height: 1.25;
}

/* Layout ------------------------------------------------------------------ */

.page {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.page-body {
	flex: 1;
	padding-top: 1.5rem;
}

.container {
	margin: 0 auto;
	max-width: 1600px;
	padding: var(--gap);
}

.centered {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
}

.site-header {
	display: flex;
	justify-content: center;
	padding: 0.75rem;
	border-bottom: 1px solid var(--border);
}

.site-header nav {
	display: flex;
	gap: 1.25rem;
}

.site-header a {
	color: inherit;
	text-decoration: none;
}

.site-header a.current {
	font-weight: 700;
}

/* The footer holds the login control and the language switcher, so its items
   need separating; before there were editions it only ever had one child. */
.site-footer {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem;
	border-top: 1px solid var(--border);
	font-size: 0.875rem;
}

/* Controls ---------------------------------------------------------------- */

.btn-primary {
	display: inline-block;
	padding: 0.5rem 0.9rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--accent-soft);
	color: var(--accent-text);
	font: inherit;
	text-decoration: none;
	cursor: pointer;
}

.btn-primary:disabled {
	opacity: 0.5;
	cursor: default;
}

.btn-block {
	width: 100%;
}

.select,
input[type="search"],
input[type="email"],
input[type="password"],
input[type="text"] {
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin-bottom: var(--gap);
	text-align: left;
}

.field label {
	font-size: 0.875rem;
	font-weight: 600;
}

.panel {
	width: 100%;
	max-width: 24rem;
	padding: 1.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.badge {
	display: inline-block;
	padding: 0 0.5rem;
	border-radius: var(--radius);
	background: var(--accent-soft);
	color: var(--accent-text);
	font-size: 0.875rem;
	font-weight: 600;
}

/* Index ------------------------------------------------------------------- */

.lead {
	font-size: 1.5rem;
}

.headline {
	margin: 0.5rem 0;
	font-size: clamp(1.75rem, 5vw, 3rem);
	line-height: 1.3;
}

.item-link {
	color: inherit;
	text-decoration: none;
}

.earlier {
	margin: 2.5rem 0;
}

.section-title {
	font-size: 1.125rem;
	font-weight: 700;
}

/* The credit sits in the footer, pushed to the left edge; the auto margin is what
   holds the login control and the language switcher over on the right. */
.credit {
	margin-right: auto;
	color: var(--text-muted);
}

.charts-section {
	margin-top: 2rem;
}

.charts {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap);
}

/* Search ------------------------------------------------------------------ */

.search-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
}

.search-options {
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

.search-results {
	margin-top: 3rem;
}

.bars {
	fill: var(--text);
}

/* Fake news --------------------------------------------------------------- */

.fake-news-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--gap);
}

.fake-news-controls {
	display: flex;
	align-items: flex-end;
	gap: var(--gap);
}

.fake-news-controls .field {
	margin-bottom: 0;
}

/* One rule replaces five Tailwind breakpoints: cards are at least 256px wide
   and the browser fits as many per row as there is room for. */
.article-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
	gap: 1.5rem;
	padding: var(--gap) 0;
}

.article-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.article-card-img {
	width: 100%;
	height: 384px;
	object-fit: cover;
}

.article-card-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	padding: var(--gap);
}

.article-card-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.5rem;
	color: var(--text-muted);
	font-size: 0.75rem;
}

.article-card-title {
	margin: 0 0 0.5rem;
	font-size: 1.125rem;
}

.article-card-title a {
	color: inherit;
	text-decoration: none;
}

.article-card-title a:hover {
	text-decoration: underline;
}

.article-card-excerpt {
	margin: 0 0 var(--gap);
	color: var(--text-muted);
}

.article-card-footer {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--gap);
	margin-top: auto;
}

.grid-more {
	display: flex;
	align-items: flex-end;
}

.votes {
	display: flex;
	align-items: center;
	gap: var(--gap);
}

.vote {
	padding: 0;
	border: 0;
	background: none;
	color: var(--text-muted);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}

.vote-up.voted {
	color: var(--up);
}

.vote-down.voted {
	color: var(--down);
}

.vote-count {
	font-weight: 600;
}

/* Articles ---------------------------------------------------------------- */

.prose {
	max-width: var(--measure);
}

.admin-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--gap);
	margin-bottom: var(--gap);
}

.title-generator-results {
	margin-top: 3rem;
}

.error {
	color: var(--down);
}

/* Flash ------------------------------------------------------------------- */

.flash {
	position: relative;
	margin: var(--gap);
	padding: var(--gap);
	border-radius: var(--radius);
	color: var(--flash-text);
}

.flash p {
	margin: 0.25rem 0;
	font-size: 1.125rem;
}

.flash-info {
	background: var(--flash-info);
}

.flash-warn {
	background: var(--flash-warn);
}

.flash-error {
	background: var(--flash-error);
}

.flash-close {
	position: absolute;
	top: 0.25rem;
	right: 0.5rem;
	border: 0;
	background: none;
	color: inherit;
	font-size: 1.25rem;
	cursor: pointer;
}

/* Animation --------------------------------------------------------------- */

.pulse {
	animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
	50% {
		opacity: 0.5;
	}
}

.htmx-indicator {
	opacity: 0;
	transition: opacity 500ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.pulse,
	.htmx-indicator {
		animation: none;
		transition: none;
	}
}

br {
	overflow-wrap: normal;
	word-break: normal;
}
