/* ==========================================================================
   css/tarjeta_credito.css
   Tarjeta de crédito animada (compartida por carrito.php y recarga.php).
   Sin dependencias: solo CSS. El comportamiento vive en js/tarjeta_credito.js.
   ========================================================================== */

.tcred-zona { margin: 6px 0 18px; }

/* ---------- Escenario 3D ---------- */
.tcred-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    margin: 0 auto 22px;
    aspect-ratio: 1.586 / 1;          /* proporción ISO 7810 ID-1 */
    perspective: 1400px;
}
/* respaldo para navegadores sin aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    .tcred-card { height: 0; padding-bottom: 63.05%; }
}

.tcred-inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform .75s cubic-bezier(.4, .2, .2, 1);
}
.tcred-card.is-flip .tcred-inner { transform: rotateY(180deg); }

.tcred-face {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    color: #fff;
    background: linear-gradient(135deg, #3a4a63 0%, #1d2636 55%, #10161f 100%);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .28), 0 2px 6px rgba(0, 0, 0, .18);
    transition: background .55s ease;
}
.tcred-back { transform: rotateY(180deg); }

/* brillo diagonal sutil */
.tcred-face::after {
    content: "";
    position: absolute;
    top: -60%; left: -30%;
    width: 60%; height: 220%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.13) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(22deg);
    pointer-events: none;
}

/* ---------- Colores por franquicia ---------- */
.tcred-card[data-marca="visa"]       .tcred-face { background: linear-gradient(135deg, #2a4d9b 0%, #16306b 55%, #0d1e46 100%); }
.tcred-card[data-marca="mastercard"] .tcred-face { background: linear-gradient(135deg, #46312b 0%, #7a3b1d 55%, #2b1a13 100%); }
.tcred-card[data-marca="amex"]       .tcred-face { background: linear-gradient(135deg, #1c7391 0%, #10566e 55%, #08303e 100%); }
.tcred-card[data-marca="diners"]     .tcred-face { background: linear-gradient(135deg, #4a5c72 0%, #2b3a4d 55%, #16202c 100%); }

/* ---------- Cara frontal ---------- */
.tcred-front { padding: 18px 20px; display: flex; flex-direction: column; }

.tcred-top { display: flex; align-items: flex-start; justify-content: space-between; }

.tcred-chip {
    width: 44px; height: 34px; border-radius: 6px;
    background: linear-gradient(135deg, #e9c96b 0%, #c8a13d 45%, #f2e0a0 100%);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
    position: relative; flex: none;
}
.tcred-chip::before, .tcred-chip::after {
    content: ""; position: absolute; left: 6px; right: 6px; height: 1px;
    background: rgba(0,0,0,.25);
}
.tcred-chip::before { top: 11px; }
.tcred-chip::after  { top: 22px; }

.tcred-marca { height: 30px; max-width: 74px; opacity: 0; transform: translateY(-6px); transition: opacity .35s ease, transform .35s ease; }
.tcred-marca.on { opacity: 1; transform: translateY(0); }

.tcred-numero {
    margin-top: auto;
    font-family: "Courier New", Consolas, monospace;
    font-size: clamp(15px, 5.1vw, 23px);
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,.45);
    white-space: nowrap;
    display: flex;
    gap: 1px;
}
.tcred-numero .g { display: inline-flex; margin-right: 11px; }
.tcred-numero .g:last-child { margin-right: 0; }

/* cada dígito entra con un pequeño salto */
.tcred-numero i { font-style: normal; display: inline-block; min-width: .62em; text-align: center; }
.tcred-numero i.nuevo { animation: tcredEntra .32s cubic-bezier(.2,.9,.3,1.4); }
@keyframes tcredEntra {
    0%   { transform: translateY(-9px) scale(.7); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
.tcred-numero i.vacio { opacity: .38; }

.tcred-pie { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 14px; gap: 12px; }
.tcred-rot { font-size: 8px; letter-spacing: 1.4px; text-transform: uppercase; opacity: .62; display: block; margin-bottom: 3px; }
.tcred-val {
    font-family: "Courier New", Consolas, monospace;
    font-size: 12px; letter-spacing: .6px; text-transform: uppercase;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: opacity .25s ease;
}
.tcred-nombre-box { min-width: 0; flex: 1; }
.tcred-vence-box  { flex: none; text-align: right; }

/* resalta el dato que se está escribiendo */
.tcred-foco { position: relative; }
.tcred-foco::before {
    content: ""; position: absolute; inset: -5px -8px; border-radius: 7px;
    border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.08);
    animation: tcredPulso 1.8s ease-in-out infinite;
}
@keyframes tcredPulso { 0%,100% { opacity: .45; } 50% { opacity: .95; } }

/* ---------- Cara trasera ---------- */
.tcred-back { display: flex; flex-direction: column; }
.tcred-banda { height: 42px; background: #10141b; margin-top: 20px; }
.tcred-cvv-fila { margin: 16px 20px 0; display: flex; align-items: center; gap: 10px; }
.tcred-cvv-caja {
    flex: 1; height: 34px; border-radius: 4px; background: #efefef; color: #1b2430;
    display: flex; align-items: center; justify-content: flex-end; padding: 0 12px;
    font-family: "Courier New", Consolas, monospace; font-size: 15px; letter-spacing: 3px;
}
.tcred-cvv-rot { font-size: 9px; letter-spacing: 1.2px; text-transform: uppercase; opacity: .72; }
.tcred-back-nota { margin: auto 20px 16px; font-size: 9px; opacity: .55; line-height: 1.5; }

/* ---------- Formulario ---------- */
.tcred-campos .form-group { margin-bottom: 12px; }
.tcred-campos input.tcred-err, .tcred-campos select.tcred-err { border-color: #d9534f; box-shadow: 0 0 0 .15rem rgba(217,83,79,.18); }
.tcred-aviso { font-size: 11px; color: #6b7683; text-align: center; margin-top: 4px; }
.tcred-aviso b { color: #3f4a57; }

@media (max-width: 420px) {
    .tcred-card { max-width: 300px; }
    .tcred-front { padding: 14px 15px; }
    .tcred-chip { width: 36px; height: 28px; }
}

/* respeta a quien pidió menos animación */
@media (prefers-reduced-motion: reduce) {
    .tcred-inner, .tcred-face, .tcred-marca { transition: none; }
    .tcred-numero i.nuevo { animation: none; }
    .tcred-foco::before { animation: none; }
}
