/**
 * The library at /thu-vien/: the index, a topic page, and one article.
 *
 * Loaded only on those three views (inc/library/listing.php decides), so nothing
 * here has to defend itself against the news archive or the forum.
 *
 * Sizes are set explicitly throughout. The child theme's style.css gives h1 a
 * 72px display size, which is right for a landing page and wrong for a manual
 * heading, so every heading in here states its own.
 */

.vf-library {
	--vf-lib-link: #566e8b;
	--vf-lib-card-shadow: 0 10px 40px rgba(40, 47, 98, 0.08);
	--vf-lib-gap: 30px;
}

/* ------------------------------------------------------------ search strip */

/**
 * The strip is a full-width band with a background image set in
 * Appearance → Theme Options → Thư viện. The image is applied inline by
 * vf_lib_search_form() so nothing here has to know its URL; the colour below is
 * what shows when no image is set, and what sits behind one that is still
 * loading.
 */
.vf-lib-search {
	background-color: #1b2430;
	background-repeat: no-repeat;
	background-position: center center;
	background-size: cover;
	padding: 120px 20px;
}

.vf-lib-search__inner {
	width: 100%;
	max-width: 800px;
	margin: 0 auto;
}

.vf-lib-search__heading-wrap {
	text-align: center;
}

.vf-lib-search__heading {
	margin: 0 0 40px;
	font-size: 38px;
	font-weight: 300;
	line-height: 1.2;
	letter-spacing: -0.04em;
	color: #fff;

	/* The band's image is chosen by an admin and can be light in places. A soft
	   shadow keeps white text legible without darkening the whole picture. */
	text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.vf-lib-search__form {
	display: flex;
	align-items: center;
	width: 100%;
	margin: 0;
	padding: 18px 15px 17px;
	background: #fff;
	border: 1px solid #f1f1f1;

	/* Square, like the reference — the pill this used to be was my invention. */
	border-radius: 0;
}

.vf-lib-search__input-wrap {
	display: flex;
	align-items: center;
	width: 100%;
}

/* The magnifier is a <button>, so every button style Flatsome would otherwise
   apply — background, padding, min-height, uppercase — has to come off. */
.vf-lib-search__icon {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	height: 30px;
	min-height: 0;
	margin: 0 0 0 15px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	line-height: 1;
	cursor: pointer;
}

.vf-lib-search__icon svg {
	height: 30px;
	width: auto;
	fill: #444b54;
	opacity: 0.5;
	transition: opacity 0.3s;
}

.vf-lib-search__icon:hover {
	background: none;
	box-shadow: none;
}

.vf-lib-search__icon:hover svg {
	opacity: 1;
}

.vf-lib-search__field {
	width: 100%;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0 15px;
	border: none;
	background: none;
	box-shadow: none;
	font-size: 16px;
	color: #595959;
}

.vf-lib-search__field::placeholder {
	color: #595959;
}

/* Flatsome rings a focused input with a box-shadow. Inside a bordered box the
   ring reads as a second border, so focus is shown on the box instead. */
.vf-lib-search__field:focus {
	background: none;
	box-shadow: none;
	outline: 0;
	color: #595959;
}

.vf-lib-search__form:focus-within {
	border-color: #d9d9d9;
}

/* -------------------------------------------------------------- index grid */

/**
 * Flex, not grid, and cards that grow — `flex: 1 1 30%` with a 12px margin is
 * what the reference uses, and it is why two topics fill the row instead of
 * leaving a third column empty the way three fixed grid tracks would.
 */
.vf-lib-grid {
	display: flex;
	flex-flow: row wrap;
	align-items: flex-start;
	margin: 0 -12px;
	padding: 28px 0 48px;
}

.vf-lib-card {
	flex: 1 1 30%;
	min-width: 0;
	margin: 12px;
	background: #fff;
	box-shadow: 0 10px 100px 0 rgba(40, 47, 98, 0.08);
}

.vf-lib-card__head {
	padding: 20px 20px 0;
}

/* The rule sits under this row, so the icon, the title and the count all share
   one baseline and the list below starts clear of it. */
.vf-lib-card__head-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 14px;
	border-bottom: 2px solid #d9e1e2;
}

