/* Spectrum Explorer page (spectrum/explorer.html, assets/js/spectrum-explorer-page.js) */

/* The site's button style sets display, which would override the browser's "hidden" switch */
.sx-app [hidden] { display: none !important; }

/* The site styles every <button> as a large uppercase outline button; these are plain controls */
.sx-chip, .sx-result, .sx-tool, .sx-tab, .sx-list button, .sx-mode, .sx-clear, .sx-more-results {
	box-shadow: none;
	font-family: "Open Sans", sans-serif;
	height: auto;
	letter-spacing: 0;
	line-height: 1.45;
	text-transform: none;
	white-space: normal;
}

/* ---------- Layout: search on top, results left, viewer right, details across the full width ---------- */
.sx-app {
	align-items: start;
	display: grid;
	gap: 1.6em;
	grid-template-areas: "search search" "results viewer" "details details";
	grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
}
.sx-area-search { grid-area: search; }
.sx-area-results { grid-area: results; }
.sx-area-viewer { grid-area: viewer; }
.sx-area-details { grid-area: details; }

/* The results column is exactly as tall as the viewer and scrolls inside */
.sx-area-results { display: flex; flex-direction: column; height: 0; min-height: 100%; }

/* ---------- Search ---------- */
.sx-search {
	background: #fff;
	border: 1px solid rgba(210, 215, 217, 0.75);
	border-radius: 12px;
	box-shadow: 0 4px 18px rgba(61, 68, 73, 0.06);
	padding: 1.3em 1.4em 1.1em;
	position: relative;
}
.sx-modes { display: flex; flex-wrap: wrap; gap: 0.4em; margin-bottom: 1em; }
.sx-mode {
	background: #f5f6f7;
	border: 1px solid rgba(210, 215, 217, 0.75);
	border-radius: 999px;
	color: #3d4449;
	cursor: pointer;
	font-size: 0.85em;
	font-weight: 600;
	padding: 0.45em 1.1em;
}
.sx-mode[aria-selected="true"] { background: #f56565; border-color: #f56565; color: #fff !important; }
.sx-mode .icon { margin-right: 0.3em; }
.sx-section { display: none; position: relative; }
.sx-section.is-active { display: block; }
.sx-field-row { display: flex; gap: 0.6em; }
.sx-field-row input { flex: 1; font-size: 1.02em; height: 3em; min-width: 0; }
.sx-field-row select { flex: 0 0 9em; height: 3em; }
.sx-field-row .button { flex: 0 0 auto; height: 3em; line-height: 3em; }
.sx-help { color: #7f888f; font-size: 0.8em; margin: 0.5em 0 0; }
.sx-suggest {
	background: #fff;
	border: 1px solid rgba(210, 215, 217, 0.9);
	border-radius: 8px;
	box-shadow: 0 12px 28px rgba(61, 68, 73, 0.14);
	left: 0;
	list-style: none;
	margin: 0.3em 0 0;
	max-height: 18em;
	overflow-y: auto;
	padding: 0.3em 0;
	position: absolute;
	right: 8.5em;
	z-index: 20;
}
.sx-suggest li { cursor: pointer; margin: 0; padding: 0.45em 1em; }
.sx-suggest li[aria-selected="true"], .sx-suggest li:hover { background: rgba(245, 101, 101, 0.08); color: #f56565; }
.sx-popular { align-items: center; display: flex; flex-wrap: wrap; font-size: 0.85em; gap: 0.45em; margin-top: 0.9em; }
/* Filters under the search box: used by every way of searching */
.sx-filters { align-items: center; display: flex; flex-wrap: wrap; font-size: 0.85em; gap: 0.45em; margin-top: 0.8em; }
.sx-filters span { color: #7f888f; margin-right: 0.2em; }
.sx-filters select { flex: 0 1 13em; font-size: 0.95em; height: 2.4em; min-width: 8em; padding: 0 2em 0 0.8em; }
.sx-filters select.is-set { border-color: #f56565; color: #d94c4c; }
.sx-popular span { color: #7f888f; margin-right: 0.2em; }
.sx-chip {
	background: #f5f6f7;
	border: 1px solid rgba(210, 215, 217, 0.75);
	border-radius: 999px;
	color: #3d4449;
	cursor: pointer;
	font-size: 0.95em;
	padding: 0.2em 0.8em;
	transition: border-color 0.2s, color 0.2s;
}
.sx-chip:hover, .sx-chip:focus-visible { border-color: #f56565; color: #f56565; outline: none; }

/* ---------- Results / Recently viewed ---------- */
.sx-results-head { align-items: baseline; display: flex; flex-wrap: wrap; gap: 0.2em 0.8em; margin-bottom: 0.6em; }
.sx-results-head h3 { font-size: 1em; margin: 0; }
.sx-results-head span { color: #7f888f; font-size: 0.8em; }
.sx-clear {
	background: none;
	border: 0;
	color: #f56565 !important;
	cursor: pointer;
	font-size: 0.78em;
	font-weight: 600;
	margin-left: auto;
	padding: 0;
}
.sx-clear:hover { text-decoration: underline; }
.sx-results { flex: 1; list-style: none; margin: 0; min-height: 0; overflow-y: auto; padding: 0 0.3em 0 0; }
.sx-results li { margin: 0 0 0.5em; padding: 0; }
.sx-result {
	background: #fff;
	border: 1px solid rgba(210, 215, 217, 0.75);
	border-radius: 10px;
	color: #3d4449;
	cursor: pointer;
	display: block;
	padding: 0.7em 0.9em;
	text-align: left;
	transition: border-color 0.2s, box-shadow 0.2s;
	width: 100%;
}
.sx-result:hover, .sx-result:focus-visible { border-color: #f56565; outline: none; }
.sx-result.is-active { border-color: #f56565; box-shadow: 0 0 0 2px rgba(245, 101, 101, 0.18); }
.sx-result strong { display: block; font-family: "Roboto Slab", serif; font-size: 0.98em; }
.sx-result .sx-formula { color: #7f888f; font-size: 0.85em; }
.sx-result .sx-meta { color: #7f888f; display: flex; flex-wrap: wrap; font-size: 0.75em; gap: 0.3em 0.9em; margin-top: 0.3em; }
.sx-tag {
	background: rgba(245, 101, 101, 0.1);
	border-radius: 999px;
	color: #d94c4c;
	font-size: 0.72em;
	font-weight: 700;
	letter-spacing: 0.06em;
	padding: 0.15em 0.65em;
	text-transform: uppercase;
}
.sx-empty, .sx-recent-hint { color: #7f888f; font-size: 0.85em; line-height: 1.5; padding: 0.4em 0.2em; }
.sx-message { color: #b54747; font-size: 0.85em; line-height: 1.5; padding: 0.4em 0.2em; }
.sx-more-results {
	background: none;
	border: 1px dashed rgba(245, 101, 101, 0.6);
	border-radius: 10px;
	color: #f56565 !important;
	cursor: pointer;
	font-size: 0.82em;
	font-weight: 600;
	padding: 0.7em;
	width: 100%;
}
.sx-more-results:hover { background: rgba(245, 101, 101, 0.06); }
.sx-results .chem-loader { padding: 1.5em 0.5em; }

/* ---------- Viewer ---------- */
.sx-viewer {
	background: linear-gradient(140deg, #26334d 0%, #3b4378 55%, #5b67c9 100%);
	border-radius: 14px;
	box-shadow: 0 10px 30px rgba(59, 67, 120, 0.3);
	color: #fff;
	padding: 1.4em 1.5em 1.1em;
	position: relative;
}
.sx-viewer-head { align-items: flex-start; display: flex; gap: 1em; justify-content: space-between; }
.sx-viewer-head h2 { color: #fff; font-size: 1.6em; margin: 0; }
.sx-viewer-head .sx-formula { color: rgba(255, 255, 255, 0.82); font-size: 1.05em; margin-top: 0.15em; }
.sx-viewer .sx-tag { background: rgba(255, 255, 255, 0.16); color: #ffd6d6; font-size: 0.7em; white-space: nowrap; }
.sx-tags { align-items: flex-end; display: flex; flex-direction: column; gap: 0.3em; }
.sx-viewer .sx-tag-note { background: rgba(126, 224, 240, 0.16); color: #c8f3fa; }
/* Several measurements of the same material: a compact switch under the name */
.sx-measure { align-items: center; display: flex; flex-wrap: wrap; font-size: 0.78em; gap: 0.5em; margin: 0.45em 0 0; }
.sx-measure span { color: rgba(255, 255, 255, 0.75); }
.sx-viewer .sx-measure select {
	background-color: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 999px;
	color: #fff;
	font-size: 1em;
	height: 2.1em;
	max-width: 100%;
	padding: 0 2.2em 0 0.9em;
}
.sx-viewer .sx-measure select option, .sx-viewer .sx-measure select optgroup { color: #3d4449; }
.sx-context { color: rgba(255, 255, 255, 0.8); font-size: 0.9em; font-style: italic; margin: 0.5em 0 0.9em; min-height: 1.4em; }
.sx-plot { height: 340px; position: relative; touch-action: pan-y; user-select: none; }
.sx-plot canvas { cursor: crosshair; display: block; height: 100%; width: 100%; }
.sx-plot-message {
	align-items: center;
	color: rgba(255, 255, 255, 0.85);
	display: flex;
	flex-direction: column;
	font-size: 0.9em;
	inset: 0;
	justify-content: center;
	position: absolute;
	text-align: center;
}
.sx-plot-message .chem-loader { color: rgba(255, 255, 255, 0.85); }
.sx-tip {
	background: #fff;
	border-radius: 6px;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
	color: #26334d;
	font-size: 0.78em;
	font-weight: 700;
	left: 0;
	opacity: 0;
	padding: 0.25em 0.6em;
	pointer-events: none;
	position: absolute;
	top: 0;
	transform: translate(-50%, -130%) scale(0.85);
	transition: opacity 0.15s, transform 0.18s cubic-bezier(.3, 1.4, .6, 1), left 0.12s, top 0.12s;
	white-space: nowrap;
}
.sx-tip.is-visible { opacity: 1; transform: translate(-50%, -130%) scale(1); }
.sx-tools { align-items: center; display: flex; flex-wrap: wrap; gap: 0.5em; justify-content: space-between; margin-top: 0.7em; }
.sx-hint { color: rgba(255, 255, 255, 0.65); font-size: 0.75em; }
.sx-buttons { display: flex; flex-wrap: wrap; gap: 0.4em; }
.sx-tool {
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 6px;
	color: #fff !important;
	cursor: pointer;
	font-size: 0.75em;
	font-weight: 600;
	padding: 0.35em 0.8em;
}
.sx-tool:hover, .sx-tool:focus-visible { background: rgba(255, 255, 255, 0.22); outline: none; }
.sx-tool[aria-pressed="true"] { background: #fff; color: #3b4378 !important; }

/* ---------- Compare: up to 4 spectra in coral, teal, gold and lilac (line colours are set by the script) ---------- */
.sx-mode-compare { margin-left: auto; }
.sx-mode-compare[aria-selected="true"] { background: #2fb5a9; border-color: #2fb5a9; }
/* "Identify my spectrum": a link to the Spectrum Toolkit's Identify tab, shaped like the search modes */
a.sx-mode { border-bottom: 1px solid rgba(210, 215, 217, 0.75); text-decoration: none; }
.sx-mode-identify { background: #fff; border-color: #3b4378; border-bottom-color: #3b4378; color: #3b4378 !important; }
.sx-mode-identify:hover, .sx-mode-identify:focus-visible { background: #3b4378; color: #fff !important; }
a.sx-tool { border-bottom: 1px solid rgba(255, 255, 255, 0.22); text-decoration: none; }
a.sx-tool[hidden] { display: none; }
.sx-pick-hint {
	align-items: center;
	background: rgba(47, 181, 169, 0.09);
	border-radius: 8px;
	color: #1f7f77;
	display: flex;
	font-size: 0.8em;
	gap: 0.5em;
	line-height: 1.4;
	margin: 0 0 0.6em;
	padding: 0.45em 0.75em;
}
.sx-pick-hint::before { background: #2fb5a9; border-radius: 50%; content: ""; flex: 0 0 0.55em; height: 0.55em; }
.sx-result.is-compared { border-color: #2fb5a9; box-shadow: 0 0 0 2px rgba(47, 181, 169, 0.2); }
.sx-legend { align-items: center; display: flex; flex-wrap: wrap; gap: 0.5em 1em; justify-content: space-between; margin: 0.55em 0 0.75em; min-height: 1.4em; }
.sx-keys { align-items: center; display: flex; flex-wrap: wrap; gap: 0.4em; min-width: 0; }
.sx-key {
	align-items: center;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	display: inline-flex;
	font-size: 0.82em;
	gap: 0.5em;
	max-width: 100%;
	padding: 0.2em 0.8em;
}
.sx-key i { border-radius: 2px; display: block; flex: 0 0 1.4em; height: 3px; }
.sx-key b { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-key-end, .sx-swap, .sx-layout button {
	box-shadow: none;
	font-family: "Open Sans", sans-serif;
	height: auto;
	letter-spacing: 0;
	line-height: 1.4;
	text-transform: none;
}
.sx-key-end {
	background: none;
	border: 0;
	color: rgba(255, 255, 255, 0.6) !important;
	cursor: pointer;
	font-size: 0.85em;
	margin-right: -0.3em;
	padding: 0 0.2em;
}
.sx-key-end:hover, .sx-key-end:focus-visible { color: #fff !important; outline: none; }
.sx-swap {
	background: none;
	border: 0;
	color: rgba(255, 255, 255, 0.6) !important;
	cursor: pointer;
	font-size: 0.8em;
	padding: 0.2em 0.3em;
	transition: transform 0.25s ease;
}
.sx-swap:hover, .sx-swap:focus-visible { color: #fff !important; outline: none; transform: rotate(180deg); }
.sx-layout { background: rgba(0, 0, 0, 0.18); border-radius: 999px; display: inline-flex; padding: 3px; }
.sx-layout button {
	background: none;
	border: 0;
	border-radius: 999px;
	color: rgba(255, 255, 255, 0.7) !important;
	cursor: pointer;
	font-size: 0.75em;
	font-weight: 600;
	padding: 0.3em 1em;
	transition: background-color 0.2s, color 0.2s;
}
.sx-layout button[aria-pressed="true"] { background: #fff; color: #26334d !important; }
.sx-layout button:hover:not([aria-pressed="true"]) { color: #fff !important; }
.sx-tip i { border-radius: 50%; display: inline-block; height: 0.6em; margin-right: 0.45em; vertical-align: 0.05em; width: 0.6em; }
.sx-peaks-pair { display: grid; gap: 1.2em; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.sx-peaks-pair > div + div { border-left: 1px solid rgba(210, 215, 217, 0.6); padding-left: 1.2em; }
.sx-peaks-pair h4, .sx-about-head { align-items: center; display: flex; font-size: 0.85em; gap: 0.5em; margin: 0 0 0.4em; }
.sx-peaks-pair h4 i, .sx-about-head i { border-radius: 2px; display: block; flex: 0 0 1.4em; height: 3px; }
.sx-peaks-pair .sx-peaks td:nth-child(3), .sx-peaks-pair .sx-peaks th:nth-child(3) { display: none; }   /* no room for assignments */
.sx-peaks .sx-bar { background: var(--bar-bg, rgba(245, 101, 101, 0.15)); }
.sx-peaks .sx-bar i { background: var(--bar, #f56565); }
.sx-peaks tbody tr:hover { background: var(--row-hover, rgba(245, 101, 101, 0.06)); }

/* Shared band: the row clicked, and the matching bands in the other spectra */
.sx-peaks tbody tr.is-selected td, .sx-peaks tbody tr.is-shared td { background: var(--row-mark, rgba(245, 101, 101, 0.14)); }
.sx-peaks tbody tr.is-selected td:first-child, .sx-peaks tbody tr.is-shared td:first-child { box-shadow: inset 3px 0 0 var(--bar, #f56565); }
.sx-shared { align-items: center; color: #fff; display: flex; flex-wrap: wrap; font-size: 0.75em; gap: 0.3em 0.9em; }
.sx-shared strong { color: #fff; font-weight: 700; }
.sx-shared small { color: rgba(255, 255, 255, 0.6); font-size: 1em; margin-left: -0.5em; }
.sx-shared span { align-items: center; display: inline-flex; gap: 0.4em; white-space: nowrap; }
.sx-shared span i { border-radius: 50%; flex: 0 0 0.6em; height: 0.6em; }
.sx-shared span b { color: #fff; font-weight: 700; }
.sx-shared span.is-missing { opacity: 0.5; }
.sx-shared span.is-missing i { background: none !important; border: 1px solid rgba(255, 255, 255, 0.7); }
.sx-shared-close {
	background: none;
	border: 0;
	box-shadow: none;
	color: rgba(255, 255, 255, 0.6) !important;
	cursor: pointer;
	font-size: 1em;
	height: auto;
	line-height: 1;
	padding: 0.2em;
}
.sx-shared-close:hover, .sx-shared-close:focus-visible { color: #fff !important; outline: none; }

/* About, comparing: one column per spectrum, side by side, divided by light lines; the labels once on the left */
.sx-about-wrap { overflow-x: auto; }
.sx-about-grid { display: grid; font-size: 0.85em; min-width: 100%; }
.sx-about-grid > * { margin: 0; padding: 0.35em 0.9em; }
.sx-about-grid dt { color: #7f888f; font-weight: 600; padding-left: 0; }
.sx-about-grid dd { border-left: 1px solid rgba(210, 215, 217, 0.6); min-width: 11em; overflow-wrap: anywhere; }
.sx-about-grid .sx-about-head { border-bottom: 1px solid rgba(210, 215, 217, 0.6); font-family: "Roboto Slab", serif; font-size: 1em; font-weight: 700; margin: 0 0 0.3em; padding-bottom: 0.55em; }

/* Stacked 3 or 4 spectra: a taller plot, so each keeps a useful height */
.sx-plot[data-rows="3"] { height: 440px; }
.sx-plot[data-rows="4"] { height: 540px; }

/* ---------- Details (full width under the results and the viewer) ---------- */
.sx-tabs { border-bottom: 1px solid rgba(210, 215, 217, 0.75); display: flex; flex-wrap: wrap; gap: 0.2em; margin: 0 0 0.9em; }
.sx-tab {
	background: none;
	border: 0;
	border-bottom: 3px solid transparent;
	color: #7f888f !important;
	cursor: pointer;
	font-size: 0.85em;
	font-weight: 600;
	padding: 0.6em 0.9em;
}
.sx-tab[aria-selected="true"] { border-bottom-color: #f56565; color: #3d4449 !important; }
.sx-panel { min-height: 6em; }
.sx-panel-note { color: #7f888f; font-size: 0.75em; margin-top: 0.7em; }
.sx-peaks { border-collapse: collapse; font-size: 0.85em; width: 100%; }
.sx-peaks th { color: #7f888f; font-size: 0.85em; text-align: left; }
.sx-peaks td, .sx-peaks th { border-bottom: 1px solid rgba(210, 215, 217, 0.5); padding: 0.4em 0.6em; }
.sx-peaks tbody tr { cursor: pointer; }
.sx-bar { background: rgba(245, 101, 101, 0.15); border-radius: 3px; display: block; height: 0.55em; position: relative; width: 8em; }
.sx-bar i { background: #f56565; border-radius: 3px; display: block; height: 100%; }
.sx-about { display: grid; font-size: 0.88em; gap: 0.45em 1.2em; grid-template-columns: max-content 1fr; margin: 0; }
.sx-about dt { color: #7f888f; font-weight: 600; }
.sx-about dd { margin: 0; }
.sx-list { list-style: none; margin: 0; padding: 0; }
.sx-list li { margin: 0 0 0.4em; padding: 0; }
.sx-list button {
	align-items: center;
	background: #fff;
	border: 1px solid rgba(210, 215, 217, 0.75);
	border-radius: 8px;
	color: #3d4449 !important;
	cursor: pointer;
	display: flex;
	font-size: 0.85em;
	font-weight: 400;
	gap: 1em;
	justify-content: space-between;
	padding: 0.55em 0.9em;
	text-align: left;
	width: 100%;
}
.sx-list button:hover { border-color: #f56565; }
.sx-list small { color: #7f888f; }

/* ---------- Smaller screens: one column ---------- */
@media screen and (max-width: 1280px) {
	.sx-app { grid-template-areas: "search" "results" "viewer" "details"; grid-template-columns: minmax(0, 1fr); }
	.sx-area-results { height: auto; min-height: 0; }
	.sx-results { display: grid; gap: 0.5em; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: 28em; }
	.sx-results li { margin: 0; }
}
@media screen and (max-width: 736px) {
	.sx-filters { display: grid; gap: 0.45em; grid-template-columns: 1fr 1fr; }
	.sx-filters span { grid-column: 1 / -1; }
	.sx-filters select { min-width: 0; width: 100%; }
	.sx-search { padding: 1em; }
	.sx-field-row { flex-wrap: wrap; }
	.sx-field-row input { flex: 1 1 100%; }
	.sx-field-row select, .sx-field-row .button { flex: 1 1 auto; }
	.sx-suggest { right: 0; }
	.sx-viewer { padding: 1.1em 1em 0.9em; }
	.sx-plot { height: 240px; }
	.sx-viewer-head h2 { font-size: 1.3em; }
	.sx-about { grid-template-columns: 1fr; gap: 0.1em; }
	.sx-about dd { margin-bottom: 0.5em; }
	.sx-bar { width: 4.5em; }
	.sx-peaks-pair { grid-template-columns: 1fr; }
	.sx-peaks-pair > div + div { border-left: 0; border-top: 1px solid rgba(210, 215, 217, 0.6); padding: 1em 0 0; }
	.sx-mode-compare { margin-left: 0; }
	.sx-plot[data-rows="3"] { height: 330px; }
	.sx-plot[data-rows="4"] { height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
	.sx-tip, .sx-chip, .sx-result { transition: none; }
}
