/**
 * Karel van het Reve theme styles.
 *
 * Plain CSS, no build step. Sizes are in rem; the root font size grows with the
 * screen width (40% -> 62.5%), so 1rem is 6.4px on phones and 10px on desktops.
 *
 * Breakpoints (media queries can't use variables, so these are repeated):
 *   xs  22.5em   ~360px
 *   sm  30em     ~480px
 *   md  45em     ~720px
 *   lg  50em     ~800px   mobile menu -> horizontal menu
 *   xl  68.75em  ~1100px
 *   xxl 87.5em   ~1400px
 *
 * Contents: base, typography, page layouts, navigation, posts.
 */

:root {
	--color-primary: #aaa;
	--color-secondary: #535658;
	--color-white: #fefefe;
	--color-black: #272727;

	--font-primary: 'EB Garamond', sans-serif;
	--font-display: 'Cinzel', serif;

	--shadow: 3px 3px 8px color-mix(in srgb, var(--color-secondary) 60%, transparent);
}


/* Base
   ========================================================================== */

*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: inherit;
}

html {
	box-sizing: border-box;
	font-size: 40%;
	background-color: var(--color-white);
	overflow-y: scroll;

	@media (min-width: 45em) {
		font-size: 50%;
	}

	@media (min-width: 50em) {
		font-size: 55%;
	}

	@media (min-width: 68.75em) {
		font-size: 62.5%;
	}
}

/* 17px on small screens, up to 20px on large ones. */
body {
	font-family: var(--font-primary);
	color: var(--color-secondary);
	font-weight: 300;
	line-height: 1.4;
	font-size: 2.65625rem;

	@media (min-width: 45em) {
		font-size: 2.125rem;
	}

	@media (min-width: 50em) {
		font-size: 2rem;
	}
}

.sidebar,
.main,
.posts,
.footer {
	word-break: break-word;
}

/* Links: underline that fills up as background on hover. */
:is(.sidebar, .main, .posts, .footer) a:is(:link, :visited) {
	color: var(--color-secondary);
	text-decoration: none;
	background: linear-gradient(to bottom, var(--color-secondary) 0%, var(--color-secondary) 100%);
	background-position: 0 100%;
	background-repeat: repeat-x;
	background-size: 1px 1px;
	transition: background-size 0.2s linear;
}

:is(.sidebar, .main, .posts, .footer) a:is(:hover, :active) {
	animation: linear 0.3s linkBg;
	animation-fill-mode: forwards;
}

@keyframes linkBg {
	0% {
		background-position: 0% 100%;
		background-size: 1px 1px;
		color: var(--color-secondary);
	}

	50% {
		background-position: 0% 60%;
		background-size: 1px 1px;
	}

	100% {
		background-position: 0% 100%;
		color: var(--color-white);
		background-size: 1px 2.5rem;
	}
}

img {
	max-width: 100%;
	width: 100%;
	display: block;
}

/* Images with their title as caption, shown on hover. */
figure {
	position: relative;
	overflow: hidden;
	box-shadow: var(--shadow);
	font-size: 1.8rem;
	line-height: 1.3;

	&:not(:last-child) {
		margin-bottom: 3rem;
	}

	figcaption {
		position: absolute;
		font-size: 1em;
		width: 100%;
		bottom: 0;
		left: 0;
		background-color: color-mix(in srgb, var(--color-black) 70%, transparent);
		color: var(--color-white);
		padding: 0.6em 1em;
		text-align: center;
		transform: translateY(100%);
		transition: all 0.2s ease-out;
		word-break: break-word;
	}

	&:hover figcaption {
		transform: translateY(0%);
	}
}

/* Touch screens: caption always visible, below the image. */
@media (hover: none) {
	figure {
		overflow: initial;
		box-shadow: none;
		line-height: 1.1;

		img {
			box-shadow: var(--shadow);
		}

		figcaption {
			position: initial;
			display: block;
			padding: 6px 0 0;
			transform: translateY(0);
			background-color: transparent;
			color: var(--color-secondary);
		}
	}
}

::selection {
	background-color: var(--color-secondary);
	color: var(--color-white);
}


