@realadvisor-sites/kit-react 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +211 -2
  3. package/bin/sites-kit-react.mjs +26 -0
  4. package/client/index.ts +21 -0
  5. package/client/islands.ts +33 -0
  6. package/components/ConsentBanner.tsx +25 -0
  7. package/components/Document.tsx +170 -0
  8. package/components/EnquiryForm.tsx +107 -0
  9. package/components/Island.tsx +39 -0
  10. package/components/LanguageSwitch.tsx +24 -0
  11. package/components/LegalContent.tsx +30 -0
  12. package/components/ListingsMap.tsx +76 -0
  13. package/components/ListingsPager.tsx +25 -0
  14. package/components/ListingsSearch.tsx +294 -0
  15. package/components/RaImage.tsx +107 -0
  16. package/components/SafeHtml.tsx +30 -0
  17. package/components/form/Button.tsx +22 -0
  18. package/components/form/Combobox.tsx +34 -0
  19. package/components/form/Input.tsx +24 -0
  20. package/components/form/Select.tsx +30 -0
  21. package/components/index.ts +15 -0
  22. package/env.d.ts +36 -0
  23. package/lib/image.ts +36 -0
  24. package/lib/records.ts +17 -0
  25. package/lib/search.ts +37 -0
  26. package/package.json +63 -4
  27. package/server/data.ts +82 -0
  28. package/server/enquiry.ts +9 -0
  29. package/server/entry.server.tsx +54 -0
  30. package/server/fixture-client.ts +2 -0
  31. package/server/kit.ts +52 -0
  32. package/server/security.ts +32 -0
  33. package/server/seo.ts +39 -0
  34. package/server/worker.ts +146 -0
  35. package/styles/consent.css +6 -0
  36. package/styles/kit.css +21 -0
  37. package/styles/map.css +58 -0
  38. package/styles/pager.css +14 -0
  39. package/styles/search.css +162 -0
  40. package/tools/check-deploy.mjs +280 -0
  41. package/tools/preview.mjs +77 -0
  42. package/vite.d.mts +2 -0
  43. package/vite.mjs +180 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The site's Worker: workers/app.ts is one line.