.vf-lib-card__title {
	display: flex;
	align-items: center;
	min-width: 0;
}

.vf-lib-card__icon {
	flex: 0 0 auto;
	width: auto;
	height: 60px;
	object-fit: contain;
}

.vf-lib-card__heading {
	margin: 0;
	padding-left: 30px;
	font-size: 20px;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: #3c3c3c;
}

/* No icon, no reason to indent the title away from the card edge. */
.vf-lib-card__icon + a .vf-lib-card__heading {
	padding-left: 30px;
}

.vf-lib-card__title > a:first-child .vf-lib-card__heading {
	padding-left: 0;
}

.vf-lib-card__title a:hover .vf-lib-card__heading {
	color: var(--vf-blue);
}

.vf-lib-card__count {
	flex: 0 0 auto;
	margin-left: 12px;
	padding: 6px;
	border-radius: 50%;
	background: #e8e8e8;
	line-height: 0;
}

.vf-lib-card__count span {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 12px;
	height: 12px;
	padding: 0 2px;
	border-radius: 999px;
	background: #eaeaea;
	color: #707070;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
}

.vf-lib-card__desc {
	margin: 0 0 6px;
	font-size: 14px;
	line-height: 1.6;
	color: var(--vf-muted);
}

.vf-lib-card__body {
	padding: 10px 20px 20px;
}

/* A plain blue link, not a pill: the reference's own stylesheet draws a bordered
   button and its site CSS then removes the border and the radius. */
.vf-lib-card__more {
	display: inline-block;
	margin: 8px 0;
	padding: 8px 0;
	color: #528ffe;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.vf-lib-card__more:hover {
	color: var(--vf-blue);
}

/* ------------------------------------------------------------- link lists */

.vf-lib-doc-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.vf-lib-doc-list li {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 10px 10px 10px 0;
	padding: 0;
	list-style: none;
}

.vf-lib-doc-list li::before {
	display: none;
}

.vf-lib-doc-icon {
	flex: 0 0 auto;
	width: 16px;
	min-width: 16px;
	margin-top: 5px;
	color: #707070;
}

.vf-lib-doc-list a {
	color: #3c3c3c;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.6;
}

.vf-lib-doc-list a:hover {
	color: #2998dd;
}

/* A sub-topic's articles are secondary to the topic's own, and the reference
   greys them back to say so. */
.vf-lib-doc-list--sub {
	margin-left: 20px;
}

.vf-lib-doc-list--sub a,
.vf-lib-doc-list--sub a:hover {
	color: var(--vf-lib-link);
}

.vf-lib-doc-list--sub .vf-lib-doc-icon {
	color: var(--vf-lib-link);
}

/* ------------------------------------------------------ sub-topic groups */

.vf-lib-subcat {
	display: flex;
	align-items: center;
	margin: 10px 10px 0 0;
	font-size: 16px;
	line-height: 2;
}

.vf-lib-subcat a {
	color: var(--vf-lib-link);
	font-weight: 500;
}

.vf-lib-subcat a:hover {
	color: var(--vf-blue);
}

.vf-lib-subcat.is-current a {
	color: var(--vf-blue);
}

/* The disclosure control. Flatsome styles every button, so the background,
   border, height and uppercase all have to come back off. */
.vf-lib-subcat__toggle {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	min-height: 0;
	margin: 0 10px 0 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--vf-lib-link);
	line-height: 1;
	cursor: pointer;
}

.vf-lib-subcat__toggle:hover {
	background: none;
	box-shadow: none;
	color: var(--vf-blue);
}

.vf-lib-subcat__arrow {
	transition: transform 0.2s;
}

.vf-lib-subcat__toggle[aria-expanded="true"] .vf-lib-subcat__arrow {
	transform: rotate(90deg);
}

.vf-lib-subcat__panel[hidden] {
	display: none;
}

