/**
 * 247ChatMate — Widget UI Controller (LOCKED v3.5)
 * --------------------------------------------------
 * PURPOSE (REVISED):
 * • One-time widget bootstrap only
 * • NO flow control
 * • NO chip handling
 * • NO notes logic
 * • NO CTA logic
 *
 * All conversational behaviour is owned by the Flow Controller.
 */

(function () {
  'use strict';

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }

  function init() {
    // 🔒 Hard guard — never initialise twice
    if (window.__matewaWidgetInitialised) return;
    window.__matewaWidgetInitialised = true;

    const widget = document.getElementById('matewa-widget');
    if (!widget) return;

    /* -----------------------------------------
       STATIC INITIAL STATE ONLY
       (No behavioural authority)
    ----------------------------------------- */

    const notesWrap = widget.querySelector('.matewa-notes');
    if (notesWrap) {
      notesWrap.classList.remove('is-active');
      notesWrap.classList.remove('is-complete');
    }

    const phoneWrap = widget.querySelector('.matewa-phone');
    if (phoneWrap) {
      phoneWrap.classList.remove('is-active', 'is-ready', 'is-complete');
    }

    const actions = widget.querySelector('.matewa-actions');
    if (actions) {
      actions.classList.remove('is-active');
    }

    // Accessibility baseline (safe, non-invasive)
    const chips = widget.querySelectorAll('.matewa-chip');
    chips.forEach(chip => {
      chip.setAttribute('aria-pressed', 'false');
    });

    // ❌ No event listeners
    // ❌ No timers
    // ❌ No state machines
    // ❌ No DOM mutation beyond static reset
  }
})();
