/* CR Space Weather Tracker
 * Brand: Curious Research purple (from the logo). Rules: no white backgrounds,
 * no drop shadows, no outlines; everything stays inside the content column.
 */
.crsw {
	--bg: #160a26;
	--panel: #22103a;
	--panel-2: #2e1650;
	--panel-3: #3a1c66;
	--brand: #8a2bc9;
	--brand-hi: #b67df0;
	--lav: #dcc4f5;
	--text: #efe6f8;
	--muted: #b9a6cf;
	--amber: #c8863a;
	--warn: #e0a84a;
	--severe: #ff7a7a;
	--good: #7fd1a3;
	--r: 14px;

	box-sizing: border-box;
	width: 100%;
	max-width: min(100%, var(--crsw-max, 100%));
	margin: 0 auto 2rem;
	padding: clamp(12px, 3vw, 28px);
	background: var(--bg);
	color: var(--text);
	border-radius: var(--r);
	font-size: 16px;
	line-height: 1.5;
	overflow: hidden;
	overflow-wrap: break-word;
	font-family: inherit;
}

/* Hard brand rules: no borders/outlines/shadows anywhere inside the tracker,
   whatever the active theme says. */
.crsw, .crsw *, .crsw *::before, .crsw *::after {
	box-sizing: border-box;
	border: 0 !important;
	outline: 0 !important;
	box-shadow: none !important;
	text-shadow: none !important;
	filter: none;
}

.crsw h2, .crsw h3, .crsw h4 { color: var(--lav); margin: 0 0 .5em; line-height: 1.2; font-weight: 700; letter-spacing: 0; text-transform: none; }
.crsw h2 { font-size: clamp(1.35rem, 3.2vw, 1.9rem); }
.crsw h3 { font-size: clamp(1.1rem, 2.4vw, 1.35rem); margin-top: 1.4em; }
.crsw h4 { font-size: 1rem; color: var(--brand-hi); }
.crsw p { margin: 0 0 .8em; color: var(--text); }
.crsw a { color: var(--brand-hi); text-decoration: underline; text-underline-offset: 3px; }
.crsw a:hover { color: var(--lav); }
.crsw img { max-width: 100%; height: auto; display: block; background: transparent; }
.crsw small, .crsw .crsw-muted { color: var(--muted); }
.crsw-vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.crsw-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 18px; }
.crsw-logo { width: min(360px, 100%); }
.crsw-head-text { flex: 1 1 260px; min-width: 0; }
.crsw-title { margin: 0 0 .2em !important; }
.crsw-sub { color: var(--muted) !important; margin: 0 !important; font-size: .95rem; }

