/*
 * Modern DFFS theme gallery. Uses the site theme's tokens (tokens.css), with fallbacks so the
 * plugin still reads correctly under another theme. Theme CSS itself never reaches this page:
 * it only ever loads inside the sandboxed preview iframes.
 */

.dffs-tg { margin-top: var(--mdffs-space-6, 1.5rem); }
.dffs-tg-requires { color: var(--mdffs-muted, #5a6577); font-size: 0.95rem; }

/* ---------- Filter + sort bar ---------- */
/* Every link the plugin styles carries a class: the site's prose-link rule
   (`.mdffs-body a:not([class])`, 0,2,1, loaded after this file) skips classed links,
   and would otherwise turn the current pill's white text blue on a blue fill. */
.dffs-tg-toolbar {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
	gap: var(--mdffs-space-3, 0.75rem); margin: var(--mdffs-space-6, 1.5rem) 0;
}
.dffs-tg-filters, .dffs-tg-sort { display: flex; flex-wrap: wrap; align-items: center; gap: var(--mdffs-space-2, 0.5rem); }
.dffs-tg-sort span { color: var(--mdffs-muted, #5a6577); font-size: 0.9rem; }
.dffs-tg-filters a, .dffs-tg-sort a {
	padding: 0.3em 0.85em; border: 1px solid var(--mdffs-line, #dbe2ec);
	border-radius: var(--mdffs-radius-pill, 999px); font-size: 0.9rem; text-decoration: none;
	color: var(--mdffs-body, #2c3542); background: var(--mdffs-surface, #fff);
}
.dffs-tg-filters a:hover, .dffs-tg-sort a:hover { border-color: var(--mdffs-primary, #2a5fd0); }
.dffs-tg-filters a[aria-current], .dffs-tg-sort a[aria-current] {
	background: var(--mdffs-primary, #2a5fd0); border-color: var(--mdffs-primary, #2a5fd0); color: #fff;
}

/* ---------- Card grid ---------- */
.dffs-tg-grid {
	list-style: none; margin: 0; padding: 0;
	display: grid; gap: var(--mdffs-space-6, 1.5rem); grid-template-columns: 1fr;
}
@media (min-width: 640px) { .dffs-tg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .dffs-tg-grid { grid-template-columns: repeat(3, 1fr); } }

.dffs-tg-card {
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--mdffs-surface, #fff); border: 1px solid var(--mdffs-line, #dbe2ec);
	border-radius: var(--mdffs-radius, 10px); box-shadow: var(--mdffs-shadow, 0 1px 2px rgba(16, 24, 40, .06));
}
.dffs-tg-card-body { padding: var(--mdffs-space-4, 1rem); display: flex; flex-direction: column; gap: var(--mdffs-space-2, 0.5rem); }
.dffs-tg-card h3 { margin: 0; font-size: 1.1rem; }
.dffs-tg-card h3 a { color: var(--mdffs-ink, #0f1c2e); text-decoration: none; }
.dffs-tg-card h3 a:hover { color: var(--mdffs-primary, #2a5fd0); text-decoration: underline; }

/* The thumbnail is the full preview rendered at 250% of the box and scaled to 40%, so it
   shows the preview at a real-form size. It starts at the "Form" section (about 570px down
   the template, at every width), past the three tab layouts, because fields and buttons
   say most about a theme. Clicks go to the card link, not the frame. */
.dffs-tg-thumb {
	position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden;
	background: #faf9f8; border-bottom: 1px solid var(--mdffs-line, #dbe2ec);
}
.dffs-tg-frame--thumb {
	position: absolute; top: -228px; left: 0; width: 250%; height: 1600px;
	border: 0; transform: scale(0.4); transform-origin: 0 0; pointer-events: none;
}

.dffs-tg-meta { margin: 0; color: var(--mdffs-muted, #5a6577); font-size: 0.9rem; }
.dffs-tg-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.dffs-tg-tags li {
	padding: 0.1em 0.6em; border-radius: var(--mdffs-radius-pill, 999px); font-size: 0.78rem;
	background: var(--mdffs-surface-alt, #f4f7fc); color: var(--mdffs-body, #2c3542); border: 1px solid var(--mdffs-line, #dbe2ec);
}
.dffs-tg-tags li.dffs-tg-extras { background: var(--mdffs-primary-050, #e9f0fb); color: var(--mdffs-primary-700, #204aa6); border-color: transparent; }

.dffs-tg-empty { color: var(--mdffs-muted, #5a6577); }

.dffs-tg-pages { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: var(--mdffs-space-8, 2rem); }
.dffs-tg-pages a, .dffs-tg-pages span {
	min-width: 2.2em; padding: 0.35em 0.6em; text-align: center; text-decoration: none;
	border: 1px solid var(--mdffs-line, #dbe2ec); border-radius: var(--mdffs-radius-sm, 6px);
}
.dffs-tg-pages span[aria-current] { background: var(--mdffs-primary, #2a5fd0); border-color: var(--mdffs-primary, #2a5fd0); color: #fff; }

/* ---------- Single theme ---------- */
.dffs-tg-single h1 { margin: 0.2em 0; }
.dffs-tg-single > .dffs-tg-tags { margin-top: var(--mdffs-space-2, 0.5rem); }
.dffs-tg-single-grid { display: grid; gap: var(--mdffs-space-8, 2rem); margin-top: var(--mdffs-space-6, 1.5rem); }
@media (min-width: 960px) { .dffs-tg-single-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }

.dffs-tg-single-preview .dffs-tg-frame {
	/* fit-frame.js sets the exact height. This fallback (no script) fits real themes, measured
	   at about 1,880px; the bare template is about 1,570px. Height doesn't change with width. */
	display: block; width: 100%; height: 1900px; border: 1px solid var(--mdffs-line, #dbe2ec);
	border-radius: var(--mdffs-radius, 10px); background: #faf9f8;
}
.dffs-tg-note { margin: var(--mdffs-space-2, 0.5rem) 0 0; color: var(--mdffs-muted, #5a6577); font-size: 0.9rem; }

.dffs-tg-single-side { display: flex; flex-direction: column; gap: var(--mdffs-space-6, 1.5rem); }
.dffs-tg-single-side .mdffs-btn { align-self: flex-start; }
.dffs-tg-description p { margin: 0 0 0.75em; }
.dffs-tg-howto {
	padding: var(--mdffs-space-4, 1rem) var(--mdffs-space-6, 1.5rem);
	border: 1px solid var(--mdffs-line, #dbe2ec); border-left: 4px solid var(--mdffs-primary, #2a5fd0);
	border-radius: var(--mdffs-radius-sm, 6px); background: var(--mdffs-surface-alt, #f4f7fc);
}
.dffs-tg-howto h2 { font-size: 1.1rem; margin: 0 0 0.5em; }
.dffs-tg-howto ol { margin: 0 0 0.75em; padding-left: 1.2em; }
.dffs-tg-howto p { margin: 0 0 0.5em; font-size: 0.95rem; }
.dffs-tg-license { margin: 0; color: var(--mdffs-muted, #5a6577); font-size: 0.9rem; }

/* ---------- Submission form (on top of the site's .mdffs-form) ---------- */
.dffs-tg-submit { margin-top: var(--mdffs-space-6, 1.5rem); }
.dffs-tg-submit a.dffs-tg-inline { color: var(--mdffs-primary, #2a5fd0); }
/* No single word left alone on the last line of a hint (ignored by browsers without support). */
.dffs-tg-submit .mdffs-form__note, .dffs-tg-submit p { text-wrap: pretty; }
/* The site styles every .mdffs-form input as a full-width box; checkboxes stay small. */
.dffs-tg-submit input[type="checkbox"] { width: auto; padding: 0; margin: 0 0.4em 0 0; vertical-align: -0.1em; }
.dffs-tg-submit input[type="file"] { padding: 0.45em 0.6em; }
.dffs-tg-tagpick { border: 0; padding: 0; flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.dffs-tg-tagpick legend { font-weight: 600; color: var(--mdffs-ink, #0f1c2e); font-size: 0.95rem; margin-bottom: 0.35rem; padding: 0; }
.dffs-tg-tagpick label, .dffs-tg-check label { font-weight: 400; }
.dffs-tg-paste summary, .dffs-tg-help summary { cursor: pointer; color: var(--mdffs-primary, #2a5fd0); font-weight: 600; }
.dffs-tg-paste textarea { margin-top: 0.5rem; font-family: var(--mdffs-font-mono, ui-monospace, Consolas, monospace); font-size: 0.85rem; }
.dffs-tg-help {
	margin-top: var(--mdffs-space-8, 2rem); padding: var(--mdffs-space-4, 1rem) var(--mdffs-space-6, 1.5rem);
	border: 1px solid var(--mdffs-line, #dbe2ec); border-radius: var(--mdffs-radius-sm, 6px); background: var(--mdffs-surface-alt, #f4f7fc);
}
.dffs-tg-help ul { padding-left: 1.2em; }
.dffs-tg-help li { margin-bottom: 0.5em; line-height: 1.6; }
.dffs-tg-dropped td:first-child { word-break: break-all; }
