/**
 * This sheet contains tyles which should be applied to both editor and front-end.
 */


/**
 * These styles will apply to iframe editor, non-iframe editor, and all front end.
 * Adding them within the body selector without .wp-admin prevents these styles from being added
 * to the editor admin parent frame. Using the body:not(.block-editor-iframe__body) prevents applying
 * these styles twice to the inner content of the iframed editor. Probably not _strictly_ needed, but
 * more convenient for debugging
 */
:where(
	.editor-styles-wrapper ,
	body:not(
		.wp-admin ,
		.wp-customizer ,
		.block-editor-iframe__body
	)
) {

	a {
		color: var(--colorLink);
		text-decoration: underline;
	}

	a:hover {
		text-decoration-color: var(--colorGreen_bright);
	}

	@supports ( text-decoration-thickness: 2px ) {
		a:hover {
			text-decoration-color: var(--colorGreen_bright);
			text-decoration-thickness: 2px;
		}
	}

	a.button {
		text-decoration: none;

		@media ( width > 550px ) {
			max-width: 200px;
		}
	}

	h1, h2, h3, h4, h5 {
		margin: 1.2em 0 .2em 0;
		line-height: 1.1em;
	}

	h3 {
		color: hsl(0, 0%, 27%);
	}

	h4 {
		color: #222;
	}

	h5 {
		color: #424242;
		margin-bottom: .2em;
		margin-top: 1.4em;
		line-height: 1.3em;
	}

	h6 {
		color: #424242;
		margin-bottom: .2em;
		margin-top: 1.4em;
		line-height: 1.3em;
	}

	.page-title, .wp-block-post-title {
		color: #851326;
	}

	.main-content h1.page-title {
		margin-block: .5rem 4rem;
	}

	.single-post .page-title {
		margin-bottom: 1em;
	}

	ul, ol {
		margin-left: 1.3em;
	}

	/* add class "hide" to a WP nav menu item to, uh, hide it. */

	li.menu-item.hide {
		display: none !important;
	}

	nav ul {
		margin: 0;
	}

	nav a {
		display: block;
		text-decoration: none;
		border-bottom: none;
	}

	ul.widget_list_wrap {
		margin-left: 0;
	}

	/* We are not using the vertical-align properties because they end up changing */
	/* the line height for the line which contains the <sup> element */

	sup {
		/* vertical-align: super */
		position: relative;
		top: -.6em;
	}

	sub {
		/* vertical-align: sub */
		position: relative;
		top: .3em;
	}

	address {
		line-height: 1.2em;
		padding-left: 2.5em;
	}

	blockquote {
		color: var(--colorGarnet_bright);
		margin: 2em auto;
		width: 90%;

		cite {
			color: hsl(0, 0%, 0%);
			font-weight: 200;
			font-style: normal;
			font-family: var(--fontSansSerif), sans-serif;
			font-size: .8em;

			&::before {
				content: "\2014"; /*  mdash */
				padding-right: .4em;
				opacity: .4;
			}
		}

		p:is(p) {
			line-height: 1.3em;
		}
	}


	hr, hr.wp-block-separator {
		clear: both;
		border-top: 1px solid #dddddd;
		border-bottom: none;
	}

	hr.hr-border {
		border-top: 0;
	}

	td {
		padding: 3px 20px 3px 0;
	}

	pre {
		background: none repeat scroll 0 0 #fafafa;
		padding: 10px;
		border-radius: 2px;
		margin: 5px 0;
		white-space: pre-wrap;
	}

	p {
		line-height: 1.4em;
	}

	input[type="text"],
	input[type="password"],
	input[type="email"],
	input[type="url"],
	input[type="tel"],
	textarea {
		background: #fff;
		padding: .5em;
		border: 1px solid #dadada;
		border-radius: 3px;
	}

	input[type="submit"],
	a.button {
		border-radius: 3px;
		border: 0;
		padding: .7em;
		margin: 5px 0;
		display: inline-block;
		cursor: pointer;
		background-color: var(--colorGarnet_bright);
		color: var(--colorGray_light);

		/* to prevent iOS yuck */
		-webkit-appearance: none;

		&:hover {
			border: 0;
			box-shadow: 0 0 90px hsla(0, 0%, 0%, .4) inset;
		}

		&:active {
			box-shadow: 0 0 90px hsla(0, 0%, 0%, .7) inset;
		}

	}

	textarea {
		max-width: 100%;
	}

	p.byline {
		border-bottom: 1px solid hsl(0, 0%, 90%);
		padding-bottom: 1em;
		font-size: .9em;
		margin-bottom: 1em;

		a {
			text-decoration: none;
		}
	}

	.less-important {
		opacity: .7;
		font-size: .85em;
	}

	/* p:not(:empty), */

	p,
	figcaption {
		margin: 0 0 1em 0;
		padding: 0 0.75em 0 0;
	}

	td {
		line-height: 1.5em;
	}

	/* this indicates an element which has been given a background color. */

	.has-background {
		padding: .6em;
	}

	.no-gap {
		gap: 0;
	}

	p.wp-caption-text, /* backwards compat selector */
	.wp-block-image figcaption,
	.wp-block-table figcaption {
		text-align: center;
		padding: .8em 1em .2em;
		color: hsl(0, 0%, 43%);
	}

	.wp-caption, /* backwards compat selector */
	.wp-block-image figcaption,
	.wp-block-embed figcaption,
	.wp-block-table figcaption {
		color: #981328;
		text-align: left;
		margin: 0;
		padding: .6em .8em .6em 1em;
		font-style: italic;

		em {
			font-style: normal;
		}

		@media (min-width: 800px) {
			padding: 1em 1em 1em 1em;
		}
	}


	.wp-caption img, /* backwards compat selector */
	.wp-block-image figure:not(.is-resized) img {
		width: 100%;
		margin: 0;
		display: block;
	}

	.wp-caption a, /* backwards compat selector */
	.wp-block-image a {
		text-decoration: none;
	}

	img {
		max-width: 100%;
		height: auto;
		@media ( width > 550px) {
			display: block;
		}
		@media (width > 1024px ) {
			&.size-large {
				width: 100%;
			}
		}
	}

	/* But images in tables shouldn't have max-width */

	& table img {
		max-width: none;
	}


	.date-month {
		height: 16px;
		color: #fff;
	}

	.date-day {
		height: 20px;
		color: #fff;
	}

	@media (min-width: 1024px) {
		h5 {
			margin-top: 1.6em;
		}

		h6 {
			margin-top: 1.6em;
		}
	}

	@media (min-width: 1400px) {
		.address-email {
			margin-top: 1.5em;
		}
	}


	.cat_tag {
		line-height: 1.5em;
		padding: .5em 0;
		border-top: 1px dotted #ccc;
		margin-top: 2em;
	}

	.cat_tag a {
		display: inline-block;
		padding: .7em;
		background: hsl(0, 0%, 98%);
		margin: 2px;
		border-radius: 2px;
		text-decoration: none;
	}

	.cat_tag a:hover, .cat_tag a:active {
		background: hsl(0, 0%, 92%);
		text-decoration: none;
	}

	.cat_tag a:first-child, .cat_tag a:first-child:hover {
		margin-left: 0;
		padding: 0;
		background: transparent;
	}

	.cat_tag a:first-child:hover {
		text-decoration: underline;
	}

	.cat_tag strong a {
		background: transparent;
	}

	/* hide link for 'exclude from loops' category */

	.cat_tag [href*="exclude-from-loops"] {
		display: none;
	}

	@media (min-width: 800px) {
		.cat_tag a {
			padding: 3px;
		}
	}

	/* the wp core styles have .wp-block-image .alignright (where the alignright is on a <figure> nested
	   inside a <div>. However, there seems to be a few edge cases where .wp-block-image and .alignright
	   are both on the <figure>, which is the top level block element. Not sure why certain images get
	   inserted that way.
	 */

	.wp-block-image.alignright {
		float: right;
	}

	.wp-block-image.alignleft {
		float: left;
	}


	.alignleft {
		text-align: left;
	}

	.alignright {
		text-align: right;
	}

	.alignnone {
		clear: both;
	}

	img.alignnone {
		height: auto;
	}

	.aligncenter {
		text-align: center;
	}

	img.aligncenter {
		margin: 0 auto;
	}

	img.alignright {
		float: right;
		margin: 0 .7em .7em 0;
	}

	img.alignleft {
		float: left;
		margin: 0 .7em .7em 0;
	}

	:is(&) {
		img.size-medium {
			width: 100%;
			margin-left: 0;
			margin-right: 0;
		}

		@media (width > 550px) {
			img.size-medium,
			img.size-full {
				width: auto;
			}
		}

		@media (width > 800px) {
			.wp-caption img,
			.wp-block-image figure:not(.is-resized) img {
				width: 100%;
			}
		}
	}

	@media (min-width: 550px) {

		img.alignleft, div.alignleft {
			margin: 0 .7em .7em 0;
			float: left;
		}

		img.alignright, div.alignright {
			margin: 0 0 .7em .7em;
			float: right;
		}

		img.alignnone, div.alignnone {

		}

		img.aligncenter, div.aligncenter {
			margin: .7em auto;
			display: block;
		}
	}

	@media (min-width: 800px) {

		img.alignleft, div.alignleft,
		img.size-medium.alignleft {
			margin: 0 1em .5em 0;
			float: left;
		}

		img.alignright, div.alignright,
		img.size-medium.alignright {
			margin: 0 0 .5em 1em;
			float: right;
		}

		img.alignnone, div.alignnone {

		}

		img.aligncenter, div.aligncenter,
		img.size-medium.aligncenter {
			margin: 1em auto;
		}
	}

	/* the core css lib wants these to be width:auto, which causes some thumbs (why? no clue)
	 * to be like 900px.
	 */

	.wp-block-latest-posts__featured-image img.size-thumbnail {
		max-width: 150px;
	}

	.wp-group-with-background-image.has-text-color.has-light-color {
		/* contrasty background in case the image doesn't load */
		background-color: hsl(0 0% 20%);
	}

	/* wp core defaults this element to white text, but no default text color, so browser uses white,
	 * which then fails accessibility contrast checker. the :not(:has([class*="background-color"]))
	 * is making sure this rule only applies if the user hasn't specified an overlay/background color
	 */

	.wp-block-cover-image:not(.has-text-color), .wp-block-cover:not(.has-text-color) {
		&:has( .has-background-dim ):not( :has( [class*="background-color"] ) ) {
			background-color: black;
		}
	}
}