3
+ *
4
+ * import { createSiteWorker } from '@realadvisor/sites-kit-react/worker';
5
+ * export default createSiteWorker(() => import('virtual:react-router/server-build'));
6
+ *
7
+ * Per request it:
8
+ * - hands the Worker env (SITE_MODE, SITES_API_URL, SITES_API_KEY,
9
+ * ANALYTICS_ID) to the kit (`@realadvisor/sites-kit-core/env`);
10
+ * - answers the 301s of site.json `redirects`, refuses cross-site form
11
+ * posts (Astro's checkOrigin);
12
+ * - makes a fresh CSP nonce (128 random bits) and passes it to React Router
13
+ * (`loadContext.nonce`: entry.server gives it to renderToReadableStream,
14
+ * <Scripts>, <ScrollRestoration> and every inline script) and to the
15
+ * content-security-policy header, the only one it is valid for;
16
+ * - renders the whole page before answering (entry.server waits for
17
+ * allReady): a page that fails mid-render is a logged 500, never a 200
18
+ * with a cut body; a 404/410 keeps its status and the site's page;
19
+ * - sets the kit's security headers (preview: the CRM may frame it);
20
+ * - renders with the page locale (`withPageLocale`), which siteClient reads
21
+ * texts in on a multilingual site.
22
+ */
23
+ import { createRequestHandler, type ServerBuild } from 'react-router';
24
+ import site from 'virtual:sites-kit/site';
25
+ import inlineStyles from 'virtual:sites-kit-react/css';
26
+ import { setRuntimeEnv, siteMode, type SiteEnv } from '@realadvisor/sites-kit-core/env';
27
+ import { notFoundPage, renderFailed } from '@realadvisor/sites-kit-core/render-error';
28
+ import { localeOfPath } from '@realadvisor/sites-kit-core/i18n';
29
+ import { withPageLocale } from '@realadvisor/sites-kit-core/page-locale';
30
+ import { createNonce, siteHeaders } from './security';
31
+
32
+ /** The parts of the Workers runtime types the kit uses (no @cloudflare/workers-types: it clashes with the DOM lib). */
33
+ export type ExecutionContext = { waitUntil(p: Promise<unknown>): void; passThroughOnException(): void };
34
+
35
+ export type SiteLoadContext = {
36
+ cloudflare: { env: SiteEnv & Record<string, unknown>; ctx: ExecutionContext };
37
+ /** This request's CSP nonce. */
38
+ nonce: string;
39
+ };
40
+
41
+ declare module 'react-router' {
42
+ interface AppLoadContext extends SiteLoadContext {}
43
+ }
44
+
45
+ const norm = (p: string) => (p.length > 1 ? p.replace(/\/+$/, '') : p).toLowerCase();
46
+ const EXACT = new Map(Object.entries(site.redirects).filter(([k]) => !k.endsWith('*')).map(([k, v]) => [norm(k), v]));
47
+ const PREFIX = Object.entries(site.redirects)
48
+ .filter(([k]) => k.endsWith('*'))
49
+ .map(([k, v]) => [norm(k.slice(0, -1)), v] as const)
50
+ .sort((a, b) => b[0].length - a[0].length);
51
+
52
+ /** 301 target for an old URL (site.json `redirects`), or null. Same-site paths only. Same rules as the Astro kit middleware. */
53
+ export function redirectFor(url: URL): string | null {
54
+ const path = norm(url.pathname);
55
+ const to = EXACT.get(path) ?? PREFIX.find(([k]) => path === k || path.startsWith(`${k}/`))?.[1];
56
+ if (!to || !to.startsWith('/') || to.startsWith('//')) return null;
57
+ if (norm(to.split('?')[0]!) === path) return null; // never a loop
58
+ return to.includes('?') || !url.search ? to : `${to}${url.search}`;
59
+ }
60
+
61
+ /** A page that ends with a script after </html> (it should not): move it back before </body>. */
62
+ function closeDocument(html: string): string {
63
+ const m = /<\/body>\s*<\/html>([\s\S]*)$/i.exec(html);
64
+ if (!m || !m[1]!.trim()) return html;
65
+ return `${html.slice(0, m.index)}${m[1]!.trim()}</body></html>`;
66
+ }
67
+
68
+ /** sitesKit({ inlineCss: true }): each linked stylesheet of the build becomes a <style> with its text (same order). */
69
+ export function inlineCss(html: string, styles: Record<string, string> = inlineStyles): string {
70
+ if (!Object.keys(styles).length) return html;
71
+ return html.replace(/<link\b[^>]*\brel="stylesheet"[^>]*>/g, (tag) => {
72
+ const href = /\bhref="([^"]+)"/.exec(tag)?.[1];
73
+ const text = href ? styles[href] : undefined;
74
+ return text == null ? tag : `<style>${text.replace(/<\/style/gi, '<\\/style')}</style>`;
75
+ });
76
+ }
77
+
78
+ /** The Worker's environment as plain strings for the SDK (it reads process.env). */
79
+ function exposeEnv(env: Record<string, unknown>) {
80
+ const proc = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process;
81
+ if (!proc?.env) return;
82
+ for (const k of ['SITE_MODE', 'SITES_API_URL', 'SITES_API_KEY', 'ANALYTICS_ID', 'SITE_URL']) {
83
+ if (typeof env[k] === 'string' && env[k] && proc.env[k] !== env[k]) proc.env[k] = env[k] as string;
84
+ }
85
+ }
86
+
87
+ const FORM_TYPES = /^(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
88
+
89
+ /**
90
+ * Cross-site form posts are refused, as Astro's `security.checkOrigin` does
91
+ * on Astro sites: a POST/PUT/PATCH/DELETE with a form content type needs an
92
+ * Origin header equal to the site's.
93
+ */
94
+ export function crossSiteForm(request: Request, url: URL): boolean {
95
+ if (['GET', 'HEAD', 'OPTIONS'].includes(request.method)) return false;
96
+ if (!FORM_TYPES.test(request.headers.get('content-type') ?? '')) return false;
97
+ return request.headers.get('origin') !== url.origin;
98
+ }
99
+
100
+ export function createSiteWorker(build: () => Promise<ServerBuild>) {
101
+ const handle = createRequestHandler(build, import.meta.env.MODE);
102
+ return {
103
+ async fetch(request: Request, env: SiteLoadContext['cloudflare']['env'], ctx: ExecutionContext): Promise<Response> {
104
+ setRuntimeEnv(env);
105
+ exposeEnv(env);
106
+ const url = new URL(request.url);
107
+ const moved = redirectFor(url);
108
+ if (moved) return new Response(null, { status: 301, headers: { location: moved } });
109
+ if (crossSiteForm(request, url)) return new Response(`Cross-site ${request.method} form submissions are forbidden`, { status: 403 });
110
+
111
+ const nonce = createNonce();
112
+ const path = url.pathname;
113
+ let res: Response;
114
+ try {
115
+ // The page locale (pageLocale(request)): siteClient reads texts in it.
116
+ res = await withPageLocale(localeOfPath(path), () => handle(request, { cloudflare: { env, ctx }, nonce }));
117
+ if ((res.headers.get('content-type') ?? '').includes('text/html') && res.body) {
118
+ const raw = await res.text(); // throws when rendering fails mid-stream
119
+ if (res.status === 200 && !raw.replace(/<!doctype html>/i, '').trim()) throw new Error('page rendered an empty body');
120
+ if (res.status === 200 && /<html[\s>]/i.test(raw) && !/<\/html>/i.test(raw)) throw new Error('page rendered a cut body (no </html>)');
121
+ const headers = new Headers(res.headers);
122
+ headers.delete('content-length');
123
+ res = new Response(inlineCss(closeDocument(raw)), { status: res.status, statusText: res.statusText, headers });
124
+ } else if ((res.status === 404 || res.status === 410) && !res.body) {
125
+ res = notFoundPage(path, res.status);
126
+ } else if (res.status >= 500 && !res.body) {
127
+ res = renderFailed(path, new Error(`HTTP ${res.status} with no body`));
128
+ }
129
+ } catch (err) {
130
+ const status = (err as { status?: unknown } | null)?.status;
131
+ res = status === 404 || status === 410 ? notFoundPage(path, status) : renderFailed(path, err);
132
+ }
133
+ // Only an HTML page carries inline scripts: the nonce goes in its CSP alone.
134
+ const html = (res.headers.get('content-type') ?? '').includes('text/html');
135
+ try {
136
+ const headers = siteHeaders(siteMode() === 'preview', html ? nonce : undefined);
137
+ for (const [k, v] of Object.entries(headers)) {
138
+ if (k === 'content-security-policy' || !res.headers.has(k)) res.headers.set(k, v);
139
+ }
140
+ } catch {
141
+ // immutable headers (Response.redirect): nothing to secure in a redirect
142
+ }
143
+ return res;
144
+ },
145
+ };
146
+ }
@@ -0,0 +1,6 @@
1
+ /* ConsentBanner: part of kit.css (import it alone for a site without the other parts). */
2
+ .consent { position: fixed; z-index: 50; inset: auto 16px 16px 16px; max-width: 560px; display: grid; gap: 12px; padding: 16px; background: var(--bg, #fff); color: var(--text, #111); border: 1px solid var(--line, #ddd); border-radius: var(--radius-card, 8px); box-shadow: 0 8px 24px rgb(0 0 0 / .12); font-size: 0.9375rem; }
3
+ .consent p { margin: 0; }
4
+ .consent a { color: inherit; }
5
+ .consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
6
+ .consent-actions .btn { flex: 1; }
package/styles/kit.css ADDED
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Every kit part's styles (from the Astro components, scoped there, plain
3
+ * class selectors here: rs-*, ra-map-*, consent*, enquiry*, field-*,
4
+ * control, btn; themed with the same tokens): the Astro kit's form.css, then
5
+ * search.css, pager.css, map.css, consent.css.
6
+ *
7
+ * Import it once, in root.tsx, where the Astro layout imports the kit's
8
+ * components (ConsentBanner): after the site's global CSS by default, so the
9
+ * kit's rules win at equal specificity (--control-h 48px), as in Astro.
10
+ * Imported from JS, the kit's Vite plugin turns it into one import per part
11
+ * (no @import for the bundler to hoist): the rules sit exactly where the
12
+ * import is. A site that needs fewer parts imports them one by one:
13
+ * import '@realadvisor/sites-kit-core/styles/form.css';
14
+ * import '@realadvisor/sites-kit-react/styles/consent.css';
15
+ * From another stylesheet (`@import`) this file is plain CSS, below.
16
+ */
17
+ @import '@realadvisor/sites-kit-core/styles/form.css';
18
+ @import './search.css';
19
+ @import './pager.css';
20
+ @import './map.css';
21
+ @import './consent.css';
package/styles/map.css ADDED
@@ -0,0 +1,58 @@
1
+ /* ListingsMap: part of kit.css (import it alone for a site without the other parts). */
2
+ /* overflow-anchor: tiles and markers come and go; the browser must not anchor the page scroll on them (the page jumped on zoom). */
3
+ .ra-map { position: relative; overflow: hidden; height: var(--map-h, 60vh); min-height: 320px; background: #f2f0ec; touch-action: none; overflow-anchor: none; }
4
+ .ra-map-viewport { position: absolute; inset: 0; cursor: grab; outline-offset: -3px; }
5
+ .ra-map-viewport:active { cursor: grabbing; }
6
+ .ra-map-tiles { position: absolute; inset: 0; filter: grayscale(1) sepia(.18) contrast(.92) brightness(1.06); }
7
+ .ra-map-tiles img { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; user-select: none; -webkit-user-drag: none; opacity: 0; transition: opacity .2s; }
8
+ .ra-map-tiles img.is-loaded { opacity: 1; }
9
+ .ra-map-markers { position: absolute; inset: 0; pointer-events: none; }
10
+ .ra-map-markers button {
11
+ position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; border: 2px solid var(--paper, #fff);
12
+ background: var(--accent, #134266); color: var(--paper, #fff); font: 600 14px/1 system-ui, sans-serif;
13
+ box-shadow: 0 2px 6px rgb(0 0 0 / .3); transition: background .15s, scale .15s; will-change: translate;
14
+ }
15
+ /* A 22px dot inside a 44px (invisible) touch target. */
16
+ .ra-map-markers .ra-map-pin { width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; }
17
+ .ra-map-markers .ra-map-pin::after { content: ''; position: absolute; inset: 11px; border: 2px solid var(--paper, #fff); border-radius: 50%; background: var(--accent, #134266); box-shadow: 0 2px 6px rgb(0 0 0 / .3); transition: background .15s; }
18
+ /* Clusters grow with their count and carry a soft halo (as on most portals). */
19
+ .ra-map-markers .ra-map-cluster {
20
+ --d: 36px; min-width: var(--d); height: var(--d); margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); border-radius: 999px; padding: 0 8px;
21
+ box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent, #134266) 22%, transparent), 0 2px 6px rgb(0 0 0 / .3);
22
+ }
23
+ .ra-map-markers .ra-map-cluster.is-m { --d: 44px; }
24
+ .ra-map-markers .ra-map-cluster.is-l { --d: 52px; font-size: 15px; }
25
+ .ra-map-markers button:hover, .ra-map-markers button.is-active, .ra-map-markers button.is-selected, .ra-map-markers button:focus-visible { scale: 1.15; z-index: 1; }
26
+ .ra-map-markers .ra-map-cluster:hover, .ra-map-markers .ra-map-cluster.is-active, .ra-map-markers .ra-map-cluster:focus-visible,
27
+ .ra-map-markers .ra-map-pin:hover::after, .ra-map-markers .ra-map-pin.is-active::after, .ra-map-markers .ra-map-pin.is-selected::after, .ra-map-markers .ra-map-pin:focus-visible::after { background: var(--text, #1c1b19); }
28
+ /* Placed by the script: above or below its marker, clear of the edges and the zoom buttons. */
29
+ .ra-map-popup {
30
+ position: absolute; left: 0; top: 0; z-index: 4; width: min(260px, calc(100% - 16px)); max-height: min(340px, calc(100% - 16px)); overflow: auto;
31
+ background: var(--paper, #fff); color: var(--text, #1c1b19); box-shadow: 0 6px 20px rgb(0 0 0 / .25); cursor: auto;
32
+ visibility: hidden; pointer-events: none; opacity: 0;
33
+ }
34
+ .ra-map-popup.is-open { visibility: visible; pointer-events: auto; opacity: 1; }
35
+ .ra-map-popup .ra-map-card { display: grid; gap: 4px; padding: 0 0 12px; color: inherit; text-decoration: none; }
36
+ .ra-map-popup .ra-map-card + .ra-map-card { border-top: 1px solid var(--line, #d6d3cf); padding-top: 12px; }
37
+ .ra-map-popup .ra-map-card img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
38
+ .ra-map-popup .ra-map-card-type, .ra-map-popup .ra-map-card-title, .ra-map-popup .ra-map-card-price { padding: 0 12px; }
39
+ .ra-map-popup .ra-map-card-type { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
40
+ .ra-map-popup .ra-map-card-price { font-weight: 600; }
41
+ .ra-map-popup .ra-map-close { position: sticky; top: 4px; float: right; margin: 4px 4px -48px 0; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgb(255 255 255 / .9); color: #1c1b19; font-size: 22px; cursor: pointer; z-index: 1; }
42
+ .ra-map-status {
43
+ position: absolute; left: 12px; top: 12px; z-index: 3; display: flex; gap: 12px; align-items: center; padding: 6px 6px 6px 14px;
44
+ background: var(--paper, #fff); box-shadow: 0 2px 8px rgb(0 0 0 / .2); visibility: hidden; pointer-events: none; opacity: 0;
45
+ }
46
+ /* Only its button takes clicks: the markers under the pill stay reachable. */
47
+ .ra-map-status.is-open { visibility: visible; opacity: 1; }
48
+ .ra-map-status.is-open button { pointer-events: auto; }
49
+ .ra-map-status button, .ra-map-zoom button { min-height: 44px; min-width: 44px; border: 0; background: var(--paper, #fff); color: var(--text, #1c1b19); font: inherit; cursor: pointer; }
50
+ .ra-map-status button { text-decoration: underline; }
51
+ .ra-map-zoom { position: absolute; right: 12px; top: 12px; z-index: 3; display: grid; box-shadow: 0 2px 8px rgb(0 0 0 / .2); }
52
+ .ra-map-zoom button { font-size: 22px; }
53
+ .ra-map-zoom button:disabled { color: #999; cursor: default; }
54
+ .ra-map-zoom button + button { border-top: 1px solid var(--line, #d6d3cf); }
55
+ .ra-map-attr { position: absolute; right: 0; bottom: 0; z-index: 3; margin: 0; padding: 2px 6px; font-size: 11px; color: #444; background: rgb(255 255 255 / .8); }
56
+ .ra-map-attr a { color: inherit; }
57
+ @media (prefers-reduced-motion: reduce) { .ra-map-markers button, .ra-map-markers .ra-map-pin::after, .ra-map-tiles img { transition: none; } }
58
+
@@ -0,0 +1,14 @@
1
+ /* ListingsPager: part of kit.css (import it alone for a site without the other parts). */
2
+ .rs-pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--rs-line); }
3
+ .rs-pager ol { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
4
+ .rs-pager a, .rs-gap { display: grid; place-items: center; min-width: 44px; height: 44px; color: var(--rs-ink); text-decoration: none; font-variant-numeric: tabular-nums; border-radius: var(--control-radius, 8px); }
5
+ .rs-pager a:hover { background: color-mix(in srgb, var(--rs-ink) 6%, transparent); }
6
+ .rs-pager a[aria-current] { background: var(--rs-on); color: var(--rs-on-ink); }
7
+ .rs-step { display: inline-flex !important; gap: 6px; padding: 0 12px; min-width: 96px; }
8
+ .rs-step:last-child { justify-content: end; }
9
+ @media (max-width: 639px) {
10
+ .rs-step span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
11
+ .rs-step { min-width: 44px; padding: 0; }
12
+ .rs-pager ol li:not(:has([aria-current])):not(:first-child):not(:last-child) { display: none; }
13
+ }
14
+
@@ -0,0 +1,162 @@
1
+ /* ListingsSearch: part of kit.css (import it alone for a site without the other parts). */
2
+ .rs {
3
+ --rs-ink: var(--text, #1c1b19);
4
+ --rs-bg: var(--paper, var(--bg, #fff));
5
+ --rs-line: var(--line, #e2dfda);
6
+ --rs-muted: var(--muted, #6b6b6b);
7
+ --rs-accent: var(--accent, #134266);
8
+ --rs-gap-x: var(--rs-gap, 32px);
9
+ --rs-top: calc(var(--header-h, 0px) + 16px);
10
+ --rs-on: var(--rs-active, var(--rs-ink));
11
+ --rs-on-ink: var(--rs-on-active, var(--rs-bg));
12
+ position: relative;
13
+ }
14
+ .rs[aria-busy='true'] .rs-region { opacity: .55; transition: opacity .2s .1s; }
15
+
16
+ /* Filters: one inline row at >= 960px, a bottom sheet (popover) on phones. */
17
+ .rs-top { display: flex; gap: 12px; align-items: end; }
18
+ .rs-filters-btn {
19
+ display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-h, 48px); padding: 0 18px;
20
+ border: 1px solid var(--rs-line); border-radius: var(--control-radius, 8px); background: var(--rs-bg); color: var(--rs-ink); font: inherit; font-weight: 600; cursor: pointer;
21
+ }
22
+ .rs-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--rs-accent); color: #fff; font-size: 12px; }
23
+ .rs-badge[hidden] { display: none; }
24
+ .rs-sheet { color: var(--rs-ink); }
25
+ .rs-sheet-head { display: flex; justify-content: space-between; align-items: center; }
26
+ .rs-sheet-title { margin: 0; font-weight: 600; font-size: 1.125rem; }
27
+ .rs-sheet-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
28
+ .rs-sheet:popover-open {
29
+ position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: 88svh; margin: 0; overflow: auto; box-sizing: border-box;
30
+ display: grid; gap: 20px; padding: 8px 20px max(20px, env(safe-area-inset-bottom)); border: 0; border-radius: var(--rs-sheet-radius, 16px) var(--rs-sheet-radius, 16px) 0 0;
31
+ background: var(--rs-bg); box-shadow: 0 -8px 32px rgb(0 0 0 / .18);
32
+ }
33
+ .rs-sheet::backdrop { background: rgb(0 0 0 / .4); }
34
+ .rs-sheet .rs-apply { width: 100%; position: sticky; bottom: 0; }
35
+ @supports not selector(:popover-open) {
36
+ .rs-filters-btn { display: none; }
37
+ .rs-sheet { display: grid; gap: 16px; }
38
+ .rs-sheet-head { display: none; }
39
+ }
40
+
41
+ .rs-offer { border: 0; margin: 0; padding: 0; min-width: 0; }
42
+ .rs-offer legend { padding: 0; margin-bottom: 6px; }
43
+ .rs-seg { display: flex; border: 1px solid var(--rs-line); border-radius: var(--control-radius, 8px); overflow: hidden; height: var(--control-h, 48px); background: var(--rs-bg); }
44
+ .rs-seg label { position: relative; flex: 1; display: flex; }
45
+ .rs-seg label + label { border-left: 1px solid var(--rs-line); }
46
+ .rs-seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
47
+ .rs-seg span { flex: 1; display: grid; place-items: center; padding: 0 16px; white-space: nowrap; font-size: .9375rem; transition: background .15s, color .15s; }
48
+ .rs-seg input:checked + span { background: var(--rs-on); color: var(--rs-on-ink); }
49
+ .rs-seg input:focus-visible + span { outline: 2px solid var(--rs-accent); outline-offset: -4px; }
50
+
51
+ @media (min-width: 960px) {
52
+ .rs-filters-btn, .rs-sheet-head { display: none; }
53
+ .rs-top { display: block; }
54
+ /* The popover, shown inline: author styles beat the UA's [popover] display:none. */
55
+ .rs-sheet, .rs-sheet:popover-open {
56
+ position: static; inset: auto; width: auto; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; background: none;
57
+ display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
58
+ }
59
+ .rs-sheet > .field { flex: 1 1 160px; min-width: 0; }
60
+ .rs-sheet > .rs-offer { flex: 0 0 auto; }
61
+ .rs-sheet > .rs-city { flex: 1.4 1 200px; }
62
+ .rs-sheet .rs-apply { width: auto; position: static; }
63
+ .rs.is-js .rs-sheet .rs-apply { display: none; }
64
+ }
65
+
66
+ .rs-bar { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin: 24px 0 16px; }
67
+ .rs-count { margin: 0; font-weight: 600; outline: none; }
68
+ .rs-tools { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
69
+ .rs-tools .rs-sort { width: auto; }
70
+ .rs-status, .rs-views { display: flex; border: 1px solid var(--rs-line); border-radius: var(--control-radius, 8px); overflow: hidden; }
71
+ .rs-status a, .rs-views a {
72
+ display: inline-flex; gap: 8px; align-items: center; min-height: calc(var(--control-h, 48px) - 2px); padding: 0 16px;
73
+ color: var(--rs-ink); text-decoration: none; font-size: .9375rem; white-space: nowrap;
74
+ }
75
+ .rs-status a + a, .rs-views a + a { border-left: 1px solid var(--rs-line); }
76
+ .rs-status a[aria-current], .rs-views a[aria-current] { background: var(--rs-on); color: var(--rs-on-ink); }
77
+ .rs-n { opacity: .7; font-variant-numeric: tabular-nums; }
78
+
79
+ .rs-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 24px; }
80
+ .rs-chips[hidden] { display: none; }
81
+ .rs-chip {
82
+ display: inline-flex; gap: 6px; align-items: center; min-height: 36px; padding: 0 10px 0 14px; border-radius: 999px;
83
+ background: color-mix(in srgb, var(--rs-accent) 10%, var(--rs-bg)); color: var(--rs-ink); text-decoration: none; font-size: .875rem;
84
+ }
85
+ .rs-chip:hover { background: color-mix(in srgb, var(--rs-accent) 18%, var(--rs-bg)); }
86
+ .rs-reset { color: var(--rs-accent); font-size: .875rem; padding: 8px 4px; }
87
+
88
+ /* Results: list view grid; map view split (cards | sticky map) at >= 960px. */
89
+ .rs-grid { --rs-cols: 1; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--rs-cols), minmax(0, 1fr)); gap: 40px var(--rs-gap-x); }
90
+ .rs-grid > li { min-width: 0; }
91
+ @media (min-width: 640px) { .rs-grid { --rs-cols: 2; } }
92
+ @media (min-width: 1024px) { .rs-grid { --rs-cols: var(--rs-columns, 3); } }
93
+ /* Map view renders up to 300 cards: skip the off-screen ones' layout. */
94
+ .rs-list > li { content-visibility: auto; contain-intrinsic-size: auto var(--rs-card-h, 420px); }
95
+ .rs-grid > li.is-map-hover, .rs-grid > li.is-selected { outline: 2px solid var(--rs-accent); outline-offset: 6px; border-radius: 2px; }
96
+
97
+ .rs-map { --map-h: min(70svh, 560px); margin-bottom: 24px; }
98
+ .rs-split { display: flex; flex-direction: column; }
99
+ .rs-split .rs-map { order: -1; }
100
+ @media (min-width: 960px) {
101
+ .rs-split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--rs-gap-x); align-items: start; }
102
+ .rs-split .rs-map { order: 2; position: sticky; top: var(--rs-top); margin: 0; --map-h: calc(100svh - var(--rs-top) - 16px); }
103
+ .rs-list { --rs-cols: 1; }
104
+ }
105
+ @media (min-width: 1280px) { .rs-list { --rs-cols: 2; gap: 32px 20px; } }
106
+ /* Map view: "search as I move the map" over the map; with it off, a "search this area" button. */
107
+ .rs-map { position: relative; }
108
+ .rs-follow { position: absolute; z-index: 5; top: 12px; left: 50%; translate: -50% 0; max-width: calc(100% - 136px); display: flex; justify-content: center; pointer-events: none; }
109
+ .rs-follow > * { pointer-events: auto; }
110
+ .rs:not(.is-js) .rs-follow { display: none; }
111
+ /* An open popup owns the top of the map (its close button sits there on a phone). */
112
+ .rs-map:has(.ra-map-popup.is-open) .rs-follow { visibility: hidden; }
113
+ .rs-follow-toggle, .rs-search-area {
114
+ display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 0 14px; border: 0; border-radius: var(--rs-pill-radius, 999px);
115
+ background: var(--rs-bg); color: var(--rs-ink); box-shadow: 0 2px 8px rgb(0 0 0 / .2); font: inherit; font-size: .875rem; white-space: nowrap; cursor: pointer;
116
+ }
117
+ .rs-follow-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--rs-on); }
118
+ .rs-follow-toggle span { overflow: hidden; text-overflow: ellipsis; }
119
+ .rs-search-area { background: var(--rs-on); color: var(--rs-on-ink); font-weight: 600; }
120
+ .rs-follow:has(.rs-search-area:not([hidden])) .rs-follow-toggle { display: none; }
121
+ .rs-empty-area { padding: 24px 0; }
122
+ .rs-note { margin: 0 0 16px; color: var(--rs-muted); font-size: .9375rem; }
123
+
124
+ /* Plain card: only when the page passes none. */
125
+ .rs-card { display: grid; gap: 4px; color: inherit; text-decoration: none; }
126
+ .rs-card img, .rs-card-nophoto { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; margin-bottom: 8px; border-radius: var(--radius-img, 0); }
127
+ .rs-card-nophoto { display: grid; place-items: center; background: var(--surface, #f2f0ec); color: var(--rs-muted); }
128
+ .rs-card-type { font-size: .8125rem; letter-spacing: .04em; text-transform: uppercase; color: var(--rs-muted); }
129
+ .rs-card-title { font-weight: 600; }
130
+ .rs-card-price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
131
+ .rs-card-facts { color: var(--rs-muted); font-size: .9375rem; }
132
+ .rs-card:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: 3px; }
133
+
134
+ .rs-empty { display: grid; gap: 12px; justify-items: start; max-width: 60ch; padding: 48px 0; }
135
+ .rs-empty-title { margin: 0; font-size: var(--rs-heading-size, clamp(1.25rem, 1rem + 1vw, 1.75rem)); font-weight: var(--rs-heading-weight, 600); line-height: 1.2; }
136
+ .rs-empty-text { margin: 0; color: var(--rs-muted); }
137
+ .rs-empty-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 0; }
138
+ .rs-relax { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
139
+ .rs-relax a { display: inline-flex; align-items: center; min-height: 44px; color: var(--rs-accent); }
140
+
141
+
142
+ /* Phone: List / Map always in reach. */
143
+ .rs-pill {
144
+ position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 20; translate: -50% 0;
145
+ display: inline-flex; gap: 8px; align-items: center; min-height: 48px; padding: 0 22px; border-radius: var(--rs-pill-radius, 999px);
146
+ background: var(--rs-on); color: var(--rs-on-ink); font-weight: 600; text-decoration: none; box-shadow: 0 6px 20px rgb(0 0 0 / .25);
147
+ }
148
+ @media (min-width: 960px) { .rs-pill { display: none; } }
149
+ /* Phone: [Filters (n)] [Sort] on one row, then the status switch and the count. */
150
+ @media (max-width: 959px) {
151
+ .rs-form { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: 'f s' 'st st' 'c c'; gap: 12px; margin-bottom: 16px; }
152
+ .rs-top, .rs-bar, .rs-tools { display: contents; }
153
+ .rs-filters-btn { grid-area: f; }
154
+ .rs-tools .rs-sort { grid-area: s; }
155
+ .rs-status { grid-area: st; }
156
+ .rs-status a { flex: 1; justify-content: center; }
157
+ .rs-count { grid-area: c; }
158
+ .rs-views { display: none; }
159
+ .rs:has(.rs-pill) .rs-region { padding-bottom: 72px; }
160
+ }
161
+ @media (prefers-reduced-motion: reduce) { .rs * { transition: none !important; } }
162
+