/* ==========================================================================
   CGT OBS — sidebar.css
   Two-column layout, contextual side pane, archive toolbar & filters,
   grid/list views. Loaded on blog / archive / search / single contexts.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Tokens (aliased to the main.css palette; raw values as fallback)
   -------------------------------------------------------------------------- */
:root {
	--cgtobs-red: var(--cgt-red, #d71920);
	--cgtobs-red-dark: var(--cgt-red-hover, #b51218);
	--cgtobs-black: var(--cgt-black, #111111);
	--cgtobs-gray: var(--cgt-gray, #4f4f4f);
	--cgtobs-light: var(--cgt-bg-light, #f5f5f5);
	--cgtobs-white: var(--cgt-white, #ffffff);
	--cgtobs-border: rgba(17, 17, 17, 0.08);
	--cgtobs-radius: var(--cgt-radius, 10px);
	--cgtobs-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

	/* Overridden inline from the Customizer (sidebar width). */
	--cgtobs-sidebar-width: 340px;
	--cgtobs-gap: clamp(28px, 3.5vw, 40px);
}

/* --------------------------------------------------------------------------
   1. Two-column layout
   -------------------------------------------------------------------------- */
.cgtobs-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--cgtobs-sidebar-width);
	gap: var(--cgtobs-gap);
	align-items: start;
	margin-block: var(--cgt-space-lg, 2rem);
}

.cgtobs-layout__main {
	min-width: 0; /* allow children (grids, tables) to shrink instead of overflow */
}

/* No sidebar (globally disabled, or no blocks to show) → single column. */
.cgtobs-layout--full {
	grid-template-columns: minmax(0, 1fr);
}

.cgtobs-layout--full .cgtobs-layout__sidebar {
	display: none;
}

/* Sticky side pane on desktop only. */
@media (min-width: 1025px) {
	.cgtobs-layout__sidebar--sticky {
		position: sticky;
		top: 100px;
		/* Pin the pane to the viewport and let it scroll on its own when its
		   content is taller than the screen, so the bottom blocks stay reachable. */
		max-height: calc(100vh - 100px - 1.5rem);
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-gutter: stable;
		/* Slim, themed scrollbar (Firefox). */
		scrollbar-width: thin;
		scrollbar-color: rgba(17, 17, 17, 0.25) transparent;
	}

	/* Slim, themed scrollbar (WebKit / Blink). */
	.cgtobs-layout__sidebar--sticky::-webkit-scrollbar {
		width: 8px;
	}

	.cgtobs-layout__sidebar--sticky::-webkit-scrollbar-track {
		background: transparent;
	}

	.cgtobs-layout__sidebar--sticky::-webkit-scrollbar-thumb {
		background: rgba(17, 17, 17, 0.2);
		border-radius: 999px;
	}

	.cgtobs-layout__sidebar--sticky:hover::-webkit-scrollbar-thumb {
		background: var(--cgtobs-red);
	}
}

/* Stack on tablet / mobile: main content first, side pane below. */
@media (max-width: 1024px) {
	.cgtobs-layout {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* --------------------------------------------------------------------------
   2. Posts grid inside the narrower main column + list view
   -------------------------------------------------------------------------- */
/* Auto-fit columns so the grid adapts to the (reduced) main-column width. */
.cgtobs-layout__main .cgt-posts-grid {
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}


/* Single article inside the two-column layout: fill the (already narrowed)
   main column, capped for readability and left-aligned beside the side pane.
   When the side pane is disabled (--full), single-post.css centering applies. */
.cgtobs-layout:not(.cgtobs-layout--full) .cgtobs-layout__main .cgt-single__hero,
.cgtobs-layout:not(.cgtobs-layout--full) .cgtobs-layout__main .cgt-single__content,
.cgtobs-layout:not(.cgtobs-layout--full) .cgtobs-layout__main .cgt-single__narrow {
	max-width: 820px;
	margin-inline: 0;
}

/* Align the top of the main column with the top of the side pane: neutralise
   the leading top padding/margin of whatever sits first in the main column
   (archive section padding, single hero padding, etc.). */
.cgtobs-layout__main > :first-child {
	margin-top: 0;
}

.cgtobs-layout__main > .cgt-section,
.cgtobs-layout__main .cgt-single__hero {
	padding-top: 0;
}

/* List view — horizontal cards. */
.cgtobs-posts-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.cgtobs-posts-list .cgt-card {
	flex-direction: row;
	align-items: stretch;
}

.cgtobs-posts-list .cgt-card__media {
	flex: 0 0 38%;
	max-width: 300px;
	aspect-ratio: 4 / 3;
	align-self: center;          /* vertically centre the thumbnail in the row */
}

/* Centre the image content within the thumbnail (both axes). */
.cgtobs-posts-list .cgt-card__img {
	object-fit: cover;
	object-position: center;
}

.cgtobs-posts-list .cgt-card__body {
	flex: 1 1 auto;
}

.cgtobs-posts-list .cgt-card__excerpt {
	display: block;
}

@media (max-width: 560px) {
	.cgtobs-posts-list .cgt-card {
		flex-direction: column;
	}
	.cgtobs-posts-list .cgt-card__media {
		flex-basis: auto;
		max-width: none;
		aspect-ratio: 16 / 9;
	}
}

/* --------------------------------------------------------------------------
   3. Archive toolbar (count + sort + view toggle)
   -------------------------------------------------------------------------- */
.cgtobs-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85rem 1rem;
	margin-bottom: var(--cgt-space-md, 1.25rem);
	background: var(--cgtobs-white);
	border: 1px solid var(--cgtobs-border);
	border-radius: var(--cgtobs-radius);
	box-shadow: var(--cgtobs-shadow);
}

.cgtobs-toolbar__count {
	margin: 0;
	font-size: 0.95rem;
	color: var(--cgtobs-gray);
}

.cgtobs-toolbar__count strong {
	color: var(--cgtobs-black);
}

.cgtobs-toolbar__controls {
	display: flex;
	align-items: center;
	gap: 0.85rem;
}

.cgtobs-sort {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0;
}

.cgtobs-sort__label {
	font-size: 0.9rem;
	color: var(--cgtobs-gray);
	white-space: nowrap;
	flex: 0 0 auto;
}

.cgtobs-sort__select {
	font: inherit;
	font-size: 0.9rem;
	color: var(--cgtobs-black);
	padding: 0.45rem 2rem 0.45rem 0.75rem;
	border: 1px solid var(--cgt-border, #e7e7e7);
	border-radius: var(--cgt-radius-sm, 6px);
	background: var(--cgtobs-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234f4f4f' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.cgtobs-sort__select:focus-visible {
	outline: 3px solid rgba(215, 25, 32, 0.4);
	outline-offset: 1px;
}

.cgtobs-view {
	display: inline-flex;
	border: 1px solid var(--cgt-border, #e7e7e7);
	border-radius: var(--cgt-radius-sm, 6px);
	overflow: hidden;
}

.cgtobs-view__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 36px;
	border: 0;
	background: var(--cgtobs-white);
	color: var(--cgtobs-gray);
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.cgtobs-view__btn + .cgtobs-view__btn {
	border-left: 1px solid var(--cgt-border, #e7e7e7);
}

.cgtobs-view__btn .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
	line-height: 1;
}

.cgtobs-view__btn:hover {
	color: var(--cgtobs-white);
}

.cgtobs-view__btn.is-active {
	background: var(--cgtobs-red);
	color: var(--cgtobs-white) !important;
}

@media (max-width: 600px) {
	.cgtobs-toolbar {
		justify-content: flex-start;
	}
	.cgtobs-toolbar__controls {
		width: 100%;
		justify-content: space-between;
	}
}

/* --------------------------------------------------------------------------
   4. Sidebar — shared block shell
   -------------------------------------------------------------------------- */
.cgtobs-sidebar {
	font-family: var(--cgt-font, "Inter", sans-serif);
}

.cgtobs-sidebar-block {
	background: var(--cgtobs-white);
	border: 1px solid var(--cgtobs-border);
	border-radius: var(--cgtobs-radius);
	padding: 20px;
	margin-bottom: 20px;
	box-shadow: var(--cgtobs-shadow);
}

.cgtobs-sidebar-block:last-child {
	margin-bottom: 0;
}

.cgtobs-sidebar-block__title {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	font-size: 1.125rem;
	line-height: 1.3;
	margin: 0 0 0.9rem;
	padding-bottom: 0.65rem;
	color: var(--cgtobs-black);
	border-bottom: 2px solid var(--cgtobs-light);
	position: relative;
}

/* Red accent under the title. */
.cgtobs-sidebar-block__title::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: -2px;
	width: 42px;
	height: 2px;
	background: var(--cgtobs-red);
}

.cgtobs-sidebar-block__title-icon {
	color: var(--cgtobs-red);
	flex: 0 0 auto;
	font-size: 20px;
	width: 20px;
	height: 20px;
	line-height: 1;
}

.cgtobs-sidebar-block__text {
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--cgtobs-gray);
	margin: 0 0 0.9rem;
}

.cgtobs-sidebar-block__cta {
	margin-top: 0.5rem;
}

.cgt-btn--block {
	display: flex;
	width: 100%;
	justify-content: center;
	text-align: center;
}

/* --------------------------------------------------------------------------
   5. Why-join checklist
   -------------------------------------------------------------------------- */
.cgtobs-checklist {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
	display: grid;
	gap: 0.55rem;
}

.cgtobs-checklist li {
	position: relative;
	padding-left: 1.75rem;
	font-size: 0.95rem;
	line-height: 1.45;
	color: var(--cgtobs-gray);
}

.cgtobs-checklist li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.15rem;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--cgtobs-red) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / 12px 12px;
}

/* --------------------------------------------------------------------------
   6. Help — compact action rows
   -------------------------------------------------------------------------- */
.cgtobs-help-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.4rem;
}

.cgtobs-help-row {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.65rem;
	border-radius: var(--cgt-radius-sm, 6px);
	transition: background 0.2s ease;
}

.cgtobs-help-row:hover,
.cgtobs-help-row:focus-visible {
	background: var(--cgtobs-light);
}

.cgtobs-help-row__icon {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(215, 25, 32, 0.1);
	color: var(--cgtobs-red);
}

.cgtobs-help-row__icon .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
	line-height: 1;
}

.cgtobs-help-row__body {
	min-width: 0;
}

.cgtobs-help-row__title {
	display: block;
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--cgtobs-black);
}

.cgtobs-help-row:hover .cgtobs-help-row__title {
	color: var(--cgtobs-red);
}

.cgtobs-help-row__desc {
	display: block;
	font-size: 0.825rem;
	line-height: 1.45;
	color: var(--cgtobs-gray);
	margin-top: 0.1rem;
}

/* --------------------------------------------------------------------------
   7. Documents list
   -------------------------------------------------------------------------- */
.cgtobs-doclist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}

