/*
Theme Name: Ekremer Theme 2
Theme URI: https://eliaskremer.com
Author: Elias Kremer
Description: Portfolio theme for eliaskremer.com. Version 2 of ekremer_theme: Customizer colour/size controls, noise overlay per page and per block, PNG alpha masks, proper tables, video and embeds.
Version: 2.5.0
Requires at least: 6.5
Requires PHP: 7.4
Text Domain: ekremer
*/

/* All colours / sizes come from Appearance → Customize → "Ekremer Theme"
   and are printed as CSS variables (--ek-*) in the page head.
   The block-level styles (tables, video, noise, mask, size) live in css/blocks.css. */

/* ---------- Fonts (bundled; the old theme had these commented out) ---------- */

@font-face {
	font-family: "Cinzel";
	src: url("fonts/Cinzel-Medium.woff2") format("woff2");
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Roboto";
	src: url("fonts/Roboto-Light.woff2") format("woff2");
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
}

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

/* Which font is used where: Customize → Ekremer Theme → Fonts
   (sets --ek-font-heading / --ek-font-body). */

/* ---------- Old variable names (kept so existing custom CSS still works) ---------- */

:root {
	--primaryColor: var(--ek-bg);
	--primaryTextColor: var(--ek-text);
	--accentColor: var(--ek-accent);
	--accentColor2: var(--ek-accent-2);
}

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar {
	width: 0.5em;
}

::-webkit-scrollbar-track {
	background: var(--ek-bg);
	margin: 0.5em;
}

::-webkit-scrollbar-thumb {
	background: var(--ek-scrollbar);
	border-radius: 100vw;
}

@supports not selector(::-webkit-scrollbar) {
	html {
		scrollbar-color: var(--ek-scrollbar) var(--ek-bg);
		scrollbar-width: thin;
	}
}

/* ---------- Base ---------- */

* {
	margin: 0;
	padding: 0;
}

html {
	font-size: var(--ek-base-font-size);
}

/* Old theme set every element to 1rem, which broke font sizes on anything
   nested (bold text inside a large paragraph etc.). Headings keep the old
   1rem default, everything else inherits properly now. */
:where(h1, h2, h3, h4, h5, h6) {
	font-size: 1rem;
	font-family: var(--ek-font-heading, "Cinzel", serif);
}

html,
body {
	height: 100%;
}

body {
	background: var(--ek-bg);
	color: var(--ek-text);
	font-family: var(--ek-font-body, "Roboto", sans-serif);
	accent-color: var(--ek-accent);
}

img {
	object-fit: cover;
}

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

.skip-link:focus {
	z-index: 100;
}

/* ---------- Background layers ---------- */

/* Parallax: the grid / grunge layers are 600px taller than the screen and
   slide up while you scroll (same direction as the original). transform runs
   on the GPU, so nothing is repainted per frame – much smoother on phones. */
@keyframes parallax {
	from {
		transform: translate3d(0, 0, 0);
	}
	to {
		transform: translate3d(0, -600px, 0);
	}
}

.background01,
.background02,
.backlight,
.ek-vignette {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: -1;
	pointer-events: none;
}

/* Fallback (browsers without luminance masks): the original look. */
.background01,
.background02 {
	height: calc(100vh + 600px);
	will-change: transform;
}

.background01 {
	background-image: url("images/grid_01.png");
	opacity: var(--ek-grid-opacity);
	animation: parallax linear;
	animation-timeline: scroll();
}

.background02 {
	background-image: url("images/grunge_map_16_bitmap_output.jpg");
	mix-blend-mode: multiply;
	animation: parallax linear;
	animation-timeline: scroll();
}

.backlight {
	background-image: url("images/background_light_02.jpg");
	opacity: var(--ek-light-opacity);
	mix-blend-mode: lighten;
	background-repeat: no-repeat;
	background-attachment: fixed;
	background-size: 100% 100%;
}

/* Colourable layers: the grey textures are used as luminance masks over a
   solid colour, so grid / dirt / light can take any colour. With the default
   white this looks the same as the original. */
