/*
Theme Name: Portfolio Feed
Description: Schlankes Portfolio-Theme nach dem Vorbild von luzianmeier.ch. Projekte erscheinen als Feed (neueste zuerst), jedes Projekt klappt auf Klick zu einer horizontalen Bildreihe mit Text am Ende auf. Ohne Page-Builder.
Version: 1.0.0
Requires at least: 6.2
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: portfolio-feed
*/

/* ------------------------------------------------------------------
   Grundwerte (im Customizer teilweise überschreibbar)
------------------------------------------------------------------ */
:root {
	--pf-bg: #fafbf6;
	--pf-text: #000;
	--pf-font: Verdana, Helvetica, Arial, sans-serif;
	--pf-item: 480px;          /* Breite des ersten Bildes */
	--pf-gap: 20px;            /* Abstand zwischen Bildern */
	--pf-entry-gap: 30px;      /* Abstand zwischen Projekten */
	--pf-text-width: 300px;    /* Breite des Textblocks */
	--pf-offset: calc((100vw - var(--pf-item)) / 3); /* linker Rand wie Original (1/3 : 2/3) */
	--pf-ease: cubic-bezier(.22,.61,.36,1);
}

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

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

body {
	font-family: var(--pf-font);
	font-size: 16px;
	line-height: 1.35;
	color: var(--pf-text);
	background-color: var(--pf-bg);
	overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover, a:focus-visible { font-weight: bold; }
strong, b, .bold { font-weight: bold; }
.small { font-size: .7em; }
img { display: block; max-width: none; }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px,1px,1px,1px); white-space: nowrap;
}

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* ------------------------------------------------------------------
   Hintergrund-Collage (fix, hinter allem)
------------------------------------------------------------------ */
.pf-bkgnd {
	position: fixed;
	top: 0; left: 50%;
	z-index: -1;
	pointer-events: none;
}
.pf-bkgnd img {
	position: absolute;
	top: var(--pf-bkgnd-top, 20px);
	left: var(--pf-bkgnd-left, -240px);
	width: var(--pf-bkgnd-size, 700px);
	height: auto;
}

/* ------------------------------------------------------------------
   Navigation – Desktop (wie Original: Pfeil oben links)
------------------------------------------------------------------ */
.pf-nav {
	position: fixed;
	top: 20px; left: 20px;
	width: 300px;
	z-index: 100;
}
.pf-nav__toggle {
	display: block;
	width: 22px; height: 17px;
	background: none; border: 0; cursor: pointer;
	color: inherit;
}
.pf-nav__toggle svg { width: 22px; height: 17px; display: block; transition: transform .25s var(--pf-ease); }
.pf-nav[data-open="true"] .pf-nav__toggle svg { transform: rotate(180deg); }
.pf-nav__brand, .pf-nav__close { display: none; }

.pf-nav__panel {
	margin-top: 10px;
	display: none;
}
.pf-nav[data-open="true"] .pf-nav__panel { display: block; animation: pf-slide .2s var(--pf-ease); }
@keyframes pf-slide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.pf-nav__list { list-style: none; }
.pf-nav__list > li { margin-bottom: .5em; }
.pf-nav__list ul { list-style: none; }

.pf-drop__btn {
	font: inherit; font-weight: bold; text-transform: uppercase;
	background: none; border: 0; padding: 0; cursor: pointer; color: inherit;
	text-align: left;
}
.pf-drop__body { display: none; padding-top: .25em; }
.pf-drop[data-open="true"] .pf-drop__body { display: block; }
.pf-drop__body p { margin-bottom: .6em; }

.pf-nav__copy { margin-top: 2em; }

/* ------------------------------------------------------------------
   Feed & Projekte
------------------------------------------------------------------ */
.pf-feed { padding-top: var(--pf-spacer, 144px); padding-bottom: 40vh; }

.pf-entry {
	position: relative;
	margin-bottom: var(--pf-entry-gap);
	height: var(--pf-h);
	/* --pf-h = Höhe des ersten Bildes bei Breite --pf-item */
	--pf-h: calc(var(--pf-item) * var(--pf-ratio, 1));
}

.pf-track {
	display: flex;
	align-items: flex-end;
	gap: var(--pf-gap);
	height: 100%;
	padding-left: var(--pf-offset);
	padding-right: calc(var(--pf-offset) * 2);
	overflow: hidden;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}