/**
 * These styles will apply to iframe editor, non-iframe editor,
 * and front-end ONLY within user-created content element (.wpcontent-area)
 */
.editor-styles-wrapper,
.wpcontent-area {
	color: #454545;

	a.fancybox {
		border: none;
	}

	& > h1:first-child {
		margin-top: .5em;
	}

	ul, ol {
		margin: .4em 0 .6em 1em;
	}

	li {
		margin: 0;
		line-height: 1.5em;
		padding: 4px 0 4px 0;
	}

	ol {
		list-style-position: outside;
		margin-left: 1em;

		li {
			padding-left: .4em;
		}

	}

	ul {
		::marker {
			color: hsl(199, 15%, 73%);
		}

		li {
			padding-left: .5em;
		}
	}

	.alternate-rows {
		margin-left: 0;
	}

	.alternate-rows li:before {
		content: '';
	}

	.alternate-rows li:nth-child(2n) {
		background: hsl(0, 0%, 97%);
		border-top: 1px solid #eee;
		border-bottom: 1px solid #eee;
	}

	ol.alternate-rows li {
		padding-left: .6em;
	}

	table {
		border: 1px solid var(--colorBlue_dark);
		border-collapse: collapse;
		font-weight: 400;
		font-size: 1em;

		tr:nth-child(2n+1) {
			background-color: hsl(0, 0%, 96%);
		}

		th, td {
			padding: 10px;
			border-color: var(--colorBlue_dark);
			border-style: solid;
			vertical-align: top;
		}

		th {
			background-color: var(--colorBlue_dark);
			color: #fff;
			font-weight: 400;
		}

		td {
			color: hsl(0, 0%, 30%);
			border-left: 1px solid hsl(198 94% 14% / .85);

			&:first-child {
				border-left-width: 0;
			}
		}

		&:not(.tablesaw) td:last-child {
			border-right-width: 1px;
		}

		&:not(.tablesaw) tr:last-child td {
			border-bottom-width: 1px;
		}

		/* tfoot is standard way, with-horizontal-totals-row is backwards compat */

		tfoot td,
		&.with-totals-row tr:last-child td {
			color: var(--colorBlue_dark);
			background-color: var(--colorGray_light);
			border-top-width: 1px;
			font-weight: 700;
		}

		&.with-horizontal-totals-row {
			td:last-child {
				color: white;
				background-color: var(--colorGray);
				border-bottom: 1px solid hsla(0, 0%, 0%, .2);
				font-weight: 700;
			}

			tr:last-child td:last-child {
				border-bottom: none;
			}
		}

	}

	table.alternate-colors {
		border-color: var(--colorGarnet_bright);

		th, td {
			border-color: var(--colorGarnet_bright);
		}

		th {
			background-color: var(--colorGarnet_bright);
		}

		td {
			border-left-color: hsl(351 80% 34% / .85);
		}

		&.with-totals-row tr:last-child td {
			color: var(--colorGarnet_bright);
			background-color: hsl(47, 92%, 94%);
		}
	}

	table.alternate-blank {
		border-color: transparent;
		background-color: transparent;

		th, tr, td {
			border-color: transparent;
			background-color: transparent;
		}

		&.with-totals-row tr:last-child td {
			color: inherit;
			background-color: transparent;
		}
	}

	/* Some customizations for the block editor's tables */

	figure.wp-block-table {
		overflow-x: initial;
	}

	.wp-block-table.is-style-stripes {
		td {
			border-color: hsl(198 94% 14% / .85);
		}

		td:last-child {
			border-right: 1px solid var(--colorBlue_dark);
		}

		tr:last-child td {
			border-bottom: 1px solid var(--colorBlue_dark);
		}

		tr:nth-child(2n+1) td {
			background-color: hsl(0, 0%, 96%);
		}
	}

	/* if the table was inserted by the block editor, and didn't use the striped
	   style, we need to not have stripes */

	.wp-block-table:not(.is-style-stripes) table {
		td {
			border: 1px solid hsl(198 94% 14% / .85);
		}

		tr:nth-child(2n+1) {
			background-color: transparent;
		}
	}


	.table-style1 {
		border-collapse: collapse;
		border: 1px solid #32797a;
		text-align: left;
	}

	.table-style1 th {
		padding: 10px;
		background: #32797a;
		color: white;
	}

	.table-style1 td {
		padding: 10px;
		color: #777777;
	}

	.table-style1 hr {
		border: 0;
		height: 1px;
		background-color: #eeeeee;
	}

	.table-style1 .totals {
		color: #32797a;
		font-weight: bold;
		background-color: #eaf1f1;
	}

	.table-style1 tbody tr:nth-child(odd) {
		background: #f5f5f5;
	}
}


