/** @jsx React.createElement */
/* Central brand config — read by Nav, Contact, Footer, etc.
   The block between the EDITMODE markers is parsed + rewritten by the host
   whenever Tweaks posts __edit_mode_set_keys. Keep it valid JSON. */

window.BRAND = /*EDITMODE-BEGIN*/{
  "emailLocal": "contacto",
  "domain": "gittenco.com",
  "phone": "+54 9 351 251 9130",
  "location": "Córdoba, Argentina",
  "tagline": "Smart Healthcare",
  "primaryColor": "#0E8FD6",
  "showSocial": false,
  "ctaLabel": "¡CUÉNTANOS TU PROYECTO!"
}/*EDITMODE-END*/;

// Derived helpers
window.BRAND_EMAIL = () => `${window.BRAND.emailLocal}@${window.BRAND.domain}`;
window.BRAND_SITE = () => `https://www.${window.BRAND.domain}`;

// Apply primary color as a CSS variable override
(function applyBrandVars() {
  applyBrandColor(window.BRAND.primaryColor);
})();

function applyBrandColor(color) {
  // Set on :root
  document.documentElement.style.setProperty('--brand', color);
  document.documentElement.style.setProperty('--brand-hover', color);
  // Inject/update a high-priority style tag so .on-dark scoped overrides are beaten
  let tag = document.getElementById('__brand_override');
  if (!tag) {
    tag = document.createElement('style');
    tag.id = '__brand_override';
    document.head.appendChild(tag);
  }
  tag.textContent = `
    :root, .on-dark { --brand: ${color} !important; --brand-hover: ${color} !important; }
  `;
}
window.__applyBrandColor = applyBrandColor;

// Subscribe to live updates so controls can mutate the page in real time
window.addEventListener('brand:update', (e) => {
  Object.assign(window.BRAND, e.detail);
  applyBrandColor(window.BRAND.primaryColor);
  window.dispatchEvent(new CustomEvent('brand:rerender'));
});
