/*
 * Subhamithra Matrimony Search - front-end styles (v1.1).
 *
 * THEMING
 * Search blocks are wrapped like the Subhamithra Matrimony Profiles pages: the outermost
 * element has class "subhamithra" plus data-theme / data-mode / data-fx, and takes its
 * colours from the shared --subhamithra-* variables of subhamithra-themes.css. This file only
 * USES those variables, so the four themes and the light/dark toggle just work.
 *
 * LEGACY / FALLBACK
 * - The old --subhamithra-ms-* names are kept as aliases of the shared variables.
 * - When the Profiles theme engine is missing, or "Classic" is chosen in the
 *   settings, the wrapper has data-subhamithra-ms-look="classic" and the original navy
 *   and red palette below applies. In that mode you can still change colours from
 *   Customizer > Additional CSS:   :root { --subhamithra-ms-primary: #0b2a5b; --subhamithra-ms-accent: #d71920; }
 *
 * Elements rendered inside [subhamithra_search] ("embedded") have no .subhamithra class of their
 * own; they inherit the variables from the outer element.
 */

/* ---------- Legacy variables (defaults used by the classic look) ---------- */
:root {
	--subhamithra-ms-primary: #1b2a5c;       /* navy */
	--subhamithra-ms-primary-dark: #111c40;
	--subhamithra-ms-accent: #c8102e;        /* red */
	--subhamithra-ms-accent-dark: #a00d25;
	--subhamithra-ms-text: #1a2038;
	--subhamithra-ms-muted: #4f5875;         /* darker than 1.0 so it passes AA on white and on the surface colour */
	--subhamithra-ms-bg: #ffffff;
	--subhamithra-ms-surface: #f3f5fa;
	--subhamithra-ms-border: #d6dcec;
	--subhamithra-ms-radius: 10px;
	--subhamithra-ms-gap: 20px;
	--subhamithra-ms-sidebar-width: 300px;
}

/* Themed look: the old names become aliases of the shared variables. */
.subhamithra-ms[data-theme] {
	--subhamithra-ms-primary: var(--subhamithra-primary);
	--subhamithra-ms-primary-dark: var(--subhamithra-primary-dark);
	--subhamithra-ms-accent: var(--subhamithra-accent);
	--subhamithra-ms-accent-dark: var(--subhamithra-accent-2);
	--subhamithra-ms-text: var(--subhamithra-text);
	--subhamithra-ms-muted: var(--subhamithra-muted);
	--subhamithra-ms-bg: var(--subhamithra-bg);
	--subhamithra-ms-surface: var(--subhamithra-surface);
	--subhamithra-ms-border: var(--subhamithra-border);
}

/* Dark mode: some dark-theme primaries are too light for white text, so start the gradient a little darker. */
.subhamithra-ms[data-theme][data-mode="dark"] {
	--subhamithra-ms-grad: linear-gradient(135deg, color-mix(in srgb, var(--subhamithra-primary) 45%, var(--subhamithra-primary-dark)) 0%, color-mix(in srgb, var(--subhamithra-accent-2) 15%, var(--subhamithra-primary-dark)) 100%);
}