/* Typography
   ========================================================================== */

.site-heading,
.heading-1,
.heading-2 {
	font-family: var(--font-display);
	font-weight: 400;
}

/* Centered dividing lines above (::before) and below (::after) an element. */
.site-heading,
.heading-2,
.post__item--news:not(:last-child),
.post__readmore {
	position: relative;
}

.site-heading::after,
.heading-2::before,
.heading-2::after,
.post__item--news:not(:last-child)::after,
.post__readmore::before {
	content: '';
	position: absolute;
	height: 1px;
	width: 85%;
	left: 50%;
	background-color: var(--color-secondary);
	transform: translateX(-50%);
}

.heading-2::before,
.post__readmore::before {
	top: 0;
}

.site-heading::after,
.heading-2::after,
.post__item--news:not(:last-child)::after {
	bottom: 0;
}

p:not(:last-child) {
	margin-bottom: 1.6rem;
}

.site-heading {
	font-size: 3rem;
	line-height: 1;
	text-align: center;

	/* The horizontal menu has its own lines. */
	@media (min-width: 50em) {
		&::after {
			display: none;
		}
	}

	@media (min-width: 22.5em) {
		font-size: 4rem;
	}

	@media (min-width: 30em) {
		font-size: 6rem;
	}

	@media (min-width: 68.75em) {
		font-size: 7rem;
	}

	@media (min-width: 87.5em) {
		font-size: 9rem;
	}

	a,
	a:hover,
	a:active {
		color: inherit;
		text-decoration: none;
		outline: none;
	}
}

.heading-1 {
	font-size: 2.5rem;
	line-height: 1;
	margin-bottom: 1.5rem;

	@media (min-width: 68.75em) {
		font-size: 3.5rem;
		margin-bottom: 3rem;
	}
}

.heading-2 {
	font-size: 2rem;
	line-height: 1;
	text-align: center;
	padding: 0.8rem;
}

.heading-3 {
	font-weight: 700;
	font-size: 2rem;
	line-height: 1.2;
}

.mb-sm {
	margin-bottom: 2rem;
}

.mb-md {
	margin-bottom: 3rem;
}

.mb-lg {
	margin-bottom: 4rem;
}

.mb-hg {
	margin-bottom: 8rem;
}


/* Page layouts
   ==========================================================================
   The container gets the class page-{n}, see inc/config.php:
   1  content right, sidebar (gallery) left
   2  content left, sidebar right
   3  archive: single centered column
   4  bibliography: content and book grid
   5  book detail
   6  "Over Karel": content left, books in the sidebar
   The order of the rules below matters, later ones override earlier ones.
   ========================================================================== */

.page-container {
	width: 90%;
	max-width: 120rem;
	min-height: 100vh;
	margin: 0 auto;
	padding: 1rem 1rem 4rem;
	grid-gap: 1.5rem;

	@media (min-width: 45em) {
		padding: 1rem 3rem 3rem;
		grid-gap: 3rem;
	}
}

/* Space between the site heading and the content on small screens. */
.page-container > .header {
	margin-bottom: 2.5rem;

	@media (min-width: 45em) {
		margin-bottom: 0;
	}
}

.page-container:is(.page-1, .page-2, .page-6) {
	display: grid;
	grid-template-rows: repeat(4, min-content);
	align-items: start;
	column-gap: 4rem;

	@media (min-width: 45em) {
		column-gap: 5rem;
	}

	@media (min-width: 30em) {
		grid-template-columns: 1fr 3fr;

		.header {
			grid-column: span 2;
		}
	}

	@media (min-width: 68.75em) {
		grid-template-columns: 1fr 2fr;
	}
}

.page-container:is(.page-2, .page-6) {
	@media (min-width: 30em) {
		grid-template-columns: 3fr 1fr;
	}

	@media (min-width: 68.75em) {
		grid-template-columns: 2fr 1fr;
	}
}

@media (min-width: 30em) {
	.page-container:is(.page-1, .page-4, .page-5) > .main {
		order: 2;
	}
}

@media (min-width: 68.75em) {
	.page-container.page-3 > :is(.main, .posts) {
		width: 75%;
		margin: 0 auto;
	}
}

