/* =========================================================================
   SurgCase — library view (front page, case archive, term archives, search).

   Every rule here is a port of an inline style from the `isIndex` branch of
   design/medical-qa-library.dc.html. Tokens live in style.css; the design's
   container queries are re-expressed as plain media queries at 900px / 560px.
   ========================================================================= */

/* -------------------------------------------------------------------------
   Layout
   ---------------------------------------------------------------------- */

.sc-lib {
	max-width: var(--sc-maxw);
	margin: 0 auto;
	padding: 22px var(--sc-gut) 80px;
	display: grid;
	grid-template-columns: 220px 1fr;
	gap: 28px;
	align-items: start;
}

.sc-lib__side {
	position: sticky;
	top: var(--sc-sticky-top);
}

.sc-lib__side-title {
	margin-bottom: 12px;
}

.sc-lib__main {
	min-width: 0;
}

/* -------------------------------------------------------------------------
   Sidebar tree
   ---------------------------------------------------------------------- */

.sc-tree__group {
	margin-top: 14px;
}

/* LINK / SUB / LEAF in the design. */
.sc-tree__dept,
.sc-tree__sys-link,
.sc-tree__leaf {
	display: block;
	padding: 5px 8px;
	margin: 1px 0;
	border-radius: 4px;
	font-size: 13.5px;
	line-height: 1.45;
	color: var(--sc-nav);
	text-decoration: none;
}

.sc-tree__dept,
.sc-tree__sys-link,
.sc-tree__leaf {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 6px;
}

.sc-tree__label {
	min-width: 0;
}

.sc-tree__dept {
	font-weight: 600;
	color: var(--sc-text);
}

.sc-tree__sys-link {
	font-size: 13px;
	color: var(--sc-mut);
}

.sc-tree__leaf {
	font-size: 12.5px;
	color: var(--sc-mut2);
	padding: 4px 8px;
}

.sc-tree__dept:hover,
.sc-tree__sys-link:hover,
.sc-tree__leaf:hover,
.sc-tree__dept:focus,
.sc-tree__sys-link:focus,
.sc-tree__leaf:focus {
	background: var(--sc-pill);
	color: var(--sc-text);
	text-decoration: none;
}

/* SEL in the design. */
.sc-tree__dept.is-active,
.sc-tree__sys-link.is-active,
.sc-tree__leaf.is-active {
	background: var(--sc-sel-bg);
	color: var(--sc-sel-text);
	font-weight: 500;
}

.sc-tree__dept.is-active {
	font-weight: 600;
}

/* System block: indented, hairline rule on the inline start edge. */
.sc-tree__sys {
	margin-inline-start: 10px;
	border-inline-start: 1px solid var(--sc-line2);
	padding-inline-start: 10px;
}

.sc-tree__count {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.6em;
	height: 1.6em;
	padding-inline: 0.4em;
	border: 1px solid var(--sc-line2);
	border-radius: 999px;
	background: var(--sc-pill);
	color: var(--sc-mut3);
	font-size: 10.5px;
	font-weight: 600;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.sc-tree__count--sm {
	color: var(--sc-mut4);
	font-size: 10px;
}

.sc-tree__dept.is-active .sc-tree__count,
.sc-tree__sys-link.is-active .sc-tree__count,
.sc-tree__leaf.is-active .sc-tree__count {
	border-color: var(--sc-white);
	background: var(--sc-white);
	color: var(--sc-sel-text);
}

/* A quiet external resource below the main-page category navigation. */
.sc-related-site {
	margin-top: 22px;
	padding-top: 14px;
	border-top: 1px solid var(--sc-line2);
}

.sc-related-site__title {
	margin-bottom: 7px;
}

.sc-related-site__link {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: var(--sc-nav);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.45;
	text-decoration: none;
}

.sc-related-site__link:hover,
.sc-related-site__link:focus {
	color: var(--sc-link-hover);
	text-decoration: underline;
}

/* -------------------------------------------------------------------------
   Heading row + subtitle
   ---------------------------------------------------------------------- */

.sc-lib__head {
	display: flex;
	align-items: center;
	gap: 20px;
	margin-bottom: 6px;
}

.sc-lib__title {
	margin: 0;
	color: var(--sc-text);
	font-size: 20px;
	font-weight: 600;
	letter-spacing: -0.02em;
	white-space: nowrap;
}

.sc-lib__search {
	flex: 1;
	min-width: 0;
	margin: 0;
	display: flex;
}

/* -------------------------------------------------------------------------
   Tag chips
   ---------------------------------------------------------------------- */

.sc-lib__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-bottom: 10px;
}

