@import '../vendor/index';
@import 'zindex';
@import 'modules/nightMode';
@import 'modules/version';
@import 'modules/commentStyle';
@import 'modules/showParent';
@import 'modules/quickMessage';
@import 'modules/accountSwitcher';
@import 'modules/betteReddit';
@import 'modules/commandLine';
@import 'modules/commentNavigator';
@import 'modules/commentPreview';
@import 'modules/commentTools';
@import 'modules/dashboard';
@import 'modules/easterEgg';
@import 'modules/newCommentCount';
@import 'modules/noParticipation';
@import 'modules/notifications';
@import 'modules/filteReddit';
@import 'modules/hover';
@import 'modules/keyboardNav';
@import 'modules/modhelper';
@import 'modules/neverEndingReddit';
@import 'modules/orangered';
@import 'modules/pageNavigator';
@import 'modules/saveComments';
@import 'modules/searchHelper';
@import 'modules/selectedEntry';
@import 'modules/showImages';
@import 'modules/sourceSnudown';
@import 'modules/spoilerTags';
@import 'modules/styleTweaks';
@import 'modules/submitIssue';
@import 'modules/subredditInfo';
@import 'modules/subredditManager';
@import 'modules/tableTools';
@import 'modules/temporaryDropdownLinks';
@import 'modules/troubleshooter';
@import 'modules/userbarHider';
@import 'modules/userInfo';
@import 'modules/redditUserInfo';
@import 'modules/userTagger';
@import 'modules/voteEnhancements';
@import 'modules/commentQuickCollapse';
@import 'modules/wheelBrowse';

@font-face {
	font-family: Batch;
	src: url('../fonts/batch-icons-webfont.woff') format('woff');
	font-weight: normal;
	font-style: normal;
}

body.res-console-open {
	overflow: hidden;
}

#console-container {
	z-index: $zindex-console-container - 1;
	position: fixed;
	inset: 0 0 0 0;
	width: 100%;
	height: 100%;
	border: none;
}

.res-logo {
	display: inline-block;
	margin-right: 5px;
	vertical-align: middle;
	width: 60px;
	height: 30px;
	background-image: url('../images/icon60x30.png');
}

.gearIcon {
	text-decoration: none !important;
	position: relative;

	&.res-gearIcon-legacy {
		display: inline-block;
		width: 15px;
		height: 15px;
		background-repeat: no-repeat;

		&::after {
			content: none;
		}
	}

	&::before,
	&::after {
		font: normal 14px/1 Batch;
		vertical-align: middle;
	}

	&::after {
		content: '\F04D';
		color: #a0e0fd;
		text-shadow: 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5, 0 0 1px #3d6da5;
	}
}

#RESAnnouncementAlert {
	display: inline-block;
	vertical-align: bottom;
	margin-left: .5em;
	color: goldenrod;
	animation: fadeIn .5s ease-out 7 alternate;

	.important {
		animation: pop 1s ease-out infinite alternate;
	}
}

@keyframes pop {
	from { transform: scale(0, 0); }
	to { transform: scale(1.5, 1.5); }
}

.editButton {
	cursor: pointer;
	width: 24px;
	height: 22px;
}

#RESKnownBugs,
#RESKnownFeatureRequests {
	list-style-type: disc;
}

.RESCloseButton::after {
	content: '✕';
	display: block;
	font: 12px/22px Verdana, sans-serif;
	background-color: #fff;
	border: 1px solid #d7d9dc;
	border-radius: 3px;
	color: #9a958e;
	text-align: center;
	width: 24px;
	height: 24px;
	z-index: 1000;
	cursor: pointer;
	box-sizing: border-box;

	&:hover {
		border-color: #999;
		background-color: #ddd;
	}
}

.RESCloseButtonTopRight {
	position: absolute;
	top: 8px;
	right: 8px;
}

