/* =========================================================
   Tessera Connect — 书影音海报墙（[tessera_media]）
   设计参考 atpx.com/misc 的 .misc-section：
   自适应网格 / 封面 125x180 圆角阴影 / hover 磨砂玻璃遮罩
   （rgba 深色 + backdrop-filter blur）+ 短评引文 + 五星评分。
   ========================================================= */
.tessera-media-wall {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.tessera-media-wall *,
.tessera-media-wall *::before,
.tessera-media-wall *::after {
	box-sizing: border-box;
}
.tessera-error {
	color: #c0392b;
	background: #fdecea;
	border: 1px solid #f5c6c6;
	padding: 10px 14px;
	border-radius: 4px;
}

/* ---- 类别选项卡 ---- */
.tessera-media-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 22px;
}
.tessera-tab {
	appearance: none;
	border: 1px solid #d8dce1;
	background: #fff;
	color: #444;
	font-size: 13px;
	line-height: 1;
	padding: 8px 14px;
	border-radius: 999px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	transition: background .2s, color .2s, border-color .2s;
}
.tessera-tab i {
	font-style: normal;
	font-size: 11px;
	color: #9aa1a9;
}
.tessera-tab:hover {
	border-color: #aab2bb;
}
.tessera-tab.is-active {
	background: #222;
	border-color: #222;
	color: #fff;
}
.tessera-tab.is-active i {
	color: rgba(255, 255, 255, .65);
}

/* ---- 海报网格 ---- */
.tessera-media-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	grid-column-gap: 20px;
	grid-row-gap: 10px;
	margin: 0;
	padding: 0;
}
.tessera-media-item {
	display: flex;
	flex-flow: column;
	align-items: center;
	user-select: none;
}
.tessera-media-item[hidden] {
	display: none;
}

/* ---- 封面 ---- */
.tessera-media-cover {
	position: relative;
	width: 125px;
	height: 180px;
	border-radius: 8px;
	box-shadow: rgba(33, 33, 33, .2) 0 2px 6px;
	overflow: hidden;
	background: #eef0f2;
}
.tessera-media-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .25s ease;
}
.tessera-media-item:hover .tessera-media-img {
	-webkit-transform: scale(1.02);
	transform: scale(1.02);
}
.tessera-media-img-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	background: repeating-linear-gradient(45deg, #eef0f2, #eef0f2 8px, #e6e9ec 8px, #e6e9ec 16px);
}
.tessera-media-img-empty span {
	font-size: 11px;
	color: #a7adb4;
}

/* ---- 磨砂玻璃遮罩（hover / 移动端点击显示） ---- */
.tessera-media-overlay {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	background-color: rgba(33, 33, 33, .25);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	/* backdrop-filter 会逃出父级 overflow:hidden 的圆角裁剪（磨砂四角变方），
	   必须自己带上与封面一致的圆角 */
	border-radius: 8px;
}
.tessera-media-overlay-hide {
	visibility: hidden;
	opacity: 0;
	transition: .4s ease;
}
.tessera-media-item:hover .tessera-media-overlay-hide {
	visibility: visible;
	opacity: 1;
}
/* 移动端（无 hover 能力）：JS 点击加 .tessera-media-active 显示遮罩，点外部退出 */
@media (hover: none) {
	.tessera-media-item:hover .tessera-media-overlay-hide {
		visibility: hidden;
		opacity: 0;
	}
	.tessera-media-item.tessera-media-active .tessera-media-overlay-hide {
		visibility: visible;
		opacity: 1;
	}
}

