/**
 * Openstream Motion: Scroll-Effekte, Startseiten-Intro, Zürcher Skyline.
 *
 * Alles ist nur aktiv, wenn html.os-motion gesetzt ist (Inline-Script im
 * <head>, nur ohne «Bewegung reduzieren»). Ohne JavaScript oder mit reduzierter
 * Bewegung bleibt die Seite statisch und vollständig sichtbar.
 * Opt-out pro Block: zusätzliche CSS-Klasse «os-no-motion».
 */

:root {
	--os-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
	--os-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
	--os-reveal-dur: 1s;
}

/* ------------------------------------------------------------------ */
/* Scroll-Reveal                                                       */
/* ------------------------------------------------------------------ */

html.os-motion [data-os-reveal] {
	transition:
		opacity var(--os-reveal-dur) var(--os-ease-out),
		transform var(--os-reveal-dur) var(--os-ease-out),
		filter var(--os-reveal-dur) var(--os-ease-out),
		clip-path 1.2s var(--os-ease-out);
	transition-delay: var(--os-delay, 0ms);
}

html.os-motion [data-os-reveal]:not(.is-inview) {
	opacity: 0;
}

/* Seitlich einfahrende Elemente dürfen die Seite nicht verbreitern (sonst
   lässt sie sich auf dem Handy seitwärts schieben). clip statt hidden, damit
   der fixierte Header (position: sticky) weiter funktioniert. */
html.os-motion .wp-site-blocks {
	overflow-x: clip;
}

/* Aufsteigen mit Unschärfe */
html.os-motion [data-os-reveal="rise"]:not(.is-inview) {
	transform: translate3d(0, 64px, 0);
	filter: blur(6px);
}

/* Seitlich einfahren (Beitragslisten, abwechselnd) */
html.os-motion [data-os-reveal="slide-left"]:not(.is-inview) {
	transform: translate3d(-80px, 0, 0);
}
html.os-motion [data-os-reveal="slide-right"]:not(.is-inview) {
	transform: translate3d(80px, 0, 0);
}

/* Bilder: Vorhang von unten, Bild zoomt zurück */
html.os-motion [data-os-reveal="clip"] {
	clip-path: inset(0 0 0 0);
}
html.os-motion [data-os-reveal="clip"]:not(.is-inview) {
	opacity: 1;
	clip-path: inset(100% 0 0 0);
}
html.os-motion [data-os-reveal="clip"] img,
html.os-motion [data-os-reveal="clip"] video,
html.os-motion [data-os-reveal="clip"] iframe {
	transition: transform 1.6s var(--os-ease-out);
	transition-delay: var(--os-delay, 0ms);
}
html.os-motion [data-os-reveal="clip"]:not(.is-inview) img,
html.os-motion [data-os-reveal="clip"]:not(.is-inview) video {
	transform: scale(1.25);
}

/* Bilder in Beiträgen: aus Streifen zusammensetzen (motion.js, playBars) */
html.os-motion [data-os-reveal="bars"] {
	position: relative;
}
html.os-motion [data-os-reveal="bars"]:not(.is-inview) {
	opacity: 1;
}
html.os-motion [data-os-reveal="bars"]:not(.os-bars-done) img {
	opacity: 0;
}
.os-bars {
	position: absolute;
	z-index: 1;
	overflow: hidden;
	pointer-events: none;
}
.os-bars > i {
	position: absolute;
	left: 0;
	width: 100%;
	background-repeat: no-repeat;
	opacity: 0;
	transition: transform 0.9s var(--os-ease-out), opacity 0.6s ease;
}
.os-bars.is-go > i {
	transform: none !important;
	opacity: 1;
}

/* Schlagwörter: aufploppen */
html.os-motion [data-os-reveal="pop"] {
	transition-timing-function: var(--os-ease-spring);
	transition-duration: 0.6s;
}
html.os-motion [data-os-reveal="pop"]:not(.is-inview) {
	transform: scale(0.4) translate3d(0, 20px, 0);
}

/* Newsletter-Box: heranzoomen */
html.os-motion [data-os-reveal="zoom"]:not(.is-inview) {
	transform: scale(0.88);
}

