/* Farben und Maße. Dark Mode überschreibt nur die Tokens. */
:root {
	color-scheme: light dark;

	--bg: #faf6ee;
	--surface: #ffffff;
	--text: #2b2a28;
	--muted: #6b675f;
	--border: #e6dfd1;
	--green: #1f5130;
	--green-soft: #e8f1ea;
	--red: #b3261e;
	--red-text: #b3261e;
	--on-accent: #ffffff;
	--gold: #c9962b;
	--gold-soft: #fbf3e0;
	--success: #1b6e20;
	--header-bg: #1f5130;
	--header-text: #ffffff;
	--focus: #c9962b;

	--radius: 0.75rem;
	--shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 12px rgb(0 0 0 / 0.05);
	--page-width: 40rem;
	--gutter: 1rem;

	/* Hintergrundbild mit Schleier, damit Text direkt auf dem Bild lesbar bleibt */
	--bg-image: url("../wichtelwald.jpg");
	--veil-top: rgb(250 246 238 / 0.88);
	--veil-bottom: rgb(250 246 238 / 0.65);

	/* Statische Schneeflocken als Hintergrundmuster */
	--snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%231f5130' stroke-opacity='.09' stroke-linecap='round' stroke-width='1.5'%3E%3Cg transform='translate(30 34)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Cg transform='translate(118 92) scale(.7)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Cg transform='translate(62 132) scale(.5)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Ccircle cx='96' cy='22' r='1.5' fill='%231f5130' fill-opacity='.09' stroke='none'/%3E%3Ccircle cx='20' cy='100' r='1.2' fill='%231f5130' fill-opacity='.09' stroke='none'/%3E%3Ccircle cx='144' cy='146' r='1.4' fill='%231f5130' fill-opacity='.09' stroke='none'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f2418;
		--surface: #173322;
		--text: #f3efe6;
		--muted: #b5bfb6;
		--border: #2b4a37;
		--green: #8fd19e;
		--green-soft: #1d3d2a;
		--red: #c0392b;
		--red-text: #ff8a80;
		--gold: #e0b354;
		--gold-soft: #2e2a17;
		--success: #8fd19e;
		--header-bg: #0b1c12;
		--focus: #e0b354;
		--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.25);
		--veil-top: rgb(15 36 24 / 0.9);
		--veil-bottom: rgb(15 36 24 / 0.7);

		--snow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23ffffff' stroke-opacity='.08' stroke-linecap='round' stroke-width='1.5'%3E%3Cg transform='translate(30 34)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Cg transform='translate(118 92) scale(.7)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Cg transform='translate(62 132) scale(.5)'%3E%3Cpath d='M0-8V8M-6.9-4L6.9 4M-6.9 4L6.9-4'/%3E%3C/g%3E%3Ccircle cx='96' cy='22' r='1.5' fill='%23ffffff' fill-opacity='.1' stroke='none'/%3E%3Ccircle cx='20' cy='100' r='1.2' fill='%23ffffff' fill-opacity='.1' stroke='none'/%3E%3Ccircle cx='144' cy='146' r='1.4' fill='%23ffffff' fill-opacity='.1' stroke='none'/%3E%3C/svg%3E");
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	font-family: system-ui, sans-serif;
	font-size: 1rem;
	line-height: 1.5;
	color: var(--text);
	background-color: var(--bg);
}

/* Fester Hintergrund als eigene Ebene, background-attachment: fixed funktioniert auf iOS nicht.
   30% hält auf schmalen Displays Wichtel und Fuchs im Bild. */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	background:
		var(--snow),
		linear-gradient(var(--veil-top), var(--veil-bottom)),
		var(--bg-image) 30% center / cover no-repeat,
		var(--bg);
}

/* Inhalt mittig, Ränder auf Geräten mit Notch frei halten */
main,
.site-footer {
	width: 100%;
	max-width: var(--page-width);
	margin: 0 auto;
	padding-left: max(var(--gutter), env(safe-area-inset-left));
	padding-right: max(var(--gutter), env(safe-area-inset-right));
}

main {
	flex: 1;
	padding-top: 1.25rem;
	padding-bottom: 1.5rem;
}

h1,
h2,
h3 {
	color: var(--green);
	line-height: 1.25;
	overflow-wrap: anywhere;
}

h1 {
	font-size: 1.6rem;
	margin: 0.25rem 0 0.75rem;
}

h2 {
	font-size: 1.2rem;
	margin: 0 0 0.5rem;
}

h3 {
	font-size: 1.05rem;
	margin: 1.25rem 0 0.4rem;
}

a {
	color: var(--green);
	text-underline-offset: 0.15em;
}

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

