/*
Theme Name: T.J. Monkey's
Description: tjmonkeys.org, dressed like tjmonkeys.com in 2004.
Author: Porter Mason
Version: 1.3.0
Requires at least: 6.6
Requires PHP: 8.1
Text Domain: tjmonkeys
*/

/*
 * Colors, fonts and base sizes live in theme.json. This is what it can't say.
 * The 2004 site used 14px Times and 10–12px Helvetica; sizes here are a few
 * steps up so it reads on a phone, with the same faces, colors and boxes.
 */

body {
	margin: 0;
}

.tjm-page {
	background: var(--wp--preset--color--paper);
	margin: 8px auto;
	max-width: 900px;
	padding: 20px 20px 28px;
}

.tjm-page :focus-visible {
	outline: 2px solid var(--wp--preset--color--teal);
	outline-offset: 2px;
}

/* Header. */
.tjm-header {
	margin-bottom: 22px;
}

.tjm-masthead {
	display: block;
	margin-bottom: 14px;
}

.tjm-masthead img {
	display: block;
	height: auto;
	margin: 0 auto;
	max-width: 100%;
	width: 720px;
}

/* The teal bar. */
.tjm-menu {
	background: var(--wp--preset--color--teal);
}

.tjm-menu .wp-block-navigation__container {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	width: 100%;
}

.tjm-menu .wp-block-navigation-item {
	border-right: 1px solid #5b8a8a;
	flex: 1 1 auto;
	justify-content: center;
}

.tjm-menu .wp-block-navigation-item:last-child {
	border-right: 0;
}

.tjm-menu.wp-block-navigation .wp-block-navigation-item__content {
	color: var(--wp--preset--color--teal-pale);
	display: block;
	font-size: 15px;
	font-weight: bold;
	letter-spacing: 0.03em;
	padding: 10px 12px;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	width: 100%;
}

.tjm-menu.wp-block-navigation .wp-block-navigation-item__content:hover,
.tjm-menu.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	color: #fff;
}

.tjm-menu.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	background: #285353;
}

/* Phones get a MENU bar that opens a list instead of the six-item bar. */
.tjm-phone-menu {
	display: none;
}

/* The gray search strip. */
.tjm-searchbar {
	background: #aaa;
	padding: 6px;
}

.tjm-searchbar .wp-block-search__inside-wrapper {
	justify-content: center;
}

.tjm-searchbar .wp-block-search__input {
	border: 1px solid #777;
	border-radius: 4px;
	flex: 0 1 280px;
	font-size: 16px; /* 16px or more, or iPhones zoom in on tap */
	min-width: 0;
	padding: 3px 6px;
}

.tjm-searchbar .wp-block-search__button {
	background: #eee;
	border: 1px solid #777;
	border-radius: 4px;
	color: #000;
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 17px;
	margin-left: 6px;
	padding: 3px 10px;
	white-space: nowrap;
}

/* Gray "Read a random Thought" buttons. */
/* At the bottom of every page, right under the Older / Newer boxes on a Thought. */
.tjm-sublinks {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 28px 0 0;
}

.single .tjm-sublinks,
.home .tjm-sublinks {
	margin-top: 6px;
}

.tjm-sublinks a {
	background: #e2e2e2;
	border: 1px solid #b5b5b5;
	border-radius: 4px;
	color: #333;
	flex: 1 1 160px;
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 14px;
	padding: 8px 6px;
	text-align: center;
	text-decoration: none;
}

.tjm-sublinks a:hover {
	background: #d2d2d2;
	color: #000;
}

/* WordPress sets pre-wrap on author bios, which shows every line break as a gap. */
.wp-block-post-author-biography {
	white-space: normal;
}

/* Bio photos keep their shape when phones narrow them. */
.wp-block-post-author-biography img {
	height: auto;
}

.tjm-sublinks .tjm-short {
	display: none;
}

p.tjm-figure {
	margin: 0;
	text-indent: 0;
}