@supports (mask-mode: luminance) {
	.background01 {
		background: var(--ek-grid-color);
		-webkit-mask-image: url("images/grid_01.png");
		mask-image: url("images/grid_01.png");
		mask-mode: luminance;
	}

	.ek-light-image .backlight {
		background: var(--ek-light-tint);
		-webkit-mask: url("images/background_light_02.jpg") no-repeat 0 0 / 100% 100%;
		mask: url("images/background_light_02.jpg") no-repeat 0 0 / 100% 100%;
		mask-mode: luminance;
	}

	/* "Coloured" dirt (Customizer → Background layers → Dirt style, or a page dirt colour). */
	.ek-dirt-colored .background02 {
		background: var(--ek-dirt-color);
		-webkit-mask-image: url("images/grunge_map_16_bitmap_output.jpg");
		mask-image: url("images/grunge_map_16_bitmap_output.jpg");
		-webkit-mask-size: var(--ek-dirt-size);
		mask-size: var(--ek-dirt-size);
		mask-mode: luminance;
		opacity: var(--ek-dirt-opacity);
		mix-blend-mode: var(--ek-dirt-blend);
	}
}

/* Spotlight (Customize → Lighting): bright in the middle, fading out. */
.ek-light-radial .backlight {
	background: radial-gradient(
		circle at var(--ek-light-x) var(--ek-light-y),
		rgba(var(--ek-light-rgb), calc(var(--ek-light-opacity) * 0.4)) 0%,
		rgba(var(--ek-light-rgb), calc(var(--ek-light-opacity) * 0.15)) calc(var(--ek-light-size) * 0.5),
		rgba(var(--ek-light-rgb), 0) var(--ek-light-size)
	);
	-webkit-mask: none;
	mask: none;
	opacity: 1;
	mix-blend-mode: normal;
}

/* Corner darkening, centred on the light. */
.ek-vignette {
	background: radial-gradient(
		ellipse farthest-corner at var(--ek-light-x) var(--ek-light-y),
		rgba(var(--ek-vignette-rgb), 0) var(--ek-vignette-start),
		rgba(var(--ek-vignette-rgb), var(--ek-vignette-strength)) 100%
	);
}

@media (prefers-reduced-motion: reduce) {
	.background01,
	.background02 {
		animation: none;
	}
}

/* ---------- Full-screen noise ---------- */

.noise {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: -1; /* behind all content: text is never grainy */
	pointer-events: none;
	background: var(--ek-noise-image);
	background-size: var(--ek-noise-size);
	opacity: var(--ek-noise-opacity);
	mix-blend-mode: var(--ek-noise-blend);
}

/* Option "Full-screen noise also covers images & videos": the same grain,
   fixed to the screen, laid over pictures only (captions stay clean). */
.ek-noise-over-media :is(figure.wp-block-image, div.wp-block-image > figure, figure.wp-block-video, .wp-block-embed__wrapper, .wp-block-cover) {
	position: relative;
}

.ek-noise-over-media :is(figure.wp-block-image, div.wp-block-image > figure, figure.wp-block-video, .wp-block-embed__wrapper):not(.has-noise)::after,
.ek-noise-over-media .wp-block-cover:not(.has-noise)::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	pointer-events: none;
	background: var(--ek-noise-static) 0 0 / var(--ek-noise-size);
	opacity: var(--ek-noise-opacity);
	mix-blend-mode: var(--ek-noise-blend);
	border-radius: inherit;
}

.ek-noise-over-media .wp-block-cover:not(.has-noise)::after {
	z-index: 0; /* above the cover image, below its text */
}

/* Phones / tablets: still grain instead of the animated GIF (saves battery
   and keeps scrolling smooth). Option "Animate the noise…" keeps it animated. */
@media (hover: none) {
	.noise {
		background-image: var(--ek-noise-static);
	}
}

/* Theme noise is on → hide an old <div class="noise"> Custom HTML block, so it isn't doubled. */
.ek-has-noise .pagecontent .noise {
	display: none;
}

/* ---------- Menu ---------- */

header .topmenubar {
	display: flex;
	flex-wrap: wrap;
	align-content: center;
	justify-content: center;
	text-align: center;
	position: fixed;
	width: 100%;
	height: calc(60 * var(--ek-u, 1px));
	background: rgba(var(--ek-header-rgb), var(--ek-header-opacity));
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	z-index: 10;
}

header .topmenu {
	display: flex;
	align-content: center;
	list-style: none;
	padding: calc(10 * var(--ek-u, 1px));
	margin: calc(10 * var(--ek-u, 1px));
	color: var(--ek-menu-text);
}

