/*
Theme Name: Traversing The Hinterland
Theme URL: http://www.traversingthehunterland.co.uk
Version: 1.0.0
Author: Paul McAlenan
Author URL: http://www.paulmcalenan.co.uk
*/

@import url('./assets/css/reset.css');

/*--------------------------------------------------------------
# VARIABLES & THEME
--------------------------------------------------------------*/
:root {
	--text-color: #36454f;
	--background-color: #ffffff;
	--hover-color: lightgray;
	--lightbox-bg: rgba(255, 255, 255, 0.9);

	--colour-valid: #57E964;
	--colour-invalid: red;
	--clr-heading: hsl(0 0% 25%);
	--darkmode-hover: 0, 0, 0;

	--charcoal: #36454f;
	--dimgrey: #696969;
	--grey: #808080;
	--darkgrey: #a9a9a9;
	--silver: #c0c0c0;
	--lightgrey: #d3d3d3;

	--blue: #4898EE;
	--white: #ffffff;
	--pink: #ff00ff;
	--tomato: #FE4340;
}

.darkmode {
	--text-color: #ebebec;
	--background-color: #1a1915;
	--clr-heading: hsl(209 50% 80%);
	--hover-color: rgb(128, 128, 128);
	--darkmode-hover: 255, 255, 255;
	--lightbox-bg: rgba(0, 0, 0, 0.5);
}

/*--------------------------------------------------------------
# FONTS & GENERAL TYPOGRAPHY
--------------------------------------------------------------*/
@font-face {
	font-family: 'Lexend';
	src: url('./assets/fonts/Lexend-Regular.woff2') format('woff2');
	font-weight: 400;
	font-display: swap;
}

@font-face {
	font-family: 'Lexend';
	src: url('./assets/fonts/Lexend-Light.woff2') format('woff2');
	font-weight: 300;
	font-display: swap;
}

@font-face {
	font-family: 'Lexend';
	src: url('./assets/fonts/Lexend-ExtraLight.woff2') format('woff2');
	font-weight: 200;
	font-display: swap;
}

@font-face {
	font-family: 'Lexend';
	src: url('./assets/fonts/Lexend-Medium.woff2') format('woff2');
	font-weight: 500;
	font-display: swap;
}

:not(a:span) span {
	color: var(--tomato);
}

img {
	display: block;
	height: auto;
	border-radius: 2px;
}

h1, header p, figure h2 {
	font-size: 1.625rem;
	font-weight: 300;
}

h2, h3 {
	font-size: 1.25rem;
}

strong {
	font-weight: 500;
}

s {
	text-decoration: line-through;
}

code {
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 0.9em;
	background-color: #f3f6f3;
	color: #2d4a3e;
	padding: 0.15em 0.4em;
	border-radius: 4px;
	border: 1px solid #e0e8e2;
}

mark {
	background-color: #e8f5e9;
	color: #1b5e20;
	padding: 0.1em 0.3em;
	border-radius: 3px;
}

hr {
	border: none;
	border-top: 2px solid;
}

/*--------------------------------------------------------------
# MAIN LAYOUT & CONTAINERS
--------------------------------------------------------------*/
html {
	overflow: auto;
	font-family: 'Lexend', sans-serif;
}

body {
	--hover-padding: 20px;
	--content-max-width: 600px;

	container: body / inline-size;
	display: grid;
	grid-template-columns:
		[fullwidth-start] 1fr [padding-start] var(--hover-padding)
		[content-start] min(100% - var(--hover-padding) * 2, var(--content-max-width)) [content-end]
		var(--hover-padding) [padding-end] 1fr [fullwidth-end];
	grid-template-rows: auto auto 1fr auto auto auto;
	row-gap: 1.5rem;
	color: var(--text-color);
	background: var(--background-color);
	font-size: 1.125rem;
	font-weight: 400;
	line-height: 1.5;
	transition: 0.8s;
	padding-right: 0 !important;
}

body:is(.search, .privacy-policy, .error404) {
	grid-template-rows: auto auto auto auto auto 1fr;
}

body > *:not(main, footer) {
	grid-column: content;
}

main, footer {
	display: grid;
	grid-column: padding;
}

main {
	min-height: 0;
}