.vf-lib-empty {
	margin: 0;
	padding: 24px 0;
	color: var(--vf-muted);
	font-size: 15px;
}

/* -------------------------------------------- two-column topic / article */

.vf-lib-layout {
	display: flex;
	align-items: flex-start;
	gap: 40px;
	padding: 32px 0 60px;
}

.vf-lib-sidebar {
	flex: 0 0 300px;
	max-width: 340px;
	position: sticky;
	top: 20px;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	background: #fff;
	border: 1px solid var(--vf-border);
	border-radius: var(--vf-radius);
	box-shadow: var(--vf-lib-card-shadow);
	padding: 8px 20px;
}

.vf-lib-sidecat + .vf-lib-sidecat {
	border-top: 1px solid var(--vf-border);
}

.vf-lib-sidecat__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 0;
}

.vf-lib-sidecat__title {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.4;
	color: var(--vf-text);
}

.vf-lib-sidecat.is-open .vf-lib-sidecat__title,
.vf-lib-sidecat__title:hover {
	color: var(--vf-blue);
}

.vf-lib-sidecat__count {
	flex: 0 0 auto;
	color: var(--vf-muted);
	font-size: 12px;
	font-weight: 700;
}

.vf-lib-sidecat__body {
	padding-bottom: 14px;
}

.vf-lib-main {
	flex: 1 1 auto;
	min-width: 0;
}

/* ------------------------------------------------------------- breadcrumb */

.vf-lib-breadcrumb {
	margin-bottom: 16px;
}

.vf-lib-breadcrumb__list {
	display: flex;
	flex-flow: row wrap;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.vf-lib-breadcrumb__list li {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
	color: var(--vf-lib-link);
	font-size: 12px;
	line-height: 1.7;
	letter-spacing: 0.035em;
}

.vf-lib-breadcrumb__list li::before {
	display: none;
}

.vf-lib-breadcrumb__list a {
	color: var(--vf-lib-link);
	font-size: 12px;
}

.vf-lib-breadcrumb__list a:hover {
	color: var(--vf-blue);
}

/* Specific enough to beat the `margin: 0` on the rule above it, which reset
   every item in the list including this one. */
.vf-lib-breadcrumb__list li.vf-lib-breadcrumb__sep {
	margin: 0 7px;
	opacity: 0.5;
}

/* ------------------------------------------------------------ topic page */

.vf-lib-main__head {
	margin-bottom: 20px;
}

.vf-lib-main__title {
	margin: 0;
	font-size: 32px;
	font-weight: 400;
	line-height: 1.25;
	letter-spacing: -0.03em;
	color: var(--vf-text);
}

.vf-lib-main__desc {
	margin: 10px 0 0;
	font-size: 15px;
	line-height: 1.7;
	color: var(--vf-muted);
}

.vf-lib-list {
	background: #fff;
	border: 1px solid var(--vf-border);
	border-radius: var(--vf-radius);
	box-shadow: var(--vf-lib-card-shadow);
	padding: 20px 24px;
}

.vf-lib-list > .vf-lib-subcat:first-child {
	margin-top: 0;
}

.vf-lib-subcat__count {
	margin-left: 8px;
	color: var(--vf-muted);
	font-size: 12px;
	font-weight: 700;
}

.vf-lib-more-link {
	display: inline-block;
	margin: 4px 0 0 22px;
	color: var(--vf-blue);
	font-size: 13px;
	font-weight: 700;
}

.vf-lib-more-link:hover {
	text-decoration: underline;
}

/* ------------------------------------------------------------- pagination */

.vf-lib-pager {
	display: flex;
	flex-flow: row wrap;
	align-items: center;
	gap: 8px;
	margin-top: 24px;
}

.vf-lib-pager .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 12px;
	border: 1px solid var(--vf-border);
	border-radius: var(--vf-radius);
	background: #fff;
	color: var(--vf-lib-link);
	font-size: 14px;
	line-height: 1;
}