/* Überschriften: Wörter steigen einzeln aus einer Maske auf */
html.os-motion [data-os-reveal="words"] {
	opacity: 1;
}
.os-word {
	display: inline-block;
	overflow: hidden;
	vertical-align: top;
	padding-bottom: 0.08em;
	margin-bottom: -0.08em;
}
.os-word > span {
	display: inline-block;
	transition: transform 0.9s var(--os-ease-out);
	transition-delay: calc(var(--os-delay, 0ms) + var(--os-i, 0) * 70ms);
}
html.os-motion [data-os-reveal="words"]:not(.is-inview) .os-word > span {
	transform: translate3d(0, 110%, 0) rotate(4deg);
}

/* Parallax-Bilder: JS setzt --os-parallax (-1 … 1) */
html.os-motion .os-parallax {
	overflow: hidden;
}
html.os-motion .os-parallax img {
	transform: translate3d(0, calc(var(--os-parallax, 0) * -6%), 0) scale(1.14);
	will-change: transform;
}
html.os-motion .os-parallax[data-os-reveal="clip"]:not(.is-inview) img {
	transform: translate3d(0, 0, 0) scale(1.3);
}

/* ------------------------------------------------------------------ */
/* Lesefortschritt in Beiträgen                                        */
/* ------------------------------------------------------------------ */

.os-progress {
	position: fixed;
	inset: 0 0 auto 0;
	height: 3px;
	z-index: 100000;
	pointer-events: none;
	transform-origin: 0 50%;
	transform: scaleX(var(--os-progress, 0));
	background: linear-gradient(90deg, var(--wp--preset--color--accent-2, #f6cff4), var(--wp--preset--color--accent-1, #ffee58));
}
.admin-bar .os-progress {
	top: var(--wp-admin--admin-bar--height, 32px);
}

/* ------------------------------------------------------------------ */
/* Zürcher Skyline (Startseite)                                        */
/* ------------------------------------------------------------------ */

.os-skyline {
	position: relative;
	z-index: 0;
	width: 100%;
	height: clamp(150px, 19vw, 330px);
	/* --os-sky-push: mobil per JS, damit die Skyline am unteren Bildschirmrand steht */
	margin-top: calc(clamp(-120px, -5vw, -24px) + var(--os-sky-push, 0px));
	/* Grauton zwischen Text- und Hintergrundfarbe, in beiden Modi dezent */
	color: color-mix(in srgb, var(--wp--preset--color--contrast) 50%, var(--wp--preset--color--base));
	pointer-events: none;
	overflow: hidden;
}
html.os-motion .os-skyline {
	animation: os-sky-in 1.2s var(--os-ease-out) both;
}
@keyframes os-sky-in {
	from { opacity: 0; }
}

/* Zwei deckungsgleiche Ebenen: «static» mit Skizzen-Filter, «live» ohne
   Filter für alles Bewegte (sonst würde der Filter in jedem Frame neu laufen). */
.os-skyline__svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: visible;
	stroke-width: 0.9;
}
.os-skyline__svg path,
.os-skyline__svg circle {
	vector-effect: non-scaling-stroke;
}
.os-skyline__svg--static > g {
	filter: url(#os-sky-sketch);
}

/* Handy: Die Skyline ist breiter als der Bildschirm (sonst sähe man nur die
   Mitte). Sie wandert langsam von rechts nach links und zurück, beide Ebenen
   gleich, damit sie deckungsgleich bleiben. */
@media (max-width: 781px) {
	.os-skyline {
		height: 180px; /* 20 % höher als die Mindesthöhe von 150px */
	}
	.os-skyline__svg {
		width: calc(180px * 1600 / 290);
		will-change: transform;
		animation: os-sky-pan 48s ease-in-out infinite alternate;
	}
}
@keyframes os-sky-pan {
	from { transform: translate3d(0, 0, 0); }
	to   { transform: translate3d(calc(100vw - 100%), 0, 0); }
}

/* Tooltips nur mit Maus; auf Touch-Geräten ohne Hover keine Trefferflächen. */
@media (hover: none) {
	.os-skyline .os-sky-lm {
		pointer-events: none;
	}
}

/* Deckkraft über die Strichfarbe, nicht über die Gruppe: so verdecken die mit
   Hintergrundfarbe gefüllten Gebäude die Hügellinien dahinter vollständig. */
.os-sky-far,
.os-sky-water,
.os-sky-cloud,
.os-sky-birds { stroke: color-mix(in srgb, currentColor 60%, transparent); }
.os-sky-mid   { stroke: color-mix(in srgb, currentColor 80%, transparent); }
.os-sky-near  { stroke: currentColor; }
.os-sky-mid path,
.os-sky-near path,
.os-sky-near circle {
	fill: var(--wp--preset--color--base);
}

/* Parallax der Ebenen: JS setzt --os-sky (0 … 1, Fortschritt beim Wegscrollen) */
.os-sky-far   { transform: translate3d(0, calc(var(--os-sky, 0) * 40px), 0); }
.os-sky-cloud { transform: translate3d(calc(var(--os-sky, 0) * -80px), calc(var(--os-sky, 0) * 50px), 0); }

/* Wahrzeichen: Hover hebt hervor, Tooltip kommt aus motion.js */
.os-sky-lm {
	pointer-events: all;
	cursor: help;
	transition: stroke 0.25s ease;
}
.os-sky-lm:hover,
.os-sky-lm.is-active {
	stroke: var(--wp--preset--color--contrast);
}
.os-skyline .os-sky-hit {
	stroke: none;
	fill: none;
}
.os-sky-tip {
	position: fixed;
	z-index: 60;
	left: 0;
	top: 0;
	max-width: 240px;
	padding: 8px 12px;
	border-radius: 8px;
	/* Durchsichtig: Skyline-Linien bleiben dahinter sichtbar, feine Kante. */
	background: color-mix(in srgb, var(--wp--preset--color--base) 82%, transparent);
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast) 30%, transparent);
	color: var(--wp--preset--color--contrast);
	font-size: 0.85rem;
	line-height: 1.35;
	pointer-events: none;
	opacity: 0;
	transform: translate3d(var(--x, 0), var(--y, 0), 0) translate(-50%, calc(-100% - 14px));
	transition: opacity 0.2s ease;
}
.os-sky-tip.is-visible {
	opacity: 1;
}
.os-sky-tip strong {
	display: block;
	font-weight: 600;
}
.os-sky-tip span {
	opacity: 0.8;
}
.os-sky-tip sup {
	font-size: 0.6em;
	line-height: 0;
}