body:not(.single, .draft, .page, .search, .error404) > main {
	grid-template-columns: inherit;
}

body:not(.single, .draft) > main > figure {
	grid-column: padding;
}

/* Header */
body > header {
	grid-column: padding;
	display: flex;
	flex-wrap: wrap;
	row-gap: 1rem;
	align-self: start;
	justify-self: stretch;
}

body:is(.single, .draft, .search) > header {
	margin-top: 2rem;
}

body > header + nav {
	position: relative;
	align-self: start;
	justify-self: stretch;
}

body > header :is(h1, p) {
	padding-left: calc(var(--hover-padding) - 2px);
	display: flex;
	flex-wrap: wrap;
	flex: 1;
	font-size: 2rem;
	font-weight: 400;
	letter-spacing: 3px;
	border: 2px solid transparent;
}

header > h1:has(a:focus-visible) {
	border: 2px solid orange;
	border-radius: 2px;
	background-color: var(--hover-color);
}

body > figure {
	height: 180px;
	background: url('assets/images/hinterland.webp') no-repeat;
	background-position: 90%;
	position: relative;
	width: 100%;
}

@container body (width < 600px) {
	body > figure {
		grid-column: padding;
	}
}

/*--------------------------------------------------------------
# LINKS & BUTTONS
--------------------------------------------------------------*/
a {
	word-break: break-word;
}

article a {
	transition: color 0.2s;
}

article a:where(:link, :visited, :focus, :active) {
	text-decoration: none;
	color: var(--blue);
}

article a:is(:hover, :focus) {
	text-decoration: none;
	color: var(--tomato);
}

article a:focus {
	text-decoration: underline;
}

/*--------------------------------------------------------------
# NAVIGATION
--------------------------------------------------------------*/
nav {
	display: flex;
}

nav:is(article + nav) {
	flex-wrap: wrap;
	row-gap: 0.5rem;
	padding: 0 var(--hover-padding);
}

nav:not(article + nav) {
	column-gap: 0.5rem;
}

nav svg,
nav a:hover svg {
	stroke: currentColor;
}

nav:has(+ main) a,
main ~ nav:last-of-type a:not([aria-label="RSS Feed"]) {
	padding: 0.25rem 0.5rem;
	border: 2px solid var(--blue);
	border-radius: 2px;
	transition: 0.6s;
}

:is(nav:not(article + nav) a, form > div > button):is(:hover, :focus-visible) {
	background-color: var(--hover-color);
}

:is(nav:not(main + nav) a, form > div > button):is(:focus-visible) {
	border-color: orange;
}

/* Pagination */
main + nav {
	align-items: center;
}

main + nav > * {
	padding: 0.25rem 0.625rem;
}

body:not(.single, .draft, .page) main + nav :first-child {
	padding-left: 0;
}

main + nav > a:has(svg) {
	padding: 0.35rem 0.125rem;
}

main + nav [aria-current] {
	font-weight: 600;
	cursor: default;
}

main + nav a:is(:hover, :focus-visible) {
	background-color: var(--hover-color);
	border-radius: 2px;
}

main + nav a:focus-visible {
	border: 2px solid orange;
}

main > nav > a > [aria-hidden] {
	display: flex;
}

/* Single Posts Navigation */
article + nav a {
	width: 100%;
}

article + nav a:hover {
	color: var(--blue);
	transition: 0.2s;
}

article + nav::before,
article + nav::after {
	content: "";
	display: block;
	border-bottom: 0.125em solid var(--silver);
	width: 100%;
}

article + nav::before {
	margin-top: 0.5em;
	margin-bottom: 1.75rem;
}

article + nav::after {
	margin-top: 1.175em;
	margin-bottom: 0.5rem;
}

article + nav > a:last-child::before {
	content: "";
	display: block;
	width: 4em;
	margin: 1em 0;
	border-bottom: 0.125em solid var(--silver);
}

article + nav span {
	display: block;
}

/* Tags */
.post_tags > a {
	padding: 0.25rem 0.5rem;
	border: 2px solid var(--blue);
	border-radius: 2px;
}

/*--------------------------------------------------------------
# CONTENT & ARTICLES
--------------------------------------------------------------*/
article, section {
	display: grid;
	row-gap: 1rem;
}