header .topmenu li a {
	text-decoration: none;
	padding: 1rem;
	font-family: var(--ek-font-heading, "Cinzel", serif);
	font-size: 1.2em;
	color: var(--ek-menu-text);
	transition: color 0.2s;
}

header .topmenu li a:hover {
	color: var(--ek-accent);
}

.current-menu-item {
	color: var(--ek-accent);
	text-decoration: underline;
	text-decoration-color: var(--ek-accent);
	text-decoration-thickness: calc(10 * var(--ek-u, 1px));
}

/* WordPress admin bar offset */
.admin-bar header .topmenubar {
	top: var(--wp-admin--admin-bar--height, 32px);
}

/* ---------- Page content ---------- */

.headline {
	text-align: center;
	padding-bottom: calc(50 * var(--ek-u, 1px));
	font-family: var(--ek-font-heading, "Cinzel", serif);
	font-size: 1.2em;
	color: var(--ek-text);
	visibility: hidden;
}

.headline.is-visible {
	visibility: visible;
	padding-top: calc(100 * var(--ek-u, 1px));
}

.pagecontent {
	font-family: var(--ek-font-body, "Roboto", sans-serif);
	color: var(--ek-text);
}

.pagecontent p,
.pagecontent h2,
.pagecontent > ul,
.pagecontent > ol,
.pagecontent > blockquote {
	padding: 1rem var(--ek-text-padding);
	margin: auto;
	max-width: var(--ek-content-width);
}

.pagecontent > ul,
.pagecontent > ol {
	padding-left: calc(var(--ek-text-padding) + 1.5em);
}

.pagecontent h3 {
	padding-top: 1rem;
	padding-bottom: 1rem;
	margin: auto;
	max-width: var(--ek-content-width);
	font-family: var(--ek-font-heading, "Cinzel", serif);
}

.pagecontent a {
	color: var(--ek-link);
}

.pagecontent a:hover {
	color: var(--ek-link-hover);
}

/* Old helper classes (Advanced → Additional CSS class) */
.pagecontent .PaddingTop5rem { padding-top: 5em; }
.pagecontent .PaddingBottom5rem { padding-bottom: 5em; }
.pagecontent .PaddingTop10rem { padding-top: 10em; }
.pagecontent .PaddingBottom10rem { padding-bottom: 10em; }

.maxWidth1920 {
	max-width: 1980px;
	height: auto;
}

.maxWidth {
	height: auto;
	max-width: 70%;
	align-content: center;
}

.zeroPaddingLR {
	padding-left: 0;
	padding-right: 0;
}

.logoFont {
	text-align: center;
	font-size: calc(50 * var(--ek-u, 1px) + 1.3vw);
	font-family: var(--ek-font-heading, "Cinzel", serif);
	padding: 0;
	margin: 0;
}

/* ---------- Home: header video (logo-masked) ---------- */

.headerVideoContainer {
	margin-left: auto;
	margin-right: auto;
	padding-left: calc(30 * var(--ek-u, 1px));
	width: calc(500 * var(--ek-u, 1px));
	height: calc(500 * var(--ek-u, 1px));
	max-width: 100%;
}

.headerVideoContainer .wp-block-video {
	height: 90%;
	width: 90%;
	max-width: calc(700 * var(--ek-u, 1px));
	max-height: calc(700 * var(--ek-u, 1px));
	margin: 10% auto 0;
}

.headerVideoContainer .wp-block-video video {
	object-fit: cover;
	height: 100%;
	width: 100%;
	clip-path: none;
	-webkit-mask: var(--ek-mask-image) center / var(--ek-mask-size) no-repeat;
	mask: var(--ek-mask-image) center / var(--ek-mask-size) no-repeat;
}

/* The old SVG clip-path block isn't needed any more. */
.pagecontent > svg[viewBox="0 0 1 1"] {
	position: absolute;
	width: 0;
	height: 0;
}

/* ---------- Columns / description table ---------- */

.wp-block-columns {
	margin: auto;
}

.wp-block-columns p {
	padding-left: 0;
	padding-right: 0;
}

.shortDescriptionTable {
	padding-top: calc(100 * var(--ek-u, 1px));
	padding-bottom: calc(100 * var(--ek-u, 1px));
	max-width: calc(900 * var(--ek-u, 1px));
	flex-wrap: nowrap;
}

.descriptionTextContainer {
	padding-left: calc(100 * var(--ek-u, 1px));
}

.descriptionTextContainer h2 {
	margin: 0;
	padding: 0;
}