/* Search */
.crsw-search { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.crsw-q {
	flex: 1 1 260px; min-width: 0; padding: 12px 14px; border-radius: 10px;
	background: var(--panel-2) !important; color: var(--text) !important; font-size: 1rem; -webkit-appearance: none; appearance: none;
}
.crsw-q::placeholder { color: var(--muted); opacity: 1; }
.crsw-q:focus { background: var(--panel-3) !important; }
.crsw-btn {
	flex: 0 0 auto; padding: 12px 18px; border-radius: 10px; cursor: pointer;
	background: var(--brand) !important; color: #fff !important; font-weight: 700; font-size: .95rem; line-height: 1.2;
	-webkit-appearance: none; appearance: none; text-transform: none; letter-spacing: 0;
}
.crsw-btn:hover, .crsw-btn:focus-visible { background: #a046e0 !important; text-decoration: underline; }
.crsw-btn-alt { background: var(--panel-3) !important; }
.crsw-btn-alt:hover, .crsw-btn-alt:focus-visible { background: #4a2680 !important; }
.crsw-btn[disabled] { opacity: .6; cursor: progress; }
.crsw-place { min-height: 1.5em; color: var(--lav); font-weight: 600; margin-bottom: 6px; }
.crsw-place .crsw-muted { font-weight: 400; }
.crsw-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.crsw-choice { padding: 8px 12px; border-radius: 999px; background: var(--panel-2) !important; color: var(--text) !important; cursor: pointer; font-size: .9rem; }
.crsw-choice:hover, .crsw-choice:focus-visible { background: var(--panel-3) !important; }

/* Tabs: wrap so every category is always visible, on any width. */
.crsw-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; padding: 6px; background: var(--panel); border-radius: 12px; }
.crsw-tab {
	flex: 1 1 auto; padding: 9px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
	background: transparent !important; color: var(--muted) !important; font-size: .9rem; font-weight: 600; line-height: 1.2;
	-webkit-appearance: none; appearance: none; text-transform: none; letter-spacing: 0;
}
.crsw-tab:hover, .crsw-tab:focus-visible { background: var(--panel-2) !important; color: var(--text) !important; }
.crsw-tab[aria-selected="true"] { background: var(--brand) !important; color: #fff !important; }

.crsw-panel { min-width: 0; }
.crsw-panel[hidden] { display: none !important; }
.crsw-loading { color: var(--muted); }

/* Cards and stat tiles */
.crsw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 10px; margin: 0 0 14px; }
.crsw-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; margin: 0 0 14px; }
.crsw-card { background: var(--panel); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.crsw-card > :last-child { margin-bottom: 0; }
.crsw-stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 2px; }
.crsw-stat-value { font-size: clamp(1.4rem, 3.6vw, 1.9rem); font-weight: 800; color: var(--text); line-height: 1.15; font-variant-numeric: tabular-nums; }
.crsw-stat-unit { font-size: .9rem; color: var(--muted); font-weight: 500; margin-left: 4px; }
.crsw-stat-note { font-size: .85rem; color: var(--muted); margin-top: 4px; }

/* Status badge (always text + colour, never colour alone) */
.crsw-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--panel-3); color: var(--text); white-space: nowrap; }
.crsw-badge.is-quiet { background: #2d2a4a; color: var(--muted); }
.crsw-badge.is-good { background: #1f3d33; color: var(--good); }
.crsw-badge.is-warn { background: #4a3313; color: var(--warn); }
.crsw-badge.is-severe { background: #4d1a24; color: var(--severe); }
.crsw-badge.is-info { background: #33195a; color: var(--brand-hi); }

/* NOAA scales row */
.crsw-scales { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.crsw-scale { background: var(--panel); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.crsw-scale b { display: block; font-size: 1.6rem; line-height: 1.1; }
.crsw-scale span { font-size: .85rem; color: var(--muted); }

/* Tables: horizontal scroll inside the column on medium widths, stacked cards on phones. */
.crsw-filter { width: 100%; padding: 10px 12px; margin: 0 0 8px; border-radius: 10px; background: var(--panel-2) !important; color: var(--text) !important; font-size: .95rem; -webkit-appearance: none; appearance: none; }
.crsw-filter::placeholder { color: var(--muted); opacity: 1; }
.crsw-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--panel); border-radius: var(--r); margin-bottom: 14px; }
.crsw table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 0; background: transparent !important; font-size: .92rem; color: var(--text); }
.crsw th, .crsw td { padding: 9px 12px; text-align: left; vertical-align: top; background: transparent !important; color: inherit; }
.crsw thead th { color: var(--lav); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2) !important; position: sticky; top: 0; }
.crsw tbody tr:nth-child(even) td { background: rgba(138, 43, 201, .09) !important; }
.crsw tbody tr:hover td { background: rgba(138, 43, 201, .2) !important; }
.crsw td.num, .crsw th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crsw tr.is-highlight td { background: rgba(200, 134, 58, .16) !important; }

@media (max-width: 640px) {
	.crsw table.crsw-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	.crsw table.crsw-stack, .crsw table.crsw-stack tbody, .crsw table.crsw-stack tr, .crsw table.crsw-stack td { display: block; width: 100%; }
	.crsw table.crsw-stack tr { padding: 8px 4px; }
	.crsw table.crsw-stack tr + tr { margin-top: 2px; }
	.crsw table.crsw-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 10px; text-align: right; }
	.crsw table.crsw-stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: 0 0 42%; }
	.crsw table.crsw-stack tbody tr:nth-child(even) td { background: transparent !important; }
	.crsw table.crsw-stack tbody tr:nth-child(even) { background: rgba(138, 43, 201, .09); }
	.crsw-scales { grid-template-columns: 1fr; }
	.crsw-tab { flex: 1 1 calc(50% - 6px); white-space: normal; text-align: center; }
}

/* Charts */
.crsw-chart { position: relative; background: var(--panel); border-radius: var(--r); padding: 12px 12px 6px; margin-bottom: 12px; min-width: 0; }
.crsw-chart h4 { margin: 0 4px 2px; }
.crsw-chart-sub { margin: 0 4px 6px !important; font-size: .82rem; color: var(--muted) !important; }
.crsw-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.crsw-chart .ax text { fill: var(--muted); font-size: 11px; }
.crsw-chart .grid line { stroke: rgba(220, 196, 245, .1); stroke-width: 1; }
.crsw-chart .zero { stroke: rgba(220, 196, 245, .35); stroke-width: 1; }
.crsw-chart .ln { fill: none; stroke: var(--brand-hi); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.crsw-chart .ln.alt { stroke: var(--amber); }
.crsw-chart .ar { fill: rgba(182, 125, 240, .14); }
.crsw-chart .bar { fill: var(--brand-hi); }
.crsw-chart .bar.is-warn { fill: var(--warn); }
.crsw-chart .bar.is-severe { fill: var(--severe); }
.crsw-chart .bar.is-fc { fill: rgba(182, 125, 240, .45); }
.crsw-chart .xh { stroke: var(--lav); stroke-width: 1; opacity: .6; }
.crsw-chart .dot { fill: var(--lav); stroke: var(--panel); stroke-width: 2; }
.crsw-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel-3); color: var(--text); padding: 6px 9px; border-radius: 8px; font-size: .8rem; white-space: nowrap; transform: translate(-50%, -110%); }
.crsw-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 4px 6px; font-size: .82rem; color: var(--muted); }
.crsw-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; background: var(--brand-hi); }
.crsw-legend i.alt { background: var(--amber); }
.crsw-legend i.warn { background: var(--warn); height: 10px; width: 10px; }
.crsw-legend i.severe { background: var(--severe); height: 10px; width: 10px; }
.crsw-legend i.fc { background: rgba(182, 125, 240, .45); height: 10px; width: 10px; }
.crsw-legend i.bar { height: 10px; width: 10px; }