.home article {
	row-gap: 0.5rem;
	padding: 20px;
	transition: 0.6s;
}

body:not(.home) :is(article, section:not(article > section)) {
	grid-template-columns:
		[padding-start] var(--hover-padding)
		[content-start] 1fr [content-end]
		var(--hover-padding) [padding-end];
	grid-template-rows: min-content min-content;
}

body:not(.home) :is(article, section) > *:not(figure, form) {
	grid-column: content;
}

body:not(.home) :is(article, section) > figure {
	grid-column: padding;
}

time {
	width: max-content;
	padding: 0.5rem 0;
	border-top: 1px solid var(--silver);
	border-bottom: 1px solid var(--silver);
	font-weight: normal;
}

main figure {
	padding: 20px;
	transition: 0.6s;
}

:is(.single, .draft) figure {
	margin-top: -1rem;
}

:is(.single, .draft) article > section {
	padding: 1rem;
	border: 1px solid var(--silver);
	border-radius: 3px;
	margin-bottom: 2rem;
}

blockquote {
	background: var(--hover-color);
	padding: 1.5rem;
	border-radius: 0.75rem;
}

.draft article aside {
	padding: 1rem;
	border: 1px solid grey;
	border-radius: 10px;
	background-color: #fff3d6;
	text-align: center;
}

@container body (width < 768px) {
	article figure > a {
		pointer-events: none;
		cursor: default;
	}

	article figcaption {
		text-align: right;
		margin-top: 10px;
	}
}

/* Private Block */
.wp-block-private-blurb-block, .private-block {
	background-color: #FCB900;
	padding: 0.5rem 1.25rem !important;
	word-break: break-all;
}

body:not(.logged-in) .wp-block-private-blurb-block {
	display: none;
}

/* Standard Responsive Embeds */
iframe {
	width: 100%;
	aspect-ratio: 16 / 9;
	height: auto;
}

.responsive-iframe-container {
	width: 100%;
}

/*--------------------------------------------------------------
# FOOTER
--------------------------------------------------------------*/
footer {
	align-self: self-end;
}

body > footer {
	display: grid;
	grid-template-columns:
		[padding-start] var(--hover-padding)
		[content-start] 1fr [content-end]
		var(--hover-padding) [padding-end];
	row-gap: 1rem;
	width: 100%;
	margin-bottom: 2.0rem;
	transition: 0.6s;
	font-size: 0.875rem;
}

body > footer > :is(a, div) {
	display: flex;
	flex-wrap: wrap;
	grid-column: content;
	row-gap: 4px;
	padding-top: 20px;
	padding-bottom: 20px;
	transition: 0.6s;
}

body > footer > :is(a, div) > p:first-child {
	flex: 100%;
}

body > footer > :is(a, div) > :is(img, a:has(img)) {
	margin-left: auto;
	align-self: end;
}

body:not(.about) > footer .copyright span {
	color: var(--blue);
}

/*--------------------------------------------------------------
# HEADER / FOOTER HOVER EFFECTS (Desktop)
--------------------------------------------------------------*/
@media screen and (min-width: 768px) {
	body > figure > span {
		position: absolute;
		top: 0px;
		height: 100%;
	}

	span.roger {
		right: 0px;
		width: 240px;
	}

	span.me {
		left: 0px;
		width: 365px;
	}

	span.roger:hover {
		background: url('assets/images/roger_glow.png') no-repeat -4px bottom;
	}

	span.me:hover {
		background: url('assets/images/me_glow.png') no-repeat 315px bottom;
	}

	figure:has(> a > img:hover) {
		cursor: pointer;
		border-radius: 3px;
		background-color: var(--lightgrey);
	}

	:is(.home, .single, .draft) figcaption:not(body > figure > figcaption) {
		display: none;
	}

	body:not(.about) > footer:has(a:hover, a:focus-visible) {
		background-color: var(--hover-color);
	}

	body:not(.about) > footer:has(a:focus-visible) {
		border: 2px solid orange;
	}
}

