<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Fault Meter – Fault Awareness Test</title>
<meta name="description" content="How well do you own up to mistakes? The Fault Meter reveals your accountability skills.">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<link rel="alternate" hreflang="en" href="https://www.faultmeter.com/?lang=en" />
<link rel="alternate" hreflang="fr" href="https://www.faultmeter.com/?lang=fr" />
<link rel="alternate" hreflang="sp" href="https://www.faultmeter.com/?lang=sp" />
<link rel="alternate" hreflang="it" href="https://www.faultmeter.com/?lang=it" />
<link rel="alternate" hreflang="pt" href="https://www.faultmeter.com/?lang=pt" />
<link rel="alternate" hreflang="jp" href="https://www.faultmeter.com/?lang=jp" />
<link rel="alternate" hreflang="cn" href="https://www.faultmeter.com/?lang=cn" />
<link rel="stylesheet" href="/style.css">

<style>
  /* Modal Styles */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .modal-overlay.visible {
    opacity: 1;
  }
  .modal-content {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 800px;
    height: 85%;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s ease;
  }
  .modal-overlay.visible .modal-content {
    transform: scale(1);
  }
  .modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #333;
    color: white;
    font-size: 20px;
    line-height: 35px;
    text-align: center;
    border: 2px solid white;
    cursor: pointer;
    z-index: 1001;
  }
  .modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
  }

  /* Cookie Banner Styles */
  .cookie-container {
      position: fixed;
      bottom: 0;
      left: 0;
      width: 100%;
      z-index: 1001;
      transform: translateY(100%);
      transition: transform 0.4s ease-in-out;
      display: none;
      padding: 20px;
      pointer-events: none; /* Allow clicks to pass through the container */
  }
  .cookie-container.visible {
      transform: translateY(0);
  }
  .cookie-banner {
      background-color: #fff;
      box-shadow: 0 5px 25px rgba(0,0,0,0.15);
      max-width: 960px;
      margin: 0 auto;
      padding: 25px;
      border-radius: 12px;
      font-family: 'Montserrat', sans-serif;
      pointer-events: auto; /* Re-enable clicks on the banner itself */
  }
  /* Initial Banner Styles */
  #initial-cookie-banner .banner-content {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 20px;
  }
  @media (min-width: 768px) {
      #initial-cookie-banner .banner-content {
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
      }
  }
  #initial-cookie-banner .banner-text {
      font-size: 14px;
      line-height: 1.6;
      margin: 0;
  }
  #initial-cookie-banner .banner-text a {
      color: #3b82f6;
      text-decoration: underline;
      cursor: pointer;
  }
  #initial-cookie-banner .banner-actions {
      display: flex;
      gap: 10px;
      flex-shrink: 0;
  }
  .btn-cookie {
      padding: 10px 20px;
      border-radius: 8px;
      font-weight: bold;
      cursor: pointer;
      transition: all 0.2s;
      font-size: 14px;
      border: 2px solid transparent;
  }
  .btn-primary {
      background-color: #3b82f6;
      color: white;
      border-color: #3b82f6;
  }
  .btn-primary:hover {
      background-color: #2563eb;
  }
  .btn-secondary {
      background-color: #e5e7eb;
      color: #1f2937;
      border-color: #d1d5db;
  }
  .btn-secondary:hover {
      background-color: #d1d5db;
  }
  .btn-link {
      background: none;
      border: none;
      color: #6b7280;
      text-decoration: underline;
      padding: 10px;
  }

  /* Detailed Settings Styles */
  #detailed-cookie-settings { display: none; }
  .allow-title {
      color: #111827;
      font-weight: bold;
      margin: 0 0 15px;
      font-size: 18px;
  }
  .cookie-category {
      border-top: 1px solid #eee;
      padding: 12px 0;
      display: flex;
      justify-content: space-between;
      align-items: center;
  }
  .btn-toggle {
      padding: 8px 16px;
      border: 2px solid #d1d5db;
      background-color: #f9fafb;
      color: #374151;
      border-radius: 8px;
      cursor: pointer;
      font-size: 14px;
      font-weight: 600;
      transition: all 0.2s ease-in-out;
  }
  .btn-toggle.active {
      background-color: #10b981;
      border-color: #10b981;
      color: white;
  }
  .btn-required {
      padding: 8px 16px;
      border: 2px solid #e9ecef;
      background-color: #e9ecef;
      color: #495057;
      border-radius: 8px;
      cursor: not-allowed;
      font-size: 14px;
      font-weight: 600;
  }
  .banner-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 20px;
      margin-top: 10px;
      border-top: 1px solid #eee;
  }
  .banner-footer .banner-actions {
      display: flex;
      align-items: center;
      gap: 10px;
  }
  .btn-cookie:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