.cgtobs-doc {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.6rem 0.7rem;
	border: 1px solid var(--cgt-border, #e7e7e7);
	border-radius: var(--cgt-radius-sm, 6px);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cgtobs-doc:hover {
	border-color: var(--cgtobs-red);
	box-shadow: var(--cgtobs-shadow);
}

.cgtobs-doc__badge {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	min-width: 38px;
	height: 30px;
	padding: 0 0.3rem;
	background: var(--cgtobs-red);
	color: var(--cgtobs-white);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	border-radius: 4px;
}

.cgtobs-doc__body {
	min-width: 0;
}

.cgtobs-doc__name {
	display: block;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--cgtobs-black);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cgtobs-doc:hover .cgtobs-doc__name {
	color: var(--cgtobs-red);
}

.cgtobs-doc__meta {
	display: block;
	font-size: 0.78rem;
	color: var(--cgtobs-gray);
}

/* --------------------------------------------------------------------------
   8. Recent posts
   -------------------------------------------------------------------------- */
.cgtobs-recent {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.85rem;
}

.cgtobs-recent__link {
	display: flex;
	gap: 0.75rem;
	align-items: center;
}

.cgtobs-recent__thumb {
	flex: 0 0 auto;
	width: 64px;
	height: 64px;
	border-radius: var(--cgt-radius-sm, 6px);
	overflow: hidden;
	background: var(--cgtobs-light);
}

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

.cgtobs-recent__body {
	min-width: 0;
}

.cgtobs-recent__title {
	display: block;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--cgtobs-black);
	transition: color 0.2s ease;
}

.cgtobs-recent__link:hover .cgtobs-recent__title {
	color: var(--cgtobs-red);
}

.cgtobs-recent__date {
	display: block;
	font-size: 0.78rem;
	color: var(--cgtobs-gray);
	margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   9. Opening hours
   -------------------------------------------------------------------------- */
.cgtobs-hours {
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--cgtobs-gray);
}

.cgtobs-hours p {
	margin: 0 0 0.6rem;
}

.cgtobs-hours p:first-child {
	color: var(--cgtobs-black);
	font-weight: 600;
}

.cgtobs-hours p:last-child {
	margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   10. Filter form + collapsible filters
   -------------------------------------------------------------------------- */
.cgtobs-filter-form__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}

.cgtobs-filter-form__title {
	margin-bottom: 0;
	border-bottom: 0;
}

.cgtobs-filter-form__title::after {
	display: none;
}

.cgtobs-filter-form__mobile-toggle {
	display: none;
	align-items: center;
	gap: 0.35rem;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--cgtobs-red);
	background: none;
	border: 1px solid var(--cgtobs-red);
	border-radius: var(--cgt-radius-pill, 999px);
	padding: 0.3rem 0.8rem;
	cursor: pointer;
}