.RESDialogSmall {
	background-color: #fff;
	border: 1px solid #c7c7c7;
	border-radius: 3px;
	font-size: 12px;
	color: #666;
	position: relative;

	> h3 {
		color: #000;
		font-size: 14px;
		line-height: 14px;
		margin: 0 0 10px;
		font-weight: normal;
		background-color: #f0f3fc;
		border-bottom: 1px solid #c7c7c7;
		width: auto;
		position: relative;
		height: 28px;
		padding: 12px 35px 0 10px; // Don't overlap close button on the right side
	}

	.RESDialogContents {
		clear: both;
		padding: 0 12px 12px 12px;
	}
}

div.usertext-edit {
	width: auto;
	max-width: 500px;
	padding: 0;
}

.usertext-edit .md,
.wiki-page #editform textarea {
	clear: left;
}

// Improve size calculation for textareas.
.usertext-edit textarea,
#wiki_page_content,
.wiki-page .wiki-page-content #wiki_revision_reason {
	box-sizing: border-box;
}

.usertext-edit .RESDialogSmall:not(.livePreview) .md.RESDialogContents {
	border: none;
	background-color: #fff;
}

.clear {
	clear: both;
}

.res-icon-button {
	cursor: pointer;
	margin: 0 2px;
	opacity: 0.4;

	&:hover {
		opacity: 1;
	}
}

.toggleButton {
	position: relative;
	display: inline-flex;
	cursor: pointer;
	white-space: nowrap;

	.toggleThumb {
		cursor: pointer;
		inset: 0 0 0 0;
		width: 40px;
		height: 15px;
		background-color: #ccc;
		border: 2px solid #ccc;
		border-radius: 2px;
		transition: .1s;
		transition-timing-function: ease-in;
	}

	&.enabled {
		&.reverseToggleButton .toggleThumb {
			background-color: #c66;
			border-color: #c66;
		}

		.toggleThumb {
			background-color: #369;
			border-color: #369;
		}
	}

	.toggleThumb::before {
		position: absolute;
		content: '';
		height: 15px;
		width: 15px;
		left: 2px;
		border-radius: 2px;
		background-color: white;
		transition: .4s;
	}

	&.enabled .toggleThumb::before {
		transform: translateX(25px);
	}

	.toggleLabel {
		display: flex;
		flex-direction: column;
		justify-content: center;
		min-width: 3ex;

		// Custom toggle labels
		&[data-disabled-text]::before {
			content: '\00a0' attr(data-disabled-text);
			display: block;
			line-height: 0;
			opacity: 1;
		}

		&[data-enabled-text]::after {
			content: '\A\00a0' attr(data-enabled-text);
			display: block;
			line-height: 0;
			opacity: 0;
		}
	}

	// Also custom toggle labels
	&.enabled .toggleLabel {
		&[data-disabled-text]::before {
			opacity: 0;
		}

		&[data-enabled-text]::after {
			opacity: 1;
		}
	}

	input[type='checkbox'] {
		display: none;
	}

	span {
		font-size: 11px;
		width: 28px;
		line-height: 20px;
		display: inline-block;
		text-align: center;
	}
}

.addRowButton {
	cursor: pointer;
	padding: 2px 5px;
	border: 1px solid #636363;
	border-radius: 3px;
}

.addRowButton:hover {
	background-color: #289dee;
	color: #fff;
}

// Universal subreddit toggle button (subscribe, filter, shortcut, etc)
// Borrowed from fancy-toggle-button
%res-fancy-toggle-button {
	font-weight: bold;
	font-size: 10px;
	color: white;
	display: inline-block;
	margin: 0 5px 5px 0;
	padding: 1px 6px;
	border: 1px solid rgb(68 68 68);
	background-image: linear-gradient(to bottom, rgb(123 184 80), rgb(117 168 73));
	border-radius: 3px;
	cursor: pointer;
}

