/*!
Twenty Nineteen Editor Styles

NOTE: Styling alignment styles require use of [data-align] selectors.
This is not ideal, but it works. Styles using those selectors should be refactored
when Gutenberg supports styling those variations more intuitively.
*/

/** === Includes === */

@import "sass/variables-site/variables-site";
@import "sass/variables-site/colors";
@import "sass/mixins/mixins-master";

/** === Content Width === */

.wp-block {
	width: calc(100vw - (2 * #{$size__spacing-unit}));

	@include media(tablet) {
		width: calc(8 * (100vw / 12));
	}

	@include media(desktop) {
		width: calc(6 * (100vw / 12 ));
	}
}

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

body {
	font-size: $font__size_base;
	font-family: $font__body;
	color: $color__text-main;
}

p {
	font-size: $font__size_base;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: $font__heading;
}

h1 {
	font-size: $font__size-xl;
	@include post-section-dash;

	@include media(tablet) {
		font-size: $font__size-xxl;
	}
}

h2 {
	font-size: $font__size-lg;
	@include post-section-dash;

	@include media(tablet) {
		font-size: $font__size-xl;
	}
}

h3 {
	font-size: $font__size-lg;
}

h4 {
	font-size: $font__size-md;
}

h5 {
	font-size: $font__size-sm;
}

h6 {
	font-size: $font__size-xs;
}

a {
	@include link-transition;
	color: $color__link;

	*:visited {

	}

	&:hover,
	&:active {
		color: $color__link-hover;
		outline: 0;
		text-decoration: none;
	}

	&:focus {
		outline: 0;
		text-decoration: underline;
	}
}

figcaption,
.gallery-caption {
	font-family: $font__heading;
	font-size: $font__size-xs;
	line-height: 1.6;
	color: $color__text-light;
}

/** === Paragraph === */

.wp-block-paragraph {

	&.has-drop-cap:not(:focus)::first-letter {
		font-family: $font__heading;
		font-size: $font__size-xxxl;
		line-height: 1;
		font-weight: bold;
		margin: 0 0.25em 0 0;
	}
}

/** === Cover Image === */

.wp-block-cover-image {

	h2,
	.wp-block-cover-image-text {
		font-family: $font__heading;
		font-size: $font__size-xl;
		font-weight: bold;
		line-height: 1.4;
	}

	&.has-left-content {
		justify-content: center;

		h2,
		.wp-block-cover-image-text {
			padding: 1em;
		}
	}

	&.has-right-content {
		justify-content: center;

		h2,
		.wp-block-cover-image-text {
			padding: 1em;
		}
	}
}

body[data-type="core/cover-image"][data-align="left"],
body[data-type="core/cover-image"][data-align="right"] {

	h2,
	.wp-block-cover-image-text {
		width: 100%;
		max-width: 305px;
	}
}

body[data-type="core/cover-image"][data-align="wide"],
body[data-type="core/cover-image"][data-align="full"] {

	@include media(desktop) {
		h2,
		.wp-block-cover-image-text {
			padding: 0;
			width: calc(6 * (100vw / 12));
			max-width: calc(6 * (100vw / 12));
		}
	}
}

/** === Gallery === */

.wp-block-gallery {

	.blocks-gallery-image figcaption,
	.blocks-gallery-item figcaption,
	.gallery-item .gallery-caption {
		font-size: $font__size-xs;
		line-height: 1.6;
	}
}

/** === Button === */

.wp-block-button {

	.wp-block-button__link {
		line-height: 1.8;
		font-family: $font__heading;
		font-size: $font__size-sm;
		font-weight: bold;
	}

	.wp-block-button__link:not(.has-background),
	.wp-block-button__link:not(.has-background) {
		background: $color__background-button;
	}

	&:not(.is-style-squared) .wp-block-button__link {
		border-radius: 5px;
	}

	&.is-style-outline .wp-block-button__link,
	&.is-style-outline .wp-block-button__link:hover,
	&.is-style-outline .wp-block-button__link:focus,
	&.is-style-outline .wp-block-button__link:active {
		background: transparent;
		border-color: $color__background-button;

		&:not(.has-text-color) {
			color: $color__background-button;
		}
	}
}

/** === Blockquote === */

.wp-block-quote {

	&:not(.is-large):not(.is-style-large) {
		border-left: 2px solid $color__link;
	}

	&.is-large,
	&.is-style-large {
		margin-top: $font__size-xxl;
		margin-bottom: $font__size-xxl;
	}

	&.is-large p,
	&.is-style-large p {
		font-size: $font__size-lg;
		line-height: 1.3;
		margin-bottom: 0.5em;
		margin-top: 0.5em;
	}

	cite,
	footer,
	.wp-block-quote__citation {
		font-family: $font__heading;
		font-size: $font__size-xs;
		line-height: 1.6;
		color: $color__text-light;
	}
}

/** === Pullquote === */

.wp-block-pullquote {
	border: none;

	&.is-style-solid-color {

		blockquote {
			width: calc(100vw - (2 * #{ $size__spacing-unit}));
			max-width: 80%;

			@include media(tablet) {
				width: calc(8 * (100vw / 12));
			}

			@include media(desktop) {
				width: calc(6 * (100vw / 12));
			}
		}

		blockquote:not(.has-text-color) p,
		.wp-block-pullquote__citation {
			color: white;
		}

		&:not(.has-background-color) {
			background-color: $color__link;
		}
	}

	blockquote {
		hyphens: auto;
		word-break: break-word;
	}
}

body[data-type="core/pullquote"],
body[data-type="core/pullquote"][data-align="left"],
body[data-type="core/pullquote"][data-align="right"] {

	blockquote > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
	blockquote > .editor-rich-text p,
	p {
		font-size: $font__size-lg;
		font-style: italic;
		line-height: 1.3;
		margin-bottom: 0.5em;
		margin-top: 0.5em;
		color: $color__text-main;

		@include media(tablet) {
			font-size: $font__size-xl;
		}
	}

	.wp-block-pullquote__citation {
		font-family: $font__heading;
		font-size: $font__size-xs;
		line-height: 1.6;
		text-transform: none;
		color: $color__text-light;
	}

	em {
		font-style: normal;
	}
}

body[data-type="core/pullquote"][data-align="left"],
body[data-type="core/pullquote"][data-align="right"] {

	.editor-block-list__block-edit {
		max-width: 50%;

		.wp-block-pullquote:not(.is-style-solid-color) {
			padding: 0;
		}

		.wp-block-pullquote.is-style-solid-color {
			padding: 1em;

			p,
			.wp-block-pullquote__citation {
				color: white;
			}
		}
	}

	blockquote > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
	blockquote > .editor-rich-text p,
	p,
	.wp-block-pullquote__citation {
		text-align: left;
	}
}

/** === File === */

.wp-block-file {
	font-family: $font__heading;

	.wp-block-file__button {
		line-height: 1.8;
		font-size: $font__size-sm;
		font-weight: bold;
		background-color: $color__link;
		border-radius: 5px;
	}
}

/** === Verse === */

.wp-block-verse,
.wp-block-verse pre {
	padding: 0;
}

/** === Code === */

.wp-block-code {
	border-radius: 0;
}

/** === Table === */

.wp-block-table {

	td, th {
		border-color: $color__text-light;
	}
}

/** === Separator === */

.wp-block-separator {

	&:not(.is-style-dots) {
		border-bottom: 2px solid $color__text-light;
	}

	&:not(.is-style-wide):not(.is-style-dots) {
		width: $font__size-xl;
		margin-left: 0;
	}

	&.is-style-dots:before {
		color: $color__text-light;
		font-size: $font__size-lg;
		letter-spacing: $font__size-sm;
	}
}

/** === Latest Posts, Archives, Categories === */

ul.wp-block-archives,
.wp-block-categories,
.wp-block-latest-posts {
	padding: 0;
	list-style-type: none;

	ul {
		padding: 0;
		list-style-type: none;
	}

	li {
		font-family: $font__heading;
		font-size: $font__size-lg;
		font-weight: bold;
		line-height: $font__line-height-heading;

		a {
			text-decoration: none;

			&:after {
				color: $color__text-light;
				content: ",";
			}
		}

		&:last-child a:after {
			color: $color__text-light;
			content: ".";
		}
	}
}

/** === Latest Posts grid view === */
.wp-block-latest-posts.is-grid {
		li {
			border-top: 2px solid $color__border;
			padding-top: (1 * $size__spacing-unit);
			margin-bottom: (2 * $size__spacing-unit);
			a {
				&:after {
					content: '';
				}
			}
			&:last-child {
				margin-bottom: auto;
				a:after {
					content: '';
				}
			}
		}
	}

/** === Latest Comments === */

.wp-block-latest-comments {

	.wp-block-latest-comments__comment-meta {
		font-family: $font__heading;
		font-weight: bold;

		.wp-block-latest-comments__comment-date {
			font-weight: normal;
		}
	}

	.wp-block-latest-comments__comment,
	.wp-block-latest-comments__comment-date,
	.wp-block-latest-comments__comment-excerpt p {
		font-size: inherit;
	}

	.wp-block-latest-comments__comment-date {
		font-size: $font__size-xs;
	}
}

/** === Classic Editor === */

/* Properly center-align captions in the classic-editor block */
.wp-caption {
	dd {
		text-align: center;
		-webkit-margin-start: 0px;
		margin-inline-start: 0px;
	}
}

.wp-block-freeform {

	/* Add style for galleries in classic-editor block */
	.gallery {

		display: flex;

		.gallery-item {
			padding: ( $size__spacing-unit * .5 );
			text-align: center;
			vertical-align: top;
			width: 100%;

			.gallery-caption {
				margin: 0;
			}
		}

		// Loops to enumerate the classes for gallery columns.
		@for $i from 2 through 9 {
			&.gallery-columns-#{$i} .gallery-item {
				max-width: calc( ( 12 / #{$i} ) * (100% / 12) );
			}
		}
	}
}
