/**
 * FastRig PC Builder - 0.4.0
 *
 * Brand: NVIDIA green #76B900 primary, pumpkin orange #FF7518 accent.
 * Glow appears on hover and on the active/selected state only - never as a
 * constant, which is the FastRig house rule.
 *
 * Everything is scoped under #fastrig-pcbuilder-root so no theme styles leak in
 * or out.
 */

#fastrig-pcbuilder-root {
	--frb-green: #76b900;
	--frb-green-soft: #8fd614;
	--frb-orange: #ff7518;
	--frb-bg: #070a08;
	--frb-panel: #0c110d;
	--frb-panel-2: #101711;
	--frb-line: rgba(255, 255, 255, 0.07);
	--frb-line-strong: rgba(118, 185, 0, 0.35);
	--frb-text: #e8efe6;
	--frb-muted: #8b978a;
	--frb-dim: #5f6b5e;
	--frb-bad: #ff5c5c;
	--frb-warn: #ffc93c;
	--frb-radius: 16px;
	--frb-radius-sm: 11px;

	position: relative;
	color: var(--frb-text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	background:
		radial-gradient(1100px 420px at 12% -10%, rgba(118, 185, 0, 0.10), transparent 60%),
		radial-gradient(900px 420px at 96% 0%, rgba(255, 117, 24, 0.07), transparent 60%),
		linear-gradient(180deg, #080c09 0%, var(--frb-bg) 100%);
	border: 1px solid var(--frb-line);
	border-radius: 22px;
	padding: 18px;
	/* No overflow:hidden here. It would turn the root into a scrollport, which
	   silently kills position:sticky on the rail, the summary and the mobile
	   bar. The backdrop clips itself with its own radius instead. */
}

/* Faint circuit grid behind everything. */
#fastrig-pcbuilder-root::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	overflow: hidden;
	background-image:
		linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
	background-size: 44px 44px;
	mask-image: linear-gradient(180deg, #000 0%, transparent 75%);
	-webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 75%);
	pointer-events: none;
}

#fastrig-pcbuilder-root [hidden] { display: none !important; }
#fastrig-pcbuilder-root * { box-sizing: border-box; }
#fastrig-pcbuilder-root :focus-visible {
	outline: 2px solid var(--frb-green);
	outline-offset: 2px;
	border-radius: 6px;
}

/* ------------------------------------------------------------------- booting */

#fastrig-pcbuilder-root.fr-boot { min-height: 320px; display: grid; place-items: center; }
.fr-boot-msg { display: flex; align-items: center; gap: 10px; color: var(--frb-muted); }
.fr-boot-spinner {
	width: 16px; height: 16px; border-radius: 50%;
	border: 2px solid rgba(118, 185, 0, 0.25);
	border-top-color: var(--frb-green);
	animation: fr-spin 0.7s linear infinite;
}
@keyframes fr-spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------------- layout */

.fr-app {
	position: relative;
	display: grid;
	grid-template-columns: 264px minmax(0, 1fr) 340px;
	gap: 16px;
	align-items: start;
}

/* ---------------------------------------------------------------- rail/slots */

.fr-rail {
	background: linear-gradient(180deg, var(--frb-panel-2), var(--frb-panel));
	border: 1px solid var(--frb-line);
	border-radius: var(--frb-radius);
	padding: 14px;
	position: sticky;
	top: 16px;
}