.cgtobs-filter-form__fields {
	margin-top: 0.85rem;
}

.cgtobs-filter {
	border-top: 1px solid var(--cgtobs-light);
	padding-block: 0.5rem;
}

.cgtobs-filter:first-child {
	border-top: 0;
	padding-top: 0;
}

.cgtobs-filter__heading {
	margin: 0;
	font-size: 1rem;
}

.cgtobs-filter__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	gap: 0.5rem;
	padding: 0.5rem 0.5rem;
	background: none;
	border: 0;
	font: inherit;
	font-weight: 600;
	color: var(--cgtobs-black);
	cursor: pointer;
}

.cgtobs-filter__chevron {
	flex: 0 0 auto;
	color: var(--cgtobs-gray);
	transition: transform 0.2s ease;
	font-size: 18px;
	width: 18px;
	height: 18px;
	line-height: 1;
}

.cgtobs-filter__toggle[aria-expanded="false"] .cgtobs-filter__chevron {
	transform: rotate(-90deg);
}

.cgtobs-filter__panel {
	padding-top: 0.35rem;
}

.cgtobs-filter__panel[hidden] {
	display: none;
}

.cgtobs-filter__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.15rem;
	max-height: 240px;
	overflow-y: auto;
}

.cgtobs-check {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.3rem 0.25rem;
	font-size: 0.9rem;
	color: var(--cgtobs-gray);
	cursor: pointer;
	border-radius: 4px;
}

