/* ------------------------------------------------------------------------- *
 *  YZ Series Companion
 *
 *  Loaded only on posts that belong to a series and on series archives.
 *  The markup is PublishPress Series' own, wrapped by yz-series.php:
 *
 *  nav.yz-series                      top of .entry (the list box)
 *    .yz-series-body                  header + .pps-post-list-box
 *  .yz-series-dock                    copy of the body that yz-series.js
 *                                     adds to <body>, see "docked copy"
 *  .ppseries-nav-landmark             end of .entry: link to the next part
 *  .yz-series-archive                 templates/taxonomy-series.php
 *
 *  The panel starts as a box at the top of the post on every screen. Once
 *  it has scrolled out of view (needs JS):
 *  >= 1180px  a copy fades in in the left margin. 1180 is the narrowest
 *             window that still leaves ~200px of margin beside the column.
 *  <  1180px  a thin bar shows at the top of the window; tapping it opens
 *             the full list as a drawer from the left.
 *
 *  Type follows the parent theme: small labels are 12px, weight 400,
 *  uppercase, light grey; titles are weight 600 at most.
 *
 *  Colour: the parent theme's "light" scheme is the dark grey one and
 *  "dark" is the brown one; both are light text on a dark ground.
 * ------------------------------------------------------------------------- */

body {
	--yz-fg: rgba(255, 255, 255, 0.8);
	--yz-muted: rgba(255, 255, 255, 0.45);
	--yz-label: rgba(255, 255, 255, 0.3); /* the theme's label grey */
	--yz-line: rgba(255, 255, 255, 0.09);
	--yz-glass: rgba(255, 255, 255, 0.035);
	--yz-sheet: rgba(40, 40, 40, 0.97);
	--yz-thumb-bg: #1e1e1e;
	--yz-accent: #43caff;
	--yz-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.07);
	--yz-card-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
body.dark {
	--yz-sheet: rgba(34, 26, 14, 0.97);
	--yz-thumb-bg: #181106;
	--yz-accent: #de6933;
}

.yz-series,
.yz-series-archive {
	line-height: 1.4;
}

/* Small uppercase labels, the theme's "Previous" / "Next" style. */
.yz-s-label,
.yz-s-kicker {
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: var(--yz-label);
}

/* ============================================================ panel */

.yz-series { font-size: 14px; margin: 0 0 32px; }

.yz-series-body {
	box-sizing: border-box;
	padding: 16px 12px 10px;
	border-radius: 18px;
	background: var(--yz-glass);
	box-shadow: var(--yz-shadow);
	-webkit-backdrop-filter: blur(24px);
	backdrop-filter: blur(24px);
}

.yz-s-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 0 6px;
}
.yz-s-where { font-size: 12px; color: var(--yz-muted); }

.yz-series-body a.yz-s-name,
.yz-series-body a.yz-s-name:visited {
	display: block;
	margin: 4px 6px 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--yz-fg);
	text-decoration: none;
}
.yz-series-body a.yz-s-name:hover { color: var(--yz-accent); }

.yz-s-progress {
	height: 2px;
	margin: 10px 6px;
	border-radius: 2px;
	background: var(--yz-line);
	overflow: hidden;
}
.yz-s-progress span {
	display: block;
	height: 100%;
	background: var(--yz-accent);
}

/* --- PublishPress list box, reset and restyled --- */

.yz-series-body .pps-post-list-box {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}
.yz-series-body .pps-post-list-title { display: none; }

