:root {
	font-family: monospace;

	--main-flow-size: 140ch;

	--color-main: light-dark(#0d0c25, #b79f1b);
	--color-main-background: light-dark(#dbdaf3, #0d0c25);
	--color-secondary: light-dark(#005653, #1bb7a8);
	--color-secondary-background: light-dark(#cdebf2, #5f4012);
	--color-highlight-shading: light-dark(#b79f1b, #005653);

	background-color: var(--color-main-background);
	color: var(--color-main);

	color-scheme: light dark;

	&:has(input[type="radio"][name="theme"]#theme-force-dark:checked) {
		color-scheme: dark;
	}

	&:has(input[type="radio"][name="theme"]#theme-force-light:checked) {
		color-scheme: light;
	}
}

body {
	margin: 0;
	min-height: 100svh;

	&::before {
		content: "";
    position: fixed;
    inset: 0;

    background: radial-gradient(circle at 50% 0, var(--color-highlight-shading), transparent 75%);
    mix-blend-mode: color-dodge;

    z-index: 1;
    pointer-events: none;
	}
}

.text-repeater {
	display: flex;
	max-width: 100%;
	white-space: nowrap;

	animation: slide-right 20s linear infinite;

	* {
		display: inline-block;
	}

	@media (prefers-reduced-motion: reduce) {
		display: inline-block;
		animation: none;

		& > * {
			display: none;

			&:nth-child(1) {
				display: inline-block;
			}
		}
	}

	&.text-repeater-inverted {
		animation-direction: reverse;

		& > * {
			translate: -100%;

			@media (prefers-reduced-motion: reduce) {
				translate: none;
			}
		}
	}
}

main {
	margin-inline: auto;
	max-inline-size: var(--main-flow-size);
	position: relative;
	z-index: 1;
	overflow-y: clip;
	min-height: 50vw;
}

article {
	isolation: isolate;

	hr {
		height: 1lh;
	  margin: 0;
		margin-inline: -1ch;

	  &::before {
		 	content: "";

			display: inline-block;
			height: 25%;
			width: 100%;
			vertical-align: middle;

			background-color: currentColor;
	  }
	}
}

.term-frame {
	font-family: "GeistPixel", "PolterPixel", monospace;
	font-size: 26.31px;
	text-decoration-thickness: 0.04rem;
	text-underline-offset: 0.12rem;
	isolation: isolate;

	padding: 1lh 2ch;

	display: block;
	position: relative;

	text-shadow:
		0 1px 0 var(--color-main-background),
		0 2px 0 var(--color-main-background);

	&:is(fieldset) {
		border: none;
		margin: 0;
	}

	&::before,
	&::after {
		pointer-events: none;

		content: "";
		z-index: -1;
		position: absolute;
		inset: 0.25lh 0.75ch;
		box-sizing: border-box;
	}

	&::before {
	  background: var(--color-main-background);
	  opacity: .5;
	}

	&::after {
		border: solid var(--color-main);
		border-width: 0.5lh 0.5ch;
		backdrop-filter: blur(200px);
	}

	& > legend:first-of-type {
		position: absolute;
		inset-block-start: 0;
		margin-block-start: .4lh;
		padding-inline: 1ch;

		line-height: 1;
		font-size: 75%;

		background: var(--color-main-background);

		max-width: calc(100% - 6ch);
		white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
	}
}

strong {
	font-weight: inherit;
	background-color: var(--color-main);
	color: var(--color-main-background);
	text-shadow: none;
}

.excerpt {
	font-size: 75%;
}

.horizontal-scroll-with-indicator {
	display: flex;
	overflow-x: scroll;
	background:
		linear-gradient(calc(-90deg - 180deg), var(--color-main-background) 2ch, transparent),
		linear-gradient(-90deg, var(--color-main-background) 2ch, transparent),
		linear-gradient(calc(-90deg - 180deg), var(--color-main), var(--color-main-background)),
		linear-gradient(-90deg, var(--color-main), var(--color-main-background));
	background-attachment:
		local,
		local,
		scroll,
		scroll;
	background-position:
		center left,
		center right,
		center left,
		center right;
	background-size:
		calc(2ch + 3ch) 100%,
		calc(2ch + 3ch) 100%,
		2ch 100%,
		2ch 100%;
	background-repeat: no-repeat;
}

.category-card {
	margin-block-start: 1lh;
	margin-inline: -2rch;
  padding: 1rlh 3rch;

  background-color: var(--color-main);
  color: var(--color-main-background);
  text-shadow: none;

  h2 {
    margin: 0;
    float: inline-start;
    font-size: calc(200% - 1px);
    margin-inline-end: 1rlh;
  }

  & > p {
    margin-block: 0;
  }
}

.post-card {
	text-decoration: inherit;
	color: inherit;
	background: none;

	&::before,
	&::after {
		background: none;
		backdrop-filter: none;
	}

	&::after {
		background: var(--color-secondary-background);
	}

	legend:first-of-type {
		background-color: var(--color-main-background);
	}

	p, h3 {
		margin-block: 0;
	}

	h3 {
		color: var(--color-secondary);
		text-decoration: underline;
	}

	&:active, &:focus {
		background: none;
		text-shadow: none;

		&::before,
		&::after {
			background-color: var(--color-secondary);
		}

		h3 {
			color: var(--color-secondary-background);
		}

		legend {
			background-color: var(--color-secondary);
		}
	}
}

.posts-list {
	padding: 0.75lh 0;
	position: relative;

	&::before,
	&::after {
		inset-inline: 0;
		border-inline: none;
		inset-block-start: 0;
		border-block-start: none;
	}

	.post-card {
		min-width: calc(100%/3);
	}

	& > legend:first-of-type {
		font-size: 100%;
		inset-block: auto 0;
  	inset-inline: auto 1ch;
	}
}

.sidebars {
	writing-mode: sideways-lr;
	position: sticky;


	@media not (max-width: calc(77ch + ((15ch + 7rlh) * 2))) {
		/* --main-flow-size + sidebar */
		top: 0;
	  bottom: 100%;
	  width: 100%;

		& > * {
			position: absolute;
			top: 0;
			display: flex;

			.term-frame {
				flex-direction: row-reverse;
			}
		}

		.sidebar-right {
			left: 100%;
		}

		.sidebar-left {
			right: 100%;
		}
	}

	@media (max-width: calc(77ch + ((15ch + 7rlh) * 2))) {
		/* --main-flow-size + sidebar */

		position: sticky;
		display: flex;
		writing-mode: horizontal-tb;
		bottom: 0;
		z-index: 1;
		overflow: hidden;
		overflow-x: auto;

		.sidebar-left,
		.sidebar-right {
			display: contents;
		}
	}

	& .term-frame {
		display: flex;
		flex-wrap: nowrap;

		legend {
			block-size: 2ch;
			padding-inline: 0.5lh;
		}
	}

	input[type="radio"] {
		display: none;

		&:checked + label {
			background-color: var(--color-secondary);
			color: var(--color-secondary-background);
		}
	}

	label,
	a,
	hr {
		display: inline-block;
		text-align: center;
		font-size: 200%;
		writing-mode: initial;
		text-decoration: none;
		block-size: 4rlh;
		inline-size: 4rlh;

		cursor: pointer;
	}

	hr {
		position: relative;
		display: inline;
		margin: 0;
		writing-mode: inherit;
		cursor: initial;

		&::before {
			content: "|";
		}
	}
}

a,
label {
	background-color: var(--color-secondary-background);
	color: var(--color-secondary);

	&:active,
	&:focus {
		background-color: var(--color-secondary);
		color: var(--color-secondary-background);
		text-shadow: none;
	}
}

hr {
	border: none;
	color: inherit;
}

p,
dl,
ul,
ol {
	margin-block: 1lh;
}

p:first-child,
dl:first-child,
ul:first-child,
ol:first-child {
	margin-block-start: 0;
}

p:last-child,
dl:last-child,
ul:last-child,
ol:last-child {
	margin-block-end: 0;
}

ul,
menu,
dir {
	padding-inline-start: 2ch;
	list-style-type: square;
}

@keyframes slide-right {
	from {
		translate: calc(var(--moving-distance) * -1);
	}

	to {
		translate: calc(var(--moving-distance) * -2);
	}
}

@keyframes spotlight-rotation {
	from {
		box-shadow: inset 0 calc(var(--circle-diameter) / 2)
			calc(var(--circle-diameter) / 1.5) var(--color-main-background);
		rotate: 0turn;
	}

	25%,
	75% {
		box-shadow: inset 0 calc(var(--circle-diameter) / -2)
			calc(var(--circle-diameter) / 1.5) var(--color-main-background);
	}

	50% {
		box-shadow: inset 0 calc(var(--circle-diameter) / 2)
			calc(var(--circle-diameter) / 1.5) var(--color-main-background);
	}

	to {
		box-shadow: inset 0 calc(var(--circle-diameter) / 2)
			calc(var(--circle-diameter) / 1.5) var(--color-main-background);
		rotate: 1turn;
	}
}
