/* Trestle board grid + reader. Loaded only on pages that render boards. */

.tb-grid {
	display: grid;
	gap: 22px;
	grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
	margin: 0;
	padding: 0;
	list-style: none;
}

.tb-card {
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 0;
	text-align: left;
	font: inherit;
	color: inherit;
	cursor: pointer;
	text-decoration: none; /* .tb-card is an <a> — theme link styles must not apply */
	background: var(--wp--preset--color--surface, #fff);
	border: 1px solid var(--wp--preset--color--line, #e3e6ec);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
	transition: transform .16s ease, box-shadow .16s ease;
}

.tb-card:hover,
.tb-card:focus-visible {
	transform: translateY(-3px);
	box-shadow: 0 6px 12px rgba(16, 24, 40, .10), 0 18px 40px rgba(16, 24, 40, .14);
}

.tb-cover {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	object-position: top center;
	background: #dfe3ea;
	border-bottom: 1px solid var(--wp--preset--color--line, #e3e6ec);
}

.tb-cover--empty {
	display: grid;
	place-items: center;
	padding: 20px;
	text-align: center;
	font-size: 13px;
	color: var(--wp--preset--color--muted, #5b6478);
	background: repeating-linear-gradient(45deg, transparent, transparent 9px,
		rgba(127, 127, 127, .09) 9px, rgba(127, 127, 127, .09) 18px);
}

.tb-meta { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px 16px; }
.tb-year { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.tb-detail { font-size: 13.5px; color: var(--wp--preset--color--muted, #5b6478); }

.tb-badge {
	align-self: flex-start;
	margin-top: 9px;
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: #20180a;
	background: var(--wp--preset--color--gold, #c9a227);
}

.tb-card--empty { cursor: default; opacity: .72; }
.tb-card--empty:hover { transform: none; }

/* Reader */
.tb-viewer {
	width: min(1080px, 94vw);
	height: min(88vh, 940px);
	padding: 0;
	border: 0;
	border-radius: 14px;
	overflow: hidden;
	color: var(--wp--preset--color--ink, #101828);
	background: var(--wp--preset--color--surface, #fff);
	box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
}

.tb-viewer::backdrop { background: rgba(6, 10, 20, .72); }

.tb-vhead {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	padding: 12px 14px;
	border-bottom: 1px solid var(--wp--preset--color--line, #e3e6ec);
}

.tb-vtitle { margin-right: auto; font-size: 16px; font-weight: 700; }

.tb-btn {
	padding: 8px 13px;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: inherit;
	background: transparent;
	border: 1px solid var(--wp--preset--color--line, #e3e6ec);
	border-radius: 9px;
	cursor: pointer;
	text-decoration: none;
}

.tb-btn:hover { background: rgba(127, 127, 127, .12); }

.tb-btn--primary {
	color: #fff;
	background: var(--wp--preset--color--navy, #0b1f3f);
	border-color: var(--wp--preset--color--navy, #0b1f3f);
}

.tb-btn--primary:hover { background: var(--wp--preset--color--navy-mid, #132c55); }

/* Only when open — a bare display:flex would override the UA's display:none
   and leave the dialog visible while closed. */
.tb-viewer[open] { display: flex; flex-direction: column; }

/* Was calc(100% - 58px), which assumed a single-row header. The buttons wrap to
   two rows on a phone, so the fixed offset pushed the PDF below the fold. */
.tb-vhead { flex: 0 0 auto; }
.tb-vbody { flex: 1 1 auto; min-height: 0; background: #43474d; }
.tb-vbody iframe { display: block; width: 100%; height: 100%; border: 0; }

@media (max-width: 560px) {
	.tb-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
	/* The UA stylesheet puts max-width/max-height and auto margins on <dialog>,
	   which clamp width:100vw to ~90% and leave it off-centre. Clear all three
	   or the reader never actually reaches the screen edges on a phone. */
	.tb-viewer {
		width: 100vw;
		height: 100dvh;
		max-width: none;
		max-height: none;
		margin: 0;
		border-radius: 0;
	}
}
