/* Game library — Legend of Dwar / landing theme extension */

.lib-main.ld-main {
	display: block !important;
	grid-template-columns: unset;
	max-width: min(1200px, 100%);
}

.lib-content {
	overflow-x: auto;
	min-width: 0;
}

.ld-section-head {
	margin-bottom: 1.25rem;
}

.ld-section-head__title {
	font-family: var(--ld-font-display);
	font-size: clamp(1.5rem, 3vw, 2rem);
	margin: 0 0 0.35rem;
	color: var(--ld-accent-bright);
}

.ld-section-head__sub {
	margin: 0;
	color: var(--ld-muted);
	font-size: 0.95rem;
}

.lib-shell {
	display: grid;
	grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
	gap: 1.25rem;
	align-items: start;
}

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

.lib-panel {
	background: var(--ld-panel);
	border: 1px solid var(--ld-panel-border);
	border-radius: var(--ld-radius);
	box-shadow: var(--ld-shadow);
	padding: 1rem 1.1rem;
}

.lib-sidebar {
	position: sticky;
	top: calc(var(--ld-header-h) + 12px);
	max-height: calc(100vh - var(--ld-header-h) - 32px);
	overflow: auto;
}

.lib-search {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.lib-search input[type="search"] {
	flex: 1;
	min-width: 0;
	padding: 0.55rem 0.75rem;
	border-radius: var(--ld-radius-sm);
	border: 1px solid rgba(201, 162, 39, 0.35);
	background: rgba(0, 0, 0, 0.35);
	color: var(--ld-text);
}

.lib-search button {
	padding: 0.55rem 1rem;
	border-radius: var(--ld-radius-sm);
	border: 1px solid var(--ld-accent-dim);
	background: linear-gradient(180deg, rgba(201, 162, 39, 0.25), rgba(201, 162, 39, 0.08));
	color: var(--ld-accent-bright);
	cursor: pointer;
	font-weight: 600;
}

.lib-nav {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 0.92rem;
}

.lib-nav__sub {
	list-style: none;
	margin: 0.15rem 0 0.35rem 0.65rem;
	padding-left: 0.55rem;
	border-left: 1px solid rgba(201, 162, 39, 0.18);
}

.lib-nav__link,
.lib-nav__folder {
	display: block;
	padding: 0.28rem 0.35rem;
	border-radius: 6px;
	color: var(--ld-muted);
	text-decoration: none;
	line-height: 1.35;
}

.lib-nav__folder {
	font-weight: 600;
	color: var(--ld-accent);
	cursor: pointer;
	user-select: none;
}

.lib-nav__folder::before {
	content: "▸ ";
	display: inline-block;
	transition: transform 0.15s;
	color: var(--ld-accent-dim);
}

.lib-nav__item.has-children.is-active > .lib-nav__folder::before,
.lib-nav__item.has-children.is-open > .lib-nav__folder::before {
	transform: rotate(90deg);
}

.lib-nav__item.has-children:not(.is-active):not(.is-open) > .lib-nav__sub {
	display: none;
}

.lib-nav__link:hover {
	color: var(--ld-text);
	background: rgba(201, 162, 39, 0.1);
}

.lib-nav__link.is-current {
	color: var(--ld-accent-bright);
	background: rgba(201, 162, 39, 0.16);
	font-weight: 600;
}

.lib-breadcrumb {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	font-size: 0.88rem;
	color: var(--ld-muted);
	margin-bottom: 0.75rem;
}

.lib-breadcrumb a {
	color: var(--ld-accent);
	text-decoration: none;
}

.lib-breadcrumb a:hover {
	text-decoration: underline;
}

.lib-page-title {
	font-family: var(--ld-font-display);
	font-size: clamp(1.35rem, 2.5vw, 1.85rem);
	margin: 0 0 1rem;
	color: var(--ld-accent-bright);
}

.lib-home-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 0.85rem;
}

.lib-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	min-height: 110px;
	padding: 0.85rem;
	border-radius: var(--ld-radius-sm);
	border: 1px solid rgba(201, 162, 39, 0.22);
	background: rgba(0, 0, 0, 0.22);
	text-decoration: none;
	color: var(--ld-text);
	transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.lib-tile:hover {
	border-color: var(--ld-accent);
	background: rgba(201, 162, 39, 0.08);
	transform: translateY(-2px);
}

.lib-tile__icon {
	font-size: 1.75rem;
	line-height: 1;
}

.lib-tile__label {
	font-size: 0.9rem;
	text-align: center;
}

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

.lib-article-list li {
	margin: 0.35rem 0;
}

.lib-article-list a {
	color: var(--ld-accent-bright);
	text-decoration: none;
}

.lib-article-list a:hover {
	text-decoration: underline;
}

