/**
 * Chantarelle Documents — front end.
 * Colours resolve from the Astra global palette, design-system hex as fallback.
 */
.chan-search {
	--chan-green:   var(--ast-global-color-0, #2E5D4B);
	--chan-green-d: var(--ast-global-color-1, #1F4335);
	--chan-ink:     var(--ast-global-color-2, #1F2420);
	--chan-body:    var(--ast-global-color-3, #35403A);
	--chan-surface: var(--ast-global-color-4, #FFFFFF);
	--chan-ground:  var(--ast-global-color-5, #F7F5F0);
	--chan-border:  var(--ast-global-color-6, #DDD8CE);
	--chan-band:    var(--ast-global-color-7, #EFEBE2);
	--chan-clay:    var(--ast-global-color-8, #A64A23);
	--chan-rule:    #78877A;
	--chan-amber:   #F3C98B;
	--chan-meta:    #4A544D;
	font-size: 18px; line-height: 1.6; color: var(--chan-body);
}
.chan-search *, .chan-search *::before, .chan-search *::after { box-sizing: border-box; }

.chan-search--band .chan-band { display: flex; gap: 56px; align-items: center; padding: 64px 48px; background: var(--chan-green); }
.chan-band__lead { width: 400px; flex-shrink: 0; }
.chan-band__count { display: block; font-size: 108px; line-height: .92; font-weight: 700; letter-spacing: -.04em; color: var(--chan-amber); font-variant-numeric: tabular-nums; }
.chan-band__heading { margin: 14px 0 12px; font-size: 38px; line-height: 1.15; font-weight: 700; color: #FFFFFF; }
.chan-band__intro { margin: 0; font-size: 19px; color: #C9DBD1; }
.chan-band__controls { flex-grow: 1; }
.chan-search--band .chan-label { color: #FFFFFF; }
.chan-search--band .chan-input { border: none; height: 68px; border-radius: 34px; padding: 0 24px; font-size: 20px; }
.chan-search--band .chan-submit { height: 68px; padding: 0 36px; border-radius: 34px; background: var(--chan-amber); color: var(--chan-ink); }
.chan-search--band .chan-submit:hover { background: #EBBA6C; }
.chan-search--band .chan-filters__legend { color: #C9DBD1; }
.chan-search--band .chan-chip { color: #FFFFFF; background: transparent; border: 2px solid #6E9384; }
.chan-search--band .chan-chip:hover { background: rgba(255,255,255,.1); }
.chan-search--band .chan-chip.is-active { background: #FFFFFF; color: var(--chan-green-d); border-color: #FFFFFF; }
.chan-search--band .chan-chip__count { background: rgba(255,255,255,.18); color: #FFFFFF; }
.chan-search--band .chan-chip.is-active .chan-chip__count { background: #DCEAE1; color: var(--chan-green-d); }

.chan-library__heading { margin: 0 0 10px; font-size: 40px; line-height: 1.15; font-weight: 700; color: var(--chan-ink); }
.chan-library__intro { margin: 0 0 26px; font-size: 19px; color: var(--chan-body); max-width: 44em; }
.chan-search--library .chan-input { height: 60px; border: 2px solid var(--chan-rule); border-radius: 30px; padding: 0 22px; font-size: 19px; }
.chan-search--library .chan-submit { height: 60px; padding: 0 30px; border-radius: 30px; background: var(--chan-green); color: var(--chan-surface); }
.chan-search--library .chan-submit:hover { background: var(--chan-green-d); }

.chan-field { margin-bottom: 22px; }
.chan-label { display: block; margin-bottom: 9px; font-size: 17px; font-weight: 700; color: var(--chan-ink); }
.chan-field__row { display: flex; gap: 12px; flex-wrap: wrap; }
.chan-input { flex: 1 1 12rem; min-width: 0; min-height: 48px; background: var(--chan-surface); color: var(--chan-ink); font: inherit; }
.chan-input::placeholder { color: var(--chan-meta); opacity: 1; }
.chan-submit { flex-shrink: 0; min-height: 48px; border: none; font-weight: 700; font-size: 19px; font-family: inherit; cursor: pointer; }

.chan-filters { margin: 0 0 4px; padding: 0; border: 0; }
.chan-filters__legend { padding: 0 0 12px; font-size: 17px; font-weight: 700; color: var(--chan-ink); }
.chan-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chan-chip {
	display: inline-flex; align-items: center; gap: 9px;
	min-height: 48px; padding: 0 20px; border-radius: 26px;
	border: 2px solid var(--chan-rule); background: var(--chan-surface); color: var(--chan-green);
	font-weight: 700; font-size: 18px; font-family: inherit; cursor: pointer;
}
.chan-chip:hover { background: #E7F0EB; }
.chan-chip.is-active { background: var(--chan-green); color: var(--chan-surface); border-color: var(--chan-green); }
.chan-chip__count { padding: 2px 9px; border-radius: 11px; background: var(--chan-band); color: var(--chan-body); font-size: 15px; font-variant-numeric: tabular-nums; }
.chan-chip.is-active .chan-chip__count { background: rgba(255,255,255,.22); color: #FFFFFF; }

.chan-results { margin-top: 28px; }
.chan-results__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2px solid var(--chan-border); }
.chan-results__count { margin: 0; font-size: 19px; font-weight: 700; color: var(--chan-ink); }
.chan-results__order { margin: 0; font-size: 17px; color: var(--chan-meta); }
.chan-results-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.chan-result__link { display: flex; align-items: center; gap: 18px; padding: 18px 22px; background: var(--chan-surface); border: 1px solid var(--chan-border); border-radius: 16px; text-decoration: none; color: var(--chan-ink); }
.chan-result__link:hover { border-color: var(--chan-green); }
.chan-result__icon { flex-shrink: 0; color: #9B2C17; display: flex; }
.chan-result__body { flex-grow: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.chan-result__title { font-size: 20px; font-weight: 700; color: var(--chan-ink); }
.chan-result__meta { font-size: 17px; color: var(--chan-meta); }
.chan-badge { flex-shrink: 0; padding: 6px 13px; font-size: 15px; font-weight: 700; border-radius: 5px; background: var(--chan-band); color: var(--chan-body); border: 1px solid var(--chan-border); }
.chan-empty { margin: 0; padding: 28px; background: var(--chan-surface); border: 1px solid var(--chan-border); border-radius: 16px; font-size: 19px; color: var(--chan-body); }
.chan-search.is-busy .chan-results { opacity: .55; }

.chan-search a:focus-visible, .chan-search button:focus-visible, .chan-search input:focus-visible { outline: 3px solid var(--chan-clay); outline-offset: 3px; }
.chan-search--band a:focus-visible, .chan-search--band button:focus-visible, .chan-search--band input:focus-visible { outline-color: var(--chan-amber); }

@media (max-width: 860px) {
	.chan-search--band .chan-band { flex-direction: column; align-items: stretch; gap: 28px; padding: 40px 20px; }
	.chan-band__lead { width: auto; }
	.chan-band__count { font-size: 76px; }
	.chan-band__heading { font-size: 28px; }
	.chan-library__heading { font-size: 30px; }
	.chan-result__link { align-items: flex-start; flex-wrap: wrap; }
	.chan-badge { margin-left: 46px; }
}
@media (prefers-reduced-motion: reduce) { .chan-search * { transition: none !important; animation: none !important; } }

/* ---------- configurable radius + grid layout ---------- */
.chan-search { --chan-radius: 16px; }
.chan-result__link,
.chan-empty { border-radius: var(--chan-radius); }

.chan-results-list--grid {
	display: grid;
	grid-template-columns: repeat(var(--chan-cols, 3), minmax(0, 1fr));
	gap: 14px;
}
.chan-cols-2 { --chan-cols: 2; }
.chan-cols-3 { --chan-cols: 3; }
.chan-cols-4 { --chan-cols: 4; }

.chan-results-list--grid .chan-result__link {
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	height: 100%;
	padding: 22px;
}
.chan-results-list--grid .chan-result__body { flex-grow: 1; }
.chan-results-list--grid .chan-badge { margin-left: 0; }

@media (max-width: 900px) { .chan-results-list--grid { --chan-cols: 2; } }
@media (max-width: 600px) { .chan-results-list--grid { --chan-cols: 1; } }

/* editor preview: keep the block from inheriting odd editor widths */
.chan-block-preview .chan-search { max-width: 100%; }

/* ---------- load more ---------- */
.chan-more { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.chan-more__btn {
	display: inline-flex; align-items: center; justify-content: center;
	min-height: 56px; padding: 0 32px; border-radius: 28px;
	border: 2px solid var(--chan-green); background: var(--chan-surface); color: var(--chan-green);
	font-size: 18px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.chan-more__btn:hover { background: var(--chan-green); color: var(--chan-surface); }
.chan-more__btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.chan-more__status { margin: 0; font-size: 17px; color: var(--chan-meta); font-variant-numeric: tabular-nums; }

/* ---------- full-bleed band, contained results ----------
   The band breaks out of the theme container to the viewport edges, while its
   own content is pushed back in so it lines up with the results underneath.
   `overflow-x: clip` (not hidden) contains the scrollbar-width overhang of
   100vw without breaking position: sticky elsewhere on the page. */
/* NOTE: the overflow guard must NOT sit on .chan-search — that element is at
   container width, so clipping there crops the band straight back to it. It goes
   on <body> instead, added by the body_class filter only when a bleed block is
   on the page. `clip` rather than `hidden` so position: sticky still works. */
body.chan-has-bleed { overflow-x: clip; }

/* Reserve the scrollbar's space permanently. Without this, a search that shortens
   the page removes the scrollbar, 100% widens by ~15px while 100vw does not, and
   the full-bleed band's calc(50% - 50vw) margins jump — which reads as the page
   "shrinking" the moment you type. Scoped with :has() so it only applies on pages
   that actually carry a bleeding band. */
html:has( body.chan-has-bleed ) { scrollbar-gutter: stable; }

.chan-search--bleed .chan-band {
	margin-inline: calc( 50% - 50vw );
	padding-inline: calc( 50vw - 50% );
	padding-block: 64px;
	max-width: 100vw;
}

/* Already full-width via the block's own alignment: don't bleed twice. */
.alignfull > .chan-search--bleed .chan-band,
.alignfull .chan-search--bleed .chan-band {
	margin-inline: 0;
	padding-inline: 48px;
	max-width: none;
}

@media (max-width: 860px) {
	.chan-search--bleed .chan-band { padding-block: 40px; }
	.alignfull .chan-search--bleed .chan-band { padding-inline: 20px; }
}

/* ---------- guard against theme list resets ----------
   Themes commonly ship `.entry-content ul { padding: revert }`, which has higher
   specificity than a bare class and restores the browser's 40px indent — pushing
   every card out of alignment with the band above. Two classes beat it. */
.chan-search .chan-results-list,
.chan-search .chan-chips {
	margin: 0;
	padding: 0;
	list-style: none;
}
.chan-search .chan-result {
	margin: 0;
	padding: 0;
	list-style: none;
}
.chan-search .chan-result::marker { content: none; }

/* Visible to screen readers only — tells people the link opens a new window. */
.chan-sr-only {
	position: absolute !important;
	width: 1px; height: 1px;
	margin: -1px; padding: 0; border: 0;
	clip-path: inset(50%);
	overflow: hidden; white-space: nowrap;
}

/* No underline on document links */
.chan-result__link, .chan-result__link:visited, .chan-result a { text-decoration: none !important; }
.chan-result__link:hover, .chan-result__link:focus { text-decoration: underline !important; }