/**
 * Blocks: Columns
 */
div.wp-block-columns.has-2-columns {

	@media (min-width: 550px) {
		.wp-block-column + .wp-block-column {
			margin-left: .7em;
		}
	}

	@media ( max-width: 550px ) {
		display: block;
	}
}

/**
 *  Blocks: Gallery
 */
ul.wp-block-gallery,
ul.blocks-gallery-grid {
	margin: 1em 0;

	li {
		padding: 0;
		line-height: 1.2;

		&:before {
			content: none;
		}

		&.blocks-gallery-image, &.blocks-gallery-item {
			figcaption {
				box-sizing: border-box;
				font-size: .65rem;
				opacity: 0;
				padding-bottom: 14px;
				transition: .2s opacity, .2s padding;
				margin-bottom: 0;
			}

			&:hover figcaption {
				opacity: 1;
				padding-bottom: 10px;
			}
		}
	}
}


/**
 * Core Latests Posts block
 */
ul.wp-block-latest-posts {

	margin: 2em 0;

	li {
		/* override default list bullet */

		&:before {
			content: none;
		}

		margin-bottom: 2em;
		padding-bottom: 1px;
	}

	.wp-block-latest-posts__post-title {
		font-size: 1.4em;
		font-weight: 800;
		text-decoration: none;
		margin-bottom: .2em;
		line-height: 1.3em;

		&:hover {
			text-decoration: underline;
		}
	}

	&:not( .is-grid ) .wp-block-latest-posts__featured-image {

		@media (min-width: 550px) {

			img {
				float: left;
				margin: 0 .9em .9em 0;
			}

			img.size-medium {
				max-width: 375px;
			}

			img.size-large {
				max-width: 100%;
				float: none;
			}
		}
	}

	&.is-grid .wp-block-latest-posts__featured-image {
		width: 100%;

		img /* :not(.size-thumbnail) */
		{
			width: 100%;
			object-fit: cover;
			aspect-ratio: 4/3;
		}
	}

	.sidebar & {
		li {
			list-style-type: none;

			/* This is the post title */

			a {
				font-size: 1.2em;
				font-weight: 600;
				font-family: var(--fontSerif), serif;
			}
		}

		/* for some added weight, needed to override */

		.wp-block-latest-posts__featured-image img {
			max-width: 100%;
			margin: 0;
			float: none;
		}

		.wp-block-latest-posts__post-excerpt {
			line-height: 1.4em;
			font-size: .9em;
		}
	}
}