/*--------------------------------------------------------------
# PRIVACY POPUP
--------------------------------------------------------------*/
#privacy {
	z-index: 9999;
	position: fixed;
	bottom: 3%;
	right: 2%;
	padding: 1.0rem;
	max-width: 60ch;
	border-radius: 10px;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.15);
	font-size: 15px;
	box-shadow: rgba(23, 43, 99, 0.4) 0 7px 28px;
}

@media (max-width: 600px) {
	#privacy {
		border-radius: 0;
		max-width: 100%;
		right: 0;
		bottom: 0;
	}
}

#privacy a {
	font-size: 15px;
	text-decoration: none;
}

#privacy a:hover {
	opacity: 0.7;
}

#privacy p {
	margin: 0;
	color: #000;
	padding-right: 4.0rem;
}

#privacy button {
	position: absolute;
	right: 0.5rem;
	top: 20px;
	align-self: center;
	line-height: 1;
	color: #fff;
	background-color: var(--blue);
	border: none;
	font-size: 24px;
	cursor: pointer;
	border-radius: 50px;
	padding: 5px 15px 10px 15px;
	transition: 0.6s;
}

#privacy button:hover {
	background-color: var(--charcoal);
}

/*--------------------------------------------------------------
# SCREEN READER
--------------------------------------------------------------*/
.screen-reader {
	clip-path: inset(50%);
	width: 1px;
	height: 1px;
	overflow: hidden !important;
	position: fixed !important;
	white-space: nowrap !important;
	word-wrap: normal !important;
}

.screen-reader-text {
	position: absolute;
	left: -9999px;
	z-index: 999;
	padding: 1.0rem;
	opacity: 0;
}

a.screen-reader-text:focus {
	color: var(--blue);
}

.screen-reader-text:focus {
	left: 0;
	transform: translateX(0%);
	opacity: 1;
}

/*--------------------------------------------------------------
# LIGHTBOX (<dialog>)
--------------------------------------------------------------*/
.lightbox-container {
	position: fixed;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	border: none;
	padding: 0;
	margin: 0;
	color: var(--text-color);
	background-color: var(--lightbox-bg);
}

.lightbox-container:focus {
	outline: none;
}

.lightbox-container.active {
	display: block;
}

.lightbox-container > *:not(figure) {
	position: absolute;
}

.lightbox-container > button {
	padding: 1rem;
}

figure.image-container {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	display: grid;
}

figure.image-container > img {
	max-width: 100%;
	max-height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.5s ease-in-out;
	transform-origin: center center;
}

figure.image-container > img.fade-in,
.fade-in {
	opacity: 1;
	transform: translateX(0);
}

figure.image-container > img.fade-out,
.fade-out {
	opacity: 0;
	transition: opacity 0.5s ease;
}

figure.image-container > figcaption {
	opacity: 0;
	transition: opacity 0.5s ease-in-out;
}

figure.image-container > figcaption.fade-in {
	opacity: 1;
}

.slide-in {
	transform: translateX(0);
	transition: opacity 0.5s ease;
}

.image-transition {
	transition: transform 1s ease-in-out;
}

.image-index {
	top: 50px;
	left: 50px;
	font-size: 1.75rem;
	letter-spacing: 0.1rem;
	cursor: default;
}

.close {
	top: 25px;
	right: 50px;
	font-size: 4rem;
	font-weight: 300;
	cursor: pointer;
}

.arrow {
	top: 50%;
	cursor: pointer;
	user-select: none;
}

#arrow-left {
	left: 50px;
}

#arrow-right {
	right: 50px;
}

.lightbox-container figcaption {
	text-align: right;
	color: var(--text-color);
}

.lightbox-container figcaption:has(span) {
	display: flex !important;
}

.lightbox-container figcaption > span:first-child {
	margin-right: auto;
}

.lightbox-container figcaption > span:last-child::before {
	content: "\00a0\2013\00a0";
}

.lightbox-container figcaption > .location + .place::before {
	content: "\00a0 at\00a0";
}

@container body (width < 768px) {
	figcaption {
		font-size: 1rem;
	}

	figcaption > span:first-child::after {
		content: '\A';
		white-space: pre-wrap;
	}

	figcaption > span:nth-child(2)::after {
		content: '\00a0\2013\00a0';
	}
}

/*--------------------------------------------------------------
# DARK MODE TOGGLE & OVERRIDES
--------------------------------------------------------------*/
.dark-mode-icon {
	display: none;
}

