$body-bg: #f7f8f9;

$primary-color: #2e5bec;
$dark-color: #3e396b;
$border-color-light: #eee;

div {
	min-width: 0; // fixes overflowing <pre>
}

// Spectre: Variables and mixins
@import "node_modules/spectre.css/src/variables";
@import "node_modules/spectre.css/src/mixins";

// Spectre: Reset and dependencies
@import "node_modules/spectre.css/src/animations";
@import "node_modules/spectre.css/src/normalize";
@import "node_modules/spectre.css/src/base";

// Spectre: Elements
@import "node_modules/spectre.css/src/typography";
@import "node_modules/spectre.css/src/asian";
@import "node_modules/spectre.css/src/forms";
@import "node_modules/spectre.css/src/buttons";

// Spectre: Layout
@import "node_modules/spectre.css/src/layout";
@import "node_modules/spectre.css/src/navbar";
@import "node_modules/spectre.css/src/off-canvas";

// Spectre: Components
@import "node_modules/spectre.css/src/accordions";
@import "node_modules/spectre.css/src/cards";
@import "node_modules/spectre.css/src/navs";
@import "node_modules/spectre.css/src/chips";
@import "node_modules/spectre.css/src/menus";

@import "node_modules/spectre.css/src/autocomplete";
@import "node_modules/spectre.css/src/utilities/loading";
@import "node_modules/spectre.css/src/utilities/colors";
@import "node_modules/spectre.css/src/utilities/divider";
@import "node_modules/spectre.css/src/utilities/display";
@import "node_modules/spectre.css/src/utilities/position";

.friends-dropdown {
	position: relative;

	.menu {
		animation: slide-down .15s ease 1;
		display: none;
		left: 0;
		max-height: 50vh;
		overflow-y: auto;
		position: absolute;
		top: 100%;
	}

	&.friends-dropdown-right {
		display: none;
		.menu {
			left: auto;
			right: 0;
		}
	}

	&.active .menu,
	.menu:hover {
		display: block;
	}

	// Fix friends-dropdown-toggle border radius in button groups
	.btn-group {
		.friends-dropdown-toggle:nth-last-child(2) {
			border-bottom-right-radius: $border-radius;
			border-top-right-radius: $border-radius;
		}
	}
}

.off-canvas .off-canvas-content {
	margin-top: 32px;
	padding-top: 1rem;
	padding-left: 1rem;
	padding-right: 1rem;
}

@media (min-width: $off-canvas-breakpoint) {
	.off-canvas .off-canvas-content {
		padding-left: 2rem;
		padding-right: 2rem;

	}
}

.off-canvas .off-canvas-toggle {
	top: 3rem;
	left: 1rem;
	color: #fff;
}

.off-canvas .off-canvas-content header.navbar {
	margin-bottom: 32px;
}

.off-canvas .off-canvas-content header.navbar.no-bottom-margin {
	margin-bottom: 0;
}

.off-canvas .off-canvas-sidebar {
	background-color: $body-bg;
	margin-top: 32px;
	width: 12rem;
}

.off-canvas .off-canvas-content header.navbar #page-title {
	margin-top: .1em;
	margin-left: 3rem;
}

h2#page-title a.dashicons {
	font-size: .8em;
	margin-right: .5em;
	vertical-align: baseline;
}

@media (min-width: $off-canvas-breakpoint) {
	.off-canvas .off-canvas-content header.navbar #page-title {
		margin-left: 0;
	}
}

::backdrop {
	background-color: rgba(0, 0, 0, 0.75);
}