.vf-lib-pager .page-numbers:hover {
	border-color: var(--vf-blue);
	color: var(--vf-blue);
}

.vf-lib-pager .page-numbers.current {
	border-color: var(--vf-blue);
	background: var(--vf-blue);
	color: #fff;
	font-weight: 700;
}

.vf-lib-pager .page-numbers.dots {
	border-color: transparent;
	background: transparent;
}

/* --------------------------------------------------------------- article */

.vf-doc {
	background: #fff;
	border: 1px solid var(--vf-border);
	border-radius: var(--vf-radius);
	box-shadow: var(--vf-lib-card-shadow);
	padding: 28px 32px 32px;
}

.vf-doc__title {
	margin: 6px 0 24px;
	font-size: 30px;
	font-weight: 400;
	line-height: 1.3;
	letter-spacing: -0.03em;
	color: var(--vf-text);
}

.vf-doc__content {
	font-size: 16px;
	line-height: 1.8;
	color: #3c3c3c;
}

.vf-doc__content > *:first-child {
	margin-top: 0;
}

.vf-doc__content h2 {
	margin: 32px 0 12px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--vf-text);
}

.vf-doc__content h3 {
	margin: 24px 0 10px;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.4;
	color: var(--vf-text);
}

.vf-doc__content p {
	margin: 0 0 16px;
}

.vf-doc__content ul,
.vf-doc__content ol {
	margin: 0 0 16px 20px;
}

.vf-doc__content li {
	margin-bottom: 6px;
}

.vf-doc__content a {
	color: var(--vf-blue);
	text-decoration: underline;
}

.vf-doc__content img,
.vf-doc__content video,
.vf-doc__content iframe {
	max-width: 100%;
	height: auto;
}

/* WordPress prints the player at the media's own pixel size, which on a
   portrait phone recording is taller than the window. Cap it and let the
   player centre itself in the column. */
.vf-doc__content .wp-video,
.vf-doc__content .wp-video-shortcode,
.vf-doc__content video {
	width: 100% !important;
	max-width: 100%;
	height: auto;
	margin-left: auto;
	margin-right: auto;
}

.vf-doc__content video {
	max-height: 70vh;
	background: #000;
	border-radius: var(--vf-radius);
}

.vf-doc__content .wp-video {
	max-width: 480px;
}

.vf-doc__content table {
	display: block;
	width: 100%;
	overflow-x: auto;
}

/* ------------------------------------------------------ footer of article */

.vf-doc__foot {
	display: flex;
	flex-flow: row wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: 36px;
	padding-top: 20px;
	border-top: 1px solid var(--vf-border);
}

.vf-doc-share {
	display: flex;
	align-items: center;
	gap: 14px;
}

.vf-doc-share__title {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.4;
	color: var(--vf-text);
}

.vf-doc-share__list {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.vf-doc-share__list li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.vf-doc-share__list li::before {
	display: none;
}

.vf-doc-share__list a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #f1f4f9;
	color: var(--vf-lib-link);
}

.vf-doc-share__list a:hover {
	background: var(--vf-blue);
	color: #fff;
}

.vf-doc__updated {
	margin: 0;
	color: var(--vf-muted);
	font-size: 13px;
}

.vf-doc__nav {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
	margin-top: 28px;
}

.vf-doc__nav-link {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px 16px;
	border: 1px solid var(--vf-border);
	border-radius: var(--vf-radius);
}

.vf-doc__nav-link:hover {
	border-color: var(--vf-blue);
}

/* A lone "next" keeps to the right-hand cell, so prev and next always sit on
   the side the reader expects even when only one of them exists. */
.vf-doc__nav-link--next {
	grid-column: 2;
	text-align: right;
}