.res-fancy-toggle-button {
	@extend %res-fancy-toggle-button;

	&.remove {
		background-image: linear-gradient(to bottom, rgb(207 97 101), rgb(190 94 96));
	}
}

.subscription-box .subButtons {
	font-size: larger;
}

span.multi-count {
	@extend %res-fancy-toggle-button;

	background: #ff7500;
	color: white;
}

.RESMenuItemButton {
	display: block;
	position: absolute;
	right: 7px;
	top: 7px;
	padding: 2px;
	width: 16px;
	height: 16px;
	line-height: 15px;
	border-radius: 3px;
}

.RESMenuItemButton:hover {
	background-color: #c8dbec;
}

.blueButton {
	cursor: pointer;
	padding: 3px 5px;
	font-size: 12px;
	line-height: 15px;
	color: #fff !important;
	border: 1px solid #636363;
	border-radius: 3px;
	background-color: #107ac4;
}

.redButton {
	cursor: pointer;
	margin-top: 12px;
	padding: 3px 5px;
	font-size: 12px;
	line-height: 15px;
	color: #fff !important;
	border: 1px solid #bc3d1b;
	border-radius: 3px;
	background-color: #ff5757;
}

.RESButton {
	margin: 5px;
	padding: 3px;
	border: 1px solid #999;
	width: 120px;
	cursor: pointer;
	border-radius: 5px;

	&:hover {
		background-color: #DDD;
	}
}

.noCtrlF::before {
	content: attr(data-text);
}

.transitionToTransparent {
	transition: opacity 3s cubic-bezier(.82, 0, 1, .55); // Change fast towards the end
	opacity: 0;
}

.RESLoadingSpinner {
	color: hsl(210deg 80% 50%);
	font-size: inherit; // Determines size of the icon.
	display: inline-block;
	vertical-align: text-bottom;
	width: 1em;
	height: .5em;
	border-bottom: .5em solid;
	border-radius: 50%;
	animation: spin 1000ms 0ms infinite linear;
}

@keyframes spin {
	100% { transform: rotate(360deg); }
}

#alert_message {
	position: fixed;
	top: 0;
	right: 0;
	left: 0;
	box-sizing: border-box;
	width: 500px;
	max-height: 100%;
	margin: auto;
	padding: 10px;
	color: black;
	text-align: left;
	font-size: 12px;
	border: 1px solid;
	background-color: #efefef;
	overflow: auto;
	z-index: $zindex-alert-message;

	@media (width <= 520px) {
		width: auto;
		left: 10px;
		right: 10px;
	}

	@media (height <= 520px) {
		height: auto;
		bottom: 10px;
	}

	input {
		border: 1px solid;
		padding: 6px 9px;
		background-color: #dfdfdf;
		cursor: pointer;
		margin-right: 10px;
	}

	> div:not(:last-of-type) {
		margin-bottom: 20px;
	}
}

#alert_message_background {
	position: fixed;
	inset: 0 0 0 0;
	background-color: rgb(0 0 0 / 70%);
	z-index: $zindex-alert-message - 1;
}

.res-icon {
	font: normal 16px/1 Batch;
	display: inline-block;

	&.res-icon-12 { font-size: 12px; }
	&.res-icon-32 { font-size: 32px; }
	&.res-icon-64 { font-size: 64px; }
	&.res-icon-128 { font-size: 128px; }

	&[data-icon]::before {
		content: attr(data-icon);
	}
}

#show_stylesheets:target + label {
	background-color: lightblue;
}

.handle {
	cursor: grab !important;
}

.builderItem {
	border: thin solid lightgrey;
	border-radius: 5px;
	background-color: rgb(10 10 10 / 5%);
	padding: .4em .5em;
	margin-top: .5em;
	margin-bottom: .5em;
	line-height: 18px;

	.builderItemControls {
		display: flex;
		margin-bottom: 5px;
		border-bottom: 1px solid #80808033;

		.builderCustomOptions {
			width: 200px;
			margin: 0;

			input[type='text'] { width: 140px; }
		}

		.builderControls {
			padding: .3em .2em;
		}

		.res-icon-button {
			font-size: 20px;

			&.handle { font-size: 27px; }
		}
	}

	input[type='checkbox'] {
		vertical-align: text-bottom !important;
	}
}