.fr-rail-head { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-bottom: 12px; }
.fr-rail-label {
	font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--frb-muted);
}
.fr-progress-count { font-size: 11px; color: var(--frb-green); font-variant-numeric: tabular-nums; }
.fr-progress {
	grid-column: 1 / -1;
	display: block; height: 4px; border-radius: 999px;
	background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.fr-progress-fill {
	display: block; height: 100%; width: 0%;
	background: linear-gradient(90deg, var(--frb-green), var(--frb-orange));
	transition: width 0.28s ease;
}

.fr-slots { display: flex; flex-direction: column; gap: 4px; }

.fr-slot {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 10px;
	width: 100%;
	text-align: left;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--frb-radius-sm);
	padding: 9px 10px;
	color: var(--frb-text);
	cursor: pointer;
	font: inherit;
	transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.fr-slot:hover { background: rgba(255, 255, 255, 0.035); border-color: var(--frb-line); }
.fr-slot.is-active {
	background: linear-gradient(90deg, rgba(118, 185, 0, 0.16), rgba(118, 185, 0, 0.03));
	border-color: var(--frb-line-strong);
	box-shadow: inset 2px 0 0 var(--frb-green), 0 0 14px rgba(118, 185, 0, 0.16);
}
.fr-slot-idx {
	font-size: 10px; letter-spacing: 0.08em; color: var(--frb-dim);
	font-variant-numeric: tabular-nums;
}
.fr-slot.is-active .fr-slot-idx { color: var(--frb-green); }
.fr-slot-body { display: grid; min-width: 0; }
.fr-slot-title { font-size: 12.5px; font-weight: 600; }
.fr-slot-pick {
	font-size: 11.5px; color: var(--frb-dim);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fr-slot.is-filled .fr-slot-pick { color: var(--frb-muted); }
.fr-slot-dot {
	width: 7px; height: 7px; border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	transition: background 0.2s ease, box-shadow 0.2s ease;
}
.fr-slot-dot.is-ok { background: var(--frb-green); box-shadow: 0 0 8px rgba(118, 185, 0, 0.7); }
.fr-slot-dot.is-bad { background: var(--frb-bad); box-shadow: 0 0 8px rgba(255, 92, 92, 0.7); }

/* --------------------------------------------------------------------- main */

.fr-main {
	background: linear-gradient(180deg, var(--frb-panel-2), var(--frb-panel));
	border: 1px solid var(--frb-line);
	border-radius: var(--frb-radius);
	padding: 16px;
	min-width: 0;
}

.fr-main-head {
	display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
	gap: 12px; padding-bottom: 14px; margin-bottom: 14px;
	border-bottom: 1px solid var(--frb-line);
}
.fr-main-title { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.fr-main-hint { margin: 2px 0 0; font-size: 12px; color: var(--frb-dim); }
.fr-main-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.fr-search, .fr-sort {
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--frb-line);
	border-radius: 999px;
	color: var(--frb-text);
	padding: 8px 14px;
	font: inherit; font-size: 13px;
	transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.fr-search { min-width: 190px; }
.fr-search::placeholder { color: var(--frb-dim); }
.fr-search:hover, .fr-sort:hover { border-color: rgba(118, 185, 0, 0.4); }
.fr-search:focus, .fr-sort:focus {
	outline: none;
	border-color: var(--frb-green);
	box-shadow: 0 0 0 3px rgba(118, 185, 0, 0.16);
}
.fr-sort { padding-right: 10px; cursor: pointer; }
.fr-sort option { background: #0c110d; color: var(--frb-text); }

.fr-chip-btn {
	background: transparent; border: 1px solid var(--frb-line); color: var(--frb-muted);
	border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 12px; cursor: pointer;
	transition: color 0.16s ease, border-color 0.16s ease;
}
.fr-chip-btn:hover { color: var(--frb-orange); border-color: rgba(255, 117, 24, 0.5); }

.fr-count { font-size: 11.5px; color: var(--frb-dim); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- cards */

.fr-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
	gap: 12px;
}

.fr-card {
	position: relative;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
	border: 1px solid var(--frb-line);
	border-radius: var(--frb-radius-sm);
	overflow: hidden;
	transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.fr-card:hover {
	transform: translateY(-2px);
	border-color: rgba(118, 185, 0, 0.5);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 16px rgba(118, 185, 0, 0.16);
}
.fr-card.is-selected {
	border-color: var(--frb-green);
	box-shadow: inset 0 0 0 1px var(--frb-green), 0 0 20px rgba(118, 185, 0, 0.28);
}

/* Shown only when the shopper has asked to see everything. */
.fr-card.is-conflict { opacity: 0.55; border-color: rgba(255, 92, 92, 0.45); }
.fr-card.is-conflict:hover { opacity: 1; border-color: var(--frb-bad); box-shadow: 0 0 16px rgba(255, 92, 92, 0.2); }
.fr-card.is-conflict::after {
	content: "";
	position: absolute; top: 0; right: 0;
	border-width: 0 16px 16px 0;
	border-style: solid;
	border-color: transparent var(--frb-bad) transparent transparent;
}

/* Specs we could not verify - stated, never disguised as a pass. */
.fr-card.is-unverified:not(.is-conflict)::after {
	content: "";
	position: absolute; top: 0; right: 0;
	border-width: 0 14px 14px 0;
	border-style: solid;
	border-color: transparent var(--frb-warn) transparent transparent;
	opacity: 0.75;
}

.fr-compat { max-width: 190px; }

.fr-card-pick {
	display: grid;
	gap: 6px;
	width: 100%;
	background: none; border: 0; color: inherit; font: inherit;
	padding: 10px; text-align: left; cursor: pointer;
}
.fr-card-media { position: relative; display: block; }
.fr-card-img {
	display: block; width: 100%; height: 112px; object-fit: contain;
	background: rgba(0, 0, 0, 0.35); border-radius: 8px;
}
.fr-card-noimg {
	display: grid; place-items: center; color: var(--frb-dim); font-size: 11px;
}
.fr-card-tick {
	position: absolute; top: 6px; left: 6px;
	width: 18px; height: 18px; border-radius: 50%;
	background: var(--frb-green);
	opacity: 0; transform: scale(0.6);
	transition: opacity 0.16s ease, transform 0.16s ease;
}
.fr-card-tick::after {
	content: ""; position: absolute; left: 6px; top: 3px;
	width: 4px; height: 9px; border: solid #05230a; border-width: 0 2px 2px 0;
	transform: rotate(43deg);
}
.fr-card.is-selected .fr-card-tick { opacity: 1; transform: scale(1); }

.fr-card-name {
	font-size: 12px; line-height: 1.35; color: var(--frb-text);
	display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
	overflow: hidden; min-height: 3.1em;
}
.fr-card-price { font-size: 13px; font-weight: 650; color: var(--frb-green-soft); }
.fr-card-stock {
	justify-self: start;
	font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
	color: var(--frb-orange); border: 1px solid rgba(255, 117, 24, 0.4);
	border-radius: 999px; padding: 1px 7px;
}

.fr-card-view {
	position: absolute; top: 8px; right: 8px;
	width: 24px; height: 24px; border-radius: 8px;
	display: grid; place-items: center;
	background: rgba(0, 0, 0, 0.55); border: 1px solid var(--frb-line);
	color: var(--frb-muted); text-decoration: none; font-size: 12px;
	opacity: 0; transition: opacity 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.fr-card:hover .fr-card-view, .fr-card-view:focus-visible { opacity: 1; }
.fr-card-view:hover { color: var(--frb-orange); border-color: rgba(255, 117, 24, 0.55); }

.fr-empty { padding: 28px 10px; text-align: center; color: var(--frb-dim); font-size: 13px; }
.fr-sentinel { height: 1px; }

.fr-more { display: block; width: 100%; margin-top: 12px; }
.fr-note {
	margin: 10px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--frb-dim);
	border-left: 2px solid rgba(255, 117, 24, 0.4); padding-left: 10px;
}

/* skeletons while the catalogue loads */
.fr-skeleton { padding: 10px; display: grid; gap: 8px; }
.fr-sk {
	display: block; border-radius: 8px;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.09) 37%, rgba(255, 255, 255, 0.04) 63%);
	background-size: 400% 100%;
	animation: fr-shimmer 1.3s ease infinite;
}
.fr-sk-img { height: 112px; }
.fr-sk-line { height: 10px; }
.fr-sk-short { width: 55%; }
@keyframes fr-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --------------------------------------------------------------------- side */

.fr-side { position: sticky; top: 16px; }
.fr-side-inner {
	background: linear-gradient(180deg, var(--frb-panel-2), var(--frb-panel));
	border: 1px solid var(--frb-line);
	border-radius: var(--frb-radius);
	padding: 16px;
	max-height: calc(100vh - 32px);
	overflow: auto;
}
.fr-side-title { margin: 0 0 12px; font-size: 15px; font-weight: 650; }

.fr-status {
	display: inline-block; padding: 6px 12px; border-radius: 999px;
	font-size: 12px; font-weight: 650;
	background: rgba(255, 255, 255, 0.05); border: 1px solid var(--frb-line); color: var(--frb-muted);
}
.fr-status.ok {
	background: rgba(118, 185, 0, 0.12); border-color: rgba(118, 185, 0, 0.5); color: #cdf78a;
	box-shadow: 0 0 14px rgba(118, 185, 0, 0.22);
}
.fr-status.warn { background: rgba(255, 201, 60, 0.1); border-color: rgba(255, 201, 60, 0.45); color: var(--frb-warn); }
.fr-status.bad {
	background: rgba(255, 92, 92, 0.1); border-color: rgba(255, 92, 92, 0.5); color: #ffb4b4;
	box-shadow: 0 0 14px rgba(255, 92, 92, 0.2);
}
.fr-status.busy { color: var(--frb-dim); }

/* power meter */
.fr-power { margin-top: 12px; display: grid; gap: 5px; }
.fr-power-track {
	display: block; height: 5px; border-radius: 999px;
	background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.fr-power-fill {
	display: block; height: 100%; width: 0%;
	background: linear-gradient(90deg, var(--frb-green), var(--frb-green-soft));
	transition: width 0.3s ease;
}
.fr-power-fill.is-tight { background: linear-gradient(90deg, var(--frb-green), var(--frb-orange)); }
.fr-power-fill.is-over { background: linear-gradient(90deg, var(--frb-orange), var(--frb-bad)); }
.fr-power-text { font-size: 11px; color: var(--frb-dim); }

/* rows */
.fr-rows { margin: 14px 0 12px; }
.fr-row {
	display: grid; grid-template-columns: 62px minmax(0, 1fr) auto;
	align-items: baseline; gap: 8px;
	padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}
.fr-row:last-child { border-bottom: none; }
.fr-row.is-clickable { cursor: pointer; }
.fr-row.is-clickable:hover .fr-row-value { color: var(--frb-green-soft); }
.fr-row-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--frb-dim); }
.fr-row-value {
	font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	transition: color 0.16s ease;
}
.fr-row-value.is-empty { color: var(--frb-dim); }
.fr-row-price { font-size: 11.5px; color: var(--frb-muted); font-variant-numeric: tabular-nums; }

.fr-total {
	display: grid; gap: 2px; padding: 12px 0;
	border-top: 1px solid var(--frb-line); border-bottom: 1px solid var(--frb-line);
}
.fr-total-label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--frb-dim); }
.fr-total-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--frb-text); }
.fr-total-note { font-size: 11px; color: var(--frb-orange); }

