@import 'mediawiki.skin.variables.less';
@import 'mediawiki.mixins.less';
@import '../echo.variables.less';
@import '../echo.mixins.less';

.mw-echo-ui-notificationItemWidget {
	display: block;
	background-color: @notification-item-background-read;
	position: relative;
	white-space: normal;
	box-sizing: border-box;

	&:not( :last-child ) {
		border-bottom: @border-width-base @border-style-base @border-color-subtle;
	}

	&:not( [ href ] ) {
		// Items without a primary URL are not clickable
		cursor: default;
	}

	label {
		// Reset browser default of cursor:default;
		cursor: inherit;
	}

	&:focus {
		text-decoration: none;
		box-shadow: @box-shadow-inset-medium @box-shadow-color-progressive--focus;
		outline: @outline-base--focus;
	}

	&:hover {
		text-decoration: none;
		// FIXME: Non-standard design token. Replace with a standard token and revise skin-theme rules.
		background-color: #ececec;

		.skin-theme-clientpref-night & {
			@media screen {
				background-color: @background-color-interactive-subtle;
			}
		}

		.skin-theme-clientpref-os & {
			@media screen and ( prefers-color-scheme: dark ) {
				background-color: @background-color-interactive-subtle;
			}
		}
	}

	&-unread {
		background-color: @background-color-base;

		&:hover {
			background-color: @background-color-interactive-subtle;
		}
	}

	> a,
	&:hover > a {
		text-decoration: none;
	}

	// Dynamic-action messages in mw.notify
	&-notify {
		&-title {
			font-weight: bold;
		}
	}

	&-content-message {
		// break-word rules are inconsistent accross browsers
		// these three rules should cover the main use cases
		// with major browser support
		word-break: break-word;
		word-wrap: break-word;
		overflow-wrap: break-word;

		&-header {
			color: @color-emphasized;
		}

		&-body {
			color: @notification-body-color;
			margin-top: 4px;

			// In the popup only, truncate the text to one-line
			// with ellipses
			.mw-echo-ui-notificationBadgeController-popup & {
				.text-overflow( @visible: false );
			}
		}
	}

	&-content-actions-timestamp {
		color: @color-emphasized;
		opacity: @opacity-low;
	}

	&-contentMain {
		display: block;
		box-sizing: border-box;
		padding: 0.8em 1em 0.5em 1em;

		.mw-echo-ui-notificationItemWidget-icon {
			position: absolute;
			top: 0.8em;
			left: 1em;

			img {
				height: 30px;
				width: 30px;
			}
		}

		.mw-echo-ui-notificationItemWidget-content-message {
			line-height: 1.3em;
			// The icon is 30px
			margin-left: 30px;
			padding-left: 0.8em;
			// Compensate for the placement of the 'mark as read'
			// button, so the message is not stretched past it.
			// The 'mark as read' circle is placed with a right
			// margin of -1em
			padding-right: 1em;
		}

		.mw-echo-ui-notificationItemWidget-content-actions {
			display: flex;
			align-items: flex-end;
			font-size: 0.9em;
			margin-top: 0.8em;
			// The icon is 30px
			margin-left: 30px;
			padding-left: 0.8em;

			&-buttons.oo-ui-buttonSelectWidget {
				display: flex;
				overflow: hidden;

				> .oo-ui-buttonOptionWidget {
					// Allow long translations (e.g. de "Seite ansehen") to wrap
					// instead of being clipped with an ellipsis (T436558).
					min-width: 0;
					max-width: 100%;
					overflow: visible;

					.oo-ui-labelElement-label {
						white-space: normal;
						overflow: visible;
						display: inline;
					}
				}
			}

			&-button {
				margin-right: 1.2em;
			}

			.mw-echo-ui-menuItemWidget-prioritized {
				// Option widget already has some right padding
				margin-right: 0.6em;
			}

			&-menu {
				vertical-align: bottom;
				padding: 0;

				> .oo-ui-buttonElement-button {
					.mw-echo-ui-mixin-hover-opacity();
				}
			}

			&-timestamp {
				flex-grow: 1;
				text-align: right;
				vertical-align: bottom;
				white-space: nowrap;
			}
		}
	}

	&-contentMain &-markAsReadButton {
		position: absolute;
		top: 0;
		right: 0;
		margin: 0;
	}

	&-contentGrouped {
		width: 100%;
		padding: 0.5em;
		display: flex;
		align-items: start;
		box-sizing: border-box;

		// Positioning fixes for bundled items
		.mw-echo-ui-notificationItemWidget-icon {
			padding-right: 0.5em;

			img {
				height: 20px;
				width: 20px;
			}
		}

		.mw-echo-ui-notificationItemWidget-content-message {
			padding-right: 0.5em;
			width: 100%;

			&-header {
				width: 100%;

				// Bundled notifications don't have bodies, only headers,
				// so they use <em> to designate excerpts. Use the body color
				// for these.
				em {
					color: @notification-body-color;
					font-style: normal;
				}
			}
		}

		.mw-echo-ui-notificationItemWidget-content-actions {
			display: flex;
			align-items: center;

			&-timestamp {
				padding-right: 0.5em;
				white-space: nowrap;
			}
		}
	}

	&-initiallyUnseen {
		animation-name: unseen-fadeout-to-read;
		animation-duration: 0.5s;
		animation-delay: 2s;
		animation-timing-function: ease-out;
		animation-fill-mode: both;

		&.mw-echo-ui-notificationItemWidget-unread {
			animation-name: unseen-fadeout-to-unread;
		}
	}

	// NOTE: The internal styling of the notifications is outside this file, because
	// it also affects the notifications in Special:Notifications
	// These styles are in modules/nojs/ext.echo.notifications.less
}

@keyframes unseen-fadeout-to-unread {
	from {
		background-color: @notification-background-unseen;
	}

	to {
		background-color: @notification-background-unread;
	}
}

@keyframes unseen-fadeout-to-read {
	from {
		background-color: @notification-background-unseen;
	}

	to {
		background-color: @notification-background-read;
	}
}
