#ifndef DECKINADASH_READING_JSON_H
#define DECKINADASH_READING_JSON_H

#include <time.h>

#include "../../../../../engine/src/astro.h"
#include "../../../../../engine/src/tarot.h"

/* Recomputes a full day's reading (astro + tarot + interpretation) from
 * `birth`/`gender`/`utc_moment` - same inputs and same
 * reading_generate()/interpret_daily_reading() calls
 * watch/src/c/reading_state.c makes - and serializes everything a UI
 * needs to render it (in watch/src/c/ui_report_window.c's own section
 * order: date, day significance, top transits+narratives, full Celtic
 * Cross spread, guidance last) as one JSON string, structurally a port
 * of interpreter/src/main.c's interp_print_json() targeting a heap
 * buffer instead of stdout.
 *
 * `i18n_dir`/`lang` locate `<i18n_dir>/<lang>.lang` (same convention as
 * engine/src/main.c's default_i18n_path()); a missing/unreadable file is
 * a non-fatal fallback to built-in English (i18n_load()'s own contract),
 * not an error returned here.
 *
 * On success, returns a malloc'd, null-terminated JSON string in
 * `*out_json` (caller must free()) and returns 0. Returns non-zero and
 * leaves `*out_json` untouched only if the underlying open_memstream()
 * allocation itself fails - not a condition this codebase's other
 * callers (deck-engine, interpreter-cli) treat as reachable in practice. */
int reading_json_generate(const BirthData *birth, Gender gender, time_t utc_moment,
                           const char *i18n_dir, const char *lang, char **out_json);

#endif