/* ---- 遮罩上的短评与评分 ---- */
.tessera-media-info {
	display: flex;
	flex-flow: column;
	justify-content: space-between;
	position: absolute;
	bottom: 0;
	z-index: 2;
	font-size: 12px;
	line-height: 1.5;
	color: #fcfcfc;
	width: 100%;
	height: 100%;
	padding: 10px;
	pointer-events: none;
}
.tessera-media-comment {
	margin-top: 10px;
	line-height: 1.45;
}
.tessera-media-comment i {
	font-style: italic;
	display: -webkit-box;
	-webkit-line-clamp: 6;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tessera-media-comment-none {
	font-style: normal !important;
	color: rgba(255, 255, 255, .62);
}
.tessera-media-info-bottom {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

/* 五星评分：灰底 + 金色前景按宽度裁切（0.5 步长 = 10% 步进） */
.tessera-stars {
	position: relative;
	display: inline-block;
	/* 它是纵向 flex（.tessera-media-info-bottom）的子项，默认被 stretch 拉成整行宽，
	   前景的百分比宽度就会按整行算 —— 每档评分都多亮一颗星
	   （实测：行盒 105px vs 灰底文字 76px，1 星亮出 1.4 颗、4 星 5 颗全亮）。
	   行盒必须收缩回灰底文字的宽度。 */
	align-self: flex-start;
	width: max-content;
	font-size: 13px;
	line-height: 1;
	letter-spacing: 2px;
	color: rgba(255, 255, 255, .38);
	white-space: nowrap;
}
.tessera-stars-fg {
	position: absolute;
	left: 0;
	top: 0;
	overflow: hidden;
	white-space: nowrap;
	color: #f5a623;
}

/* 评分下方的鉴赏年份行 */
.tessera-media-date {
	margin-top: 5px;
	font-size: 11px;
	color: rgba(255, 255, 255, .75);
	letter-spacing: .05em;
}

/* ---- 名称行：中文名 + 关联文章小图标 ---- */
.tessera-media-title {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	margin: 10px 0 0;
	padding: 0 5px;
	font-size: 12px;
	font-weight: 600;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
}
.tessera-media-name {
	color: inherit;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}
a.tessera-media-name:hover {
	color: #e0700a;
	text-decoration: none;
}

/* ---- 名称下方小字：创作者 / 国家/地区（颜色比名称浅） ---- */
.tessera-media-sub {
	max-width: 125px;
	margin: 3px 0 6px;
	font-size: 11px;
	font-weight: 400;
	color: #9aa1a9;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---- 分批渲染：「显示更多」 ---- */
.tessera-media-more {
	display: flex;
	justify-content: center;
	margin: 18px 0 4px;
}
/* 没有剩余条目（或没有 JS、模板展不开）时整块不占位。
   注意：`[hidden]` 是 HTML 属性，会被任何作者 display 规则覆盖（UA 样式表优先级最低），
   所以「显示」的那条规则必须排除 [hidden]，否则属性写了也白写。 */
.tessera-media-wall:not(.is-js) .tessera-media-more,
.tessera-media-more[hidden] {
	display: none;
}
.tessera-media-more-btn {
	display: none;
	appearance: none;
	border: 1px solid #d8dce1;
	background: #fff;
	color: #444;
	font-size: 13px;
	line-height: 1;
	padding: 10px 18px;
	border-radius: 999px;
	cursor: pointer;
}
.tessera-media-wall.is-js .tessera-media-more-btn:not([hidden]) {
	display: inline-flex;
	align-items: center;
}
.tessera-media-more-btn:hover {
	border-color: #aab2bb;
}

/* 数据超过单次读取上限时的说明（不是报错，用提示色） */
.tessera-media-notice {
	margin: 14px 0 0;
	padding: 8px 12px;
	font-size: 12px;
	line-height: 1.6;
	color: #8a6116;
	background: #fff8e5;
	border: 1px solid #f0d9a8;
	border-radius: 6px;
}

/* ---- 小屏收紧（参考 atpx 响应式） ---- */
@media (max-width: 480px) {
	.tessera-media-grid {
		grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
		grid-column-gap: 12px;
	}
	.tessera-media-cover {
		width: 105px;
		height: 150px;
	}
	.tessera-media-sub {
		max-width: 105px;
	}
	/* 封面变小后内容区只剩 ~130px 高，6 行短评 + 底部评分（~145px）会溢出，
	   评分/鉴赏年份被推到封面底边之外裁掉。少显示几行并收一点上边距：
	   4 行(70px) + 6px + 底部(~31px) = 107px，留 23px 余量。 */
	.tessera-media-comment {
		margin-top: 6px;
	}
	.tessera-media-comment i {
		-webkit-line-clamp: 4;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tessera-media-img,
	.tessera-media-overlay-hide,
	.tessera-tab {
		transition: none;
	}
}
