/**
 * Frontend styles for the public resource catalog and detail page (spec
 * §12, §13, §31). No external assets (fonts, icons, CDNs) are loaded --
 * every visual comes from this file alone, and the type family is inherited
 * from the host theme so the plugin sits inside any design rather than
 * fighting it. The plugin owns rhythm, hierarchy, colour and its components;
 * it never imposes a typeface.
 *
 * @package DragonSolutions\Reservations
 */

/* -- Design tokens ---------------------------------------------------------- */
/* Defaults live on :root so a site can override them site-wide. The accent
   colours (--dr-primary / --dr-primary-hover / --dr-primary-tint /
   --dr-on-primary) are also emitted as an inline <style> from the plugin's
   Appearance settings (see Frontend\FrontendPalette), which wins by source
   order. Only --dr- prefixed names are defined, so nothing global is touched.
   This block is duplicated in frontend-form.css (the form can load without
   the catalog stylesheet) -- keep the two in sync. */

:root {
	--dr-ink: #1a2231;
	--dr-text: #3c4655;
	--dr-muted: #6b7686;
	--dr-line: #e6e9ee;
	--dr-line-strong: #d4d9e0;
	--dr-surface: #ffffff;
	--dr-panel: #f5f6f8;
	--dr-primary: #1e4a5f;
	--dr-primary-hover: #163a4b;
	--dr-primary-tint: #eaf1f3;
	--dr-on-primary: #ffffff;
	--dr-radius: 14px;
	--dr-radius-sm: 9px;
	--dr-shadow: 0 1px 2px rgba(20, 30, 45, 0.04), 0 10px 26px -14px rgba(20, 30, 45, 0.16);
	--dr-shadow-hover: 0 2px 6px rgba(20, 30, 45, 0.07), 0 20px 44px -18px rgba(20, 30, 45, 0.26);
}

/* -- Catalog grid ----------------------------------------------------------- */

/* Cards keep a comfortable minimum width and wrap to fit the available space,
   so a single item is never squeezed into a thin sliver and the grid adapts to
   the theme's content width on its own. The columns setting caps the maximum
   number per row via max-width (an upper bound, not a forced count). */
.dragon-catalog-grid {
	display: grid;
	/*
	 * auto-fit (not auto-fill) collapses the empty tracks a small catalog would
	 * otherwise leave behind, so a lone resource centres instead of clinging to
	 * a half-width column. The max MUST stay 1fr, not a fixed length: the
	 * auto-repeat count uses a definite max as the per-track width, so a fixed
	 * cap here (e.g. 340px) makes the browser fit only one wide track per row.
	 * The lone-card stretch that 1fr would otherwise cause is capped on the
	 * card itself (max-width + justify-self below), not on the track.
	 */
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 22px;
	margin: 28px auto;
}

/*
 * Cap and centre the card within its (possibly full-width) grid track. This is
 * what keeps a single-resource catalog from stretching one card edge to edge
 * while still letting many cards wrap into an even multi-column grid.
 */
.dragon-catalog-grid .dragon-resource-card {
	max-width: 340px;
	justify-self: center;
	width: 100%;
}

.dragon-catalog-columns-1 {
	max-width: 480px;
}

.dragon-catalog-columns-2 {
	max-width: 780px;
}

.dragon-catalog-columns-3 {
	max-width: 1080px;
}

.dragon-catalog-columns-4 {
	max-width: 1380px;
}

/* -- Filter toolbar --------------------------------------------------------- */

.dragon-catalog-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 14px 16px;
	align-items: flex-end;
	padding: 18px 20px;
	margin-bottom: 26px;
	background: var(--dr-panel);
	border: 1px solid var(--dr-line);
	border-radius: var(--dr-radius);
}

.dragon-catalog-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
	min-width: 160px;
	flex: 1 1 160px;
}

.dragon-catalog-field label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--dr-muted);
}

.dragon-catalog-field input,
.dragon-catalog-field select {
	box-sizing: border-box;
	width: 100%;
	padding: 9px 11px;
	font: inherit;
	line-height: 1.4;
	color: var(--dr-ink);
	background: var(--dr-surface);
	border: 1px solid var(--dr-line-strong);
	border-radius: var(--dr-radius-sm);
}