.pf-track::-webkit-scrollbar { display: none; }

.pf-entry.is-open .pf-track {
	overflow-x: auto;
	cursor: grab;
}
.pf-entry.is-open .pf-track.is-dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }

.pf-el {
	flex: 0 0 auto;
	height: 100%;
	position: relative;
}
.pf-el img,
.pf-el video {
	height: 100%;
	width: auto;
	user-select: none;
	-webkit-user-drag: none;
}
.pf-el--first { width: var(--pf-item); cursor: pointer; }
.pf-el--first img { width: 100%; height: 100%; object-fit: cover; }
.pf-entry.is-open .pf-el--first { cursor: inherit; }

/* weitere Elemente: zu, bis aufgeklappt */
.pf-el--more {
	display: none;
	opacity: 0;
}
.pf-entry.is-open .pf-el--more { display: block; animation: pf-fade .6s var(--pf-ease) forwards; }
@keyframes pf-fade { to { opacity: 1; } }

.pf-el--media { aspect-ratio: 16 / 9; }
.pf-el--media iframe,
.pf-el--media .wp-block-embed__wrapper,
.pf-el--media figure { width: 100%; height: 100%; margin: 0; }
.pf-el--media iframe { display: block; border: 0; }

/* Textblock am Ende */
.pf-el--text {
	width: var(--pf-text-width);
	align-self: flex-end;
	height: auto;
	max-height: 100%;
	overflow-y: auto;
	scrollbar-width: thin;
}
.pf-text { padding-left: 0; }
.pf-text p,
.pf-text ul,
.pf-text ol { margin-bottom: .5em; }
.pf-text ul, .pf-text ol { padding-left: 1.2em; }
.pf-text .pf-title { margin-bottom: .5em; }
.pf-text > *:last-child { margin-bottom: 0; }

/* Farbfläche hinter dem Text (pro Projekt wählbar) */
.pf-text.has-bg {
	background: var(--pf-text-bg);
	padding: 18px 20px 16px;
}
/* Farbflächen aus dem Block-Editor (Absatz / Gruppe mit Hintergrund) */
.pf-text .has-background { padding: 14px 16px; margin-bottom: .5em; }

/* Bei geschlossenem Projekt: Hinweis (nur mobil sichtbar) */
.pf-caption { display: none; }

/* ------------------------------------------------------------------
   Pagination
------------------------------------------------------------------ */
.pf-pagination {
	padding-left: var(--pf-offset);
	width: calc(var(--pf-offset) + var(--pf-item));
	text-align: center;
}
.pf-pagination .page-numbers { padding: 0 .3em; }
.pf-pagination .current { font-weight: bold; }

.pf-empty { padding-left: var(--pf-offset); max-width: calc(var(--pf-offset) + 480px); }

/* ------------------------------------------------------------------
   Einzelansicht / Seiten (falls jemand direkt verlinkt)
------------------------------------------------------------------ */
.pf-page { padding: 120px var(--pf-offset) 80px; max-width: calc(var(--pf-offset) * 2 + 640px); }
.pf-page h1 { font-size: 1.1em; margin-bottom: 1em; }
.pf-page p { margin-bottom: .8em; }
.pf-page img { max-width: 100%; height: auto; }

/* ------------------------------------------------------------------
   Tablet
------------------------------------------------------------------ */
@media (max-width: 1100px) and (min-width: 768px) {
	:root { --pf-offset: 140px; }
}

