/*
 * The default listing page.
 *
 * The governing rule here is that this file sets LAYOUT and almost never sets
 * TYPE OR COLOUR. Fonts, text colour and page background are left entirely
 * alone so they inherit from the theme — which is why a page rendered by this
 * looks like the rest of the site rather than like a plugin.
 *
 * Where a colour genuinely is needed — the price, the active tab, the brochure
 * button — it comes from --bsh-accent, which the template sets inline from the
 * PDF Accent Colour setting, with --bsh-accent-ink as readable text on top of
 * it. One setting drives the listing page and the brochure it generates, so the
 * two cannot disagree.
 *
 * Rules and tints stay derived from currentColor, which can never clash because
 * it is by definition a colour the theme already chose. Only the accent itself
 * is configured.
 */

.bsh-listing {
	/*
	 * --bsh-accent and --bsh-accent-ink are set inline on this element from the
	 * PDF Accent Colour setting, so a listing page and the brochure it generates
	 * are the same colour. These are the values used if that ever fails.
	 *
	 * The previous default was currentColor, which was wrong in a way worth
	 * remembering: the button set `color` on itself and then read
	 * `background: currentColor`, which resolved to the colour it had just been
	 * given rather than the inherited one — so it rendered white on white. A
	 * colour used as a background must not be defined in terms of the text
	 * colour of the element painting it.
	 */
	--bsh-accent: #0A2872;
	--bsh-accent-ink: #ffffff;
	--bsh-rule: color-mix(in srgb, currentColor 14%, transparent);
	--bsh-tint: color-mix(in srgb, currentColor 5%, transparent);
	--bsh-gap: clamp(1.25rem, 3vw, 2.5rem);

	max-width: var(--wp--style--global--wide-size, 1200px);
	margin-inline: auto;
	padding-inline: clamp(1rem, 4vw, 2rem);
	padding-block: var(--bsh-gap);
}

/* Browsers without color-mix get a grey that reads on light and dark alike. */
@supports not (color: color-mix(in srgb, red 50%, transparent)) {
	.bsh-listing {
		--bsh-rule: rgba(128, 128, 128, 0.3);
		--bsh-tint: rgba(128, 128, 128, 0.08);
	}
}

/* ---------------------------------------------------------------- gallery */

.bsh-gallery__main {
	margin: 0;
	aspect-ratio: 16 / 9;
	background: var(--bsh-tint);
	overflow: hidden;
	border-radius: 6px;
}

/* The whole image is the button that opens the viewer. Bare, so it looks like
   the photograph it wraps and not like a control. */
.bsh-gallery__open {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
}

.bsh-gallery__main img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ------------------------------------------------------- full-screen view */

.bsh-lightbox {
	position: fixed;
	inset: 0;
	/* Above sticky theme headers, which routinely sit in the thousands. */
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: clamp(0.5rem, 3vw, 2.5rem);
	background: rgba(0, 0, 0, 0.92);
	cursor: zoom-out;
}

/* [hidden] loses to display:flex without this. */
.bsh-lightbox[hidden] { display: none; }

/* The page behind must not scroll while the viewer is over it. */
body.bsh-lightbox-open { overflow: hidden; }

.bsh-lightbox__figure {
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: default;
}

.bsh-lightbox__figure img {
	max-width: 100%;
	/* Room for the counter beneath without the image ever being cropped. */
	max-height: calc(100vh - 6rem);
	width: auto;
	height: auto;
	display: block;
	object-fit: contain;
}

.bsh-lightbox__close,
.bsh-lightbox__nav {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transition: background .15s ease-in-out;
}

.bsh-lightbox__close:hover,
.bsh-lightbox__nav:hover { background: rgba(255, 255, 255, 0.28); }

.bsh-lightbox__nav { width: 52px; height: 52px; }

.bsh-lightbox__close {
	position: absolute;
	top: clamp(0.5rem, 2vw, 1.5rem);
	right: clamp(0.5rem, 2vw, 1.5rem);
	width: 44px;
	height: 44px;
}

.bsh-lightbox__count {
	position: absolute;
	bottom: clamp(0.5rem, 2vw, 1.5rem);
	left: 0;
	right: 0;
	margin: 0;
	text-align: center;
	color: rgba(255, 255, 255, 0.75);
	font-size: 0.85rem;
}

/* On a phone the arrows would take most of the width, so they sit over the
   photograph's edges rather than beside it. */
@media (max-width: 600px) {
	.bsh-lightbox { padding: 0.5rem; }
	.bsh-lightbox__nav {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		width: 44px;
		height: 44px;
	}
	.bsh-lightbox__nav--prev { left: 0.5rem; }
	.bsh-lightbox__nav--next { right: 0.5rem; }
}

.bsh-gallery__strip {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-top: 0.5rem;
}

.bsh-gallery__arrow {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 62px;
	padding: 0;
	border: 1px solid var(--bsh-rule);
	border-radius: 4px;
	background: var(--bsh-tint);
	color: inherit;
	cursor: pointer;
}

.bsh-gallery__arrow:hover { background: var(--bsh-rule); }

.bsh-gallery__thumbs {
	display: flex;
	gap: 0.5rem;
	list-style: none;
	margin: 0;
	padding: 0 0 0.25rem;
	overflow-x: auto;
	scroll-behavior: smooth;
	/* Firefox; the WebKit equivalent is below. */
	scrollbar-width: thin;
}

.bsh-gallery__thumbs::-webkit-scrollbar { height: 6px; }
.bsh-gallery__thumbs::-webkit-scrollbar-thumb {
	background: var(--bsh-rule);
	border-radius: 3px;
}

