/* =========================================================
   Font presets — các thử nghiệm font cho ebook
   Lưu ý: các font commercial (Lodestone, Calvera, Elodie...)
   không có trên Google Fonts; mình dùng font Google Fonts
   có vibe tương tự, đánh dấu "≈" để phân biệt.
   ========================================================= */

const FONT_PRESETS = {
  cinzel: {
    label: "Cuốn Sử Thi",
    note: "Cinzel × Cormorant Garamond — vibe La Mã cổ điển",
    display: '"Cinzel", "Cormorant Garamond", serif',
    body: '"Cormorant Garamond", Georgia, serif',
    displayWeight: 600,
    displayTracking: "0.14em",
  },
  lodestone: {
    label: "Lodestone ≈ UnifrakturCook",
    note: "Blackletter / gothic — đậm chất sử thi tối",
    display: '"UnifrakturCook", "Cinzel", serif',
    body: '"EB Garamond", Georgia, serif',
    displayWeight: 700,
    displayTracking: "0.06em",
    vnLimited: true,
  },
  calvera: {
    label: "Calvera ≈ Cinzel Decorative",
    note: "Display elegant với serif lượn — sử thi sang",
    display: '"Cinzel Decorative", "Cinzel", serif',
    body: '"Cormorant Garamond", Georgia, serif',
    displayWeight: 700,
    displayTracking: "0.12em",
  },
  barakah: {
    label: "Barakah ≈ Marcellus SC",
    note: "Roman small-caps cổ kính, trang nghiêm",
    display: '"Marcellus SC", "Cinzel", serif',
    body: '"Lora", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.18em",
  },
  elodie: {
    label: "Elodie ≈ Italianno (default)",
    note: "Script lượn duyên dáng cho heading, EB Garamond cho thân bài",
    display: '"Italianno", "Cinzel", cursive',
    body: '"EB Garamond", "Cormorant Garamond", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.04em",
    vnLimited: true,
  },
  dopesype: {
    label: "Dopesype ≈ Rubik Mono One",
    note: "Display nặng / mono-block — phong cách hiện đại lệch dòng",
    display: '"Rubik Mono One", "Cinzel", sans-serif',
    body: '"Cormorant Garamond", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.06em",
  },
  saltsatar: {
    label: "Saltsatar ≈ Pirata One",
    note: "Pirata One — vibe pirate / treasure map",
    display: '"Pirata One", "Cinzel", serif',
    body: '"EB Garamond", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.08em",
    vnLimited: true,
  },
  groovyscript: {
    label: "Groovyscript ≈ Berkshire Swash",
    note: "Berkshire Swash — funky, hơi 70s",
    display: '"Berkshire Swash", "Cinzel", cursive',
    body: '"Lora", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.05em",
  },
  almendra: {
    label: "Bonus · Almendra",
    note: "Serif lượn fantasy, sách phép thuật",
    display: '"Almendra", "Cinzel", serif',
    body: '"EB Garamond", Georgia, serif',
    displayWeight: 700,
    displayTracking: "0.08em",
  },
  monoton: {
    label: "Bonus · Monoton",
    note: "Art-deco rỗng — vibe phim cổ điển",
    display: '"Monoton", "Cinzel", sans-serif',
    body: '"Cormorant Garamond", Georgia, serif',
    displayWeight: 400,
    displayTracking: "0.06em",
    vnLimited: true,
  },
};

const FONT_PRESET_KEYS = Object.keys(FONT_PRESETS);

function applyFontPreset(key) {
  const p = FONT_PRESETS[key] || FONT_PRESETS.cinzel;
  const root = document.documentElement;
  root.style.setProperty("--serif-display", p.display);
  root.style.setProperty("--serif-body", p.body);
  root.style.setProperty("--display-weight", p.displayWeight);
  root.style.setProperty("--display-tracking", p.displayTracking);
}

Object.assign(window, { FONT_PRESETS, FONT_PRESET_KEYS, applyFontPreset });