</style>
</head>
<body>
<!-- Background elements -->
<div class="background-elements">
<div class="bg-blob-1"></div>
<div class="bg-blob-2"></div>
<div class="bg-blob-3"></div>
<div class="bg-blob-4"></div>
<div class="bg-blob-5"></div>
<div class="bg-blob-6"></div>
</div>

<header>
<div class="langs">
        <a href="?lang=en" class="active" title="EN">
          🇬🇧      </a>
        <a href="?lang=fr"  title="FR">
          🇫🇷      </a>
        <a href="?lang=sp"  title="SP">
          🇪🇸      </a>
        <a href="?lang=it"  title="IT">
          🇮🇹      </a>
        <a href="?lang=pt"  title="PT">
          🇵🇹      </a>
        <a href="?lang=jp"  title="JP">
          🇯🇵      </a>
        <a href="?lang=cn"  title="CN">
          🇨🇳      </a>
  </div>
<div class="logo">Meter Tool</div>
<div class="domain">www.faultmeter.com</div>
</header>

<main>
<div class="hero-icon">
  <img src="/images/speedometer-icon.png" alt="Speedometer Icon" width="64" height="64">
</div>

<h1>Fault Meter – Accountability Quiz</h1>
<p class="description">
  Find out how to take responsibility and improve your results.  <br><br>
  Get Notified When Meter Tool Launches
</p>


<form method="post" autocomplete="off">
  <label for="email-input" class="sr-only">Your email</label>
  <input type="email" id="email-input" name="email" placeholder="Your email" required>

  <label for="captcha-input" class="sr-only">How much is 2 + 1?</label>
  <input type="text" id="captcha-input" name="captcha" 
         placeholder="How much is 2 + 1?" required>
  
  <label class="gdpr-checkbox">
      <input type="checkbox" name="gdpr_consent" required>
      <span class="checkmark"></span>
      I consent to the processing of my email address for the purpose of sending a notification of the launch of the service. More information can be found in the Privacy Policy  </label>

  <button type="submit">Notify me when ready</button>
</form>

<div class="disclaimer">We will use your email for possible notification about the service launch. Submission is non-binding and creates no right to notification. We try to contact interested parties but do not guarantee it. This website is for informational and entertainment purposes only.</div>
</main>

<!-- Footer -->
<footer class="legal-footer">
<div class="legal-links">
<a href="https://gvghs.com/law/en/privacy.html" class="legal-link">Privacy Policy</a>
<span class="separator"> | </span>
<a href="https://gvghs.com/law/en/terms.html" class="legal-link">Terms of Service</a>
<span class="separator"> | </span>
<a href="https://gvghs.com/law/en/legal-notice.html" class="legal-link">Legal Notice</a>
<span class="separator"> | </span>
<a href="https://gvghs.com/law/en/disclaimer.html" class="legal-link">Disclaimer</a>
<span class="separator"> | </span>
<a href="https://gvghs.com/law/en/contact.html" class="legal-link">Contact</a>
<span class="separator"> | </span>
<a href="#" onclick="showCookieBanner(event)" class="legal-link">Cookie Settings</a>
</div>
<div class="copyright">
© 2025 Meter Tool</div>
</footer>