.dragon-catalog-field input:focus,
.dragon-catalog-field select:focus {
	outline: none;
	border-color: var(--dr-primary);
	box-shadow: 0 0 0 3px var(--dr-primary-tint);
}

.dragon-catalog-field-submit {
	justify-content: flex-end;
	flex: 0 0 auto;
	min-width: 0;
}

/* -- Resource card ---------------------------------------------------------- */

.dragon-resource-card {
	display: flex;
	flex-direction: column;
	background: var(--dr-surface);
	border: 1px solid var(--dr-line);
	border-radius: var(--dr-radius);
	overflow: hidden;
	box-shadow: var(--dr-shadow);
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.dragon-resource-card:hover,
.dragon-resource-card:focus-within {
	transform: translateY(-3px);
	box-shadow: var(--dr-shadow-hover);
	border-color: var(--dr-line-strong);
}

.dragon-resource-card-thumbnail {
	display: block;
	overflow: hidden;
	background: var(--dr-panel);
}

.dragon-resource-card-thumbnail img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.dragon-resource-card:hover .dragon-resource-card-thumbnail img {
	transform: scale(1.03);
}

.dragon-resource-card-placeholder {
	width: 100%;
	aspect-ratio: 3 / 2;
	background:
		linear-gradient(135deg, var(--dr-panel) 0%, #eceef2 100%);
}

.dragon-resource-card-body {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 20px;
	flex: 1;
}

.dragon-resource-card-title {
	margin: 0;
	font-size: 1.18rem;
	line-height: 1.25;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--dr-ink);
}

.dragon-resource-card-title a {
	color: inherit;
	text-decoration: none;
}

.dragon-resource-card-title a:hover {
	color: var(--dr-primary);
}

.dragon-resource-card-excerpt {
	margin: 0;
	color: var(--dr-text);
	line-height: 1.55;
	font-size: 0.95rem;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.dragon-resource-card-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	font-size: 0.82rem;
	color: var(--dr-muted);
	margin-top: 2px;
}

.dragon-resource-card-category::before {
	content: "";
}

.dragon-resource-card-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: auto;
	padding-top: 6px;
}

/* -- Buttons (own the look regardless of theme .button styles) -------------- */

.dragon-resource-card-reserve,
.dragon-reserve-primary {
	display: inline-flex;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	padding: 10px 18px;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	color: var( --dr-on-primary, #fff );
	background: var(--dr-primary);
	border: 1px solid var(--dr-primary);
	border-radius: var(--dr-radius-sm);
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
}

.dragon-resource-card-reserve:hover,
.dragon-reserve-primary:hover {
	background: var(--dr-primary-hover);
	border-color: var(--dr-primary-hover);
	color: var( --dr-on-primary, #fff );
}

.dragon-resource-card-reserve:active,
.dragon-reserve-primary:active {
	transform: translateY(1px);
}

.dragon-resource-card-detail {
	display: inline-flex;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	padding: 10px 18px;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	color: var(--dr-primary);
	background: transparent;
	border: 1px solid var(--dr-line-strong);
	border-radius: var(--dr-radius-sm);
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.dragon-resource-card-detail:hover {
	background: var(--dr-primary-tint);
	border-color: var(--dr-primary);
	color: var(--dr-primary);
}

/* Catalog filter submit ("Filter") -- the template gives it only .button. */
.dragon-catalog-field-submit button {
	display: inline-flex;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	color: var( --dr-on-primary, #fff );
	background: var(--dr-primary);
	border: 1px solid var(--dr-primary);
	border-radius: var(--dr-radius-sm);
	cursor: pointer;
	transition: background 0.15s ease;
}

.dragon-catalog-field-submit button:hover {
	background: var(--dr-primary-hover);
	border-color: var(--dr-primary-hover);
}

/* -- Status badge: text is always present, colour is never the only signal
      (spec §31). A small dot reinforces the state at a glance. --------------- */

.dragon-status-badge {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 4px 12px 4px 10px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	border: 1px solid transparent;
	white-space: nowrap;
}

.dragon-status-badge::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	flex: 0 0 auto;
}

.dragon-status-available {
	background: #e9f7ec;
	border-color: #b7e3c1;
	color: #146c2e;
}

.dragon-status-partially_available {
	background: #fdf4e3;
	border-color: #f0d9a6;
	color: #7a5200;
}

.dragon-status-unavailable {
	background: #fdecec;
	border-color: #f2c4c5;
	color: #9a2b2c;
}

.dragon-status-paused {
	background: #eef0f3;
	border-color: #d4d9e0;
	color: #4a5464;
}

/* -- Pagination ------------------------------------------------------------- */

.dragon-catalog-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 28px;
	justify-content: center;
}

.dragon-catalog-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--dr-line-strong);
	border-radius: var(--dr-radius-sm);
	color: var(--dr-ink);
	text-decoration: none;
	font-weight: 600;
}