/* ---------- Projects grid (Query Loop with class "projectsPosts") ---------- */

.projectsPosts {
	flex-wrap: nowrap;
}

.projectsPosts .wp-block-column {
	margin-left: 0.5em;
	margin-right: 0.5em;
}

.projectsPosts .wp-block-post-template .wp-block-column {
	position: relative;
	margin: auto;
}

.projectsPosts .wp-block-post-template img {
	transition: opacity 0.5s;
	opacity: 1;
}

.projectsPosts .wp-block-post-template .wp-block-post-title {
	opacity: 0;
	transition: 0.5s;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	width: calc(200 * var(--ek-u, 1px));
}

.projectsPosts .wp-block-post-template .projectPostCollumn {
	position: relative;
	margin-top: 1em;
	margin-bottom: 1em;
}

.projectsPosts .wp-block-post-template li:hover .wp-block-post-title,
.projectsPosts .wp-block-post-template li:focus-within .wp-block-post-title {
	opacity: 1;
}

.wp-block-post-template li:hover img,
.wp-block-post-template li:focus-within img {
	opacity: 0.3;
}

.wp-block-post-template .wp-block-post-title a {
	text-decoration: none;
	color: var(--ek-text);
}

.wp-block-query {
	max-width: calc(900 * var(--ek-u, 1px));
	margin: auto;
}

.wp-block-post {
	width: 100%;
	padding: 0;
	margin: 0;
}

.wp-block-post-template .is-flex-container {
	gap: 0;
	align-content: center;
}

/* ---------- Archive grid (index.php) ---------- */

.ek-post-grid {
	list-style: none;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(calc(260 * var(--ek-u, 1px)), 1fr));
	gap: 1em;
	max-width: var(--ek-wide-width);
	margin: 0 auto;
	padding: 0 1em 4em;
}

.ek-post-grid a {
	position: relative;
	display: block;
	color: var(--ek-text);
	text-decoration: none;
}

.ek-post-grid img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	transition: opacity 0.5s;
}

.ek-post-grid__title {
	display: block;
	padding: 0.5em 0;
	font-family: var(--ek-font-heading, "Cinzel", serif);
}

.ek-post-grid a:hover img {
	opacity: 0.3;
}

/* ---------- Footer ---------- */

.footer {
	font-family: var(--ek-font-body, "Roboto", sans-serif);
	color: var(--ek-text);
	text-align: center;
	padding: 2em 0 calc(20 * var(--ek-u, 1px));
	position: relative;
}

.footer a {
	text-decoration: none;
	color: var(--ek-text);
}

.footer a:hover {
	color: var(--ek-link-hover);
}

.footer-menu,
.footer .footer-menu ul {
	list-style: none;
	display: flex;
	justify-content: center;
	gap: 0.5em 1.5em;
	flex-wrap: wrap;
}

/* ---------- Responsive ---------- */

@media only screen and (max-width: 700px) {
	.headerVideoContainer {
		width: 300px;
		height: 300px;
	}

	.descriptionTextContainer {
		padding-left: 3rem;
	}

	.projectsPosts .wp-block-column {
		margin-left: 2px !important;
	}

	.wp-block-post-template .projectPostCollumn {
		margin-top: 2px;
		margin-bottom: 2px;
	}

	.projectsPosts .wp-block-post-template .wp-block-post-title {
		width: 100px;
	}

	.projectsPosts a {
		font-size: 1rem;
	}

	.maxWidth {
		max-width: 90%;
	}

	.pagecontent h3 {
		max-width: 80%;
	}
}

@media only screen and (max-width: 500px) {
	header .topmenu li a {
		padding: 5px;
		font-size: 0.9em;
	}

	header .topmenu {
		padding: 0;
		margin: 0;
	}

	.headerVideoContainer {
		padding-left: 0;
	}

	.shortDescriptionTable {
		flex-wrap: wrap;
		padding-left: 0;
	}

	.shortDescriptionTable img {
		width: 250px;
	}

	.projectsPosts .wp-block-post-template .wp-block-post-title {
		width: 45px;
	}

	.projectsPosts a {
		font-size: 0.7rem;
		white-space: nowrap;
	}

	.pagecontent p,
	.pagecontent h2 {
		padding-left: min(var(--ek-text-padding), 1.5rem);
		padding-right: min(var(--ek-text-padding), 1.5rem);
	}
}
