#pragma once
// card_meta — formatting for the bank card's decorative metadata overlay: capture length as
// bars.beats.subdivisions (bottom-left, musical) and seconds.milliseconds (bottom-right,
// wall-clock). Both are non-interactive; bank_panel draws them via the kit.

#include <string>

#include "core/ui/rect.h"

namespace reasampler::ui {

// Both card overlay strips — the name line across the top, the length read-out along the
// bottom — are this tall, with this much horizontal inset.
inline constexpr int kCardStripHeight = 12;
inline constexpr int kCardStripPad    = 3;

// The strip the card's name line occupies: across the top of the cell, drawn OVER the
// waveform exactly as the length read-out is drawn over it at the bottom, rather than a
// reserved non-drawing band — kCardStripHeight (12px) is a small slice of the shipping 84px
// cell, and the overlay matches the bottom read-out's existing convention rather than
// introducing a second layout rule. The draw site scrims behind the text so it stays legible
// over the waveform's accent fill (`kCardNameScrimAlpha`, `theme.h`). Empty when the cell has
// no room for both strips plus a waveform worth looking at — the caller draws nothing rather
// than burying the card under text.
Rect cardNameStrip(const Rect& cell);

// Musical length inputs, taken straight off a Sample's capture-time stamp. tempoBpm 0 = unknown;
// timeSigNum/Denom 0 = unstamped.
struct MusicalLength {
    double lengthSeconds = 0.0;
    double tempoBpm      = 0.0;
    int    timeSigNum    = 0;
    int    timeSigDenom  = 0;
};

// bars.beats.subdivisions from a capture-time tempo + meter stamp.
//
// 1-based, zero-padded to two subdivision digits: "1.1.00" is a bar-aligned/zero-length capture,
// "2.3.50" is 1 bar + 2 beats + half a beat. Unstamped meter or unknown tempo (tempoBpm <= 0)
// returns "" — no musical read-out is derivable, caller keeps the s.ms read-out. Subdivision is
// 0..99 (hundredths of a beat), floored — a display quantum, not tick-accurate PPQ.
std::string formatBarsBeats(const MusicalLength& m);

// seconds.milliseconds from a wall-clock length (always derivable, meter-independent).
// "S.mmm", rounded to nearest ms. Negative length clamps to "0.000".
std::string formatSecondsMs(double lengthSeconds);

} // namespace reasampler::ui