.dragon-catalog-pagination .page-numbers:hover {
	border-color: var(--dr-primary);
	color: var(--dr-primary);
}

.dragon-catalog-pagination .page-numbers.current {
	background: var(--dr-primary);
	border-color: var(--dr-primary);
	color: var( --dr-on-primary, #fff );
}

/* -- Detail page ------------------------------------------------------------ */

.dragon-resource-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 16px;
	margin-bottom: 24px;
}

.dragon-resource-detail section {
	margin: 40px 0;
}

.dragon-section-title {
	margin: 0 0 16px;
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--dr-ink);
	position: relative;
	padding-bottom: 10px;
}

.dragon-section-title::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 42px;
	height: 3px;
	border-radius: 2px;
	background: var(--dr-primary);
}

.dragon-gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 12px;
}

.dragon-gallery-item img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: var(--dr-radius-sm);
	border: 1px solid var(--dr-line);
	transition: transform 0.2s ease;
}

.dragon-gallery-item:hover img {
	transform: scale(1.02);
}

.dragon-gallery-link {
	display: block;
	cursor: zoom-in;
}

body.dragon-lightbox-open {
	overflow: hidden;
}

.dragon-lightbox[hidden] {
	display: none;
}

.dragon-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	grid-template-columns: minmax(44px, 1fr) minmax(0, auto) minmax(44px, 1fr);
	align-items: center;
	gap: clamp(6px, 2vw, 24px);
	padding: clamp(12px, 3vw, 40px);
	background: rgba(5, 12, 18, 0.94);
	color: #fff;
}

.dragon-lightbox__figure {
	grid-column: 2;
	min-width: 0;
	margin: 0;
	text-align: center;
}

.dragon-lightbox__image {
	display: block;
	max-width: min(82vw, 1400px);
	max-height: calc(100vh - 110px);
	width: auto;
	height: auto;
	margin: 0 auto;
	object-fit: contain;
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

.dragon-lightbox__caption {
	min-height: 1.5em;
	margin-top: 10px;
	font-size: 0.9rem;
	color: rgba(255, 255, 255, 0.82);
}

.dragon-lightbox__button {
	display: inline-grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.45);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.35);
	color: #fff;
	font: inherit;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.dragon-lightbox__button[hidden] {
	display: none;
}

.dragon-lightbox__button:hover,
.dragon-lightbox__button:focus-visible {
	border-color: #fff;
	background: rgba(255, 255, 255, 0.16);
	outline: 2px solid transparent;
}

.dragon-lightbox__previous {
	grid-column: 1;
	justify-self: end;
}

.dragon-lightbox__next {
	grid-column: 3;
	justify-self: start;
}

.dragon-lightbox__close {
	position: absolute;
	top: max(12px, env(safe-area-inset-top));
	right: max(12px, env(safe-area-inset-right));
}

@media (max-width: 640px) {
	.dragon-lightbox {
		grid-template-columns: 1fr 1fr;
		grid-template-rows: minmax(0, 1fr) auto;
		padding: 56px 12px max(12px, env(safe-area-inset-bottom));
	}

	.dragon-lightbox__figure {
		grid-column: 1 / -1;
		grid-row: 1;
	}

	.dragon-lightbox__image {
		max-width: calc(100vw - 24px);
		max-height: calc(100vh - 150px);
	}

	.dragon-lightbox__previous,
	.dragon-lightbox__next {
		grid-row: 2;
		justify-self: center;
	}

	.dragon-lightbox__previous {
		grid-column: 1;
	}

	.dragon-lightbox__next {
		grid-column: 2;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dragon-gallery-item img,
	.dragon-lightbox__button {
		transition: none;
	}
}

.dragon-parameters-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.95rem;
}