/* Dezente Daueranimationen (angehalten, solange die Skyline nicht sichtbar ist) */
.os-skyline.is-paused * {
	animation-play-state: paused !important;
}
.os-sky-wave {
	stroke-dasharray: 18 26;
	animation: os-wave 9s linear infinite;
}
.os-sky-wave--2 { stroke-dasharray: 10 34; animation-duration: 13s; animation-direction: reverse; }
.os-sky-wave--3 { stroke-dasharray: 6 40; animation-duration: 17s; }
@keyframes os-wave {
	to { stroke-dashoffset: -440; }
}
.os-sky-beacon {
	fill: #e5484d;
	animation: os-beacon 2.6s ease-in-out infinite;
}
.os-sky-beacon--prime { animation-delay: 1.3s; }
@keyframes os-beacon {
	0%, 60%, 100% { fill-opacity: 0.15; }
	70%, 85% { fill-opacity: 1; }
}
.os-sky-crane-jib {
	transform-box: view-box;
	transform-origin: 520px 96px;
	animation: os-crane 22s ease-in-out infinite;
}
@keyframes os-crane {
	0%, 100% { transform: scaleX(1); }
	45%, 55% { transform: scaleX(-0.7); }
}
.os-sky-crane-hook {
	animation: os-hook 11s ease-in-out infinite;
}
@keyframes os-hook {
	50% { transform: translateY(26px); }
}
.os-sky-clock {
	transform-box: view-box;
	transform-origin: 720px 146px;
	animation: os-clock 60s linear infinite;
}
@keyframes os-clock {
	to { transform: rotate(360deg); }
}
.os-sky-birds {
	animation: os-birds 38s linear infinite;
}
@keyframes os-birds {
	from { transform: translate3d(-900px, 20px, 0); }
	to   { transform: translate3d(1000px, -30px, 0); }
}