.cgtobs-check:hover {
	background: var(--cgtobs-light);
	color: var(--cgtobs-black);
}

.cgtobs-check input {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	accent-color: var(--cgtobs-red);
	margin: 0;
}

.cgtobs-check__text {
	flex: 1 1 auto;
	min-width: 0;
}

.cgtobs-check__count {
	flex: 0 0 auto;
	font-size: 0.75rem;
	color: var(--cgtobs-gray);
	background: var(--cgtobs-light);
	border-radius: var(--cgt-radius-pill, 999px);
	padding: 0.05rem 0.5rem;
}

/* Date range */
.cgtobs-daterange {
	display: grid;
	gap: 0.6rem;
}

.cgtobs-daterange__field {
	display: grid;
	gap: 0.25rem;
	margin: 0;
}

.cgtobs-daterange__label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--cgtobs-black);
}

.cgtobs-daterange input[type="date"] {
	font: inherit;
	font-size: 0.9rem;
	padding: 0.5rem 0.6rem;
	border: 1px solid var(--cgt-border, #e7e7e7);
	border-radius: var(--cgt-radius-sm, 6px);
	color: var(--cgtobs-black);
	background: var(--cgtobs-white);
	width: 100%;
}

/* Apply / reset */
.cgtobs-filter-form__actions {
	display: grid;
	gap: 0.5rem;
	margin-top: 1rem;
	padding-top: 0.85rem;
	border-top: 1px solid var(--cgtobs-light);
}

.cgtobs-filter-form__reset {
	text-align: center;
	font-size: 0.85rem;
	color: var(--cgtobs-gray);
}

.cgtobs-filter-form__reset:hover {
	color: var(--cgtobs-red);
	text-decoration: underline;
}

/* Mobile: collapse the filter fields behind the toggle button. */
@media (max-width: 1024px) {
	.cgtobs-filter-form__mobile-toggle {
		display: inline-flex;
	}
	.cgtobs-filter-form.is-js .cgtobs-filter-form__fields {
		display: none;
	}
	.cgtobs-filter-form.is-js.is-open .cgtobs-filter-form__fields {
		display: block;
	}
}

/* --------------------------------------------------------------------------
   11. Small helper
   -------------------------------------------------------------------------- */
.cgt-btn--sm {
	padding: 0.5rem 0.9rem;
	font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   12. Type-size & state fixes
   The side pane lives inside .cgt-main, whose base `h2/h3` rules are more
   specific than a single block class — so they were inflating the side-pane
   titles. These rules raise specificity to win and bring sizes back down.
   -------------------------------------------------------------------------- */
.cgtobs-sidebar .cgtobs-sidebar-block__title {
	font-size: 1rem;
	line-height: 1.3;
}

.cgtobs-sidebar .cgtobs-filter__heading,
.cgtobs-sidebar .cgtobs-filter__toggle {
	font-size: 0.92rem;
	line-height: 1.3;
}

.cgtobs-toolbar .cgtobs-toolbar__count {
	font-size: 0.9rem;
}

/* Filter section headers: red only on hover, never a persistent state after
   a click. Keyboard focus shows a neutral (non-red) ring. */
.cgtobs-sidebar .cgtobs-filter__toggle:hover .cgtobs-filter__title,
.cgtobs-sidebar .cgtobs-filter__toggle:hover .cgtobs-filter__chevron {
	color: var(--cgtobs-white);
}

.cgtobs-sidebar .cgtobs-filter__toggle:focus {
	outline: none;
}

.cgtobs-sidebar .cgtobs-filter__toggle:focus-visible {
	outline: 2px solid rgba(17, 17, 17, 0.35);
	outline-offset: 2px;
	border-radius: 4px;
}