.sc-chip {
	font-size: 12.5px;
	border: 1px solid var(--sc-line);
	background: var(--sc-white);
	color: var(--sc-body2);
	border-radius: 3px;
	padding: 4px 9px;
	line-height: 1.45;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.sc-chip:hover,
.sc-chip:focus {
	color: var(--sc-text);
	text-decoration: none;
	background: var(--sc-bg);
}

.sc-chip.is-active {
	background: var(--sc-sel-bg);
	border-color: var(--sc-sel-line);
	color: var(--sc-sel-text);
}

.sc-chip.is-active:hover,
.sc-chip.is-active:focus {
	background: var(--sc-sel-bg);
	color: var(--sc-sel-text);
}

.sc-chip__x {
	font-size: 13px;
	line-height: 1;
	color: var(--sc-sel-text);
	opacity: 0.7;
}

/* -------------------------------------------------------------------------
   Result count row
   ---------------------------------------------------------------------- */

.sc-lib__results {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	border-bottom: 1px solid var(--sc-line);
	padding-bottom: 8px;
	margin-bottom: 2px;
}

.sc-lib__count {
	font-size: 13px;
	color: var(--sc-mut);
}

.sc-lib__reset {
	font-size: 12.5px;
	flex: none;
}

/* -------------------------------------------------------------------------
   Case rows
   ---------------------------------------------------------------------- */

.sc-row {
	padding: 16px 0;
	border-bottom: 1px solid var(--sc-line2);
}

.sc-row__head {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin-bottom: 4px;
}

.sc-row__num {
	font-size: 12px;
	color: var(--sc-mut3);
	flex: none;
}

.sc-row__title {
	font-size: 16.5px;
	font-weight: 500;
	letter-spacing: -0.01em;
	line-height: 1.35;
	text-decoration: none;
}

.sc-row__meta {
	font-size: 11.5px;
	color: var(--sc-mut3);
	flex: none;
}

.sc-row__excerpt {
	margin: 0 0 9px;
	color: var(--sc-body2);
	font-size: 14px;
	line-height: 1.6;
	max-width: 72ch;
}

.sc-row__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.sc-row__path {
	font-size: 11.5px;
	color: var(--sc-mut2);
	margin-inline-end: 4px;
}

/* -------------------------------------------------------------------------
   Pager
   ---------------------------------------------------------------------- */

.sc-pager {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 22px;
	flex-wrap: wrap;
}

.sc-pager__btn {
	min-width: 34px;
	min-height: 34px;
	text-align: center;
	padding: 5px 8px;
	border-radius: 4px;
	border: 1px solid var(--sc-input-line);
	background: var(--sc-white);
	color: var(--sc-body2);
	font-size: 13px;
	line-height: 1.4;
	text-decoration: none;
	display: inline-block;
}

.sc-pager__ellipsis {
	min-width: 18px;
	text-align: center;
	color: var(--sc-mut2);
}

.sc-pager__btn:hover,
.sc-pager__btn:focus {
	color: var(--sc-text);
	text-decoration: none;
	background: var(--sc-bg);
}

.sc-pager__btn.is-current,
.sc-pager__btn.is-current:hover {
	background: var(--sc-link);
	border-color: var(--sc-link);
	color: var(--sc-white);
	font-weight: 500;
}

.sc-pager__btn.is-disabled {
	color: var(--sc-disabled);
	pointer-events: none;
}

.sc-pager__info {
	font-size: 12.5px;
	color: var(--sc-mut2);
}

/* -------------------------------------------------------------------------
   Empty state
   ---------------------------------------------------------------------- */

.sc-lib__empty {
	padding: 48px 0;
	text-align: center;
	color: var(--sc-mut2);
	font-size: 14px;
}

/* -------------------------------------------------------------------------
   Responsive — the design's @container site rules
   ---------------------------------------------------------------------- */

@media (max-width: 900px) {
	.sc-lib {
		grid-template-columns: 1fr;
		gap: 18px;
	}

	.sc-lib__side {
		position: static;
	}

	.sc-related-site {
		margin-top: 10px;
		padding-top: 10px;
	}

	/* The tree collapses into a wrapped row of chips; topic leaves drop out. */
	.sc-tree {
		display: flex;
		flex-wrap: wrap;
		gap: 4px;
	}

	.sc-tree__leaf {
		display: none;
	}

	.sc-tree__group {
		margin-top: 0;
		display: flex;
		flex-wrap: wrap;
		gap: 4px;
	}

	.sc-tree__sys {
		margin-inline-start: 0;
		border: 0;
		padding-inline-start: 0;
		display: flex;
		gap: 4px;
	}

	.sc-lib__head {
		flex-wrap: wrap;
		gap: 8px;
	}

	.sc-lib__search {
		order: 3;
		flex-basis: 100%;
	}
}

@media (max-width: 560px) {
	.sc-row__meta {
		display: none;
	}

	.sc-lib {
		padding-inline: 18px;
		padding-bottom: 56px;
	}

	.sc-pager {
		gap: 4px;
	}

	.sc-pager > .sc-spacer {
		display: none;
	}

	.sc-pager__info {
		flex-basis: 100%;
		margin-top: 4px;
	}
}

/* -------------------------------------------------------------------------
   Print — the library keeps only its title and the rows
   ---------------------------------------------------------------------- */

@media print {
	.sc-lib {
		display: block;
		padding: 0;
	}

	.sc-lib__results {
		border-bottom: 1px solid #ccc;
	}

	.sc-row {
		break-inside: avoid;
	}
}
