/*
 * Template Demo Gallery — front-end styles
 *
 * Design language: a "contact sheet" — the gallery cards borrow the
 * sprocket-hole strip and monospace frame labels of a film contact
 * sheet (a nod to mennerphoto.com's photography roots), while the
 * device frames stay closer to literal iPhone/iPad silhouettes, since
 * visitors need to recognise them at a glance.
 *
 * No web fonts are loaded — system font stacks only, so this plugin
 * never makes an external request from a visitor's browser.
 */

.tdg-gallery,
.tdg-viewer {
	--tdg-ink: #1b1a17;
	--tdg-paper: #f6f2e9;
	--tdg-paper-dim: #eae4d6;
	--tdg-safelight: #e2762e;
	--tdg-ash: #8b8578;
	--tdg-line: rgba(27, 26, 23, 0.14);
	--tdg-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--tdg-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
	box-sizing: border-box;
}

.tdg-gallery *,
.tdg-viewer *,
.tdg-gallery *::before,
.tdg-viewer *::before,
.tdg-gallery *::after,
.tdg-viewer *::after {
	box-sizing: inherit;
}

/* ----------------------------------------------------------------- */
/* Gallery grid & cards                                               */
/* ----------------------------------------------------------------- */

.tdg-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
	gap: 28px;
	margin: 1.5em 0;
}

@media (min-width: 700px) {
	.tdg-gallery {
		grid-template-columns: repeat(var(--tdg-columns, 3), 1fr);
	}
}

.tdg-empty {
	font-family: var(--tdg-sans);
	color: #666;
}

.tdg-card {
	appearance: none;
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 0;
	background: var(--tdg-paper);
	border: 1px solid var(--tdg-line);
	border-radius: 3px;
	text-align: left;
	cursor: pointer;
	font: inherit;
	color: var(--tdg-ink);
	overflow: hidden;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tdg-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 10px 24px rgba(27, 26, 23, 0.14);
}

.tdg-card:focus-visible {
	outline: 3px solid var(--tdg-safelight);
	outline-offset: 2px;
}

/* Sprocket-hole strip along the top edge, contact-sheet style. */
.tdg-card::before {
	content: "";
	display: block;
	height: 10px;
	background-color: var(--tdg-ink);
	background-image: radial-gradient(circle, var(--tdg-paper) 2.5px, transparent 2.6px);
	background-size: 16px 10px;
	background-position: 8px center;
	background-repeat: repeat-x;
}

.tdg-card-frame {
	display: block;
	aspect-ratio: 16 / 10;
	background: var(--tdg-paper-dim);
	overflow: hidden;
}

.tdg-card-frame img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tdg-card-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(
		135deg,
		var(--tdg-paper-dim),
		var(--tdg-paper-dim) 10px,
		var(--tdg-line) 10px,
		var(--tdg-line) 11px
	);
}

.tdg-card-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px 16px 18px;
}

.tdg-card-eyebrow {
	font-family: var(--tdg-mono);
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tdg-safelight);
}

.tdg-card-title {
	font-family: var(--tdg-sans);
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
}

.tdg-card-excerpt {
	font-family: var(--tdg-sans);
	font-size: 14px;
	line-height: 1.5;
	color: var(--tdg-ash);
}

.tdg-card-cta {
	margin-top: 8px;
	font-family: var(--tdg-mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--tdg-ink);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.tdg-card:hover .tdg-card-cta,
.tdg-card:focus-visible .tdg-card-cta {
	color: var(--tdg-safelight);
}

/* ----------------------------------------------------------------- */
/* Viewer overlay                                                     */
/* ----------------------------------------------------------------- */

.tdg-viewer {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: var(--tdg-ink);
	font-family: var(--tdg-sans);
}

.tdg-viewer[hidden] {
	display: none;
}

body.tdg-viewer-open {
	overflow: hidden;
}

.tdg-viewer-toolbar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 16px;
	background: var(--tdg-ink);
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	color: var(--tdg-paper);
}