.dark-mode-toggle {
	background: transparent;
	cursor: pointer;
	position: relative;
	display: grid;
	margin-right: var(--hover-padding);
	align-self: center;
	place-items: center;
	width: 45px;
	height: 45px;
	margin-left: auto;
	border-radius: 50%;
	transition: background 0.5s, border 0.5s;
	border: 2px solid transparent;
}

.dark-mode-toggle:is(:hover, :focus-visible) {
	background-color: rgba(var(--darkmode-hover), 0.1);
}

.dark-mode-toggle:focus-visible {
	border: 2px solid orange;
}

.darkmode .sl-wrapper .sl-image .sl-caption {
	background: rgba(0, 0, 0, 0.4) !important;
	color: rgb(235, 235, 236);
}

.darkmode .sl-overlay {
	background: rgba(0, 0, 0, 0.8) !important;
}

/*--------------------------------------------------------------
# SEARCH FORM
--------------------------------------------------------------*/
form[role=search] {
	position: relative;
	display: flex;
	width: 2.8rem;
	height: 2.8rem;
	border: 2px solid var(--text-color);
	border-radius: 5px;
	overflow: hidden;
	transition: width 300ms ease-in-out;
}

form[role=search]:focus-within {
	width: 100% !important;
}

form[role=search]:focus-within input {
	width: calc(100% - 3.8rem);
	opacity: 1;
	margin-left: 1rem;
	cursor: text;
}

form[role=search] input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 2.8rem;
	background: transparent;
	flex-grow: 1;
	transition: 0.4s;
	opacity: 0;
	z-index: 2;
	cursor: pointer;
}

form[role=search] input::placeholder {
	opacity: 0;
	transition: 0.4s;
}

form[role=search] input:hover::placeholder {
	opacity: 1;
}

form[role=search] input:focus::placeholder {
	color: transparent;
}

form[role=search]:hover input {
	border-color: var(--blue);
}

form[role=search]:has(input:focus-visible),
form[role=search]:has(button:focus-visible) {
	border-color: orange;
}

form[role=search]:has(input.mouse-focused) {
	border-color: var(--blue);
}

form[role=search] button {
	width: 2.8rem;
	height: 2.8rem;
	margin-left: auto;
	z-index: 99;
	pointer-events: none;
}

form[role=search]:focus-within button {
	pointer-events: all;
}

form[role=search] button:hover {
	cursor: pointer;
}

form[role=search] button svg {
	vertical-align: bottom;
	margin: auto;
}

form[role=search] button:focus-visible svg {
	color: orange;
}

/*--------------------------------------------------------------
# TOOLTIP
--------------------------------------------------------------*/
.link-preview {
	--arrow-color: rgba(0, 0, 0, 0.8);
	padding: 1rem;
	border-radius: 5px;
	z-index: 1000;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.link-preview::after {
	content: '';
	position: absolute;
	width: 0;
	height: 0;
	border: 10px solid transparent;
}

.tooltip-above::after {
	top: 100%;
	left: 50%;
	margin-left: -10px;
	/* border-top-color: var(--arrow-color); */
}

.tooltip-below::after {
	bottom: 100%;
	left: 50%;
	margin-left: -10px;
	/* border-bottom-color: var(--arrow-color); */
}

.link-preview.show {
	display: block;
	opacity: 1;
}

.link-preview-card {
	display: grid;
	row-gap: 0.5rem;
}

.mastodon {
	display: flex;
	align-items: center;
	gap: .5rem;
	width: fit-content;
	color: var(--text);
	border: 2px solid var(--blue);
	border-radius: 10px;
	padding: .5rem;
	transition: 0.6s;
	margin: 1rem 0;
}

.mastodon:hover {
	color: var(--text);
	background-color: var(--hover-color);
}

.mastodon:focus {
	color: var(--text);
	text-decoration: none;
}

.mastodon svg {
	display: inline-block;
}

[aria-label="RSS Feed"] {
	display: flex;
	margin-left: auto;
	padding: 0.35rem 0.125rem;
}

[aria-label="RSS Feed"] svg {
	height: 1lh;
  width: auto; /* Maintains aspect ratio */
  align-items: center;
}