.builderWrap {
	display: flex;
	align-items: center;
	position: relative;
}

.builderNote {
	margin-left: 10px;
}

.builderBlock {
	flex-wrap: wrap;
	white-space: pre-wrap;

	input,
	select {
		font-size: 1em;
	}

	&-error {
		outline: 2px dotted darkred;

		&::before {
			content: 'Error: ' attr(error);
			display: block;
			color: red;
		}
	}
}

.builderControls {
	padding: .2em .1em;
	align-self: flex-start;

	&.res-icon-button {
		font-size: 14px;
	}
}

.builderTrailingControls {
	margin-left: auto !important;

	.builderBlock[data-type='group'] + & {
		position: absolute; // Avoids the delete button taking vertical space, shriking the recursive block
		right: 0;
	}
}

.builderMulti {
	margin: 3px 0;

	li {
		padding: 3px 0;
		list-style-type: none !important;

		.dragged {
			border: medium dashed grey;
			border-radius: 3px;
			background-color: #f0f3fc;
		}

		&:nth-of-type(2n) {
			background-color: rgb(10 10 10 / 5%);
		}
	}

	&:empty::before {
		border: medium dashed grey;
		border-radius: 3px;
		color: grey;
		content: 'nothing here yet. add something!';
		padding: 5px 10px;
		text-align: center;
		display: block;
	}
}

.addBuilderBlock {
	margin: .4em 0 .4em .4em;
}

.durationField {
	input[type='number'] {
		width: 3em;
	}
}

.checkset {
	display: inline-block;

	input[type='checkbox'] {
		display: none;
	}

	label {
		border: thin grey solid;
		background-color: white;
		padding: 2px 4px;
		cursor: pointer;

		&:first-of-type {
			border-top-left-radius: 6px;
			border-bottom-left-radius: 6px;
		}

		&:last-of-type {
			border-top-right-radius: 6px;
			border-bottom-right-radius: 6px;
		}
	}

	*:checked + label {
		background-color: darkgrey;
		text-decoration: underline;
	}
}