.tdg-viewer-title {
	font-family: var(--tdg-mono);
	font-size: 13px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tdg-viewer-devices {
	display: flex;
	gap: 4px;
	margin: 0 auto;
	background: rgba(255, 255, 255, 0.06);
	border-radius: 999px;
	padding: 3px;
}

.tdg-device-btn {
	appearance: none;
	border: 0;
	background: transparent;
	color: var(--tdg-paper);
	font-family: var(--tdg-mono);
	font-size: 12px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	padding: 7px 14px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
}

.tdg-device-btn.is-active {
	background: var(--tdg-safelight);
	color: var(--tdg-ink);
}

.tdg-device-btn:focus-visible {
	outline: 2px solid var(--tdg-safelight);
	outline-offset: 2px;
}

.tdg-viewer-actions {
	display: flex;
	align-items: center;
	gap: 14px;
	flex: 0 0 auto;
}

.tdg-viewer-newtab {
	color: var(--tdg-paper);
	font-size: 13px;
	text-decoration: none;
	white-space: nowrap;
	opacity: 0.85;
}

.tdg-viewer-newtab:hover,
.tdg-viewer-newtab:focus-visible {
	opacity: 1;
	text-decoration: underline;
}

/* Only shown when the current demo has an uploaded zip file; sits to
   the right of the Desktop/Tablet/Mobile toggle, with extra spacing
   (margin-left) so it doesn't crowd it. */
.tdg-viewer-download {
	appearance: none;
	border: 1px solid var(--tdg-safelight);
	background: transparent;
	color: var(--tdg-safelight);
	font-family: var(--tdg-mono);
	font-size: 12px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	padding: 7px 14px;
	border-radius: 999px;
	margin-left: 24px;
	cursor: pointer;
}

.tdg-viewer-download[hidden] {
	display: none;
}

.tdg-viewer-download:hover,
.tdg-viewer-download:focus-visible {
	background: var(--tdg-safelight);
	color: var(--tdg-ink);
}

.tdg-viewer-close {
	appearance: none;
	border: 1px solid rgba(255, 255, 255, 0.3);
	background: transparent;
	color: var(--tdg-paper);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.tdg-viewer-close:hover,
.tdg-viewer-close:focus-visible {
	border-color: var(--tdg-safelight);
	color: var(--tdg-safelight);
}

.tdg-viewer-stage {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	padding: 24px;
}

/* ----------------------------------------------------------------- */
/* Device frame                                                       */
/* ----------------------------------------------------------------- */

.tdg-device-frame {
	position: relative;
	background: #000;
	transition: width 0.25s ease, height 0.25s ease, border-radius 0.25s ease;
}

.tdg-device-screen {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: var(--tdg-paper);
}

.tdg-viewer-iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

.tdg-viewer-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--tdg-mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--tdg-ash);
	background: var(--tdg-paper);
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.tdg-viewer-loading[hidden] {
	opacity: 0;
}

/* Desktop: a plain browser-style window, no bezel. */
.tdg-device-frame[data-device="desktop"] {
	width: min(100%, 1180px);
	height: 100%;
	max-height: 720px;
	border-radius: 8px;
	padding: 30px 0 0;
}

.tdg-device-frame[data-device="desktop"]::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 30px;
	background-color: #26241f;
	border-radius: 8px 8px 0 0;
	background-repeat: no-repeat;
	background-position: 16px center, 36px center, 56px center;
	background-image: radial-gradient(circle, #e2762e 3.5px, transparent 3.6px),
		radial-gradient(circle, #55524a 3.5px, transparent 3.6px),
		radial-gradient(circle, #55524a 3.5px, transparent 3.6px);
	background-size: 8px 8px;
}

.tdg-device-frame[data-device="desktop"] .tdg-device-screen {
	border-radius: 0 0 8px 8px;
}

/* Tablet: iPad-like — thick bezel, single camera dot, no home button. */
.tdg-device-frame[data-device="tablet"] {
	width: 560px;
	height: 760px;
	max-width: 100%;
	max-height: 100%;
	border-radius: 34px;
	padding: 22px 16px;
	box-shadow: 0 0 0 2px #2b2a26 inset;
}

.tdg-device-frame[data-device="tablet"]::before {
	content: "";
	position: absolute;
	top: 9px;
	left: 50%;
	transform: translateX(-50%);
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #3a3833;
}

.tdg-device-frame[data-device="tablet"] .tdg-device-screen {
	border-radius: 14px;
}

/* Mobile: iPhone-like — notch, side buttons, rounded corners. */
.tdg-device-frame[data-device="mobile"] {
	width: 375px;
	height: 760px;
	max-width: 100%;
	max-height: 100%;
	border-radius: 46px;
	padding: 14px 10px;
	box-shadow: 0 0 0 2px #2b2a26 inset;
}

.tdg-device-frame[data-device="mobile"]::before {
	content: "";
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%);
	width: 120px;
	height: 26px;
	background: #000;
	border-radius: 14px;
	z-index: 1;
}

.tdg-device-frame[data-device="mobile"]::after {
	content: "";
	position: absolute;
	right: -2px;
	top: 120px;
	width: 3px;
	height: 60px;
	background: #2b2a26;
	border-radius: 2px 0 0 2px;
}

.tdg-device-frame[data-device="mobile"] .tdg-device-screen {
	border-radius: 32px;
}

@media (prefers-reduced-motion: reduce) {
	.tdg-card,
	.tdg-device-frame,
	.tdg-viewer-loading {
		transition: none;
	}
}

@media (max-width: 640px) {
	.tdg-viewer-toolbar {
		flex-wrap: wrap;
		row-gap: 8px;
	}

	.tdg-viewer-title {
		order: -1;
		flex: 1 1 100%;
		text-align: center;
	}

	.tdg-viewer-newtab {
		display: none;
	}
}