/* Schallwellen beim Lautsprecher (Höngg) */
.os-sky-sound path {
	fill: none !important;
	animation: os-sound 2.4s ease-out infinite;
}
.os-sky-sound path:nth-child(2) { animation-delay: 0.3s; }
.os-sky-sound path:nth-child(3) { animation-delay: 0.6s; }
@keyframes os-sound {
	0%, 100% { opacity: 0; }
	30% { opacity: 1; }
	70% { opacity: 0; }
}

/* Fensterlichter nur nachts (Dark Mode) */
.os-sky-lights {
	display: none;
	fill: var(--wp--preset--color--accent-1, #ffee58);
	opacity: 0.45;
}
html[data-theme="dark"] .os-sky-lights {
	display: inline;
}
.os-sky-lights rect {
	animation: os-twinkle 7s ease-in-out infinite;
}
.os-sky-lights rect:nth-child(4n)   { animation-delay: 2s; animation-duration: 9s; }
.os-sky-lights rect:nth-child(4n+1) { animation-delay: 4.5s; }
.os-sky-lights rect:nth-child(5n)   { animation: none; }
@keyframes os-twinkle {
	50% { opacity: 0.25; }
}

/* ------------------------------------------------------------------ */
/* Startseiten-Intro: zuerst nur OPENSTREAM                            */
/* ------------------------------------------------------------------ */

html.os-intro,
html.os-intro body {
	overflow: hidden;
}

/* Alles ausser der Wortmarke ausblenden (nur Deckkraft, bleibt im DOM). */
.os-intro-target {
	transition:
		opacity 1s var(--os-ease-out),
		transform 1.1s var(--os-ease-out),
		filter 1s var(--os-ease-out);
	transition-delay: var(--os-delay, 0ms);
}
/* Per Selektor ausblenden, damit nichts aufblitzt, bevor motion.js (defer)
   geladen ist. Die Skyline bleibt sichtbar. */
html.os-intro header.wp-block-template-part .wp-block-group:has(> .wp-block-navigation),
html.os-intro header.wp-block-template-part :is(.wp-block-navigation, .wp-block-search),
html.os-intro main > :not(.entry-content),
html.os-intro main .entry-content > :not(.os-skyline),
html.os-intro footer.wp-block-template-part,
html.os-intro .os-intro-target {
	opacity: 0;
	transform: translate3d(0, 30px, 0);
	filter: blur(8px);
	pointer-events: none;
}
html.os-intro header.wp-block-template-part .wp-block-group:has(> .wp-block-navigation),
html.os-intro .os-intro-target--nav {
	transform: translate3d(0, -20px, 0);
}

/* Wortmarke in der Fenstermitte, gleitet beim Start an ihren Platz. */
.os-intro-mark {
	transition: transform 1.3s var(--os-ease-out);
}
html.os-intro .os-intro-mark {
	transform: translate3d(0, var(--os-intro-shift, 0px), 0) scale(1.04);
}

/* Hinweis unten in der Mitte */
.os-intro-hint {
	position: fixed;
	left: 50%;
	bottom: max(28px, env(safe-area-inset-bottom));
	z-index: 50;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	transform: translateX(-50%);
	color: var(--wp--preset--color--contrast);
	font-size: 0.8rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	opacity: 0;
	transition: opacity 0.6s ease;
	pointer-events: none;
}
/* Die Laufweite hängt auch hinter dem letzten Buchstaben Raum an: ausgleichen,
   damit Wort und Linie optisch mittig stehen. */
.os-intro-hint > span:first-child {
	margin-right: -0.18em;
}
.os-intro-hint.is-placed {
	bottom: auto;
	transform: translate(-50%, -100%);
}
html.os-intro .os-intro-hint.is-visible {
	opacity: 0.6;
}
.os-intro-hint__line {
	width: 1px;
	height: 44px;
	background: currentColor;
	transform-origin: top;
	animation: os-hint 1.8s var(--os-ease-out) infinite;
}
@keyframes os-hint {
	0% { transform: scaleY(0); opacity: 1; }
	60% { transform: scaleY(1); opacity: 1; }
	100% { transform: scaleY(1) translateY(20px); opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* Newsletter (Startseite): «Anmelden»-Button                           */
/* ------------------------------------------------------------------ */

/* Beim Erscheinen zwei weiche Ringe, danach alle paar Sekunden ein
   Lichtstreif über den Button. Hover hebt ihn leicht an. */
.os-cta {
	position: relative;
	overflow: hidden;
	isolation: isolate;
	transition: transform 0.35s var(--os-ease-out), box-shadow 0.35s var(--os-ease-out);
}
.os-cta::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(110deg, transparent 35%, color-mix(in srgb, var(--wp--preset--color--accent-1, #ffee58) 75%, transparent) 50%, transparent 65%);
	transform: translateX(-120%);
}
.os-cta.is-live {
	animation: os-cta-ring 1.6s ease-out 2;
}
.os-cta.is-live::after {
	animation: os-cta-sheen 6s ease-in-out 1.2s infinite;
}
.os-cta:hover,
.os-cta:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--wp--preset--color--contrast) 60%, transparent);
}
@keyframes os-cta-ring {
	0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--wp--preset--color--contrast) 45%, transparent); }
	100% { box-shadow: 0 0 0 18px transparent; }
}
@keyframes os-cta-sheen {
	0%, 70% { transform: translateX(-120%); }
	100%    { transform: translateX(120%); }
}