/*!
(cs)spinner.css - http://jh3y.github.io/-cs-spinner
Licensed under the MIT license

Jhey Tompkins (c) 2014.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// (cs)spinner base styling
.csspinner {
	position: relative;

	&::before {
		content: '';
		z-index: 1;
		position: absolute;
		inset: 0 0 0 0;
		background-color: #999;
		opacity: 0.6;
	}

	&::after {
		z-index: 2;
		content: '';
		height: 40px;
		width: 40px;
		position: absolute;
		top: 50%;
		left: 50%;
		margin: -24px 0 0 -24px;
		transition: all .75s ease 0s;
		border-radius: 100%;
		border-top: 4px solid #555;
		animation: fadeIn 2s 1 cubic-bezier(.3, .25, .7, .15), standard .75s infinite linear;
		transform-origin: center;
	}

	// (cs)spinner ringed spinner.
	// a spinner with a static ring and no overlay.
	&.ringed::after {
		border: 4px solid #8bbdd6;
		border-top-color: #0052d6;
		opacity: 1;
	}
}

// (cs)spinner standard rotation animation used for duo, double-up etc.
@keyframes standard {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
}

.res-step {
	cursor: pointer;
	user-select: none;

	&-container {
		display: flex;
		align-items: center;
		margin: 4px 0 4px 10px;

		&[first-piece='true'] .res-step-previous::after,
		&[last-piece='true'] .res-step-next::after {
			content: '\F157';
		}

		&[first-piece='true'] .res-step-previous,
		&[last-piece='true'] .res-step-next {
			transform: scaleX(-1);
		}

		&[first-piece='true'][last-piece='true'] {
			display: none;
		}
	}

	&::after {
		font: normal 18px/16px Batch;
		content: '\F158';
		display: inline-block;
		vertical-align: middle;
		color: #90acff;
		width: 16px;
	}

	&-next::after {
		transform: scaleX(-1);
	}

	&:hover::after {
		color: #6286f4;
	}

	&-progress {
		font-size: 13px;
		min-width: 60px;
		text-align: center;
	}
}

.tabmenu li.res-tabmenu-button {
	user-select: none;
	display: inline-block;

	a {
		cursor: pointer;

		&[aftercontent]::after {
			content: attr(aftercontent);
		}
	}

	&.selected a:not(:only-child) {
		&:first-child {
			border-right: none;
		}

		&:last-child {
			border-left: none;
		}
	}
}

#beta-help .help-section::after {
	margin: .5em;
	display: block;
	content: 'Since you are using RES with reddit beta, you should also check out /r/RESissues if you experience bugs.';
}

.pinnable-content.pinned .dismiss-pinnable {
	top: 30px !important;
}

html[res-warning]::before {
	position: fixed;
	content: attr(res-warning);
	right: 20px;
	bottom: 20px;
	z-index: 99999999;
	color: red;
	font-size: 1em;
	background-color: wheat;
	padding: 3px;
	border-radius: 3px;
	opacity: 0.5;
}

.res-hide-following ~ * {
	display: none !important;
}

.res-floater {
	&-list {
		all: initial;
		display: inline-flex;
		align-items: center;
		float: right;
		font-size: 10px;

		> li {
			display: flex;
			opacity: 0.7;
			&:hover { opacity: 1; }

			> * {
				padding: 2px;
			}
		}
	}

	&-visibleAfterScroll {
		position: fixed;
		will-change: transform;
		z-index: 10000000;
		right: 8px;
	}

	&-belowNavbar {
		position: fixed;
		z-index: 5;
		right: 8px;
		top: 60px;
		padding: 0.2em 0.1em;
		background: white;
		border: 1px #ccc solid;
	}

	&-inNavbar {
		position: fixed;
		right: 6px;
		top: 14px;
		z-index: 100;
	}
}

body.res-dashboard {
	.id-t3_qi5iy, // this first line hides the "you need RES 4.0+ to view the dashboard" link
	.id-t3_8qcn09,
	.tabmenu li:not(.res-tabmenu-button),
	.pagename,
	.side {
		display: none;
	}

	.res-dashboard-tab {
		font-variant: small-caps;
		font-size: 1.2em;
		vertical-align: bottom;

		// We want the tabs to act as a radio, i.e. don't allow deselect the currently selected
		&.selected a:first-child { pointer-events: none; }

		&:not(.selected) a + .gearIcon {
			display: none;
		}
	}

	.tabmenu {
		display: inline-flex !important;
		align-items: flex-end;
	}

	.dashboardPane {
		table {
			margin: 0;
			width: 100%;
		}

		th {
			min-width: 0;
			padding: 5px 8px;
			border: 1px solid rgb(200 200 200);

			&:first-child {
				width: auto;
				white-space: normal;
			}
		}

		tr:nth-child(2n) {
			background-color: #7979791a;
		}

		.deleteIcon {
			color: transparent;
			cursor: pointer;
		}

		tr:hover .deleteIcon { color: #369; }
	}
}

.res-button-undo {
	position: absolute;
	bottom: 20px;
	right: 20px;
	border-radius: 5px;
	background-color: #3a3a3af2;
	box-shadow: 0 0 6px 2px #3a3a3a;
	border: none;
	padding: 7px;
	color: white;
	font-size: 14px;
	cursor: pointer;
}

.pushRight {
	margin-left: auto;
}