.lib-pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
	padding: 0.5rem 0.75rem;
	border-radius: var(--ld-radius-sm);
	background: rgba(0, 0, 0, 0.25);
	border: 1px solid rgba(201, 162, 39, 0.15);
}

.lib-pager a {
	color: var(--ld-accent-bright);
	text-decoration: none;
	font-weight: 600;
}

.lib-pager select {
	background: rgba(0, 0, 0, 0.35);
	color: var(--ld-text);
	border: 1px solid rgba(201, 162, 39, 0.35);
	border-radius: 6px;
	padding: 0.35rem 0.5rem;
}

.lib-body {
	color: var(--ld-text);
	line-height: 1.65;
	font-size: 0.98rem;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

/* Legacy portal markup: force readable colors on dark theme */
.lib-body,
.lib-body * {
	color: inherit;
}

.lib-body font,
.lib-body span[style*="color"],
.lib-body p[style*="color"],
.lib-body td[style*="color"],
.lib-body b[style*="color"],
.lib-body a[style*="color"] {
	color: inherit !important;
}

.lib-body a,
.lib-body a font,
.lib-body a span {
	color: var(--ld-accent-bright) !important;
}

.lib-body a:hover {
	text-decoration: underline;
}

.lib-body img[src*="tbl-"] {
	display: none;
}

.lib-body p {
	margin: 0.65rem 0;
}

.lib-body h1,
.lib-body h2,
.lib-body h3,
.lib-body b[style] {
	font-family: var(--ld-font-display);
	color: var(--ld-accent-bright);
}

.lib-body table {
	width: 100% !important;
	max-width: 100%;
	border-collapse: collapse;
	margin: 0.85rem 0;
	font-size: 0.92rem;
	background: rgba(0, 0, 0, 0.2);
	border: 1px solid rgba(201, 162, 39, 0.18);
	border-radius: 8px;
	overflow: hidden;
	table-layout: auto;
}

.lib-body table[width],
.lib-body table[style*="width"] {
	max-width: 100% !important;
}

.lib-body .tbl-usi_bg,
.lib-body .tbl-usi_bg td,
.lib-body .tbl-usi_bg th {
	background: rgba(0, 0, 0, 0.28) !important;
	color: var(--ld-text) !important;
}

.lib-body .tbl-usi_bg a {
	color: var(--ld-accent-bright) !important;
}

.lib-body td,
.lib-body th {
	padding: 0.45rem 0.55rem;
	border: 1px solid rgba(201, 162, 39, 0.12);
	vertical-align: top;
}

.lib-body tr:nth-child(even) td {
	background: rgba(201, 162, 39, 0.04);
}

.lib-body ul,
.lib-body ol {
	margin: 0.5rem 0 0.75rem 1.25rem;
	padding: 0;
}

.lib-body blockquote {
	margin: 0.75rem 0;
	padding: 0.65rem 0.85rem;
	border-left: 3px solid var(--ld-accent-dim);
	background: rgba(0, 0, 0, 0.25);
	border-radius: 0 8px 8px 0;
	color: var(--ld-muted);
}

.lib-body img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
}

.lib-body img[width="1"],
.lib-body img[height="1"],
.lib-body img[src=""],
.lib-body img:not([src]) {
	display: none;
}

.lib-body a {
	color: var(--ld-accent-bright);
}

.lib-body hr {
	border: none;
	border-top: 1px solid rgba(201, 162, 39, 0.2);
	margin: 1rem 0;
}

.lib-legacy-box {
	margin: 1rem 0;
	padding: 0.85rem 1rem;
	border: 1px solid rgba(201, 162, 39, 0.25);
	border-radius: var(--ld-radius-sm);
	background: rgba(0, 0, 0, 0.28);
}

.lib-legacy-box__title {
	font-family: var(--ld-font-display);
	color: var(--ld-accent-bright);
	font-weight: 600;
	text-align: center;
	margin-bottom: 0.65rem;
	padding-bottom: 0.45rem;
	border-bottom: 1px solid rgba(201, 162, 39, 0.2);
}

.lib-body .brd2-all {
	border-color: rgba(201, 162, 39, 0.2) !important;
}

.lib-search-results {
	list-style: none;
	margin: 0;
	padding: 0;
}

.lib-search-results li {
	padding: 0.65rem 0;
	border-bottom: 1px solid rgba(201, 162, 39, 0.12);
}

.lib-search-results a {
	color: var(--ld-accent-bright);
	text-decoration: none;
	font-weight: 600;
}

.lib-search-results small {
	display: block;
	color: var(--ld-muted);
	margin-top: 0.15rem;
}

.lib-empty {
	color: var(--ld-muted);
	padding: 2rem 1rem;
	text-align: center;
}