.page-container:is(.page-4, .page-5) :is(.main, .sidebar) {
	padding: 2rem 0;
}

.page-container .main > .content {
	margin-bottom: 3rem;
}

.page-container .sidebar {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(45%, 1fr));
	grid-gap: 1rem;
	align-items: start;

	@media (min-width: 30em) {
		grid-template-columns: 1fr;
		grid-gap: 0;
	}
}

.page-container > .posts {
	order: 99;
}

@media (min-width: 30em) {
	.page-container.page-1 > .sidebar {
		grid-row: span 2;
	}

	.page-container.page-1 > .posts {
		grid-column: 2 / -1;
	}
}

/* Faded photo on the right (or left, below) of the page. */
.page-container .background {
	position: fixed;
	top: 0;
	right: 0;
	height: 100vh;
	width: 60vh;
	z-index: -10;
	background-image:
		linear-gradient(to left, color-mix(in srgb, var(--color-white) 40%, transparent), var(--color-white)),
		url(../img/bg-right.jpg);
	background-size: cover;
	filter: opacity(0.35);
}

.page-container:is(.page-2, .page-4, .page-6) .background {
	left: 0;
	right: initial;
	width: 55vh;
	background-image:
		linear-gradient(to right, color-mix(in srgb, var(--color-white) 40%, transparent), var(--color-white)),
		url(../img/bg.jpg);
}

/* Single column up to md. */
.page-container.page-6 {
	grid-template-columns: 1fr;

	.header {
		grid-column: span 1;
	}

	@media (min-width: 45em) {
		grid-template-columns: 3fr 1fr;

		.header {
			grid-column: span 2;
		}
	}

	@media (min-width: 68.75em) {
		grid-template-columns: 2fr 1fr;
	}
}


/* Navigation
   ==========================================================================
   Below lg: a menu button (a label for the hidden checkbox) that opens a
   full-screen menu. From lg: a horizontal menu below the site heading.
   ========================================================================== */

.nav__checkbox {
	display: none;
}

