/** Shared four-phase environment templates for full and static cards (#146). */ import { html, nothing, type TemplateResult } from 'lit'; import { DAY_CYCLE_PALETTES, type DayCyclePhase, type DayCycleState, } from './sun'; const PHASES: readonly DayCyclePhase[] = ['dawn', 'day', 'dusk', 'night']; /** CSS variables owned by the stage rather than copied into its plan tree. */ export function dayCycleStageVars(state: DayCycleState | null): string { if (!state) return ''; const palette = DAY_CYCLE_PALETTES[state.phase]; return [ `--hp-day-cycle-outline-near:${palette.outlineNear}`, `--hp-day-cycle-outline-mid:${palette.outlineMid}`, `--hp-day-cycle-outline-far:${palette.outlineFar}`, ].join(';'); } /** Four constant layers make gradient changes genuinely cross-fade in CSS. */ export function renderDayCycleEnvironment( state: DayCycleState | null, viewWeight = 1, ): TemplateResult | typeof nothing { if (!state) return nothing; const position = [ `--hp-day-cycle-sun-x:${state.sunX.toFixed(2)}%`, `--hp-day-cycle-sun-y:${state.sunY.toFixed(2)}%`, `--hp-day-cycle-sun-opacity:${state.sunOpacity.toFixed(3)}`, `opacity:${Math.min(1, Math.max(0, viewWeight)).toFixed(4)}`, ].join(';'); return html``; }