/* buttons */
.fr-actions { display: grid; gap: 8px; margin: 14px 0 0; }
.fr-btn {
	border-radius: 11px; padding: 11px 14px; font: inherit; font-size: 13.5px; font-weight: 650;
	cursor: pointer; border: 1px solid var(--frb-line);
	background: rgba(255, 255, 255, 0.04); color: var(--frb-text);
	transition: transform 0.14s ease, box-shadow 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}
.fr-btn:hover:not(:disabled) { transform: translateY(-1px); }
.fr-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fr-primary { background: var(--frb-green); border-color: var(--frb-green); color: #06210a; }
.fr-primary:hover:not(:disabled) { box-shadow: 0 0 18px rgba(118, 185, 0, 0.45); filter: brightness(1.06); }
.fr-accent { background: var(--frb-orange); border-color: var(--frb-orange); color: #2a0f00; }
.fr-accent:hover:not(:disabled) { box-shadow: 0 0 18px rgba(255, 117, 24, 0.45); filter: brightness(1.06); }
.fr-ghost { background: transparent; color: var(--frb-muted); }
.fr-ghost:hover:not(:disabled) { color: var(--frb-text); border-color: rgba(255, 255, 255, 0.2); }
.fr-btn.is-busy { position: relative; color: transparent; }
.fr-btn.is-busy::after {
	content: ""; position: absolute; inset: 0; margin: auto;
	width: 15px; height: 15px; border-radius: 50%;
	border: 2px solid rgba(0, 0, 0, 0.25); border-top-color: rgba(0, 0, 0, 0.75);
	animation: fr-spin 0.7s linear infinite;
}

.fr-feedback { margin-top: 10px; font-size: 12px; color: var(--frb-muted); }
.fr-feedback.is-error { color: var(--frb-bad); }

/* issue blocks */
.fr-blocks { display: grid; gap: 10px; margin-top: 14px; }
.fr-block { font-size: 12.5px; }
.fr-block > strong {
	display: block; margin-bottom: 4px;
	font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--frb-dim);
}
.fr-block ul { margin: 0; padding-left: 16px; }
.fr-block li { margin: 3px 0; line-height: 1.45; }
.fr-block.fr-issues li { color: #ffb4b4; }
.fr-block.fr-warnings li { color: var(--frb-warn); }
.fr-block.fr-unverified li { color: #c8d2c4; }
.fr-block.fr-notes li { color: #b9e08a; }

/* ------------------------------------------------------------- mobile bar */

.fr-bar {
	display: none;
	position: sticky; bottom: 0; z-index: 5;
	margin: 14px -18px -18px;
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
	background: rgba(8, 12, 9, 0.94);
	backdrop-filter: blur(10px);
	border-top: 1px solid var(--frb-line);
	border-radius: 0 0 20px 20px;
	align-items: center; justify-content: space-between; gap: 12px;
}
.fr-bar-info { display: grid; min-width: 0; }
.fr-bar-status { font-size: 12px; font-weight: 650; color: var(--frb-muted); }
.fr-bar-status.ok { color: #cdf78a; }
.fr-bar-status.warn { color: var(--frb-warn); }
.fr-bar-status.bad { color: #ffb4b4; }
.fr-bar-total { font-size: 15px; font-weight: 700; }
.fr-bar-btn { padding: 9px 16px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1280px) {
	.fr-app { grid-template-columns: 224px minmax(0, 1fr) 300px; }
}

@media (max-width: 1080px) {
	.fr-app { grid-template-columns: minmax(0, 1fr) 300px; }
	.fr-rail { grid-column: 1 / -1; position: static; }
	.fr-slots {
		flex-direction: row;
		overflow-x: auto;
		gap: 8px;
		padding-bottom: 4px;
		scroll-snap-type: x proximity;
	}
	/* max-width so a long part name ellipsises instead of stretching the chip. */
	.fr-slot { width: auto; min-width: 168px; max-width: 236px; flex: 0 0 auto; scroll-snap-align: start; }
}

@media (max-width: 900px) {
	#fastrig-pcbuilder-root { padding: 14px; border-radius: 18px; }
	.fr-app { grid-template-columns: minmax(0, 1fr); }
	.fr-side { position: static; }
	.fr-side-inner { max-height: none; }
	.fr-bar.is-visible { display: flex; }
	.fr-main-head { align-items: flex-start; }
	.fr-search { flex: 1 1 160px; min-width: 0; }
}

@media (max-width: 520px) {
	.fr-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
	.fr-card-img, .fr-sk-img { height: 92px; }
	.fr-main-title { font-size: 17px; }
}

/* ------------------------------------------------------------- scrollbars */

#fastrig-pcbuilder-root .fr-side-inner {
	scrollbar-width: thin;
	scrollbar-color: var(--frb-green) rgba(0, 0, 0, 0.4);
}
#fastrig-pcbuilder-root .fr-side-inner::-webkit-scrollbar { width: 9px; height: 9px; }
#fastrig-pcbuilder-root .fr-side-inner::-webkit-scrollbar-track {
	background: rgba(0, 0, 0, 0.4); border-radius: 999px;
}
#fastrig-pcbuilder-root .fr-side-inner::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: linear-gradient(180deg, var(--frb-green) 0%, var(--frb-orange) 100%);
}

/* The slot strip sits directly under the build progress bar, so its scrollbar
   stays muted - a green/orange thumb there reads as a second progress bar. */
#fastrig-pcbuilder-root .fr-slots {
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
#fastrig-pcbuilder-root .fr-slots::-webkit-scrollbar { height: 6px; }
#fastrig-pcbuilder-root .fr-slots::-webkit-scrollbar-track { background: transparent; }
#fastrig-pcbuilder-root .fr-slots::-webkit-scrollbar-thumb {
	border-radius: 999px; background: rgba(255, 255, 255, 0.16);
}

/* ----------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
	#fastrig-pcbuilder-root *,
	#fastrig-pcbuilder-root *::before,
	#fastrig-pcbuilder-root *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
	.fr-card:hover { transform: none; }
}