/**
 * Core buttons block/s
 */
a.wp-block-button__link {
	border-radius: 4px;
	color: #fff;
	background: var(--colorGarnet);
	font-size: .9em;

	&:hover {
		box-shadow: 0 0 90px hsla(0, 0%, 0%, .4) inset;
		/* override normal link 2px underline */
		border-width: 1px;
		color: white;
	}

	&:active {
		box-shadow: 0 0 90px hsla(0, 0%, 0%, .7) inset;
		color: white;
	}
}


/**
 * Wide Alignments
 */
.alignwide, .alignfull {
	/* the padding is used to calculate the inner content to line up correctly along the left side */
	--parentPadding: var(--padding, 2em);
	--leftPageMargin: calc((100vw - var(--wrapper)) / 2);
	--sideMargin: calc(-1 * var(--leftPageMargin) / 2);
	position: relative;
	max-width: none !important;
	/* override alignright, etc classes */
	float: none;
	box-sizing: border-box;

	.is-layout-constrained {
		margin-inline: auto;
		max-width: var(--wrapper);
	}
}

.alignfull {
	width: 100vw;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
}

body.template-width-medium .alignfull {
	/* normally you'd just use left: 50% to make this fullwidth, but when our content column isn't
	 * centered, we have to account for the off-centered size
	 */
	left: calc(50% + (var(--wrapper) - var(--contentWidth)) / 2);
}

