/* Royect Sol y Clima – comparativa animada split / caldera de gas.
   Todo cuelga de .rsc-comp para no afectar al resto del sitio. */

.rsc-comp {
	--c-hp: var(--azul);
	--c-hp-suave: var(--azul-suave);
	--c-gas: var(--ambar-oscuro);
	--c-gas-suave: var(--ambar-suave);
	--c-calor: #dc2626;
	--c-frio: #0ea5e9;
	--c-sol: var(--ambar);
	--c-humo: #9ca3af;
	--c-panel: #fff;
	--c-linea: var(--borde);
	--c-apagado: var(--texto-2);
	--c-metal: #e5e7eb;
	--c-metal-osc: #9ca3af;
	--c-sala: #f9fafb;
	--c-muro: #cbd5e1;
	--c-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	display: grid;
	gap: 20px;
	margin-top: 40px;
}

/* ---------- paneles ---------- */
.rsc-comp__escena { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .rsc-comp__escena { grid-template-columns: 1fr; } }

.rsc-comp__panel { background: var(--c-panel); border: 1px solid var(--c-linea); border-radius: var(--radio); overflow: hidden; display: grid; grid-template-rows: auto auto 1fr; min-width: 0; }
.rsc-comp__cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--c-linea); }
.rsc-comp__cab h3 { font-size: 16px; font-weight: 600; }
.rsc-comp__eti { font-family: var(--c-mono); font-size: 11px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.rsc-comp__panel--hp .rsc-comp__eti { background: var(--c-hp-suave); color: var(--c-hp); }
.rsc-comp__panel--gas .rsc-comp__eti { background: var(--c-gas-suave); color: var(--c-gas); }
.rsc-comp svg { display: block; width: 100%; height: auto; }

.rsc-comp__dato { padding: 16px 18px 18px; border-top: 1px solid var(--c-linea); display: grid; gap: 8px; align-content: start; min-height: 132px; }
.rsc-comp__val { font-size: clamp(20px, 2.6vw, 27px); font-weight: 500; line-height: 1.15; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.rsc-comp__panel--hp .rsc-comp__val { color: var(--c-hp); }
.rsc-comp__panel--gas .rsc-comp__val { color: var(--c-gas); }
.rsc-comp__nota { margin: 0; color: var(--texto-2); font-size: 15px; line-height: 1.5; max-width: 52ch; }
.rsc-comp__barra { height: 10px; border-radius: 999px; background: var(--c-metal); overflow: hidden; transition: opacity .4s; }
.rsc-comp__barra i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.rsc-comp__panel--hp .rsc-comp__barra i { background: var(--c-hp); }
.rsc-comp__panel--gas .rsc-comp__barra i { background: var(--c-gas); }
.rsc-comp__barra.es-oculta { opacity: 0; }
.rsc-comp__dato > * { transition: opacity .35s, transform .35s; }
.rsc-comp__dato.es-cambio > * { opacity: 0; transform: translateY(6px); }

/* ---------- pie de escena ---------- */
.rsc-comp__pie { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: baseline; }
.rsc-comp__paso { font-family: var(--c-mono); font-size: 13px; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.rsc-comp__pie h3 { font-size: clamp(18px, 2.2vw, 23px); font-weight: 500; letter-spacing: -0.025em; }
.rsc-comp__pie p { grid-column: 2; margin: 0; color: var(--texto-2); max-width: 70ch; line-height: 1.55; }
@media (max-width: 560px) { .rsc-comp__pie { grid-template-columns: 1fr; } .rsc-comp__pie p { grid-column: 1; } }

/* ---------- controles ---------- */
.rsc-comp__mandos { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rsc-comp__mandos button { font: inherit; font-size: 15px; color: var(--negro); background: #fff; border: 1px solid var(--borde-2); border-radius: 999px; padding: 9px 16px; cursor: pointer; transition: border-color .15s; }
/* el selector lleva el elemento para ganar a la regla general de arriba:
   sin eso el texto se quedaba negro sobre fondo negro al pasar el ratón */
.rsc-comp__mandos button.rsc-comp__play { background: var(--negro); color: #fff; border-color: var(--negro); min-width: 118px; }
/* el hover solo en dispositivos con puntero: en táctil se queda pegado tras
   tocar y dejaba el botón de reanudar ilegible */
@media (hover: hover) {
	.rsc-comp__mandos button:hover { border-color: var(--negro); }
	.rsc-comp__mandos button.rsc-comp__play:hover { background: #262626; border-color: #262626; color: #fff; }
}
.rsc-comp__puntos { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 260px; }
.rsc-comp__puntos button { flex: 1 1 0; min-width: 30px; height: 32px; padding: 0; position: relative; overflow: hidden; font-family: var(--c-mono); font-size: 12px; color: var(--texto-2); border-radius: 8px; }
.rsc-comp__puntos button[aria-current="true"] { color: var(--negro); border-color: var(--negro); }
.rsc-comp__puntos button .p { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--c-hp); }

.rsc-comp__condiciones { border-top: 1px solid var(--c-linea); padding-top: 12px; }
.rsc-comp__condiciones summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 14px; color: var(--texto-2); transition: color .15s; }
.rsc-comp__condiciones summary::-webkit-details-marker { display: none; }
.rsc-comp__condiciones summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s; }
.rsc-comp__condiciones[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.rsc-comp__condiciones summary:hover { color: var(--negro); }
.rsc-comp__condiciones summary:focus-visible { outline: 3px solid var(--azul); outline-offset: 3px; border-radius: 6px; }
.rsc-comp__fuente { font-size: 13px; color: var(--texto-2); line-height: 1.5; padding-top: 10px; margin: 0; }

/* ---------- dibujo ---------- */
.rsc-comp .muro { fill: var(--c-sala); stroke: var(--c-muro); stroke-width: 3; }
.rsc-comp .suelo { stroke: var(--c-muro); stroke-width: 2; }
.rsc-comp .caja { fill: var(--c-metal); stroke: var(--c-metal-osc); stroke-width: 1.5; }
.rsc-comp .rejilla-svg { fill: none; stroke: var(--c-metal-osc); stroke-width: 1; }
.rsc-comp .aspa { fill: var(--c-metal-osc); }
.rsc-comp .rotulo { fill: var(--texto-2); font-family: var(--c-mono); font-size: 11px; }
.rsc-comp .tubo { fill: none; stroke: var(--c-metal); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.rsc-comp .flujo { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 6 9; animation: rsc-dash 1.1s linear infinite; }
.rsc-comp .flujo.calor { stroke: var(--c-calor); }
.rsc-comp .flujo.frio { stroke: var(--c-frio); }
.rsc-comp .flujo.gasf { stroke: var(--c-sol); stroke-dasharray: 3 6; animation-duration: 1.6s; }
.rsc-comp .flujo.inv { animation-direction: reverse; }
@keyframes rsc-dash { to { stroke-dashoffset: -30; } }

.rsc-comp .ventilador { transform-box: fill-box; transform-origin: center; animation: rsc-gira .9s linear infinite; }
@keyframes rsc-gira { to { transform: rotate(360deg); } }

.rsc-comp .aire path { fill: none; stroke: var(--c-calor); stroke-width: 2.5; stroke-linecap: round; opacity: 0; animation: rsc-aire 2.4s ease-out infinite; }
.rsc-comp .aire path:nth-child(2) { animation-delay: .8s; }
.rsc-comp .aire path:nth-child(3) { animation-delay: 1.6s; }
@keyframes rsc-aire { 0% { opacity: 0; transform: translateY(-6px); } 25% { opacity: .9; } 100% { opacity: 0; transform: translateY(46px); } }

.rsc-comp .subecalor path { fill: none; stroke: var(--c-calor); stroke-width: 2.2; stroke-linecap: round; opacity: 0; animation: rsc-sube 2.8s ease-out infinite; }
.rsc-comp .subecalor path:nth-child(2) { animation-delay: .9s; }
.rsc-comp .subecalor path:nth-child(3) { animation-delay: 1.8s; }
@keyframes rsc-sube { 0% { opacity: 0; transform: translateY(8px); } 30% { opacity: .8; } 100% { opacity: 0; transform: translateY(-34px); } }

.rsc-comp .radiador { fill: var(--c-metal); stroke: var(--c-metal-osc); stroke-width: 1.2; transition: fill .8s; }
.rsc-comp .caliente .radiador { fill: var(--c-gas-suave); stroke: var(--c-gas); }

.rsc-comp .llama { transform-box: fill-box; transform-origin: 50% 100%; animation: rsc-titila .35s ease-in-out infinite alternate; }
.rsc-comp .llama .o { fill: var(--c-gas); }
.rsc-comp .llama .i { fill: var(--c-sol); }
@keyframes rsc-titila { from { transform: scaleY(.85) scaleX(1.05); } to { transform: scaleY(1.1) scaleX(.95); } }

.rsc-comp .humo circle { fill: var(--c-humo); opacity: 0; transform-box: fill-box; transform-origin: center; animation: rsc-humo 3.2s ease-out infinite; }
.rsc-comp .humo circle:nth-child(2) { animation-delay: .8s; }
.rsc-comp .humo circle:nth-child(3) { animation-delay: 1.6s; }
.rsc-comp .humo circle:nth-child(4) { animation-delay: 2.4s; }
@keyframes rsc-humo { 0% { opacity: 0; transform: translate(0,4px) scale(.6); } 15% { opacity: .9; } 100% { opacity: 0; transform: translate(26px,-24px) scale(1.9); } }

.rsc-comp .co2 { fill: var(--c-humo); font-family: var(--c-mono); font-size: 11px; font-weight: 500; opacity: 0; transition: opacity .5s; }
.rsc-comp.es-co2 .co2 { opacity: 1; }

.rsc-comp .term-fondo { fill: var(--c-metal); stroke: var(--c-metal-osc); }
.rsc-comp .term { fill: var(--c-calor); transition: height 1.4s ease, y 1.4s ease, fill .6s; }
.rsc-comp .term-txt { fill: var(--negro); font-family: var(--c-mono); font-size: 12px; font-weight: 500; }

.rsc-comp .placa rect.celda { fill: var(--c-frio); opacity: .75; }
.rsc-comp .placa .marco { fill: none; stroke: var(--c-metal-osc); stroke-width: 1.5; }
.rsc-comp .solwrap { opacity: 0; transition: opacity .6s; }
.rsc-comp.es-solar .solwrap { opacity: 1; }
.rsc-comp .rayo { stroke: var(--c-sol); stroke-width: 2; stroke-linecap: round; animation: rsc-rayo 2s ease-in-out infinite alternate; }
@keyframes rsc-rayo { from { opacity: .3; } to { opacity: 1; } }
.rsc-comp .solc { fill: var(--c-sol); }
.rsc-comp .flujo.sol { stroke: var(--c-sol); stroke-dasharray: 4 7; }

.rsc-comp .cartel { opacity: 0; transition: opacity .5s; }
.rsc-comp .cartel rect { fill: #fff; stroke: var(--c-linea); }
.rsc-comp .cartel text { fill: var(--negro); font-size: 12.5px; font-weight: 600; }

/* verano: el ciclo se invierte y la caldera se apaga */
.rsc-comp.es-verano .aire path { stroke: var(--c-frio); }
.rsc-comp.es-verano #rsc-pA-calor { animation-direction: reverse; }
.rsc-comp.es-verano #rsc-pA-frio { animation-direction: normal; }
.rsc-comp.es-verano .caldera-viva { opacity: 0; }
.rsc-comp.es-verano .gas-caliente { opacity: 0; }
.rsc-comp.es-verano .cartel { opacity: 1; }
.rsc-comp .caldera-viva, .rsc-comp .gas-caliente { transition: opacity .6s; }

/* ---------- ahorro final ---------- */
.rsc-comp [hidden] { display: none !important; }
.rsc-comp__ahorro { background: var(--c-panel); border: 1px solid var(--c-linea); border-radius: var(--radio); padding: 22px; display: grid; gap: 22px; }
.rsc-comp__ahorro-cab { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; }
.rsc-comp__cifra { font-size: clamp(40px, 7vw, 66px); font-weight: 600; line-height: 1; color: var(--c-hp); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.rsc-comp__cifra small { font-size: .36em; font-weight: 500; color: var(--texto-2); margin-left: 6px; letter-spacing: 0; }
.rsc-comp__epigrafe { font-family: var(--c-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--texto-2); margin-bottom: 6px; }
.rsc-comp__supuestos { display: flex; flex-wrap: wrap; gap: 6px; max-width: 460px; }
.rsc-comp__supuestos span { font-family: var(--c-mono); font-size: 11.5px; padding: 5px 10px; border-radius: 999px; background: var(--fondo-gris); border: 1px solid var(--c-linea); color: var(--texto-2); }
.rsc-comp__filas { display: grid; gap: 14px; }
.rsc-comp__fila { display: grid; grid-template-columns: minmax(0,240px) 1fr 84px; gap: 12px; align-items: center; }
@media (max-width: 660px) { .rsc-comp__fila { grid-template-columns: 1fr 76px; } .rsc-comp__pila { grid-column: 1 / -1; grid-row: 2; } }
.rsc-comp__fila b { font-weight: 600; font-size: 15px; display: block; }
.rsc-comp__fila em { font-style: normal; font-size: 13px; color: var(--texto-2); }
.rsc-comp__pila { position: relative; display: flex; height: 38px; border-radius: 8px; background: var(--fondo-gris); box-shadow: inset 0 0 0 1px var(--c-linea); }
.rsc-comp__pila i:first-child { border-radius: 8px 0 0 8px; }
/* marca de hasta donde llega el aire acondicionado: hace visible el sobrecoste */
.rsc-comp__corte { position: absolute; top: -7px; bottom: -7px; left: var(--x); border-left: 2px dashed var(--negro); opacity: 0; transition: opacity .5s 1.4s; }
.rsc-comp__ahorro:not([hidden]) .rsc-comp__corte { opacity: 1; }
.rsc-comp__corte b { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-family: var(--c-mono); font-size: 12px; font-weight: 600; color: var(--negro); background: rgba(255,255,255,.92); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.rsc-comp__pila i { display: block; height: 100%; width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.rsc-comp__pila i:last-of-type { border-radius: 0 8px 8px 0; }
.rsc-comp__total { font-family: var(--c-mono); font-weight: 500; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.rsc-comp .t-calor { background: var(--c-calor); }
.rsc-comp .t-frio { background: var(--c-frio); }
.rsc-comp .t-fijo { background: var(--c-sol); }
.rsc-comp .t-mant { background: var(--c-metal-osc); }
.rsc-comp__leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--texto-2); }
.rsc-comp__leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.rsc-comp__leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.rsc-comp__confort { display: grid; gap: 10px; }
.rsc-comp__confort svg { overflow: visible; }
.rsc-comp .verano { fill: var(--c-gas-suave); }
.rsc-comp .verano-txt { fill: var(--c-gas); font-family: var(--c-mono); font-size: 11px; }
.rsc-comp .guia { stroke: var(--c-linea); stroke-width: 1; stroke-dasharray: 4 5; }
.rsc-comp .guia-txt { fill: var(--texto-2); font-family: var(--c-mono); font-size: 11px; }
.rsc-comp .eje { stroke: var(--c-linea); stroke-width: 1.5; }
.rsc-comp .mes { fill: var(--texto-2); font-family: var(--c-mono); font-size: 12px; text-anchor: middle; }
.rsc-comp .linea { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rsc-comp .linea--hp { stroke: var(--c-hp); }
.rsc-comp .linea--gas { stroke: var(--c-gas); }
/* el trazo se dibuja al llegar a la ultima escena */
.rsc-comp__confort.es-dibujado .linea { stroke-dasharray: 900; animation: rsc-trazo 1.5s ease-out forwards; }
.rsc-comp__confort.es-dibujado .linea--gas { animation-delay: .45s; }
@keyframes rsc-trazo { from { stroke-dashoffset: 900; } to { stroke-dashoffset: 0; } }
.rsc-comp__leyenda .l-hp, .rsc-comp__leyenda .l-gas { width: 14px; height: 3px; border-radius: 2px; }
.rsc-comp__leyenda .l-hp { background: var(--c-hp); }
.rsc-comp__leyenda .l-gas { background: var(--c-gas); }

@media (prefers-reduced-motion: reduce) {
	.rsc-comp *, .rsc-comp *::before, .rsc-comp *::after {
		animation-duration: 0s !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0s !important;
	}
	.rsc-comp .aire path, .rsc-comp .subecalor path { opacity: .7; }
}
