// ── Branding (BRAND_*) ─────────────────────────────────────────────────────
//
// Single source of instance branding. Reads BRAND_* env vars once at startup,
// with Runic Gateway defaults, so any instance substitutes its own identity
// without a rebuild (the app ships as one prebuilt image).
//
// How it reaches the UI:
//   • Text + colors + asset paths are surfaced to the SPA through the public
//     settings API (settings.model.getPublic → SiteContext). The two fields the
//     admin can edit (site title, contact email) override these defaults.
//   • The static index.html shell (title/description/OG/favicon) is templated by
//     Express at serve time (see src/app.js).
//   • Server-side consumers (emails, TOTP issuer, API docs) read this directly.
//
// Image assets are delivered from the /brand mount (BRAND_LOGO/HERO/FAVICON), or
// any absolute URL. Runic Gateway ships neutral defaults baked into the image so
// an instance with no BRAND_* set still renders.
require('dotenv').config()

const name = process.env.BRAND_NAME || 'Runic Gateway'

const brand = {
  name,
  shortName: process.env.BRAND_SHORT_NAME || name,
  // Game-neutral defaults. Core is the platform, not one game's site: which game
  // this instance is for is the operator's to say, through these two vars or an
  // installed module (MODULE_SYSTEM.md §2.7.1, slice 4). Every real instance
  // overrides both — `.env.uomysticmoon.example` sets its own wording — so these
  // are what an unconfigured instance shows, not what anyone ships.
  tagline: process.env.BRAND_TAGLINE || 'an independent, privately-run game server',
  description:
    process.env.BRAND_DESCRIPTION ||
    `${name} — an independent, privately-run game server. News, screenshots, guides, and community notes.`,
  contactEmail: process.env.BRAND_CONTACT_EMAIL || process.env.CONTACT_TO || '',
  url: process.env.BRAND_URL || '',
  // Visual
  accent: process.env.BRAND_ACCENT_COLOR || '#7f99bd',
  logo: process.env.BRAND_LOGO || '', // empty → no logo image rendered
  hero: process.env.BRAND_HERO || '/assets/img/runic-emblem.png',
  favicon: process.env.BRAND_FAVICON || '/assets/img/favicon.ico', // Runic Gateway default emblem
}

// Discord embeds want an int (0xRRGGBB). Parse the accent hex once; fall back to
// the default accent if it's malformed.
brand.accentInt = (() => {
  const hex = String(brand.accent).replace('#', '')
  const n = parseInt(hex, 16)
  return Number.isNaN(n) ? 0x7f99bd : n
})()

module.exports = brand