/* Image galleries (SDO, SOHO, OVATION…) */
.crsw-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; margin-bottom: 14px; }
.crsw-figure { margin: 0; background: var(--panel); border-radius: var(--r); padding: 8px; min-width: 0; }
.crsw-figure img { border-radius: 10px; width: 100%; background: #0d0618; }
.crsw-figure figcaption { font-size: .82rem; color: var(--muted); padding: 6px 4px 0; }

.crsw-note { background: var(--panel-2); border-radius: var(--r); padding: 12px 14px; color: var(--text); font-size: .92rem; margin-bottom: 14px; }
.crsw-note strong { color: var(--lav); }
.crsw-gap { background: #33195a; }
.crsw-alert { background: var(--panel); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; }
.crsw-alert summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.crsw-alert pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; background: var(--panel-2); color: var(--text); padding: 10px; border-radius: 10px; margin: 10px 0 0; max-width: 100%; overflow-x: auto; }

.crsw-foot { margin-top: 20px; font-size: .8rem; }
.crsw-foot p { color: var(--muted) !important; margin: 0; }

.crsw-meter { height: 10px; border-radius: 6px; background: var(--panel-3); overflow: hidden; margin-top: 8px; }
.crsw-meter > span { display: block; height: 100%; background: var(--brand-hi); border-radius: 6px; }

@media (prefers-reduced-motion: no-preference) {
	.crsw-tab, .crsw-btn, .crsw-choice { transition: background-color .15s ease; }
}
@media (forced-colors: active) {
	.crsw-tab[aria-selected="true"] { text-decoration: underline; }
}