/*
 * The gang photo on Meet the Gang. Each person is a link the size of the
 * photo, stacked by who stands in front; only their outline (the SVG polygon)
 * takes the pointer. On hover they grow a little, from their feet, over a
 * filled-in patch of background, still behind anyone in front of them.
 */
.tjm-faces {
	border: 5px solid #000;
	margin-bottom: 16px;
	overflow: hidden;
	position: relative;
}

.tjm-page .tjm-faces img.tjm-full {
	margin: 0;
}

/* wpautop leaves an empty <p> in here, which made the box taller than the
   photo and threw every cut-out off. Only the photo sets the size. */
.tjm-faces > :not(img, a, .tjm-tags) {
	display: none;
}

.tjm-faces .tjm-person {
	inset: 0;
	pointer-events: none;
	position: absolute;
}

.tjm-faces svg {
	height: 100%;
	inset: 0;
	pointer-events: none;
	position: absolute;
	width: 100%;
}

.tjm-faces svg * {
	cursor: pointer;
	fill: transparent;
	pointer-events: all;
}

.tjm-page .tjm-faces img.tjm-cutout,
.tjm-page .tjm-faces img.tjm-behind {
	max-width: none;
	pointer-events: none;
	position: absolute;
}

/* The patch shows at once, and goes only once he's back in place. */
.tjm-page .tjm-faces img.tjm-behind {
	opacity: 0;
	transition: opacity 0s 0.2s;
}

.tjm-page .tjm-faces img.tjm-cutout {
	transform-origin: 50% 100%;
	transition: transform 0.2s ease-out, filter 0.2s;
}

.tjm-faces .tjm-person:hover img.tjm-behind,
.tjm-faces .tjm-person:focus-visible img.tjm-behind {
	opacity: 1;
	transition: none;
}

.tjm-faces .tjm-person:hover img.tjm-cutout,
.tjm-faces .tjm-person:focus-visible img.tjm-cutout {
	filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6));
	transform: scale(1.08);
}

.tjm-faces .tjm-person:focus-visible {
	outline: 3px solid #cc9933;
	outline-offset: -3px;
}

.tjm-faces .tjm-tags {
	inset: 0;
	pointer-events: none;
	position: absolute;
	z-index: 20;
}

.tjm-faces .tjm-tag {
	background: #336666;
	color: #ccecec;
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 14px;
	font-weight: bold;
	opacity: 0;
	padding: 2px 8px;
	position: absolute;
	text-transform: uppercase;
	transform: translate(-50%, 6px);
	transition: opacity 0.12s;
	white-space: nowrap;
}

/* The nth tag belongs to the nth person. */
.tjm-faces:has(.tjm-person:nth-child(2):is(:hover, :focus-visible)) .tjm-tag:nth-child(1),
.tjm-faces:has(.tjm-person:nth-child(3):is(:hover, :focus-visible)) .tjm-tag:nth-child(2),
.tjm-faces:has(.tjm-person:nth-child(4):is(:hover, :focus-visible)) .tjm-tag:nth-child(3),
.tjm-faces:has(.tjm-person:nth-child(5):is(:hover, :focus-visible)) .tjm-tag:nth-child(4),
.tjm-faces:has(.tjm-person:nth-child(6):is(:hover, :focus-visible)) .tjm-tag:nth-child(5),
.tjm-faces:has(.tjm-person:nth-child(7):is(:hover, :focus-visible)) .tjm-tag:nth-child(6),
.tjm-faces:has(.tjm-person:nth-child(8):is(:hover, :focus-visible)) .tjm-tag:nth-child(7),
.tjm-faces:has(.tjm-person:nth-child(9):is(:hover, :focus-visible)) .tjm-tag:nth-child(8) {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.tjm-page .tjm-faces img.tjm-cutout {
		transition: none;
	}
}