/* ------------------------------------------------------------------
   Mobile
------------------------------------------------------------------ */
@media (max-width: 767px) {
	:root {
		--pf-item: calc(100vw - 32px);
		--pf-gap: 10px;
		--pf-entry-gap: 44px;
		--pf-offset: 16px;
		--pf-text-width: min(82vw, 340px);
	}

	body { font-size: 15px; }

	/* Collage dezenter */
	.pf-bkgnd img { --pf-bkgnd-size: 420px; --pf-bkgnd-left: -60px; --pf-bkgnd-top: 80px; opacity: .35; }

	/* Kopfleiste */
	.pf-nav {
		top: 0; left: 0; right: 0;
		width: auto;
		height: 52px;
		display: flex; align-items: center; justify-content: space-between;
		padding: 0 16px;
	}
	/* Hintergrund als eigene Ebene, damit das fixe Vollbild-Menü nicht eingesperrt wird */
	.pf-nav::before {
		content: ""; position: absolute; inset: 0; z-index: -1;
		background: color-mix(in srgb, var(--pf-bg) 88%, transparent);
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
		border-bottom: 1px solid rgba(0,0,0,.06);
	}
	.pf-nav__brand, .pf-nav__toggle { position: relative; z-index: 2; }
	.pf-nav[data-open="true"] .pf-nav__toggle { visibility: hidden; }
	.pf-nav__brand {
		display: block;
		font-weight: bold; text-transform: uppercase; font-size: 13px; letter-spacing: .02em;
	}
	.pf-nav__toggle {
		width: 44px; height: 44px; margin-right: -10px;
		display: flex; align-items: center; justify-content: center;
	}
	.pf-nav__toggle svg { display: none; }
	.pf-burger, .pf-burger::before, .pf-burger::after {
		display: block; width: 22px; height: 2px; background: currentColor; position: relative;
		transition: transform .25s var(--pf-ease), opacity .2s;
	}
	.pf-burger::before, .pf-burger::after { content: ""; position: absolute; left: 0; }
	.pf-burger::before { top: -7px; }
	.pf-burger::after { top: 7px; }

	/* Vollbild-Menü */
	.pf-nav__panel {
		display: block;
		position: fixed; inset: 0;
		margin: 0;
		background: var(--pf-bg);
		padding: 72px 24px calc(32px + env(safe-area-inset-bottom));
		overflow-y: auto;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
		visibility: hidden;
		opacity: 0;
		transform: translateY(-8px);
		transition: opacity .22s var(--pf-ease), transform .22s var(--pf-ease), visibility 0s .22s;
		z-index: 1;
	}
	.pf-nav[data-open="true"] .pf-nav__panel {
		visibility: visible; opacity: 1; transform: none;
		transition: opacity .22s var(--pf-ease), transform .22s var(--pf-ease);
		animation: none;
	}
	.pf-nav__close {
		display: flex; align-items: center; justify-content: center;
		position: absolute; top: 4px; right: 6px;
		width: 44px; height: 44px;
		background: none; border: 0; color: inherit; cursor: pointer;
		font-size: 28px; line-height: 1;
	}
	.pf-nav__list > li { margin-bottom: 0; border-bottom: 1px solid rgba(0,0,0,.1); }
	.pf-nav__list > li > a,
	.pf-drop__btn {
		display: flex; justify-content: space-between; align-items: center;
		width: 100%; min-height: 56px; font-size: 17px;
	}
	.pf-drop__btn::after { content: "+"; font-weight: normal; font-size: 22px; transition: transform .2s; }
	.pf-drop[data-open="true"] .pf-drop__btn::after { transform: rotate(45deg); }
	.pf-drop__body { padding: 0 0 18px; font-size: 16px; line-height: 1.5; }
	.pf-nav__copy { font-size: 12px; }

	/* Feed */
	.pf-feed { padding-top: 76px; }

	.pf-track {
		padding-right: 16px;
		scroll-padding-left: 16px;
		/* Vertikales Scrollen der Seite hat Vorrang, horizontales Wischen nur im Projekt */
		touch-action: pan-y;
	}
	.pf-entry.is-open .pf-track {
		touch-action: pan-x pan-y;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		cursor: auto;
	}
	.pf-el { scroll-snap-align: start; }
	:root { --pf-text-width: calc(100vw - 32px); }
	.pf-el--text {
		align-self: stretch;
		max-height: none;
		overflow: visible;
	}
	.pf-entry.is-open .pf-el--text,
	.pf-el--text:not(.pf-el--more) {
		display: flex; flex-direction: column; justify-content: flex-end;
	}
	.pf-el--text .pf-text { max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

	/* Titelzeile unter dem geschlossenen Projekt */
	.pf-caption {
		display: flex; justify-content: space-between; gap: 12px;
		padding: 8px 16px 0;
		font-size: 13px;
		position: absolute; top: 100%; left: 0; right: 0;
	}
	.pf-caption__title { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.pf-caption__hint { white-space: nowrap; opacity: .6; }

	.pf-pagination { width: auto; padding: 0 16px; }
	.pf-empty { padding: 0 16px; }
	.pf-page { padding: 80px 16px 60px; }
}

/* ruhige Variante bei reduzierter Bewegung */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Editor-Hilfe: Farbflächen im Block-Editor */
.is-style-farbflaeche { padding: 14px 16px; }