/* 48px touch target, centered on the .nav__background circle. */
.nav__button {
	position: fixed;
	top: calc(4.65rem - 24px);
	left: calc(4.4rem - 24px);
	z-index: 9999;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* Hamburger icon: the element is the middle line, ::before and ::after the others. */
.nav__icon {
	position: relative;
}

.nav__icon,
.nav__icon::before,
.nav__icon::after {
	width: 3rem;
	height: 2px;
	display: inline-block;
	background-color: var(--color-black);
}

.nav__icon::before,
.nav__icon::after {
	content: '';
	position: absolute;
	left: 0;
	transition: all 0.2s;
}

.nav__icon::before {
	top: -0.8rem;
}

.nav__icon::after {
	top: 0.8rem;
}

/* Circle that grows to fill the screen when the menu opens. */
.nav__background {
	height: 6rem;
	width: 6rem;
	opacity: 0;
	border-radius: 50%;
	position: fixed;
	top: 1.65rem;
	left: 1.4rem;
	background-image: radial-gradient(var(--color-white), color-mix(in srgb, var(--color-primary) 70%, transparent));
	z-index: 999;
	transition: all 0.4s cubic-bezier(0.83, 0, 0.17, 1);
}

.nav__button:hover .nav__icon::before {
	top: -1rem;
}

.nav__button:hover .nav__icon::after {
	top: 1rem;
}

.nav__list {
	height: 100vh;
	width: 0;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 1500;
	opacity: 0;
	transition: all 0.4s cubic-bezier(0.68, -0.6, 0.32, 1.6);
	display: grid;
	align-content: center;
	grid-template-columns: minmax(50%, auto);
	justify-content: center;
}

.nav__item {
	white-space: nowrap;
	display: block;
	padding: 2rem;
	text-align: center;
}

.nav__link:is(:link, :visited) {
	line-height: 1.6;
	color: var(--color-secondary);
	display: inline-block;
	text-decoration: none;
	padding: 0;
	width: 100%;
	text-align: center;
	font-family: var(--font-display);
	position: relative;
	z-index: 10;
	transition: all 0.08s 0.12s linear;

	@media (min-width: 68.75em) {
		padding: 0 1rem;
	}
}

/* Bar that grows from the center to fill the link on hover. */
.nav__link::before {
	position: absolute;
	content: '';
	background-color: var(--color-secondary);
	height: 100%;
	width: 2px;
	z-index: -10;
	top: 0;
	left: 0;
	opacity: 0;
}

.nav__link:is(:hover, :active, .active) {
	color: var(--color-white);

	&::before {
		animation: linear 0.2s navHover;
		animation-fill-mode: forwards;
	}
}

.nav__link.active::before {
	animation-duration: 0s;
}

@keyframes navHover {
	40% {
		width: 2px;
		left: 50%;
		opacity: 1;
	}

	100% {
		width: 100%;
		left: 0;
		opacity: 1;
	}
}

/* Menu open. */
.nav__checkbox:checked ~ .nav__background {
	transform: scale(80);
	opacity: 1;
}

.nav__checkbox:checked ~ .nav__list {
	width: 100%;
	opacity: 1;
}

/* Hamburger becomes a cross. */
.nav__checkbox:checked ~ .nav__button .nav__icon {
	background-color: transparent;

	&::before {
		top: 0;
		transform: rotate(135deg);
	}

	&::after {
		top: 0;
		transform: rotate(-135deg);
	}
}

/* Horizontal menu. */
@media (min-width: 50em) {
	.nav__button,
	.nav__background {
		display: none;
	}

	.nav__list {
		opacity: 1;
		width: auto;
		height: auto;
		top: initial;
		left: initial;
		list-style: none;
		padding: 1rem 0;
		position: relative;
		display: flex;
		justify-content: center;

		&::before,
		&::after {
			content: '';
			display: inline-block;
			height: 1px;
			background-color: var(--color-secondary);
			position: absolute;
			width: 80%;
		}

		&::before {
			top: 0;
			left: 0;
		}

		&::after {
			bottom: 0;
			right: 0;
		}
	}

	.nav__item {
		flex: 1;
		flex-basis: content;
		padding: 0;

		&:not(:last-child) {
			border-right: 1px solid var(--color-secondary);
		}
	}
}


/* Posts
   ========================================================================== */

/* Book covers grid. */
.post__list--book .post__list-inner {
	display: grid;
	grid-gap: 2rem;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));

	@media (min-width: 30em) {
		grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
	}
}

/* Books in the sidebar of "Over Karel". */
.post__list--type-over_kvhr .post__list-inner {
	@media (min-width: 45em) {
		grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
	}

	@media (min-width: 68.75em) {
		grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
	}
}

/* News items, separated by a line (see Typography). */
.post__item--news {
	padding: 2rem 0;

	&.with-image {
		display: grid;
		grid-template-columns: 1fr 2fr;
	}
}

.post__item--book {
	transition: all 0.2s ease-out;

	&:hover {
		transform: scale(1.1);
	}
}

.post__item--book-preview figure {
	font-size: 1.3rem;
}

/* Wide cover. */
.post__item--book-preview-id-379 {
	grid-column: span 2;
}

.post__heading,
.post__date {
	grid-column: span 2;
}

.post__image ~ .post__text {
	margin-left: 2rem;
}

.post__date {
	margin-bottom: 1.5rem;
	font-style: italic;
}

.post__readmore {
	padding: 2rem;
	text-align: center;
}

/* Single book or news item. */
.post-full > .main > .post-wrapper {
	padding-bottom: 3rem;
}

.post-full > .main .info {
	font-style: italic;
	margin-bottom: 2rem;
}

/* Cover below the text on phones, left of it from sm. */
.post-full.post-with-image > .main > .post-wrapper {
	> .image {
		padding-top: 3rem;
		max-width: 60%;
	}

	@media (min-width: 30em) {
		display: grid;
		grid-gap: 3rem;
		grid-template-columns: 1fr 2.5fr;

		> .image {
			order: -1;
			padding: 0;
			max-width: initial;
		}
	}

	@media (min-width: 50em) {
		grid-template-columns: 1fr 2fr;
	}
}