/* A photo across the whole column (the gang on Meet the Gang). */
.tjm-page img.tjm-full {
	box-sizing: border-box;
	display: block;
	height: auto;
	margin: 0 0 16px;
	width: 100%;
}

/* Running text: Thoughts, bios, pages. Every paragraph indented, the same gap. */
.tjm-thought .wp-block-post-content,
.tjm-text {
	overflow-wrap: break-word;
}

/*
 * One rhythm for everything in running text: the same gap between any two
 * blocks (paragraph, list, quote, table), indents to tell paragraphs apart.
 * WordPress's own block gap is turned off here so it can't add a second one.
 */
.tjm-thought .wp-block-post-content > *,
.tjm-text > *,
.tjm-text blockquote > *,
.tjm-thought .wp-block-post-content blockquote > * {
	margin-block: 0;
}

.tjm-thought .wp-block-post-content > * + *,
.tjm-text > * + *,
.tjm-text blockquote > * + *,
.tjm-thought .wp-block-post-content blockquote > * + * {
	margin-block-start: 0.55em;
}

.tjm-thought .wp-block-post-content p,
.tjm-text p {
	hyphens: auto;
	text-align: justify;
	text-indent: 1.4em;
}

.tjm-thought .wp-block-post-content li p,
.tjm-text li p,
.tjm-thought .wp-block-post-content td p,
.tjm-text td p {
	margin: 0;
	text-indent: 0;
}

.tjm-thought .wp-block-post-content blockquote,
.tjm-text blockquote {
	margin-inline: 1.6em;
}

.tjm-thought .wp-block-post-content :is(ul, ol),
.tjm-text :is(ul, ol) {
	padding-left: 1.6em;
}

.tjm-thought .wp-block-post-content ul,
.tjm-text ul {
	list-style-type: circle;
}

.tjm-thought .wp-block-post-content li + li,
.tjm-text li + li {
	margin-top: 0.3em;
}

.tjm-thought .wp-block-post-content > :is(h2, h3, h4, h5),
.tjm-text > :is(h2, h3, h4, h5) {
	margin-block-start: 1.1em;
}

/* An empty line the writer left on purpose (before a P.S., an aside, a credit). */
.tjm-thought .wp-block-post-content > hr.tjm-pause,
.tjm-text > hr.tjm-pause,
hr.tjm-pause {
	border: 0;
	height: 0;
	margin-block: 0.9em 0;
}

/* Old content uses align="left|right" and hspace on images. */
.tjm-page img {
	height: auto;
	max-width: 100%;
}

.tjm-page img[align="right"] {
	float: right;
	margin: 4px 0 14px 28px;
}

.tjm-page img[align="left"] {
	float: left;
	margin: 4px 28px 14px 0;
}

/* A Thought. */
.tjm-kicker,
.tjm-date {
	color: var(--wp--preset--color--gray);
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 14px;
	font-weight: bold;
	margin: 0;
}

.tjm-thought .wp-block-post-title {
	margin: 4px 0 10px;
}

.tjm-thought .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}

/* The sign-off: "— Porter", not indented, like the end of a letter. */
.tjm-byline {
	clear: both;
	margin: 16px 0 0;
}

.tjm-byline::before {
	color: var(--wp--preset--color--gray);
	content: "\2014\00a0";
}

/*
 * Each Thought sits in its own box, like the gray-framed content table on the
 * 2001 site, so it's clear what's the piece and what's the site around it.
 */
article.tjm-thought {
	border: 6px solid #e2e2e2;
	border-radius: 4px;
	padding: 28px 26px 16px;
}

.tjm-vote {
	border-top: 1px dotted #bbb;
	clear: both;
	color: var(--wp--preset--color--red);
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 16px;
	font-weight: bold;
	margin: 24px 0 0;
	padding: 10px 0;
}

.tjm-vote a {
	color: var(--wp--preset--color--red);
	display: inline-block;
	font-weight: normal;
	margin-left: 14px;
}

