/*
 * Homepage solar calculator («Калькулятор сонячних панелей»).
 * Markup: template-parts/solar-calculator.php, behaviour:
 * assets/js/solar-calculator.js. Loaded after autonomy-calculator.css: the
 * section is `.ac.sc`, so the card, scene, pins, cables, appliance chips,
 * dark panel, tabs, buttons, phone dock, tokens and reduced-motion rules all
 * come from there. This file adds what the solar mockup has on top: season
 * crossfade, panel cards with a quantity stepper, station / season pills,
 * the result block and bars.
 *
 * Breakpoints are the autonomy calculator's: ≥1200 desktop, 768–1199 tablet,
 * <768 phone.
 */

/* --- Scene: summer / winter crossfade -------------------------------------- */

.sc-season,
.sc-wires {
	opacity: 0;
	transition: opacity 0.4s ease;
}

.sc-season.is-shown,
.sc-wires.is-shown {
	opacity: 1;
}

/* Cable width per the solar mockup (thicker than the house scene's). */
.sc-scene {
	--wire-w: 1.3;
	--pulse-w: 0.45;
}

@media (min-width: 768px) {
	.sc-scene {
		--wire-w: 1;
		--pulse-w: 0.35;
	}
}

@media (min-width: 1200px) {
	.sc-scene {
		--wire-w: 0.78;
		--pulse-w: 0.26;
	}
}

.sc .ac-route.is-on .ac-wire,
.sc .ac-route.is-fading .ac-wire {
	filter: drop-shadow(0 0 1.2px rgba(63, 207, 90, 0.9));
}

.sc .ac-route.is-on .ac-pulse {
	opacity: 0.6;
}

.sc-pin {
	gap: 0.35em;
}

.sc-pin[hidden],
.sc-block[hidden],
.sc-result__arrow[hidden],
.sc-bar__note[hidden] {
	display: none;
}