.yz-series-body .pps-post-list {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
/* The rail through the thumbnails, like the home timeline's. */
.yz-series-body .pps-post-list:before {
	content: "";
	position: absolute;
	left: 29px;
	top: 28px;
	bottom: 28px;
	width: 2px;
	border-radius: 2px;
	background: var(--yz-line);
}

.yz-series-body .pps-post-item {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 8px 10px;
	border: 0;
	border-radius: 12px;
	background: none;
	transition: background-color .2s ease;
}
.yz-series-body .pps-post-item:hover { background: rgba(255, 255, 255, 0.05); }
.yz-series-body .pps-post-item.current-post {
	background: color-mix(in srgb, var(--yz-accent) 12%, transparent);
}

.yz-series-body .pps-post-thumbnail { flex: 0 0 40px; position: relative; }
.yz-series-body .pps-post-thumbnail a { display: block; }
.yz-series-body .pps-post-thumbnail img {
	display: block;
	width: 40px;
	height: 40px;
	margin: 0;
	border-radius: 10px;
	object-fit: cover;
	background: var(--yz-thumb-bg); /* hides the rail behind transparent images */
	box-shadow: 0 0 0 1px var(--yz-line);
	filter: saturate(0.7) brightness(0.85);
	transition: filter .2s ease;
}
.yz-series-body .pps-post-item:hover .pps-post-thumbnail img,
.yz-series-body .pps-post-item.current-post .pps-post-thumbnail img { filter: none; }
.yz-series-body .pps-post-item.current-post .pps-post-thumbnail img {
	box-shadow: 0 0 0 2px var(--yz-accent);
}

/* Title block: kicker on top, then name, then subtitle. */
.yz-series-body .pps-post-content {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.yz-series-body .pps-post-content .yz-s-kicker { order: -1; font-size: 11px; }
.yz-series-body .current-post .yz-s-kicker { color: var(--yz-accent); }

.yz-series-body .pps-post-title {
	margin: 0;
	padding: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	letter-spacing: normal;
}
.yz-series-body .current-post .pps-post-title { font-weight: 600; }
/* :visited too: the theme colours visited links, which would make parts
   the reader has opened look like a different kind of link. */
.yz-series-body .pps-post-title a,
.yz-series-body .pps-post-title a:visited {
	color: var(--yz-fg);
	text-decoration: none;
}
.yz-series-body .pps-post-title a:hover { color: var(--yz-accent); }
/* Make the whole row clickable through the title link. */
.yz-series-body .pps-post-title a:after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 12px;
}

.yz-s-sub {
	font-size: 12px;
	color: var(--yz-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---------------------------------------------------- docked copy */
/* yz-series.js appends this to <body> once the box above has scrolled
   out of view:
     .yz-series-dock
       button.yz-series-open    narrow: pill (phones) or edge handle
       .yz-series-scrim         narrow: dims the page behind the drawer
       .yz-series-drawer        wide: left panel; narrow: drawer
         button.yz-series-close
         .yz-series-body        copy of the box
   --yz-top is where the window's top edge effectively is (below a fixed
   header), --yz-gap is the left edge of the post column. Both are set by
   the script. */

.yz-series-dock {
	--yz-top: 0px;
	--yz-gap: 240px;
	font-size: 14px;
	line-height: 1.4;
}
.yz-series-open,
.yz-series-scrim,
.yz-series-close { display: none; }

.yz-series-drawer {
	position: fixed;
	z-index: 95;
	visibility: hidden;
	opacity: 0;
}

/* Wide: a panel in the left margin, beside the column. */
@media only screen and (min-width: 1180px) {
	.yz-series-drawer {
		top: calc(var(--yz-top) + 30px);
		left: max(16px, calc(var(--yz-gap) - 32px - 290px));
		width: min(290px, calc(var(--yz-gap) - 48px));
		transition: opacity .25s ease, visibility 0s linear .25s;
	}
	.yz-series-drawer .yz-series-body {
		max-height: calc(100vh - var(--yz-top) - 60px);
		overflow-y: auto;
		scrollbar-width: thin;
	}
	.yz-series-dock.is-on .yz-series-drawer {
		visibility: visible;
		opacity: 1;
		transition: opacity .25s ease;
	}
}

/* Narrow: an opener (button / handle); the full list opens as a drawer. */
@media only screen and (max-width: 1179px) {
	.yz-series-open {
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		z-index: 95;
		box-sizing: border-box;
		margin: 0;
		padding: 0;
		border: 0;
		color: var(--yz-fg);
		background: var(--yz-sheet);
		box-shadow: var(--yz-shadow);
		-webkit-backdrop-filter: blur(20px);
		backdrop-filter: blur(20px);
		cursor: pointer;
		visibility: hidden;
		opacity: 0;
		transition: opacity .2s ease, width .2s ease, visibility 0s linear .2s;
	}
	.yz-series-dock.is-on .yz-series-open {
		visibility: visible;
		opacity: 1;
		transition: opacity .2s ease, width .2s ease;
	}
	.yz-series-open:hover,
	.yz-series-open[aria-expanded="true"] { color: var(--yz-accent); }
	.yz-series-open svg { width: 20px; height: 20px; }
	.yz-open-chev,
	.yz-open-where { display: none; }

	.yz-series-scrim {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 100000; /* above the admin bar */
		background: rgba(0, 0, 0, 0.55);
		visibility: hidden;
		opacity: 0;
		transition: opacity .28s ease, visibility 0s linear .28s;
	}
	/* The drawer is the same card as the wide panel, sliding in from the
	   left. Its ground is nearly opaque because it covers the text. */
	.yz-series-drawer {
		left: 12px;
		z-index: 100001;
		box-sizing: border-box;
		width: min(320px, calc(100vw - 24px));
		opacity: 1;
		transform: translateX(calc(-100% - 24px));
		transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
	}
	.yz-series-dock.is-open .yz-series-scrim,
	.yz-series-dock.is-open .yz-series-drawer {
		visibility: visible;
		opacity: 1;
		transform: none;
		transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
	}
	.yz-series-drawer .yz-series-body {
		max-height: var(--yz-drawer-max, 80vh);
		overflow-y: auto;
		scrollbar-width: thin;
		background: color-mix(in srgb, var(--yz-sheet) 94%, transparent);
	}
	.yz-series-drawer .yz-s-head { padding-right: 36px; }

	.yz-series-close {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 9px;
		right: 9px;
		z-index: 1;
		width: 30px;
		height: 30px;
		margin: 0;
		padding: 0;
		border: 0;
		border-radius: 50%;
		color: var(--yz-muted);
		background: rgba(255, 255, 255, 0.06);
		cursor: pointer;
	}
	.yz-series-close:hover { color: var(--yz-fg); }
	.yz-series-close svg { width: 16px; height: 16px; }

	html.yz-series-lock { overflow: hidden; }
}

/* Phones: a small pill bottom-left (list icon and k/n), on the drawer's
   side, in thumb reach. */
@media only screen and (max-width: 1023px) {
	.yz-series-open {
		gap: 8px;
		left: 16px;
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		height: 48px;
		padding: 0 18px 0 16px;
		border-radius: 999px;
	}
	.yz-open-where {
		display: inline;
		font-size: 14px;
		font-weight: 500;
		font-variant-numeric: tabular-nums;
		line-height: 1;
	}
	.yz-series-drawer {
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		--yz-drawer-max: calc(100vh - 32px - env(safe-area-inset-bottom, 0px));
	}
}

/* Narrow desktop windows: a handle on the left edge. A mouse cannot trigger
   the edge-swipe "back" gesture that makes a handle risky on phones. */
@media only screen and (min-width: 1024px) and (max-width: 1179px) {
	.yz-series-open {
		left: 0;
		top: calc(var(--yz-top) + (100vh - var(--yz-top)) / 2 - 32px);
		width: 20px;
		height: 64px;
		border-radius: 0 12px 12px 0;
		color: var(--yz-fg);
		background: rgba(255, 255, 255, 0.12);
		box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
	}
	.yz-series-open:hover,
	.yz-series-open:focus-visible { width: 26px; }
	.yz-series-drawer {
		top: calc(var(--yz-top) + 30px);
		width: 290px;
		--yz-drawer-max: calc(100vh - var(--yz-top) - 60px);
	}
	.yz-open-list { display: none; }
	.yz-open-chev { display: block; }
	.yz-series-open svg { width: 16px; height: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.yz-series-dock * { transition: none !important; }
}

@media print {
	.yz-series,
	.yz-series-dock { display: none; }
}

/* =================================================== next part link */
/* PublishPress' series navigation, set to show the next part only (see
   yz-series.php). One row in the theme's card style: thumbnail, label,
   short title, chevron. */

.ppseries-nav-landmark { margin: 40px 0 24px; line-height: 1.4; }

.ppseries-nav-landmark .pps-navigation-content {
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
}
.ppseries-nav-landmark .pps-nav-series-title { display: none; }
.ppseries-nav-landmark .pps-nav-links { display: block; }

.entry .ppseries-nav-landmark a.pps-nav-link,
.entry .ppseries-nav-landmark a.pps-nav-link:visited {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 16px 20px;
	border: 0;
	border-radius: 20px;
	color: var(--yz-fg);
	text-decoration: none;
	background: rgba(255, 255, 255, 0.06);
	box-shadow: var(--yz-card-shadow);
}

.ppseries-nav-landmark .pps-nav-featured-image {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	margin: 0;
	border-radius: 12px;
	object-fit: cover;
	background: var(--yz-thumb-bg);
}

.ppseries-nav-landmark .pps-nav-link-text {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.25;
}
.ppseries-nav-landmark .pps-nav-next .pps-nav-link-text:before {
	content: "Next in series";
	display: block;
	margin-bottom: 2px;
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: var(--yz-label);
}
/* Chinese side of the site: "Xi Lie Xia Yi Pian" (next in series). */
.ppseries-nav-landmark .pps-nav-next .pps-nav-link-text:lang(zh):before {
	content: "\7CFB\5217\4E0B\4E00\7BC7";
	letter-spacing: 0;
}

/* PublishPress draws an arrow (line + chevron); the theme uses a chevron. */
.ppseries-nav-landmark .pps-nav-arrow {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	color: inherit;
	transition: color .2s ease-out;
}
.ppseries-nav-landmark .pps-nav-arrow line { display: none; }
.entry .ppseries-nav-landmark a.pps-nav-link:hover .pps-nav-arrow { color: var(--yz-accent); }

/* ===================================================== series archive */

.yz-sa-head { margin: 0 0 32px; }
.yz-sa-title {
	margin: 6px 0 10px;
	font-size: 42px;
	font-weight: 600;
	letter-spacing: -0.04em;
	line-height: 1.2;
	color: var(--yz-fg);
}
.yz-sa-desc { margin: 0 0 10px; font-size: 17px; color: rgba(255, 255, 255, 0.6); }
.yz-sa-desc p { margin: 0 0 8px; }

.yz-sa-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 18px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.yz-sa-item { margin: 0; padding: 0; list-style: none; }

.yz-s-card,
.yz-s-card:visited {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	border-radius: 16px;
	color: var(--yz-fg);
	text-decoration: none;
	background: rgba(255, 255, 255, 0.06);
	box-shadow: var(--yz-card-shadow);
	transition: transform .25s ease, box-shadow .25s ease;
}
.yz-s-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.yz-s-card-img { display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.yz-s-card-img img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	transition: transform .4s ease;
}
.yz-s-card:hover .yz-s-card-img img { transform: scale(1.03); }
.yz-s-card-text { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 18px; }
.yz-s-card-title { font-size: 18px; font-weight: 600; }
.yz-s-card-sub { font-size: 14px; color: var(--yz-muted); }
.yz-s-card-excerpt {
	font-size: 14px;
	color: var(--yz-muted);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.yz-s-card-date { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--yz-muted); }