.vf-doc__nav-label {
	color: var(--vf-muted);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.vf-doc__nav-title {
	color: var(--vf-text);
	font-size: 15px;
	line-height: 1.45;
}

.vf-doc__nav-link:hover .vf-doc__nav-title {
	color: var(--vf-blue);
}

/* ---------------------------------------------------- table of contents */

.vf-lib-main.has-toc {
	display: flex;
	align-items: flex-start;
	gap: 32px;
}

.vf-lib-main.has-toc .vf-doc {
	flex: 1 1 auto;
	min-width: 0;
}

.vf-doc-toc {
	flex: 0 0 220px;
	position: sticky;
	top: 20px;
}

.vf-doc-toc__title {
	margin: 0 0 10px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--vf-muted);
}

.vf-doc-toc__list {
	margin: 0;
	padding: 0 0 0 14px;
	border-left: 2px solid var(--vf-border);
	list-style: none;
}

.vf-doc-toc__item {
	margin: 0;
	padding: 4px 0;
	list-style: none;
}

.vf-doc-toc__item::before {
	display: none;
}

.vf-doc-toc__item a {
	color: var(--vf-lib-link);
	font-size: 13px;
	line-height: 1.5;
}

.vf-doc-toc__item a:hover {
	color: var(--vf-blue);
}

.vf-doc-toc__item--h3 {
	padding-left: 12px;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 1024px) {
	/* 38 → 30 → 24px, the steps the reference's own stylesheet uses. */
	.vf-lib-search__heading {
		font-size: 30px;
	}

	.vf-lib-search {
		padding: 80px 20px;
	}

	/* Two per row from 768px down, one from 670px — the reference's own steps,
	   which is why these two do not sit on the 1024/767 breakpoints the rest of
	   this stylesheet uses. */
	.vf-lib-sidebar {
		flex-basis: 260px;
	}

	/* Below the desktop breakpoint the contents rail would squeeze the article
	   into a column too narrow to read; it goes back above the text instead. */
	.vf-lib-main.has-toc {
		display: block;
	}

	.vf-doc-toc {
		position: static;
		margin-top: 24px;
	}
}

@media (max-width: 767px) {
	.vf-lib-search {
		padding: 56px 16px;
	}

	.vf-lib-search__heading {
		margin-bottom: 24px;
		font-size: 24px;
	}

	.vf-lib-search__form {
		padding: 12px 10px;
	}

	.vf-lib-search__icon,
	.vf-lib-search__icon svg {
		height: 24px;
	}

	.vf-lib-search__icon {
		margin-left: 8px;
	}

	.vf-lib-search__field {
		padding: 0 10px;
		font-size: 15px;
	}

	.vf-lib-grid {
		padding: 20px 0 32px;
	}

	.vf-lib-layout {
		display: block;
		padding: 24px 0 40px;
	}

	/* The sidebar is a long list of everything; on a phone it belongs under the
	   article, not stacked on top of it where it would push the page the reader
	   asked for off the screen. */
	.vf-lib-sidebar {
		position: static;
		max-width: none;
		max-height: none;
		margin-top: 32px;
		order: 2;
	}

	.vf-lib-main {
		order: 1;
	}

	.vf-lib-layout {
		display: flex;
		flex-direction: column;
	}

	.vf-lib-main__title {
		font-size: 24px;
	}

	.vf-doc {
		padding: 20px 18px 24px;
	}

	.vf-doc__title {
		font-size: 24px;
	}

	.vf-doc__nav {
		grid-template-columns: minmax(0, 1fr);
	}

	.vf-doc__nav-link--next {
		grid-column: 1;
		text-align: left;
	}
}

/* ------------------------------------- card grid: the reference's own steps */

/**
 * 768px and 670px, not the 1024/767 pair the rest of this stylesheet uses.
 * These two come from the reference's stylesheet and are kept where it puts
 * them, so the cards break to two-up and one-up at the same widths as the
 * design they were copied from.
 */
@media only screen and (max-width: 768px) {
	.vf-lib-card {
		flex: 1 1 45%;
	}
}

@media only screen and (max-width: 670px) {
	.vf-lib-card {
		flex: 1 1 100%;
	}

	.vf-lib-card__icon {
		height: 44px;
	}

	.vf-lib-card__heading {
		padding-left: 16px;
		font-size: 18px;
	}
}