/* Classic look: navy and red, independent of the Profiles themes. */
.subhamithra-ms[data-subhamithra-ms-look="classic"] {
	--subhamithra-primary: var(--subhamithra-ms-primary);
	--subhamithra-primary-dark: var(--subhamithra-ms-primary-dark);
	--subhamithra-accent: var(--subhamithra-ms-accent);
	--subhamithra-accent-2: var(--subhamithra-ms-accent-dark);
	--subhamithra-page: transparent;
	--subhamithra-bg: var(--subhamithra-ms-bg);
	--subhamithra-surface: var(--subhamithra-ms-surface);
	--subhamithra-text: var(--subhamithra-ms-text);
	--subhamithra-muted: var(--subhamithra-ms-muted);
	--subhamithra-border: var(--subhamithra-ms-border);
	--subhamithra-head: var(--subhamithra-ms-primary);
	--subhamithra-link: var(--subhamithra-ms-primary);
	--subhamithra-shadow: rgba(27, 42, 92, .16);
	--subhamithra-grad: linear-gradient(135deg, var(--subhamithra-ms-accent), var(--subhamithra-ms-accent-dark));
	--subhamithra-on-primary: #ffffff;
	--subhamithra-ms-grad: linear-gradient(135deg, var(--subhamithra-ms-accent), var(--subhamithra-ms-accent-dark));
	--subhamithra-radius: var(--subhamithra-ms-radius);
	--subhamithra-radius-lg: calc(var(--subhamithra-ms-radius) + 6px);
	--subhamithra-gap: var(--subhamithra-ms-gap);
	--subhamithra-font-head: inherit;
	--subhamithra-font-body: inherit;
	color: var(--subhamithra-text);
}
.subhamithra-ms[data-subhamithra-ms-look="classic"] .subhamithra-btn--primary { background: var(--subhamithra-ms-accent); border-color: var(--subhamithra-ms-accent); color: #fff; box-shadow: none; }
.subhamithra-ms[data-subhamithra-ms-look="classic"] .subhamithra-btn--primary:hover { background: var(--subhamithra-ms-accent-dark); border-color: var(--subhamithra-ms-accent-dark); color: #fff; }
.subhamithra-ms[data-subhamithra-ms-look="classic"] .subhamithra-item .subhamithra-btn--small:hover { background: var(--subhamithra-ms-primary); border-color: var(--subhamithra-ms-primary); color: #fff; }

/* Shared helpers on every wrapper. */
.subhamithra-ms {
	/* Form-control border: strong enough (3:1) to see the box in every theme and mode. */
	--subhamithra-ms-field-border: color-mix(in srgb, var(--subhamithra-muted) 80%, var(--subhamithra-bg));
	--subhamithra-ms-focus: var(--subhamithra-link);
	/* Same hue family as the Profiles gradient, but dark enough for white text (4.5:1) in every theme and mode. */
	--subhamithra-ms-grad: linear-gradient(135deg, var(--subhamithra-primary) 0%, color-mix(in srgb, var(--subhamithra-accent-2) 40%, var(--subhamithra-primary-dark)) 100%);
	box-sizing: border-box;
}
.subhamithra-ms *, .subhamithra-ms *::before, .subhamithra-ms *::after { box-sizing: border-box; }

/* Visually hidden, still read by screen readers. */
.subhamithra-ms-sr, .subhamithra-ms .subhamithra-ms-sr {
	position: absolute !important;
	width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Visible keyboard focus in every theme (accent gold fails 3:1 on light backgrounds, link colour does not). */
.subhamithra-ms :is(a, button, input, select, summary, [tabindex]):focus-visible {
	outline: 3px solid var(--subhamithra-ms-focus);
	outline-offset: 2px;
}

/* ---------- Layout for [subhamithra_search] ---------- */
.subhamithra-ms-layout { display: grid; gap: calc(var(--subhamithra-gap, 22px) + 2px); align-items: start; }
.subhamithra-ms-layout--sidebar { grid-template-columns: var(--subhamithra-ms-sidebar-width) minmax(0, 1fr); }
.subhamithra-ms-layout--top { grid-template-columns: minmax(0, 1fr); }
.subhamithra-ms-layout__filters, .subhamithra-ms-layout__results { min-width: 0; }

/* ---------- Cards: filter form and quick search ---------- */
.subhamithra-ms-formwrap, .subhamithra-ms-quick {
	background: var(--subhamithra-bg);
	color: var(--subhamithra-text);
	border: 1px solid var(--subhamithra-border);
	border-top: 4px solid var(--subhamithra-primary);
	border-radius: var(--subhamithra-radius-lg, 20px);
	padding: 18px 20px 20px;
	box-shadow: 0 14px 34px -22px var(--subhamithra-shadow, rgba(0, 0, 0, .25));
	min-width: 0;
}
.subhamithra-ms-quick { border-top-color: var(--subhamithra-accent); }
.subhamithra-ms-title { margin: 0 0 14px; font-family: var(--subhamithra-font-head, inherit); font-size: 1.2em; line-height: 1.25; color: var(--subhamithra-head, var(--subhamithra-primary)); }
.subhamithra-ms-form { margin: 0; }

/* ---------- Fields ---------- */
.subhamithra-ms-fields { display: grid; gap: 14px 16px; }
.subhamithra-ms-formwrap--vertical .subhamithra-ms-fields { grid-template-columns: minmax(0, 1fr); }
.subhamithra-ms-formwrap--horizontal .subhamithra-ms-fields { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.subhamithra-ms .subhamithra-ms-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.subhamithra-ms .subhamithra-ms-field > label,
.subhamithra-ms .subhamithra-ms-range > legend { font-weight: 600; font-size: .92em; padding: 0; margin: 0 0 6px; color: var(--subhamithra-text); float: none; width: 100%; display: block; }
.subhamithra-ms .subhamithra-ms-field input[type="text"],
.subhamithra-ms .subhamithra-ms-field input[type="number"],
.subhamithra-ms .subhamithra-ms-field select {
	width: 100%; max-width: 100%; min-width: 0; padding: 11px 13px; font: inherit; font-size: .95rem; line-height: 1.3;
	color: var(--subhamithra-text); background: var(--subhamithra-surface);
	border: 1.5px solid var(--subhamithra-border); border-color: var(--subhamithra-ms-field-border);
	border-radius: var(--subhamithra-radius, 12px);
	transition: border-color .2s, box-shadow .2s, background .2s;
}
.subhamithra-ms .subhamithra-ms-field select option { background: var(--subhamithra-bg); color: var(--subhamithra-text); }
.subhamithra-ms .subhamithra-ms-field input::placeholder { color: var(--subhamithra-muted); opacity: 1; }
.subhamithra-ms .subhamithra-ms-field input:focus,
.subhamithra-ms .subhamithra-ms-field select:focus {
	border-color: var(--subhamithra-ms-focus); background: var(--subhamithra-bg);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--subhamithra-ms-focus) 22%, transparent);
}

.subhamithra-ms-range__inputs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
.subhamithra-ms-range__inputs--select { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.subhamithra-ms-note { margin: 12px 0 0; color: var(--subhamithra-muted); font-size: .88em; }
.subhamithra-ms-hint-admin { margin: 0 0 12px; }

.subhamithra-ms-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.subhamithra-ms-actions .subhamithra-btn { flex: 1 1 auto; text-align: center; }
.subhamithra-ms-formwrap--horizontal .subhamithra-ms-actions .subhamithra-btn { flex: 0 0 auto; min-width: 140px; }

/* Mobile toggle (shown only when JS is active, see media query). */
.subhamithra-ms .subhamithra-ms-toggle { display: none; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 0 0 12px; }
.subhamithra-ms .subhamithra-ms-toggle__label { display: inline-flex; align-items: center; gap: 8px; }
.subhamithra-ms-badge { min-width: 22px; text-align: center; background: var(--subhamithra-ms-grad); }
/* Accessible primary buttons and "current page" chip (white text >= 4.5:1). */
.subhamithra-ms .subhamithra-btn--primary { background: var(--subhamithra-ms-grad); color: var(--subhamithra-on-primary, #fff); }
.subhamithra-ms .subhamithra-btn--primary:hover { color: var(--subhamithra-on-primary, #fff); }
.subhamithra-ms-badge[data-count="0"], .subhamithra-ms-badge[data-count="0"] ~ .subhamithra-ms-sr { display: none; }

/* ---------- Results ---------- */
.subhamithra-ms-results { position: relative; min-width: 0; min-height: 96px; }
.subhamithra-ms-results .subhamithra-list, .subhamithra-ms-results .subhamithra-ms-toolbar, .subhamithra-ms-results .subhamithra-ms-chips { transition: opacity .15s ease; }
.subhamithra-ms-results.is-loading .subhamithra-list,
.subhamithra-ms-results.is-loading .subhamithra-ms-toolbar,
.subhamithra-ms-results.is-loading .subhamithra-ms-chips,
.subhamithra-ms-results.is-loading .subhamithra-ms-empty { opacity: .4; pointer-events: none; }
.subhamithra-ms-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin: 0 0 14px; }
.subhamithra-ms-count { margin: 0; font-weight: 700; color: var(--subhamithra-head, var(--subhamithra-primary)); }
.subhamithra-ms-count:focus, .subhamithra-ms-empty:focus { outline: none; }
.subhamithra-ms-count:focus-visible, .subhamithra-ms-empty:focus-visible { outline: 3px solid var(--subhamithra-ms-focus); outline-offset: 4px; border-radius: 6px; }
.subhamithra-ms-sort { display: flex; align-items: center; gap: 8px; margin: 0; }
.subhamithra-ms-sort label { font-weight: 600; font-size: .92em; }
.subhamithra-ms-sort select {
	padding: 9px 12px; font: inherit; color: var(--subhamithra-text); background: var(--subhamithra-surface);
	border: 1.5px solid var(--subhamithra-border); border-color: var(--subhamithra-ms-field-border); border-radius: var(--subhamithra-radius, 12px);
}
.subhamithra-ms-sort select:focus { border-color: var(--subhamithra-ms-focus); }
.subhamithra-ms-chips { margin: 0 0 var(--subhamithra-gap, 22px) !important; }
.subhamithra-ms-chips li { color: var(--subhamithra-text); }

/* Loading indicator (added by the script while a search is running). */
.subhamithra-ms-loader {
	position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3;
	display: inline-flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px;
	background: var(--subhamithra-bg); color: var(--subhamithra-text); border: 1px solid var(--subhamithra-border);
	box-shadow: 0 10px 26px var(--subhamithra-shadow, rgba(0, 0, 0, .25)); font-weight: 600; font-size: .92em;
}
.subhamithra-ms-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--subhamithra-border); border-top-color: var(--subhamithra-link); animation: kmsMsSpin .7s linear infinite; }
@keyframes kmsMsSpin { to { transform: rotate(360deg); } }

/* Empty state: icon, headline, tips and a call-to-action button (see also .subhamithra-empty in Profiles). */
.subhamithra-ms .subhamithra-empty { text-align: center; max-width: 520px; margin: 0 auto; padding: 28px 12px; }
.subhamithra-ms .subhamithra-empty__icon { width: 72px; height: 72px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; background: var(--subhamithra-grad, var(--subhamithra-primary)); color: var(--subhamithra-on-primary, #fff); }
.subhamithra-ms .subhamithra-ms-empty__title { margin: 0 0 8px; font-family: var(--subhamithra-font-head, inherit); font-size: 1.35rem; color: var(--subhamithra-head, var(--subhamithra-primary)); }
.subhamithra-ms .subhamithra-empty p { color: var(--subhamithra-muted); margin: 0 0 10px; }
.subhamithra-ms .subhamithra-ms-tips { margin: 0 auto 14px; padding: 0; list-style: none; display: inline-block; text-align: left; color: var(--subhamithra-text); }
.subhamithra-ms .subhamithra-ms-tips li { position: relative; padding-left: 20px; margin: 4px 0; }
.subhamithra-ms .subhamithra-ms-tips li::before { content: ""; position: absolute; left: 4px; top: .65em; width: 7px; height: 7px; border-radius: 50%; background: var(--subhamithra-accent); }
.subhamithra-ms .subhamithra-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.subhamithra-ms .subhamithra-row--center { justify-content: center; }

/* Notices and error messages (match Profiles; also used when its stylesheet is absent). */
.subhamithra-ms .subhamithra-notice, .subhamithra-ms-hint-admin {
	border-left: 4px solid var(--subhamithra-primary, #1b2a5c); background: var(--subhamithra-surface, #f3f5fa); color: var(--subhamithra-text, #1a2038);
	padding: 12px 16px; margin: 0 0 var(--subhamithra-gap, 20px); border-radius: 0 var(--subhamithra-radius, 10px) var(--subhamithra-radius, 10px) 0;
}
.subhamithra-ms .subhamithra-notice p, .subhamithra-ms-hint-admin p { margin: 0 0 8px; }
.subhamithra-ms .subhamithra-notice p:last-child, .subhamithra-ms-hint-admin p:last-child { margin-bottom: 0; }
.subhamithra-ms .subhamithra-notice--error { border-color: var(--subhamithra-danger, #b3261e); }
.subhamithra-ms .subhamithra-notice--warning, .subhamithra-ms-hint-admin { border-color: var(--subhamithra-accent, #c8102e); }
.subhamithra-ms .subhamithra-notice--error a, .subhamithra-ms .subhamithra-notice--warning a { color: var(--subhamithra-link); }
.subhamithra-ms-error .subhamithra-row { margin-top: 6px; }

/* Pagination: current page and hover use the theme colours. */
.subhamithra-ms-results .subhamithra-pagination .current { background: var(--subhamithra-ms-grad); border-color: transparent; color: var(--subhamithra-on-primary, #fff); }
.subhamithra-ms-results .subhamithra-pagination a:hover { border-color: var(--subhamithra-primary); color: var(--subhamithra-link); }

/* ---------- Quick search widget ---------- */
.subhamithra-ms-quick form { margin: 0; }
.subhamithra-ms-quick__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 16px; align-items: end; }
.subhamithra-ms-quick__submit .subhamithra-btn { width: 100%; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.subhamithra-ms-layout--sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
	/* The panel collapses only when JavaScript can reopen it. */
	.subhamithra-ms--js .subhamithra-ms-toggle { display: flex; }
	.subhamithra-ms--js .subhamithra-ms-panel { display: none; }
	.subhamithra-ms--js .subhamithra-ms-panel.is-open { display: block; }
	.subhamithra-ms-formwrap { padding: 14px 14px 16px; }
	.subhamithra-ms-formwrap--horizontal .subhamithra-ms-actions .subhamithra-btn { flex: 1 1 auto; }
	.subhamithra-ms-toolbar { flex-direction: column; align-items: flex-start; }
	.subhamithra-ms-sort { width: 100%; }
	.subhamithra-ms-sort select { flex: 1 1 auto; min-width: 0; }
}

@media (max-width: 640px) {
	.subhamithra-ms .subhamithra-list { grid-template-columns: minmax(0, 1fr); }
	.subhamithra-ms-quick { padding: 14px; }
	.subhamithra-ms .subhamithra-empty__icon { width: 60px; height: 60px; }
	.subhamithra-ms .subhamithra-row--center .subhamithra-btn { flex: 1 1 100%; }
}

@media (max-width: 380px) {
	.subhamithra-ms-range__inputs { gap: 6px; }
	.subhamithra-ms .subhamithra-ms-field input[type="text"],
	.subhamithra-ms .subhamithra-ms-field input[type="number"],
	.subhamithra-ms .subhamithra-ms-field select { padding: 10px 10px; }
	.subhamithra-ms-results .subhamithra-pagination a, .subhamithra-ms-results .subhamithra-pagination span.page-numbers { padding: 7px 11px; }
}

@media (prefers-reduced-motion: reduce) {
	.subhamithra-ms-results, .subhamithra-ms-results .subhamithra-list, .subhamithra-ms-results .subhamithra-ms-toolbar { transition: none; }
	.subhamithra-ms-spinner { animation-duration: 2s; }
}

@media (forced-colors: active) {
	.subhamithra-ms .subhamithra-ms-field input, .subhamithra-ms .subhamithra-ms-field select, .subhamithra-ms-sort select { border-color: ButtonText; }
	.subhamithra-ms-formwrap, .subhamithra-ms-quick { border-color: CanvasText; }
}