<!-- Cookie Consent Container -->
<div id="cookie-container" class="cookie-container">
  <div class="cookie-banner">
      <!-- Initial Banner -->
      <div id="initial-cookie-banner">
          <div class="banner-content">
              <p class="banner-text">
                  We use cookies to improve your experience. For more details, please read our <a href="https://gvghs.com/law/en/privacy.html" onclick="openLegalModal(this.href, event)">Privacy Policy</a>.
              </p>
              <div class="banner-actions">
                  <button id="btn-accept-all" class="btn-cookie btn-primary">Accept All</button>
                  <button id="btn-customize" class="btn-cookie btn-secondary">Customize</button>
                  <button id="btn-reject-all" class="btn-cookie btn-link">Reject All</button>
              </div>
          </div>
      </div>

      <!-- Detailed Settings -->
      <div id="detailed-cookie-settings">
          <h3 class="allow-title">Customize Your Cookie Settings</h3>
          <div class="cookie-category">
              <h4>Analytical Use</h4>
              <div class="btn-group">
                  <button class="btn-toggle" data-category="analytics" data-value="true">Agree</button>
                  <button class="btn-toggle" data-category="analytics" data-value="false">Disagree</button>
              </div>
          </div>
          <div class="cookie-category">
              <h4>Functional Use</h4>
              <button class="btn-required" disabled>Required</button>
          </div>
          <div class="cookie-category">
              <h4>Marketing Use</h4>
              <div class="btn-group">
                  <button class="btn-toggle" data-category="marketing" data-value="true">Agree</button>
                  <button class="btn-toggle" data-category="marketing" data-value="false">Disagree</button>
              </div>
          </div>
          <div class="cookie-category">
              <h4>Personalization Use</h4>
              <div class="btn-group">
                  <button class="btn-toggle" data-category="personalization" data-value="true">Agree</button>
                  <button class="btn-toggle" data-category="personalization" data-value="false">Disagree</button>
              </div>
          </div>
          <div class="banner-footer">
              <button id="btn-detailed-reject-all" class="btn-cookie btn-secondary">Reject All</button>
              <div class="banner-actions">
                  <span id="save-prefs-notice" style="display: none; font-size: 12px; color: #ef4444; margin-right: 15px;">Please make a choice for all categories.</span>
                  <button id="save-cookie-prefs" class="btn-cookie btn-secondary" disabled>Save Preferences</button>
                  <button id="btn-detailed-minimize" class="btn-cookie btn-link">Minimize</button>
                  <button id="btn-detailed-accept-all" class="btn-cookie btn-primary">Accept All</button>
              </div>
          </div>
      </div>
  </div>
</div>


<!-- Legal Content Modal -->
<div id="legalModal" class="modal-overlay">
  <div class="modal-content">
    <div class="modal-close" onclick="closeLegalModal()">&times;</div>
    <iframe id="legalFrame" class="modal-iframe" src="about:blank" frameborder="0"></iframe>
  </div>
</div>


<script>
// Cookie Consent Banner Functionality
document.addEventListener('DOMContentLoaded', () => {
  const container = document.getElementById('cookie-container');
  const initialBanner = document.getElementById('initial-cookie-banner');
  const detailedSettings = document.getElementById('detailed-cookie-settings');
  const savePrefsBtn = document.getElementById('save-cookie-prefs');
  const savePrefsNotice = document.getElementById('save-prefs-notice');
  if (!container) return;

  let cookiePreferences = {};

  function loadPreferences() {
      const savedPrefsString = localStorage.getItem('cookiePreferences');
      if (savedPrefsString) {
          const savedPrefs = JSON.parse(savedPrefsString);
          cookiePreferences = { ...savedPrefs, functional: true };
      } else {
          // First time, no choice made yet. Use null for unselected state.
          cookiePreferences = {
              analytics: null,
              marketing: null,
              personalization: null,
              functional: true,
          };
      }
  }

  function areAllChoicesMade() {
      return cookiePreferences.analytics !== null &&
             cookiePreferences.marketing !== null &&
             cookiePreferences.personalization !== null;
  }

  function updateUIFromState() {
      for (const category in cookiePreferences) {
          if (category === 'functional') continue;
          
          const value = cookiePreferences[category];
          const agreeButton = detailedSettings.querySelector(`.btn-toggle[data-category="${category}"][data-value="true"]`);
          const disagreeButton = detailedSettings.querySelector(`.btn-toggle[data-category="${category}"][data-value="false"]`);

          if (!agreeButton || !disagreeButton) continue;

          // Reset both buttons first
          agreeButton.classList.remove('active');
          disagreeButton.classList.remove('active');

          if (value === true) {
              agreeButton.classList.add('active');
          } else if (value === false) {
              disagreeButton.classList.add('active');
          }
          // If value is null, neither button is active, showing a neutral state.
      }
  }

  function saveAndClose(prefs) {
      // This function is now only called when all choices are made or via accept/reject all.
      const finalPrefs = {
          analytics: prefs.analytics === true,
          marketing: prefs.marketing === true,
          personalization: prefs.personalization === true,
          functional: true
      };

      localStorage.setItem('cookieConsentSaved', 'true');
      localStorage.setItem('cookiePreferences', JSON.stringify(finalPrefs));
      
      // This is where you would add logic to disable/enable scripts based on finalPrefs
      if (!finalPrefs.analytics) {
          // Example: remove analytics cookie
          document.cookie = "uv_id=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
      }
      
      container.classList.remove('visible');
  }

  window.showCookieBanner = function(event) {
      if (event) event.preventDefault();
      loadPreferences(); // Load current or default state
      updateUIFromState(); // Update UI based on loaded state
      initialBanner.style.display = 'block';
      detailedSettings.style.display = 'none';
      container.style.display = 'block';
      setTimeout(() => container.classList.add('visible'), 10);
  }

  // Button event listeners
  document.getElementById('btn-accept-all').addEventListener('click', () => {
      saveAndClose({ analytics: true, marketing: true, personalization: true, functional: true });
  });

  document.getElementById('btn-reject-all').addEventListener('click', () => {
      saveAndClose({ analytics: false, marketing: false, personalization: false, functional: true });
  });

  document.getElementById('btn-customize').addEventListener('click', () => {
      loadPreferences(); 
      updateUIFromState();
      
      // Enable/disable save button based on whether all choices have been made
      if (areAllChoicesMade()) {
          savePrefsBtn.disabled = false;
      } else {
          savePrefsBtn.disabled = true;
      }
      savePrefsNotice.style.display = 'none'; // Ensure notice is hidden initially
      initialBanner.style.display = 'none';
      detailedSettings.style.display = 'block';
  });

  document.getElementById('btn-detailed-minimize').addEventListener('click', () => {
      detailedSettings.style.display = 'none';
      initialBanner.style.display = 'block';
  });

  document.getElementById('btn-detailed-reject-all').addEventListener('click', () => {
      saveAndClose({ analytics: false, marketing: false, personalization: false, functional: true });
  });

  document.getElementById('btn-detailed-accept-all').addEventListener('click', () => {
      saveAndClose({ analytics: true, marketing: true, personalization: true, functional: true });
  });

  savePrefsBtn.addEventListener('click', () => {
      saveAndClose(cookiePreferences);
  });

  savePrefsBtn.addEventListener('mouseenter', () => {
      if (savePrefsBtn.disabled) {
          savePrefsNotice.style.display = 'inline';
      }
  });

  savePrefsBtn.addEventListener('mouseleave', () => {
      savePrefsNotice.style.display = 'none';
  });

  detailedSettings.querySelectorAll('.btn-toggle').forEach(button => {
      button.addEventListener('click', () => {
          const category = button.dataset.category;
          const value = button.dataset.value === 'true';
          cookiePreferences[category] = value;
          updateUIFromState();
          
          // Check if all choices have been made to enable the save button
          if (areAllChoicesMade()) {
              savePrefsBtn.disabled = false;
              savePrefsNotice.style.display = 'none';
          }
      });
  });

  // Initial check to show banner for new visitors
  if (!localStorage.getItem('cookieConsentSaved')) {
      showCookieBanner();
  }
});