.dragon-parameters-table th,
.dragon-parameters-table td {
	text-align: left;
	padding: 11px 14px;
	border-bottom: 1px solid var(--dr-line);
}

.dragon-parameters-table th {
	width: 40%;
	font-weight: 600;
	color: var(--dr-muted);
}

.dragon-parameters-table td {
	color: var(--dr-ink);
}

.dragon-parameters-table tr:last-child th,
.dragon-parameters-table tr:last-child td {
	border-bottom: 0;
}

.dragon-documents-list,
.dragon-links-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.dragon-document-item,
.dragon-link-item {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: var(--dr-surface);
	border: 1px solid var(--dr-line);
	border-radius: var(--dr-radius);
	padding: 14px 18px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dragon-document-item:hover,
.dragon-link-item:hover {
	border-color: var(--dr-line-strong);
	box-shadow: var(--dr-shadow);
}

.dragon-document-download {
	display: inline-flex;
	align-items: center;
	padding: 8px 16px;
	font-weight: 600;
	color: var(--dr-primary);
	border: 1px solid var(--dr-line-strong);
	border-radius: var(--dr-radius-sm);
	text-decoration: none;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.dragon-document-download:hover {
	background: var(--dr-primary-tint);
	border-color: var(--dr-primary);
}

.dragon-video-embed {
	margin: 0 0 12px;
}

.dragon-video-embed iframe {
	max-width: 100%;
	border-radius: var(--dr-radius-sm);
}

.dragon-resource-availability {
	background: var(--dr-panel);
	border: 1px solid var(--dr-line);
	border-radius: var(--dr-radius);
	padding: 24px;
}

.dragon-not-bookable-message {
	font-weight: 600;
	color: var(--dr-ink);
}

/* -- Sticky mobile reservation CTA (spec §13) ------------------------------- */

.dragon-sticky-cta {
	display: none;
}

@media (max-width: 600px) {
	.dragon-sticky-cta {
		display: block;
		position: sticky;
		bottom: 0;
		z-index: 100;
		width: 100%;
		box-sizing: border-box;
		padding: 15px 16px;
		text-align: center;
		text-decoration: none;
		font-weight: 700;
		background: var(--dr-primary);
		color: var( --dr-on-primary, #fff );
		box-shadow: 0 -6px 20px -10px rgba(20, 30, 45, 0.3);
	}
}

/* -- Responsive safety ------------------------------------------------------ */

.dragon-catalog-archive img,
.dragon-resource-detail img {
	max-width: 100%;
	height: auto;
}

@media (max-width: 600px) {
	.dragon-catalog-field,
	.dragon-catalog-field-submit {
		flex: 1 1 100%;
		min-width: 0;
	}

	.dragon-catalog-field-submit {
		justify-content: stretch;
	}

	.dragon-catalog-field-submit button {
		width: 100%;
	}

	.dragon-resource-card-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.dragon-resource-card-actions a {
		width: 100%;
	}

	.dragon-resource-availability {
		padding: 18px 16px;
	}
}

/* -- Accessibility (spec §31) ----------------------------------------------- */

.dragon-catalog-archive a:focus-visible,
.dragon-resource-detail a:focus-visible,
.dragon-catalog-filters input:focus-visible,
.dragon-catalog-filters select:focus-visible,
.dragon-catalog-filters button:focus-visible,
.dragon-resource-card a:focus-visible,
.dragon-document-download:focus-visible {
	outline: 2px solid var(--dr-primary);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.dragon-catalog-archive *,
	.dragon-catalog-grid *,
	.dragon-resource-detail * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}

	.dragon-resource-card:hover {
		transform: none;
	}

	.dragon-resource-card:hover .dragon-resource-card-thumbnail img {
		transform: none;
	}
}