/* ------------------------------------------------------------------ */
/* Startseite: «Grüezi und willkommen bei» über der Wortmarke          */
/* ------------------------------------------------------------------ */

.os-greeting {
	margin: 0 0 clamp(0.7rem, 1.8vw, 1.8rem) !important;
	font-family: var(--wp--preset--font-family--albula-pro);
	font-size: clamp(1.4rem, 3.9vw, 4rem);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.01em;
	position: relative;
	/* Gleiches Grau wie der Slogan unter dem Logo (typing-static). */
	color: #3a3a3a !important;
	transition: opacity 0.7s ease, filter 0.7s ease;
}
.os-greeting__ghost {
	visibility: hidden;
}
.os-greeting__typed {
	position: absolute;
	inset: 0;
}
/* Kein Aufblitzen des fertigen Texts, bevor motion.js übernimmt. */
html.os-motion .os-greeting:not(.is-ready) {
	opacity: 0;
}
html[data-theme="dark"] .os-greeting {
	color: #9a9a9c !important;
}
.os-greeting.is-gone {
	opacity: 0;
	filter: blur(6px);
}
/* Slogan erst nach dem Gruss zeigen. */
html.os-motion body.home .typing-heading-container {
	transition: opacity 0.8s ease;
}
html.os-motion body.home .typing-heading-container:not(.os-slogan-ready) {
	opacity: 0;
}
.os-greeting__caret {
	display: inline-block;
	width: 0.06em;
	height: 0.9em;
	margin-left: 0.08em;
	vertical-align: -0.08em;
	background: currentColor;
	opacity: 0;
}
.os-greeting.is-typing .os-greeting__caret {
	opacity: 1;
	animation: os-caret 0.9s steps(1) infinite;
}
@keyframes os-caret {
	50% { opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* Reduzierte Bewegung: Daueranimationen aus                           */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.os-skyline *,
	.os-intro-hint__line,
	.os-cta,
	.os-cta::after,
	.os-greeting__caret {
		animation: none !important;
	}
	.os-sky-far,
	.os-sky-cloud {
		transform: none !important;
	}
	@media (max-width: 781px) {
		.os-skyline__svg {
			transform: translate3d(calc((100vw - 100%) / 2), 0, 0);
		}
	}
	.os-progress {
		display: none;
	}
}