/*
 * Flex items shrink by default, and with twenty thumbnails in the strip they
 * were compressed to slivers a few pixels wide instead of overflowing — which
 * is why the strip could not be scrolled: there was nothing overflowing to
 * scroll. Refusing to shrink is what makes both the size and the scrolling
 * work.
 */
.bsh-gallery__thumbs > li {
	flex: 0 0 auto;
}

.bsh-gallery__thumb {
	border: 2px solid transparent;
	background: none;
	padding: 0;
	cursor: pointer;
	border-radius: 4px;
	overflow: hidden;
	display: block;
	line-height: 0;
}

.bsh-gallery__thumb.is-current {
	border-color: var(--bsh-accent);
}

.bsh-gallery__thumb img {
	width: 92px;
	height: 62px;
	object-fit: cover;
	display: block;
}

/* ------------------------------------------------------------------- head */

.bsh-listing__head {
	display: flex;
	flex-wrap: wrap;
	gap: var(--bsh-gap);
	align-items: flex-start;
	justify-content: space-between;
	margin-block: var(--bsh-gap);
}

.bsh-listing__intro {
	flex: 1 1 22rem;
}

/* No font-size or font-family: the theme's h1 is the site's h1. */
.bsh-listing__title {
	margin: 0 0 0.35em;
}

.bsh-listing__location {
	margin: 0 0 0.5em;
	opacity: 0.75;
}

.bsh-listing__price {
	margin: 0;
	font-size: 1.5em;
	font-weight: 700;
	color: var(--bsh-accent);
}

.bsh-listing__tags {
	margin: 0.75em 0 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.bsh-tag {
	font-size: 0.8em;
	padding: 0.25em 0.7em;
	border-radius: 999px;
	background: var(--bsh-tint);
	border: 1px solid var(--bsh-rule);
}

.bsh-listing__finance {
	margin-top: 0.6em;
	font-size: 0.9em;
	opacity: 0.8;
}

.bsh-listing__finance p { margin: 0; }

.bsh-listing__actions {
	flex: 0 1 18rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

/*
 * The brochure button.
 *
 * Styled here rather than left to the shortcode, because the shortcode ships a
 * bare <button> with no styling of its own — on a theme that does not style
 * buttons it rendered as a grey sliver a few pixels wide, which is what it
 * looked like on the first live page.
 *
 * .rightboat-pdf-button is the shortcode's own class, matched as well as ours,
 * so the button is styled even if the class attribute is ever dropped.
 */
.bsh-listing__actions .rightboat-pdf-form { margin: 0; }

.bsh-listing__actions .bsh-btn,
.bsh-listing__actions .rightboat-pdf-button {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 0.85em 1.4em;
	border: 1px solid var(--bsh-accent);
	border-radius: 6px;
	background: var(--bsh-accent);
	color: var(--bsh-accent-ink);
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: opacity .15s ease-in-out;
}

.bsh-listing__actions .bsh-btn:hover,
.bsh-listing__actions .rightboat-pdf-button:hover {
	opacity: 0.88;
}



/* ------------------------------------------------------------- highlights */

.bsh-highlights {
	list-style: none;
	margin: 0 0 var(--bsh-gap);
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
	gap: 1px;
	background: var(--bsh-rule);
	border: 1px solid var(--bsh-rule);
	border-radius: 6px;
	overflow: hidden;
}

.bsh-highlight {
	background: var(--wp--preset--color--base, #fff);
	padding: 0.9rem 1rem;
	text-align: center;
}

/* The theme's own background, whatever it is, rather than a white card on a
   dark site. */
@supports not (background: var(--wp--preset--color--base)) {
	.bsh-highlight { background: transparent; }
}

.bsh-highlight__label {
	display: block;
	font-size: 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.65;
	margin-bottom: 0.25em;
}

.bsh-highlight__value {
	display: block;
	font-weight: 600;
}

/* ----------------------------------------------------------------- panels */

.bsh-panels__nav {
	display: flex;
	gap: 0.25rem;
	border-bottom: 1px solid var(--bsh-rule);
	margin-bottom: var(--bsh-gap);
	overflow-x: auto;
}

.bsh-panels__tab {
	appearance: none;
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	padding: 0.7em 1.2em;
	cursor: pointer;
	font: inherit;
	color: inherit;
	opacity: 0.6;
	white-space: nowrap;
}

.bsh-panels__tab.is-current {
	opacity: 1;
	border-bottom-color: var(--bsh-accent);
	font-weight: 600;
}

.bsh-panels__panel > :first-child { margin-top: 0; }
.bsh-panels__panel > :last-child  { margin-bottom: 0; }

/* ------------------------------------------------------------------ specs */

.bsh-specs {
	width: 100%;
	border-collapse: collapse;
}

.bsh-specs th,
.bsh-specs td {
	text-align: left;
	padding: 0.7em 0.9em;
	border-bottom: 1px solid var(--bsh-rule);
	vertical-align: top;
}

.bsh-specs th {
	width: 40%;
	font-weight: 600;
	opacity: 0.75;
}

.bsh-specs tr:nth-child(odd) th,
.bsh-specs tr:nth-child(odd) td {
	background: var(--bsh-tint);
}

/* ------------------------------------------------------- enquiry, similar */

.bsh-enquiry,
.bsh-similar {
	margin-top: calc(var(--bsh-gap) * 1.5);
	padding-top: var(--bsh-gap);
	border-top: 1px solid var(--bsh-rule);
}

.bsh-enquiry__title,
.bsh-similar__title {
	margin-top: 0;
}

/* The grid brings its own card CSS; it only needs room to breathe in here. */
.bsh-similar .rb-boat-grid { margin-top: 0.5rem; }

/* --------------------------------------------------------------- narrower */

@media (max-width: 640px) {
	.bsh-listing__actions {
		flex: 1 1 100%;
	}

	.bsh-specs th {
		width: 50%;
	}
}