.friends-page {
	background-color: $body-bg;
	color: $body-font-color;
	overflow-wrap: break-word;

	code,
	pre {
		overflow: auto;
	}

	min-height: 100vh;

	a:visited {
		color: $link-color-dark;
	}

	a.off-canvas-toggle:visited {
		color: #fff;
	}

	a,
	a:visited,
	a:hover,
	a:focus,
	a:active {
		color: $link-color;
	}

	summary.accordion-header {
		color: $link-color;
		cursor: pointer;
		white-space: nowrap;
		text-overflow: ellipsis;
		.dashicons {
  			vertical-align: bottom;
		}
	}

	.btn-arrow:before {
		content: "→ ";
	}

	.accordion[open] .accordion-body {
		max-height: 100rem;
	}

	.nav-links div a,
	.nav-links div a:hover {
		@extend .btn, .btn-primary;
	}

	.menu {

		a,
		a:active,
		a:visited {
			color: #333;
			padding: .2rem;
		}

		.menu-item+.menu-item {
			margin-top: 0;
		}

		.divider[data-content] {
			margin: 0.8rem 0 0.4rem 0;
		}

		.menu-item.friends-dropdown {
			margin-top: 0.2rem;
			margin-bottom: 0.4rem;
		}

		.menu-item small.label-secondary {
			display: none;
		}

		.menu-item:hover small.label-secondary {
			display: inline-block;
		}


		.has-icon-left .ab-icon {
			line-height: 1.2;
			margin-right: .2em;

			.dashicons.dashicons-plus {
				color: #32c170;
				font-size: .5em;
				margin-left: -1.5em;
				margin-top: -2.1em;
			}
		}
	}

	button,
	input {
		min-height: auto;
	}

	.d-none {
		display: none;
	}

	dialog {
		border: 0;
		box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
	}


	header.navbar section.navbar-section.author {
		flex: 3;
		min-width: 20em;
	}

	summary.quick-status-panel-opener {
		margin-bottom: 2em;
		cursor: pointer;
	}

	article {
		margin-bottom: 2em;
		.card-title {
			padding-left: .8rem;
		}
		.card-body {

			img,
			video {
				max-width: 100% !important;
				height: auto;
			}
		}
		.overflow {
			height: .5em;
		}

		.boosted .follow-button, .boosted .follow-button span.name {
			display: none;
		}

		.boosted:hover .follow-button {
			display: inline;
		}

		&.format-status {
			div.teaser {
				display: none;
			}

			.card-title {
				padding-left: 0;
			}
		}

		&.format-image {
			a.collapse-post {
				display: none;
			}
			.card-footer {
				padding-top: 0;
				padding-bottom: 1rem;
			}

			.card-footer a .text {
				display: block;
				font-size: 10px;
				line-height: 8px;
			}
		}
	}

	.card {
		height: 100%;
		box-shadow: 0 0 2px rgba(48, 55, 66, .15);
		padding: 0;
		border: 0;
		border-radius: 10px;

		.card-body {

			ul,
			ol {
				margin-left: 1rem;
			}

			img,
			video {
				max-width: 100% !important;
				height: auto;
			}

			.wp-block-image,
			.wp-block-gallery {

				&.alignfull,
				&.alignwide {
					margin: 0;
				}

				figcaption {
					text-align: center;
					font-size: .8rem;
				}
			}

			p.note {
				border-left: 4px solid #eee;
				padding: 1rem;
				margin-left: 1rem;
				font-size: .8rem;
				color: #666;
				background-color: #f7f7f7;
			}
		}

		margin-bottom: 1em;

		@media (max-width: $off-canvas-breakpoint) {
			& {
				width: 100%;
				margin-left: 0;
				margin-right: 0;

				.card-body {
					padding: 1rem;
				}

				.card-title {
					padding-left: 1rem;
				}
				textarea {
					width: 100%;
				}

				.card-footer {
					padding-top: 0;
					padding-bottom: 1rem;
					div.friends-dropdown {
						display: inline-block;
					}
				}

				.card-footer a .text {
					display: block;
					font-size: 10px;
					line-height: 8px;
				}
			}
		}
	}

	.friends-brand {
		position: fixed;
		margin-left: 1em;
		margin-top: 1em;
		font-size: 1.5em;

		.friends-logo {

			a,
			a:visited,
			a:active {
				color: $link-color;
			}

			h2 {
				display: inline-block;
				font-size: 1.2rem;
				font-weight: 700;
				line-height: 1.5rem;
				margin-bottom: 0;
				text-transform: uppercase;

			}
		}

		.friends-sidebar-customize {
			color: #999;
			font-size: .4rem;
			line-height: .6rem;
			display: block;
		}
	}

	#friends-sidebar .friends-nav {
		bottom: 1.5rem;
		-webkit-overflow-scrolling: touch;
		overflow-y: auto;
		padding: .5rem;
		position: fixed;
		top: 5.5rem;
		width: 12rem;
		margin-left: 1em;

		.accordion-header {
			padding: 0;
		}

		.subscription-count, .friend-count{
			border: 1px solid $primary-color;
			color: $primary-color;
			padding: 4px 4px 4px 6px;
			font-size: 10px;
			border-radius: 20px;
			line-height: 20px;
			vertical-align: bottom;
		}
	}

	#quick-post-panel {
		display: none;
		margin-bottom: 2em;

		&.open {
			display: block;
		}

		p.description {
			font-color: $dark-color;
			font-size: .6rem;
		}

		.activitypub_preview {
			background-color: #f7f8f9;
			padding: .5em;
			margin-top: 1em;
			margin-bottom: 1em;
			max-height: 6em;
			overflow-y: auto;

			figcaption {
				float: right;

				a:any-link {
					color: #999;
				}
			}
		}
	}

	img.avatar {
		border-radius: 5px;
		max-width: 36px;
		max-height: 36px;
	}

	img.avatar.avatar-overlay {
		position: absolute;
		margin-left: -16px;
		margin-top: 24px;
		border-radius: 100%;
	}

	div.friends-widget {
		margin-bottom: 2em;
	}

	div.friends-main-widget h1 a {
		color: #222;
		text-decoration: none;
	}

	div.friends-widget h4 a {
		color: #222;
		text-decoration: none;
	}

	div.friends-widget a.open-requests {
		font-size: 90%;
		font-weight: normal;
	}

	div.friends-widget ul {
		margin: .5em 0 1em 0;
		padding: 0;
	}

	div.friends-widget h5 {
		margin-bottom: .5em;
		font-size: .7rem;
		text-transform: uppercase;
		font-weight: bold;
		letter-spacing: 2px;
		color: $primary-color;
	}

	section.posts {
		.card {
			header.entry-header {
				display: flex;
				font-size: 88%;
				line-height: 1.4;
				max-width: 100%;
				margin: 0;
				padding: .8rem;
				padding-bottom: 1.5em;

				div.avatar {
					margin-right: .5em;
				}

				@media (min-width: $off-canvas-breakpoint) {
					padding-top: .5rem;
					padding-right: 1rem;
					padding-left: 1rem;
				}

				@media (max-width: $off-canvas-breakpoint) {
					div.author {
						max-width: 19em;
					}
				}

				div.friends-dropdown {
					display: inline-block;
					margin-right: -.4rem;
				}
			}

			h4.entry-title {
				font-size: 130%;
				line-height: 1.4;
				margin: 0 0 1em 0;
				text-align: left;

				a {
					text-decoration: none;

					span.dashicons {
						margin-top: 4px;
						margin-left: 6px;
						color: #32c170;
					}
				}

				&:after {
					display: none;
				}
			}
		}

		span.reading-time::before {
			content: " | ";
		}

		article.status-trash {
			opacity: .5;
		}

		article.card.column.post_format-post-format-status.format-status header.entry-header div.post-meta {
			width: calc(100% - 12em);
		}

		&.all-collapsed article:not(.uncollapsed):not(:only-child),
		article.collapsed {
			div.card-body {
				display: none;
			}

			header.entry-header {
				padding-left: 1rem;

				div.avatar {
					display: none;
				}

				padding-bottom: 0;

				div.author {
					display: inline;
				}

				div.permalink {
					&::before {
						content: " | ";
					}

					display: inline;
				}
			}

			h4.card-title {
				padding-left: 1rem;
			}

			a.collapse-post {
				display: none;
			}

			&.format-status {
				padding-bottom: 0;
				margin-bottom: .5em;
				width: 100%;

				div.teaser {
					text-overflow: ellipsis;
					overflow: hidden;
					height: 1.5em;
					display: inline-block;
					margin-left: 60px;
					margin-right: 2em;
					margin-top: -1em;
					margin-bottom: 0.6em;
				}

				header {
					padding-left: 0;
					margin-bottom: 0;

					div.post-meta {
						width: calc(100% - 7em);
						max-height: 1.5em;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					div.avatar {
						display: block;
						margin-left: 1em;
					}
				}
			}

			&.format-image {
				div.card-body {
					display: block;
				}
				header, h4.card-title {
					display: none
				}
			}

			footer.entry-meta {
				display: none;
			}
		}

		footer.entry-meta {
			display: flex;
			justify-content: flex-end;

			a {
				color: $link-color;

				.dashicons {
					vertical-align: middle;
				}

			}

			.btn:hover {
				color: $link-color;
			}
		}

		footer.comments-content {
			border-top: 1px solid $border-color-light;
			&.closed {
				display: none;
			}

			.comment-list {
				padding-left: 0;
				list-style: none;
			}

			.comment-list>li {
				margin-top: var(--global--spacing-vertical);
				margin-bottom: var(--global--spacing-vertical);
			}

			.comment-list .children {
				list-style: none;
				margin-left: 0;
				padding-left: 5px;
				border-left: 3px solid #eee;
			}

			.comment-list .children>li {
				margin-top: var(--global--spacing-vertical);
				margin-bottom: var(--global--spacing-vertical);
			}

			@media only screen and (min-width: 482px) {

				.comment-list .depth-2,
				.comment-list .depth-3 {
					padding-left: calc(4 * var(--global--spacing-horizontal));
				}
			}

			.comment-reply-title {
				margin-top: 1em;
			}

			.comment-reply-title small {
				margin-left: 1em;
			}

			.comment-form-comment label {
				display: block;
			}
		}
	}

	section.followers {
		ul li {
			list-style: none;
			.already-following {
				color: #ccc;
			}
			img {
				vertical-align: middle;
			}
			.follower .ab-icon {
				.dashicons.dashicons-plus,.dashicons.dashicons-yes {
					color: #32c170;
					font-size: .5em;
					margin-left: -1.5em;
					margin-top: -2.1em;
				}
				.dashicons.dashicons-no {
					color: #dc1717;
					font-size: .5em;
					margin-left: -1.5em;
					margin-top: -2.1em;
				}
			}

			.form-icon.loading {
				margin-left: 1em;
			}
			details summary span {
				margin-left: .5em;
				border-bottom: 1px solid #ccc;
				span {
					margin-left: 0;
					border-bottom: 0;
				}
			}
		}
	}

	ul.friend-posts img.avatar {
		vertical-align: middle;
		margin-right: .3em;
	}

	a.explanation-friends-auth-link,
	a.friends-auth-link,
	a.friends-auth-link:link,
	a.friends-auth-link:active,
	a.friends-auth-link,
	a.friends-auth-link:link,
	a.friends-auth-link:active {
		color: #333;
	}

	a.friends-auth-link span.dashicons-admin-users {
		display: inline;
	}

	a.friends-auth-link span.dashicons,
	button.friends-auth-link span.dashicons {
		color: #32c170;
		margin-left: 6px;
	}

	a.explanation-friends-auth-link:hover,
	a.friends-auth-link :hover,
	a.friends-auth-link:hover,
	a.friends-auth-link:hover span.dashicons,
	button.friends-auth-link:hover span.dashicons {
		color: #32c170;
	}

	a.explanation-friends-auth-link:hover,
	a.friends-auth-link :hover,
	a.friends-auth-link:hover {
		text-decoration: underline;
	}

	a.explanation-friends-auth-link:hover span,
	a.friends-auth-link :hover span,
	a.friends-auth-link:hover span {
		text-decoration: none;
	}

	.form-autocomplete .form-autocomplete-input .form-input {
		width: auto;
	}

	.friends-reaction-picker button {
		padding: .5rem;
		margin: 0;
		font-size: 18px;
		background-color: #fff;
		border: 0;
		cursor: pointer;
		z-index: 999999;
	}

	.friends-reaction-picker button:focus {
		outline: none;
	}

	a.display-message.unread {
		font-weight: bold;
	}

	.friend-message .conversation .messages {
		max-height: 40em;
		overflow: auto;

		.wp-block-friends-message {
			max-width: 80%;
			margin: 1em;
			border-bottom: 1px solid $border-color-light;
		}
	}

	.chip {
		background-color: #fff;
	}

	/* to support mastodon style tags */
	.invisible {
		font-size: 0;
		line-height: 0;
		display: inline-block;
		width: 0;
		height: 0;
		position: absolute;

		img,
		svg {
			margin: 0 !important;
			border: 0 !important;
			padding: 0 !important;
			width: 0 !important;
			height: 0 !important
		}
	}

	.ellipsis::after {
		content: "…"
	}
}