/* "Here's what you can do next, friend:" */
.tjm-next {
	margin-top: 26px;
}

.tjm-next h2 {
	font-size: 18px;
	margin: 0 0 8px;
}

.tjm-next-links {
	display: grid;
	gap: 6px;
	grid-template-columns: repeat(2, 1fr);
}

.tjm-next-links a {
	background: #eee;
	border: 1px solid #ccc;
	border-radius: 4px;
	display: block;
	padding: 8px 10px;
	text-decoration: none;
}

.tjm-next-links a:hover {
	background: #e2e2e2;
}

.tjm-next-older {
	grid-column: 1;
}

.tjm-next-newer {
	grid-column: 2;
	text-align: right;
}

.tjm-next-label {
	color: var(--wp--preset--color--gray);
	display: block;
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 12px;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.tjm-next-older .tjm-next-label::before {
	content: "\2190\00a0";
}

.tjm-next-newer .tjm-next-label::after {
	content: "\00a0\2192";
}

.tjm-next-title {
	color: var(--wp--preset--color--link);
	display: block;
	font-size: 17px;
	line-height: 1.3;
	margin-top: 2px;
}

/* Lists of Thoughts (archives, author pages, search): bulleted, like Top 50 and the gang. */
.tjm-list .wp-block-post-template {
	list-style: circle;
	margin: 0;
	padding-left: 1.6em;
}

.tjm-list .wp-block-post {
	display: list-item;
	margin: 0 0 0.35em;
}

.tjm-list .wp-block-post-title {
	display: inline;
	font-family: var(--wp--preset--font-family--times);
	font-size: inherit;
	font-weight: normal;
	line-height: inherit;
}

.tjm-list .tjm-list-meta {
	color: var(--wp--preset--color--gray);
	display: inline;
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 14px;
	margin-left: 8px;
}

/* WordPress makes title links inline-block, which lines a wrapped title up by
   its last line, so the bullet sat next to line two. */
.tjm-list .wp-block-post-title a {
	display: inline;
}

/* On an author's own page, their name on every line is just noise. */
.author .tjm-list .wp-block-post-author-name {
	display: none !important;
}

.tjm-list .tjm-list-meta > * {
	display: inline;
	margin: 0 6px 0 0;
}

.tjm-page .by {
	color: var(--wp--preset--color--gray);
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 14px;
	margin-left: 4px;
}

.tjm-text ol.tjm-top50 li + li,
.tjm-text ul.tjm-gang li + li {
	margin-top: 0.35em;
}

/* Archives: the author list in columns, the months one year per line. */
.tjm-text ul.tjm-gang:not(.tjm-types) {
	column-gap: 24px;
	columns: 3 11em;
}

.tjm-text ul.tjm-gang li {
	break-inside: avoid;
}

.tjm-text ul.tjm-gang:not(.tjm-types) li {
	margin: 0 0 0.35em;
}

.tjm-text ul.tjm-months {
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 15px;
	list-style: none;
	padding-left: 0;
}

.tjm-text ul.tjm-months li {
	padding-left: 3.2em; /* a year's months wrap under its first month */
	text-indent: -3.2em;
}

.tjm-months a {
	display: inline-block;
	text-indent: 0;
	margin-right: 0.5em;
}

.tjm-months .tjm-year {
	display: inline-block;
	font-weight: bold;
	text-indent: 0; /* or it takes the li's -3.2em again */
	width: 3.2em;
}

.wp-block-query-pagination {
	font-family: var(--wp--preset--font-family--gothic);
	font-size: 15px;
	gap: 12px;
	margin-top: 16px;
}

/* The bottom of every page: a small logo (home) over the 2001 street photo. */
.tjm-footer-gang {
	clear: both;
	margin-top: 40px;
	text-align: center;
}

.tjm-footer-gang a,
.tjm-footer-gang img {
	display: block;
	margin: 0 auto;
}

.tjm-footer-logo img {
	height: auto;
	width: 300px;
}

.tjm-page img.tjm-footer-photo {
	border: 5px solid #000;
	box-sizing: border-box;
	height: auto;
	margin-top: 16px;
	width: 320px;
}

.tjm-footer {
	clear: both;
	color: #333;
	font-size: 15px;
	font-style: italic;
	margin-top: 32px;
	text-align: center;
}

/* Phones. */
@media (max-width: 560px) {
	.tjm-page {
		margin: 0;
		padding: 12px 16px 24px;
	}

	body {
		font-size: 19px;
	}

	.tjm-page h1 {
		font-size: 26px;
	}

	.tjm-menu.wp-block-navigation {
		display: none;
	}

	.tjm-phone-menu {
		background: var(--wp--preset--color--teal);
		display: block;
		font-family: var(--wp--preset--font-family--gothic);
	}

	.tjm-phone-menu summary {
		color: #fff;
		cursor: pointer;
		font-size: 16px;
		font-weight: bold;
		letter-spacing: 0.05em;
		list-style: none;
		padding: 12px 16px;
		text-transform: uppercase;
	}

	.tjm-phone-menu summary::-webkit-details-marker {
		display: none;
	}

	/* Three bars, then an × when open. */
	.tjm-phone-menu summary::after {
		content: "\2630";
		float: right;
		font-size: 20px;
		line-height: 1;
	}

	.tjm-phone-menu[open] summary::after {
		content: "\2715";
	}

	.tjm-phone-menu ul {
		border-top: 1px solid #5b8a8a;
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.tjm-phone-menu li + li {
		border-top: 1px solid #5b8a8a;
	}

	.tjm-phone-menu a {
		color: var(--wp--preset--color--teal-pale);
		display: block;
		font-size: 16px;
		font-weight: bold;
		letter-spacing: 0.03em;
		padding: 13px 16px;
		text-decoration: none;
		text-transform: uppercase;
	}

	.tjm-phone-menu a:hover {
		background: #285353;
		color: #fff;
	}

	/* On phones the box is just a rule across the top and bottom, edge to
	   edge, so the text gets the full width. */
	article.tjm-thought {
		border-left: 0;
		border-radius: 0;
		border-right: 0;
		margin-inline: -16px;
		padding: 24px 16px 14px;
	}

	/* Each label on one line; whole buttons wrap only when they must. */
	.tjm-sublinks a {
		flex: 1 1 auto;
		font-size: 14px;
		padding: 9px 10px;
		white-space: nowrap;
	}

	.tjm-sublinks .tjm-long {
		display: none;
	}

	.tjm-sublinks .tjm-short {
		display: inline;
	}

	.tjm-thought .wp-block-post-content p,
	.tjm-text p {
		text-align: left;
	}

	.tjm-thought .wp-block-post-content blockquote,
	.tjm-text blockquote {
		margin: 0.8em;
	}

	/* Small photos (bios, most Thoughts) stay beside the text; big ones stack. */
	.tjm-page img[align] {
		max-width: 42%;
	}

	.tjm-page img[align="right"] {
		margin-left: 16px;
	}

	.tjm-page img[align="left"] {
		margin-right: 16px;
	}

	.tjm-page img.tjm-wide,
	.tjm-page img.tjm-wide[align] {
		display: block;
		float: none;
		margin: 8px auto;
		max-width: 100%;
	}

	.tjm-next-links {
		grid-template-columns: 1fr;
	}

	.tjm-next-links a,
	.tjm-next-newer {
		grid-column: 1;
		text-align: left;
	}

	.tjm-vote {
		line-height: 1.6;
	}

	.tjm-vote-q {
		display: block;
	}

	.tjm-vote a {
		margin: 6px 18px 0 0;
	}
}

/* "233 Thoughts, 51 Bits, 1 Weak In News": each part wraps whole. */
.tjm-gang .by span {
	white-space: nowrap;
}
