@import 'mediawiki.skin.variables.less';
@import '../mmv.variables.less';

@panel-below-fold-background-color: @background-color-interactive-subtle;

@vertical-padding: 10px;
@horizontal-padding: 20px;
@space-above-credit: 2px;

.mw-mmv-info-box {
	display: inline-block;
	overflow: hidden;
	border: 1px solid @border-color-muted;
	border-radius: @border-radius-base;
	background-color: @background-color-interactive-subtle;
}

.mw-mmv-title-contain {
	position: relative;
}

.mw-mmv-title-para {
	@height: @metadatabar-above-fold-inner-height - 2 * @vertical-padding; // needs explicit height for text truncation logic
	margin: 0 0 @vertical-padding; // use margin instead of padding for bottom so text is not visible
	padding: @vertical-padding @horizontal-padding 0 @horizontal-padding;
	height: @height;
	line-height: @height;

	&.mw-mmv-ttf-normal {
		font-size: 20px;
	}

	&.mw-mmv-title-small {
		font-size: 18px;
	}

	&.mw-mmv-title-smaller {
		@vertical-padding: 6px;
		@height: @metadatabar-above-fold-inner-height - 2 * @vertical-padding;
		height: @height;
		margin: 0 0 @horizontal-padding;
		padding: @vertical-padding @horizontal-padding 0 @horizontal-padding;
		line-height: floor( (@height / 2) );  // two lines
		font-size: 16px;
	}

	// this should be after the size-specific styles so it can override any height set there
	&.mw-mmv-ttf-untruncated {
		height: auto;
	}

	.mw-mmv-ttf-ellipsis {
		right: @horizontal-padding;
		bottom: 3px;

		&::before {
			background-image: linear-gradient( to right, @background-color-transparent 0%, @panel-above-fold-background-color 100% );
		}
	}
}

.mw-mmv-credit {
	@padding-right: 5px;
	margin: 0;
	color: @color-subtle;
	padding: 0 0 @padding-right;
	font-size: 0.85em;

	.metadata-panel-is-closed {
		height: @metadatabar-below-fold-pushup-height - @space-above-credit - @border-width-base; // needs explicit height for text truncation logic
		line-height: @metadatabar-below-fold-pushup-height - @space-above-credit - @border-width-base;
	}

	&.empty {
		height: 0.85em;
	}

	.mw-mmv-ttf-ellipsis {
		right: @padding-right;
		bottom: 13px;
		background-color: @panel-below-fold-background-color; // clip text

		&::before {
			background-image: linear-gradient( to right, @background-color-transparent 0%, @panel-below-fold-background-color 100% );
		}
	}
}

.mw-mmv-source-author {
	line-height: 1.8em;
}

.mw-mmv-title {
	// this element is the click target for text untruncation; with the default display:inline it would be an
	// inline box which can have "gaps" between the lines, making clicks seem to have no effect
	display: inline-block;
}

.mw-mmv-image-metadata {
	width: 100%;
	position: relative;
	margin-top: -@metadatabar-below-fold-pushup-height;
	border-top: 1px solid @border-color-muted;
	background-color: @panel-below-fold-background-color;
	padding-top: @space-above-credit;

	.jq-fullscreened & {
		// Make sure content fits into the screen. This assumes no paddings.
		height: @metadatabar-below-fold-pushup-height - @border-width-base - @space-above-credit;
		overflow: hidden;
	}

	.jq-fullscreened .mw-mmv-untruncated & {
		height: auto;
	}
}

.mw-mmv-author::before {
	.cdx-mixin-css-icon( @cdx-icon-user-avatar, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
	content: ' ';
	margin-right: @spacing-50;
}

.mw-mmv-image-desc-div {
	overflow-y: auto;
	max-height: 150px;
	margin-bottom: 15px;

	&.empty {
		display: none;
	}
}

.mw-mmv-image-desc-div,
.mw-mmv-image-links-div {
	display: inline-block;
	vertical-align: top;
}

@littlefont: 0.85em;
@mediumfont: 0.95em;

.mw-mmv-image-desc {
	font-size: @mediumfont;
	color: @color-subtle;
}

.mw-mmv-image-links {
	margin: 0 20px;
	word-break: break-word;
	line-height: 1.5;

	li {
		list-style: none;
		font-size: @littlefont;

		&.empty {
			display: none;
		}

		// Make sure the next list item is not visible when the
		// metadata panel is closed
		.metadata-panel-is-closed &.mw-mmv-license-li {
			height: @metadatabar-below-fold-pushup-height - @space-above-credit;
			line-height: @metadatabar-below-fold-pushup-height - @space-above-credit;
		}

		&::before {
			content: ' ';
			margin-right: @spacing-50;
		}

		&.mw-mmv-license-li::before {
			.cdx-mixin-css-icon( @cdx-icon-lock, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.mw-mmv-license-li.cc-license::before {
			.cdx-mixin-css-icon( @cdx-icon-logo-c-c, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.mw-mmv-license-li.pd-license::before {
			.cdx-mixin-css-icon( @cdx-icon-un-lock, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.mw-mmv-filename-li::before {
			.cdx-mixin-css-icon( @cdx-icon-image, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.mw-mmv-datetime-li::before {
			.cdx-mixin-css-icon( @cdx-icon-clock, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.mw-mmv-location-li::before {
			.cdx-mixin-css-icon( @cdx-icon-map-pin, @param-fill-color: @color-subtle, @param-size-icon: @size-icon-small );
		}

		&.empty::before {
			background-image: none !important; /* stylelint-disable-line declaration-no-important */
		}
	}
}

.mw-mmv-license-contain,
.mw-mmv-license {
	text-align: right;
}

.mw-mmv-filename-prefix {
	padding-right: 4px;
	cursor: text;
}

.mw-mmv-title-para,
.mw-mmv-credit,
.mw-mmv-image-desc {
	padding-left: @horizontal-padding;
}

.mw-mmv-label {
	background-color: @background-color-interactive;
	color: @color-base;
	margin-left: 6px;
	margin-top: 1px;
	border-radius: @border-radius-base;
	padding: 2px 5px;
	font-size: 0.9em;

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

.mw-mmv-image-metadata-column {
	float: left;
}

.mw-mmv-image-metadata-desc-column {
	width: 66.5%;
}

.mw-mmv-image-metadata-links-column {
	max-width: 33.5%;
	width: 25%;
	text-align: right;
	float: right;
	transition: width 0.2s ease-out;

	.mw-mmv-untruncated & {
		width: 33.5%;
		text-align: left;
	}
}

.mw-mmv-restrictions {
	display: inline-block;
	line-height: 14px;
}

.mw-mmv-restriction-label {
	cursor: default;
	display: inline-block;
	height: 16px;

	&,
	&:hover {
		background-color: @background-color-warning-subtle;
		border: 1px solid @border-color-warning;
	}
}

.mw-mmv-restriction-label-inner {
	display: inline-block;
	width: 14px;
	height: 14px;
	text-indent: -9999px;
	text-align: left;
	background-size: contain;

	&::after {
		float: right;
		text-indent: 0;
	}
}

.mw-mmv-permission-link {
	cursor: pointer;

	.jq-fullscreened & {
		display: none;
	}
}

.mw-mmv-optout-link.pending {
	cursor: wait;
	color: @color-subtle;
}