/* Panel badges are counters, not toggles: green while at least one is added. */
.sc-pin.is-on {
	background: var(--ac-accent);
	border-color: var(--ac-accent);
	box-shadow: 0 0 0 3px rgba(63, 207, 90, 0.25), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.sc .is-pop {
	animation: ac-pop 0.3s ease-out;
}

/* --- Blocks under the scene ------------------------------------------------- */

.sc-block {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.sc-block__head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
}

.sc-block__sum {
	font-family: var(--ac-mono);
	font-size: 12px;
	color: var(--ac-text-2);
	white-space: nowrap;
}

.sc-panels {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 10px;
}

.sc-card {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 14px;
	border-radius: 14px;
	border: 1px solid var(--ac-border);
	background: var(--ac-surface);
	scroll-snap-align: start;
	transition: border-color 0.2s, background-color 0.2s;
}

.sc-card.is-on {
	border-color: var(--ac-accent);
	background: var(--ac-accent-soft);
}

.sc-card__top {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.sc-card__icon {
	flex: none;
	width: 22px;
	height: 22px;
	opacity: 0.9;
}

.sc-card__text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.sc-card__name {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-wrap: pretty;
}

.sc-card__sub {
	font-family: var(--ac-mono);
	font-size: 12px;
	color: var(--ac-text-2);
	white-space: nowrap;
}

.sc-stepper {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 2px;
	border-radius: 999px;
	background: #f2f2f2;
	transition: background-color 0.2s;
}

.sc-card.is-on .sc-stepper {
	background: #dff5e3;
}

.sc-stepper__btn {
	flex: none;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}

.sc-stepper__btn--minus {
	background: #fff;
	color: var(--ac-ink);
}

.sc-stepper__btn--minus:disabled {
	background: transparent;
	color: #b5b5b5;
	cursor: default;
}

.sc-stepper__btn--plus {
	background: var(--ac-ink);
	color: #fff;
}

.sc-stepper__qty {
	display: inline-block;
	min-width: 2ch;
	font-family: var(--ac-mono);
	font-size: 16px;
	font-weight: 500;
	text-align: center;
}

/* --- Result panel ----------------------------------------------------------- */

.sc-panel {
	gap: 20px;
}

.sc-mode .ac-tab__name {
	white-space: nowrap;
}

.sc .sc-mode {
	min-height: 48px;
}

.sc-switches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.sc-pills {
	position: relative;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	padding: 4px;
	border-radius: 999px;
	background: var(--ac-panel-2);
}

.sc-pills--station {
	flex: 1 1 220px;
}

.sc-pills--season {
	flex: 0 1 auto;
}

.sc-pills__thumb {
	position: absolute;
	top: 4px;
	bottom: 4px;
	left: 4px;
	width: calc((100% - 8px) / 2);
	border-radius: 999px;
	background: #2c2c2c;
	transition: transform 0.25s ease, background-color 0.25s;
}

.sc-pills[data-index="1"] .sc-pills__thumb {
	transform: translateX(100%);
}

.sc-pills--season .sc-pills__thumb {
	background: #ffd76a;
}

.sc-pills--season[data-index="1"] .sc-pills__thumb {
	background: #dbe8f5;
}

.sc-pill {
	position: relative;
	z-index: 1;
	min-height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 0;
	padding: 6px 10px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: #8a8a8a;
	font-size: 13px;
	font-weight: 700;
	white-space: nowrap;
	cursor: pointer;
	transition: color 0.25s;
}

.sc-pill svg {
	flex: none;
}

.sc-pills--station .sc-pill[aria-selected="true"] {
	color: #fff;
}

.sc-pills--season .sc-pill {
	padding-inline: 12px;
	color: #bdbdbd;
}

.sc-pills--season .sc-pill[aria-checked="true"] {
	color: var(--ac-ink);
}

.sc-station .ac-station__photo {
	width: 64px;
	height: 64px;
	border-radius: 12px;
}

.sc-station .ac-station__name {
	font-size: 18px;
}

.sc-result {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 132px;
}

.sc-result.is-surplus .ac-label {
	color: var(--ac-accent);
}

.sc-result.is-deficit .ac-label {
	color: var(--ac-low);
}

.sc-result__value {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 10px;
}

.sc-result__arrow {
	align-self: center;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--ac-accent);
	color: var(--ac-ink);
	font-size: 20px;
	font-weight: 800;
}

.sc-result.is-deficit .sc-result__arrow {
	background: var(--ac-low);
}

.sc-result__big {
	font-size: clamp(40px, 4.2vw, 60px);
	font-weight: 600;
	letter-spacing: -0.035em;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	color: #fff;
}

.sc-result__big.is-idle {
	color: #5a5a5a;
}

.sc-result__unit {
	font-size: 16px;
	color: #9a9a9a;
}

.sc-result__text {
	font-size: 14px;
	line-height: 1.5;
	color: #d6d6d6;
	text-wrap: pretty;
}

.sc-bars {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.sc-bar {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.sc-bar__track {
	height: 10px;
	padding: 2px;
	border-radius: 5px;
	background: var(--ac-track);
}

.sc-bar__fill {
	height: 100%;
	border-radius: 3px;
	background: #e6e6e6;
	transition: width 0.4s ease, background-color 0.3s;
}

.sc-bar__fill.is-green {
	background: var(--ac-accent);
}

.sc-bar__fill.is-amber {
	background: var(--ac-low);
}

.sc-bar__note {
	font-size: 12px;
	color: var(--ac-text-3);
}

/* Kit: the station row has no green dot. */
.sc-kit__station::before {
	display: none;
}

.sc-kit .ac-connected__item {
	padding-block: 8px;
}

.sc-dock__result {
	font-family: var(--ac-mono);
	font-size: 12px;
	color: #cfcfcf;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/*
 * Product page of a panel that is not on the picture: its card is a fifth
 * one, laid across the whole row above the four others (no orphan card).
 */
@media (min-width: 768px) {
	.sc-card--wide {
		grid-column: 1 / -1;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.sc-card--wide .sc-stepper {
		flex: 0 0 180px;
	}
}

/* --- Tablet ----------------------------------------------------------------- */

@media (max-width: 1199px) {
	.sc-panels {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* --- Phones: panel cards scroll sideways, like the appliance chips --------- */

@media (max-width: 767px) {
	.sc-panels {
		grid-template-columns: none;
		grid-auto-flow: column;
		/* 152px = the stepper (two 44px buttons and the count) plus padding. */
		grid-auto-columns: minmax(152px, calc((100% - 20px) / 2.1));
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scroll-padding: 0 20px;
		padding: 4px 20px 6px;
		margin: -4px -20px 0;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		overscroll-behavior-x: contain;
	}

	.sc-panels::-webkit-scrollbar {
		display: none;
	}

	.sc-card__name {
		font-size: 13px;
	}
}

@media (min-width: 600px) and (max-width: 767px) {
	.sc-panels {
		grid-auto-columns: calc((100% - 30px) / 3.25);
	}
}

/* Overload note in the balance mode (same box as the autonomy calculator's). */
.sc-warn[hidden] {
	display: none;
}

.sc .ac-cta.is-busy {
	opacity: 0.6;
	pointer-events: none;
}

/* "0 / 1 000 Вт (максимум входу)" is too long for one line on narrow phones. */
.sc-bar .ac-meter__val {
	white-space: normal;
	text-align: right;
}