@media (MAX-width: 1024px) {
	.alignwide {
		width: 100vw;
		left: 50%;
		right: 50%;
		margin-left: -50vw;
		margin-right: 50vw;
	}
}

@media (min-width: 1024px) {
	.alignfull {
		/* for some reason, 100vw causes horiz scrollbar at wider screens */
		width: 99.5vw !important;
	}

	.alignwide {
		margin-inline: var(--sideMargin);
	}

	body.template-width-medium {
		.alignwide {
			/* This rule puts the right side of box halfway between edge of contentarea and the right
			 * window edge. Remove this rule to made box look centered on the contentarea (so the rightside of the box
			 * isn't equidistant from right side of contentarea and edge of screen.
			 */

			&.extrawide {
				margin-right: calc((var(--wrapper) - var(--contentWidth) - 100vw) / 4);
			}

			.is-layout-constrained {
				margin-left: calc(var(--leftPageMargin) / 2 - var(--parentPadding));
			}
		}
	}
}


.alignwide, .alignfull {
	/* for when images are fullwidth */

	figcaption {
		background: none;
		margin: 0 auto;
		box-shadow: none;
		max-width: var(--wrapper);
	}
}


.wp-block-cover {
	.wp-block-cover__inner-container {
		max-width: var(--wrapper);
	}
}


.wp-block-media-text {
	/* The Media & Text block defaults the text to "large" and normally has a
	 * control to change it's size. But we've disabled the font size control,
	 * (see block-registration.php in after_setup_theme hook). So font size
	 * picker here doesn't show up.
	 */

	p.has-large-font-size {
		font-weight: 200;
		line-height: 1.2em;
		margin: .5em 0;
	}
}


/**
 * Core search block with variants
 */
.wp-block-search {
	margin-block: 1em;

	button.wp-element-button {
		background: var(--colorGarnet);
		color: white;
		border: none;
		border-radius: 1px;
		font-size: .9em;
	}

	&.wp-block-search__text-button {
	}

	&.wp-block-search__icon-button {
	}

	&.wp-block-search__button-outside {
	}

	&.wp-block-search__button-inside {
		.wp-block-search__inside-wrapper {
			padding: 1em;
			background: var(--colorGray_light);
		}
	}
}


/**
 * Miscellaneous
 */
p.is-style-academic-introduction.is-style-academic-introduction {
	color: var(--colorGarnet);
	font-family: var(--fontSansSerif), sans-serif;
	line-height: 1.5;
	font-weight: 400;
	font-size: 1.5em;
	margin-block: 1em 1.7em;

	&::after {
		display: block;
		content: '';
		height: 8px;
		background: hsl(0 0% 92%);
		width: 150px;
		margin-top: 1.5em;
	}
}


