/* ╔══════════════════════════════════════════════════════════════════╗
   ║  MODALES CARTE — accès aux informations et code PIN               ║
   ║  Deux surfaces dédiées, indépendantes des anciennes modales       ║
   ║  génériques de l’écran Cartes.                                   ║
   ╚══════════════════════════════════════════════════════════════════╝ */

.card-modal-mask {
  --cm-navy: #11152f;
  --cm-navy-deep: #090c1e;
  --cm-line: rgba(168, 175, 208, .16);
  --cm-line-strong: rgba(142, 169, 255, .3);
  --cm-text: #f5f7fc;
  --cm-muted: #a8afd0;
  --cm-soft: #737b9e;
  --cm-signature: #8ea9ff;
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(70% 60% at 50% 0%, rgba(72, 92, 190, .2), transparent 70%),
    rgba(4, 6, 18, .74);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
  backdrop-filter: blur(12px) saturate(1.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .24s ease, visibility .24s ease;
}
.card-modal-mask.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.card-sheet {
  position: relative;
  box-sizing: border-box;
  width: min(460px, 100%);
  max-height: min(92dvh, 860px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--cm-line-strong);
  border-radius: 28px;
  background:
    radial-gradient(90% 55% at 15% 0%, rgba(142, 169, 255, .14), transparent 64%),
    linear-gradient(158deg, #1a2042 0%, #11152f 48%, #090c1e 100%);
  color: var(--cm-text);
  box-shadow:
    0 34px 80px -30px rgba(0, 0, 0, .9),
    inset 0 1px 0 rgba(255, 255, 255, .1);
  transform: translateY(18px) scale(.985);
  transition: transform .3s cubic-bezier(.22, 1, .36, 1);
}
.card-sheet [hidden] { display: none !important; }
.card-modal-mask.show .card-sheet { transform: translateY(0) scale(1); }
.card-sheet::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
  pointer-events: none;
}
.card-sheet__grip {
  width: 42px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: rgba(168, 175, 208, .28);
}
.card-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.card-sheet__heading { min-width: 0; }
.card-sheet__eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--cm-signature);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.2;
  text-transform: uppercase;
}
.card-sheet__title {
  margin: 0;
  color: #fff;
  font-size: 23px;
  font-weight: 760;
  letter-spacing: -.035em;
  line-height: 1.08;
}
.card-sheet__close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(168, 175, 208, .2);
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  color: var(--cm-muted);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.card-sheet__close:hover { background: rgba(255, 255, 255, .11); border-color: var(--cm-line-strong); color: #fff; }
.card-sheet__close:active { transform: scale(.93); }
.card-sheet__close:focus-visible,
.card-sheet__primary:focus-visible,
.card-sheet__ghost:focus-visible,
.pin-key:focus-visible,
.card-details__link:focus-visible {
  outline: 2px solid var(--cm-signature);
  outline-offset: 2px;
}
.card-sheet__desc {
  margin: 13px 0 0;
  color: var(--cm-muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.card-sheet__primary,
.card-sheet__ghost {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 680;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.card-sheet__primary {
  border: 1px solid rgba(174, 194, 255, .62);
  background: linear-gradient(155deg, #b8c9ff 0%, #91a8f8 52%, #7d95ef 100%);
  color: #0a0d1e;
  box-shadow: 0 14px 30px -16px rgba(142, 169, 255, .78), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.card-sheet__primary:hover:not(:disabled) { background: linear-gradient(155deg, #c6d3ff 0%, #9eb3fb 52%, #8ca2f4 100%); }
.card-sheet__primary:active:not(:disabled) { transform: scale(.985); }
.card-sheet__primary:disabled { cursor: not-allowed; opacity: .38; box-shadow: none; }
.card-sheet__ghost {
  border: 1px solid var(--cm-line);
  background: rgba(255, 255, 255, .035);
  color: var(--cm-muted);
}
.card-sheet__ghost:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.card-sheet__ghost:active { transform: scale(.985); }
.card-sheet__actions { display: grid; gap: 8px; margin-top: 16px; }
.card-sheet__foot { display: grid; gap: 8px; margin-top: 18px; }

/* ── Informations de la carte ─────────────────────────────────────── */
.card-details__lock {
  position: relative;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--cm-line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, .018));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.card-details__lock-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.card-details__lock-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(142, 169, 255, .28);
  border-radius: 13px;
  background: rgba(142, 169, 255, .1);
  color: var(--cm-signature);
}
.card-details__lock-copy { min-width: 0; display: grid; gap: 2px; }
.card-details__lock-copy b { color: #fff; font-size: 13px; font-weight: 680; }
.card-details__lock-copy small { color: var(--cm-soft); font-size: 11px; }
.card-details__status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(168, 175, 208, .16);
  border-radius: 999px;
  color: var(--cm-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.card-details__status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
#details-modal-mask[data-state="revealed"] .card-details__status {
  border-color: rgba(95, 176, 62, .28);
  background: rgba(95, 176, 62, .1);
  color: #a9e28e;
}
#details-modal-mask[data-state="error"] .card-details__status {
  border-color: rgba(239, 90, 103, .28);
  background: rgba(239, 90, 103, .1);
  color: #ffadb5;
}
#details-modal-mask[data-state="verifying"] .card-details__status {
  border-color: rgba(142, 169, 255, .28);
  background: rgba(142, 169, 255, .1);
  color: #c8d5ff;
}
.card-details__label {
  display: block;
  margin: 16px 0 8px;
  color: var(--cm-muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.card-otp {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}
.card-otp__cell {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(168, 175, 208, .2);
  border-radius: 13px;
  background: rgba(5, 8, 22, .34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  color: #fff;
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.card-otp__cell.is-filled {
  border-color: rgba(142, 169, 255, .42);
  background: rgba(142, 169, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 0 0 1px rgba(142, 169, 255, .08);
}
.card-details__lock:focus-within .card-otp__cell {
  border-color: rgba(142, 169, 255, .3);
}
.card-otp:focus-within .card-otp__cell {
  border-color: rgba(142, 169, 255, .48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 0 0 1px rgba(142, 169, 255, .08);
}
.card-otp__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  padding: 0;
  opacity: 0;
  cursor: text;
  font-size: 16px;
}
#details-verify { margin-top: 13px; }
.card-details__message {
  min-height: 18px;
  margin: 9px 0 0;
  color: #ffadb5;
  font-size: 11.5px;
  line-height: 1.45;
}
.card-details__message:empty { display: none; }
.card-details__link {
  display: inline-flex;
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cm-signature);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.card-details__link:hover { color: #fff; }
.card-details__data { margin-top: 18px; }
.card-details__number {
  padding: 15px 16px;
  border: 1px solid var(--cm-line-strong);
  border-radius: 18px;
  background:
    radial-gradient(100% 100% at 0% 0%, rgba(142, 169, 255, .14), transparent 58%),
    rgba(5, 8, 22, .36);
}
.card-details__number span,
.card-details__grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--cm-soft);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.card-details__number b {
  display: block;
  color: #fff;
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1.3;
}
.card-details__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--cm-line);
  border-radius: 18px;
  background: var(--cm-line);
}
.card-details__grid > div {
  min-width: 0;
  padding: 12px 14px;
  background: #11152f;
}
.card-details__grid b {
  display: block;
  overflow: hidden;
  color: #fff;
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-details__grid b.is-masked,
.card-details__number b.is-masked { color: var(--cm-muted); letter-spacing: .12em; }

/* ── Code PIN ─────────────────────────────────────────────────────── */
.pin-progress {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0 2px;
}
.pin-progress__step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--cm-soft);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pin-progress__step i {
  width: 23px;
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cm-line);
  border-radius: 8px;
  color: var(--cm-soft);
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
}
.pin-progress__step.is-active { color: #fff; }
.pin-progress__step.is-active i {
  border-color: rgba(142, 169, 255, .5);
  background: rgba(142, 169, 255, .18);
  color: #c8d5ff;
}
.pin-progress__line { flex: 1; height: 1px; background: var(--cm-line); }
.card-sheet--pin #pin-dots {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 18px 0 14px;
}
.card-sheet--pin .pin-dot {
  width: 43px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(168, 175, 208, .2);
  border-radius: 14px;
  background: rgba(5, 8, 22, .34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.card-sheet--pin .pin-dot::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(168, 175, 208, .25);
  transition: background .18s ease, transform .18s ease;
}
.card-sheet--pin .pin-dot.filled {
  border-color: rgba(142, 169, 255, .45);
  background: rgba(142, 169, 255, .13);
}
.card-sheet--pin .pin-dot.filled::after { background: var(--cm-signature); transform: scale(1.14); }
.card-sheet--pin .pin-dot.error {
  border-color: rgba(239, 90, 103, .5);
  background: rgba(239, 90, 103, .12);
}
.card-sheet--pin .pin-dot.error::after { background: #ff8c97; }
.card-sheet--pin #pin-dots[data-reveal="true"] .pin-dot[data-digit]:not([data-digit=""])::after {
  content: attr(data-digit);
  width: auto;
  height: auto;
  background: none;
  color: #fff;
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}
.pin-status {
  min-height: 16px;
  margin: -3px 0 9px;
  color: #ffadb5;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}
.pin-status:empty { display: none; }
.card-sheet--pin .pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  max-width: 330px;
  margin: 0 auto;
}
.card-sheet--pin .pin-key {
  height: 58px;
  border: 1px solid rgba(168, 175, 208, .17);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(35, 42, 82, .92), rgba(14, 18, 42, .96));
  color: #fff;
  box-shadow: 0 8px 18px -12px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .1);
  font-family: var(--f-mono, 'JetBrains Mono', monospace);
  font-size: 20px;
  font-weight: 550;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.card-sheet--pin .pin-key:hover { border-color: rgba(142, 169, 255, .35); background: linear-gradient(180deg, rgba(45, 54, 102, .95), rgba(19, 24, 55, .98)); }
.card-sheet--pin .pin-key:active { transform: scale(.94) translateY(1px); background: rgba(142, 169, 255, .18); }
.card-sheet--pin .pin-key--empty { border-color: transparent; background: transparent; box-shadow: none; pointer-events: none; }
.card-sheet--pin .pin-key--reveal {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--cm-soft);
}
.card-sheet--pin .pin-key--reveal:hover { border-color: rgba(142, 169, 255, .22); background: rgba(142, 169, 255, .06); color: var(--cm-signature); }
.card-sheet--pin .pin-key--reveal:active { background: rgba(142, 169, 255, .12); }
.pin-eye--closed { display: none; }
.card-sheet--pin .pin-key--reveal[aria-pressed="true"] { color: var(--cm-signature); }
.card-sheet--pin .pin-key--reveal[aria-pressed="true"] .pin-eye--open { display: none; }
.card-sheet--pin .pin-key--reveal[aria-pressed="true"] .pin-eye--closed { display: block; }
.card-sheet--pin .pin-key--del {
  border-color: rgba(239, 90, 103, .22);
  background: linear-gradient(180deg, rgba(239, 90, 103, .14), rgba(239, 90, 103, .055));
  color: #ff9aa4;
}
.card-sheet--pin .pin-key--del:hover { border-color: rgba(239, 90, 103, .4); background: rgba(239, 90, 103, .18); }
.pin-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 15px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--cm-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .025);
  color: var(--cm-soft);
  font-size: 10.5px;
  line-height: 1.5;
}
.pin-note svg { flex: 0 0 auto; margin-top: 1px; color: var(--cm-signature); }
.pin-protected,
.pin-success {
  margin-top: 18px;
  padding: 22px 16px;
  border: 1px solid var(--cm-line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .018));
  text-align: center;
}
.pin-protected__icon,
.pin-success__icon {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  border: 1px solid rgba(142, 169, 255, .3);
  border-radius: 15px;
  background: rgba(142, 169, 255, .12);
  color: var(--cm-signature);
}
.pin-success__icon {
  border-color: rgba(95, 176, 62, .32);
  background: rgba(95, 176, 62, .12);
  color: #a9e28e;
}
.pin-protected b,
.pin-success b { display: block; color: #fff; font-size: 14px; font-weight: 700; }
.pin-protected p,
.pin-success p {
  max-width: 320px;
  margin: 7px auto 15px;
  color: var(--cm-muted);
  font-size: 11.5px;
  line-height: 1.55;
}
.pin-success p { margin-bottom: 0; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .card-modal-mask { align-items: flex-end; padding: 0; }
  .card-sheet {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 4px);
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 28px 28px 0 0;
  }
  .card-sheet__grip { margin-bottom: 16px; }
  .card-sheet__title { font-size: 22px; }
  .card-otp__cell { height: 48px; border-radius: 12px; }
  .card-sheet--pin .pin-dot { width: 40px; height: 47px; }
  .card-sheet--pin .pin-key { height: 54px; }
}
@media (max-height: 620px) {
  .card-modal-mask { padding: 8px; }
  .card-sheet { max-height: calc(100dvh - 32px); padding-top: 14px; }
  .card-sheet__grip { margin-bottom: 8px; }
  .card-sheet__desc { margin-top: 8px; }
  .pin-progress, .pin-note { display: none; }
  .pin-protected, .pin-success { margin-top: 12px; padding: 14px 12px; }
  .pin-protected p { margin-bottom: 10px; }
  .card-details__lock { margin-top: 12px; padding: 12px; }
  .card-otp__cell { height: 44px; }
  .card-sheet--pin .pin-dot { height: 42px; }
  .card-sheet--pin .pin-key { height: 46px; font-size: 18px; }
  .card-sheet__foot, .card-sheet__actions { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-modal-mask, .card-sheet, .card-sheet__primary, .card-sheet__ghost,
  .pin-key, .pin-dot, .card-otp__cell { transition: none; }
}
