'use client' import { useDarkMode } from '@/components/interactive-demo/demo-speak' /** * Carnot cycle animated scene — piston apparatus + live P-V diagram. * Driven by AnimPlayerShell via `step` (0..4). Pure SVG, transitions on * transform/opacity only (GPU-friendly, reduced-motion safe). */ const PISTON_Y = [105, 70, 135, 170, 110] const GAS_HOT = [1, 0.55, 0.12, 0.6, 0.5] const GAS_COLD = [0, 0.45, 0.9, 0.4, 0.4] const T_LABEL = ['T_h', 'T_h → T_c', 'T_c', 'T_c → T_h', 'η'] // P–V anchors (illustrative) const A = { x: 405, y: 50 } const B = { x: 495, y: 159 } const C = { x: 630, y: 212 } const D = { x: 465, y: 175 } const ANCHORS = [A, B, C, D] const CYCLE = `${A.x},${A.y} ${B.x},${B.y} ${C.x},${C.y} ${D.x},${D.y}` const EASE = 'transform 700ms cubic-bezier(0.22, 1, 0.36, 1), opacity 500ms ease' export function CarnotCycleAnimView({ step, lang }: { step: number; lang: string }) { const fr = lang.startsWith('fr') const dark = useDarkMode() const s = Math.min(step, 4) const ink = dark ? '#EDE7DB' : '#242422' const muted = dark ? '#A39C8D' : '#686762' const plum = dark ? '#D07AA6' : '#9F3F70' const blue = dark ? '#7FA8CC' : '#3F6F9F' const line = dark ? '#3B352A' : '#D6D0C6' const card = dark ? '#221E17' : '#FFFDF8' const paper = dark ? '#17140F' : '#F4F0E8' const pistonY = PISTON_Y[s] const showHotPlate = s === 0 const showColdPlate = s === 2 const showInsulation = s === 1 || s === 3 const showQh = s === 0 const showQc = s === 2 const showWout = s === 0 || s === 1 const showWin = s === 2 || s === 3 const marker = ANCHORS[Math.min(s, 3)] const segDone = s // segments A→B (0), B→C (1), C→D (2), D→A (3) return ( {/* ══ Piston apparatus ══ */} {/* cylinder walls */} {/* gas: cold + hot crossfade */} {/* piston */} {/* hot plate */} {showHotPlate ? ( {fr ? 'Source chaude' : 'Hot'} T_h ) : null} {/* cold plate */} {showColdPlate ? ( {fr ? 'Source froide' : 'Cold'} T_c ) : null} {/* insulation */} {showInsulation ? ( {fr ? 'Isolant (Q = 0)' : 'Insulated (Q = 0)'} ) : null} {/* Q_h arrow in */} Q_h {/* Q_c arrow out */} Q_c {/* W arrows */} W W {/* temperature label inside gas */} {T_LABEL[s]} {/* ══ P–V diagram ══ */} P–V {/* axes */} V P {/* isotherms */} T_h T_c {/* cycle area (final beat) */} {s === 4 ? ( W ) : null} {/* cycle segments, revealed progressively */} = 0 ? 1 : 0.15} /> = 1 ? 1 : 0.15} style={{ transition: 'opacity 500ms ease' }} /> = 2 ? 1 : 0.15} style={{ transition: 'opacity 500ms ease' }} /> = 3 ? 1 : 0.15} style={{ transition: 'opacity 500ms ease' }} /> {/* current state marker */} ) }