// Analytics tracking
let startTime = Date.now();
let screenRes = screen.width + 'x' + screen.height;

window.addEventListener('beforeunload', function() {
  let sessionDuration = Math.round((Date.now() - startTime) / 1000);
  
  if (navigator.sendBeacon) {
      let formData = new FormData();
      formData.append('analytics', '1');
      formData.append('session_duration', sessionDuration);
      formData.append('screen_resolution', screenRes);
      navigator.sendBeacon('analytics-endpoint.php', formData);
  }
});
</script>
<script src="analytics-client.js"></script>

<script>
// General Modal Logic (for legal links)
const legalModal = document.getElementById('legalModal');
const legalFrame = document.getElementById('legalFrame');

function openLegalModal(url, event) {
if (event) event.preventDefault();
legalFrame.src = url;
legalModal.style.display = 'flex';
setTimeout(() => legalModal.classList.add('visible'), 10); 
document.body.style.overflow = 'hidden';
}

function closeLegalModal() {
legalModal.classList.remove('visible');
legalModal.addEventListener('transitionend', () => {
  legalModal.style.display = 'none';
  legalFrame.src = 'about:blank';
  document.body.style.overflow = '';
}, { once: true });
}

document.addEventListener('DOMContentLoaded', function() {
// Add event listeners for links in the footer
const legalLinks = document.querySelectorAll('.legal-footer .legal-links a.legal-link');
legalLinks.forEach(link => {
  if (!link.hasAttribute('onclick')) {
    link.addEventListener('click', function(event) {
      openLegalModal(this.getAttribute('href'), event);
    });
  }
});

// Close modal by clicking on the background
legalModal.addEventListener('click', function(event) {
  if (event.target === legalModal) {
    closeLegalModal();
  }
});

// Close modal with the Escape key
document.addEventListener('keydown', function(event) {
    if (event.key === 'Escape' && legalModal.classList.contains('visible')) {
        closeLegalModal();
    }
});
});
</script>

</body>
</html>