/* Kopfzeile mit Zuckerstangen-Band */
.site-header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding-top: max(0.75rem, env(safe-area-inset-top));
	padding-bottom: 0.75rem;
	padding-left: max(var(--gutter), env(safe-area-inset-left), (100% - var(--page-width)) / 2 + var(--gutter));
	padding-right: max(var(--gutter), env(safe-area-inset-right), (100% - var(--page-width)) / 2 + var(--gutter));
	background: var(--header-bg);
	color: var(--header-text);
}

.site-header::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -6px;
	height: 6px;
	background: repeating-linear-gradient(-45deg, var(--red) 0 8px, #ffffff 8px 16px);
}

.site-header a {
	color: var(--header-text);
	text-decoration: none;
}

.brand {
	font-weight: 700;
	font-size: 1.15rem;
	white-space: nowrap;
}

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

.site-header nav a {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
	padding: 0 0.6rem;
	border-radius: 0.5rem;
}

.site-header nav a:hover {
	background: rgb(255 255 255 / 0.12);
}

.site-footer {
	padding-top: 1rem;
	padding-bottom: max(1rem, env(safe-area-inset-bottom));
	text-align: center;
	color: var(--muted);
	font-size: 0.9rem;
}

/* Karten */
main > section,
main > form {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1rem;
	margin: 0 0 1rem;
}

main > section > :last-child {
	margin-bottom: 0;
}

.recipient {
	border-top: 4px solid var(--red);
	text-align: center;
}

.recipient::before {
	content: "🎁";
	display: block;
	font-size: 2.5rem;
	line-height: 1;
	margin-bottom: 0.5rem;
}

.recipient ul {
	text-align: left;
	display: inline-block;
	margin: 0 auto 0.75rem;
}

/* Formulare */
form {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

label,
legend {
	font-weight: 600;
}

input[type="text"] {
	width: 100%;
	min-height: 2.75rem;
	padding: 0.5rem 0.75rem;
	font: inherit;
	font-size: 1rem; /* mindestens 16px, sonst zoomt iOS beim Fokus */
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 0.5rem;
}

input[type="text"]:focus {
	border-color: var(--green);
}

fieldset {
	width: 100%;
	min-width: 0;
	margin: 0;
	padding: 0.75rem;
	border: 1px solid var(--border);
	border-radius: 0.5rem;
}

#wishes {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-bottom: 0.6rem;
}

input.secret-link {
	font-family: ui-monospace, monospace;
	font-size: 0.95rem;
	text-overflow: ellipsis;
	background: var(--green-soft);
}

/* Buttons: Primär rot, type=button als Sekundär, .danger als roter Umriss */
button {
	min-height: 2.75rem;
	padding: 0.5rem 1.1rem;
	font: inherit;
	font-weight: 600;
	color: var(--on-accent);
	background: var(--red);
	border: 2px solid var(--red);
	border-radius: 0.5rem;
	cursor: pointer;
}

button:hover {
	filter: brightness(1.08);
}

button[type="button"] {
	color: var(--green);
	background: transparent;
	border-color: var(--green);
}

button.danger {
	color: var(--red-text);
	background: transparent;
	border-color: var(--red-text);
}

/* Während htmx-Anfragen laufen */
.htmx-request button[type="submit"],
button.htmx-request {
	opacity: 0.6;
	pointer-events: none;
}

/* Auf dem Handy volle Breite, ab Tablet natürliche Breite */
form > button,
fieldset > button,
.link-actions > button {
	width: 100%;
}

@media (min-width: 32rem) {
	:root {
		--gutter: 1.5rem;
	}

	h1 {
		font-size: 1.9rem;
	}

	main > section,
	main > form {
		padding: 1.25rem 1.5rem;
	}

	form > button,
	fieldset > button,
	.link-actions > button {
		width: auto;
		align-self: flex-start;
	}
}

/* Teilen-Button und Lesezeichen-Hinweis unter Links */
.link-actions {
	margin-top: 0.5rem;
}

.bookmark-hint {
	font-size: 0.875rem;
	color: var(--muted);
}

kbd {
	padding: 0.05rem 0.35rem;
	font: inherit;
	font-size: 0.8rem;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 0.3rem;
}

/* Auf Touch-Geräten ohne Tastatur hilft der Tastenkürzel-Hinweis nicht */
@media (hover: none) and (pointer: coarse) {
	.bookmark-hint {
		display: none;
	}
}

/* Hinweise */
.error {
	color: var(--red-text);
	margin: 0;
}

.success {
	color: var(--success);
	margin: 0;
}

.warning {
	background: var(--gold-soft);
	border-left: 4px solid var(--gold);
	border-radius: 0.4rem;
	padding: 0.6rem 0.75rem;
}

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

/* Teilnehmerliste */
.participants {
	list-style: none;
	padding: 0;
	margin: 0;
}

.participants li {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.5rem 1rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border);
	overflow-wrap: anywhere;
}

.participants li:last-child {
	border-bottom: 0;
}

.participants form {
	display: block;
}

.participants form > button {
	width: auto;
}
