/* ============================================
   CARDS.EC-WEB.FR - Credit Card Format UI
   Design: Neo-Glassmorphism Business Card
   Ratio: 85.6mm × 54mm (1.585:1)
   ============================================ */

/* === CSS Variables === */
:root {
    /* Colors */
    --accent: #6366f1;
    --accent-light: #a5b4fc;
    --accent-dark: #4338ca;
    
    /* Surfaces */
    --bg-primary: #0f0f12;
    --bg-secondary: #18181b;
    --bg-card: rgba(24, 24, 27, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    /* Text */
    --text-primary: #fafafa;
    --text-secondary: rgba(250, 250, 250, 0.7);
    --text-muted: rgba(250, 250, 250, 0.4);
    
    /* Effects */
    --blur-intensity: 20px;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(99, 102, 241, 0.4);
    --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 80px rgba(99, 102, 241, 0.15);
    
    /* Card dimensions - Credit card ratio 1.585:1 */
    --card-width: min(480px, 94vw);
    --card-height: calc(var(--card-width) / 1.585);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-card: 20px;
    
    /* Animation */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 600ms;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f4f4f5;
    --bg-secondary: #e4e4e7;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(0, 0, 0, 0.02);
    --text-primary: #09090b;
    --text-secondary: rgba(9, 9, 11, 0.7);
    --text-muted: rgba(9, 9, 11, 0.4);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 80px rgba(99, 102, 241, 0.08);
}

/* === Base Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    transition: background var(--duration-slow) var(--ease-out-expo);
}

/* === Noise Overlay === */
.noise-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* === Ambient Background === */
.ambient-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    animation: float 25s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    top: -150px;
    right: -150px;
    opacity: 0.12;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-light);
    bottom: -100px;
    left: -100px;
    opacity: 0.08;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* === Main Wrapper === */
.card-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 1.5rem;
}

/* === Theme Toggle === */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.theme-toggle:hover {
    background: var(--bg-card);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* === Edit Link === */
.edit-link {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.edit-link:hover {
    background: var(--bg-card);
    transform: scale(1.05);
}

.edit-link svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

/* === Kiosk Button === */
.kiosk-btn {
    position: fixed;
    top: 1.25rem;
    right: 4.5rem;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.kiosk-btn:hover {
    background: var(--bg-card);
    transform: scale(1.05);
}

.kiosk-btn svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

/* === Card Scene (3D Container) === */
.card-scene {
    perspective: 1200px;
    perspective-origin: center;
}

.card-3d {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
    transform-style: preserve-3d;
    transition: transform 0.7s var(--ease-out-expo);
    cursor: pointer;
}

.card-3d.flipped {
    transform: rotateY(180deg);
}

/* === Card Face === */
.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-card);
    overflow: hidden;
}

.card-front { transform: rotateY(0deg); }
.card-back { transform: rotateY(180deg); }

/* === Card Inner === */
.card-inner {
    position: relative;
    z-index: 2;
    height: 100%;
    padding: 1.5rem;
    display: flex;
    gap: 1.25rem;
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-intensity));
    -webkit-backdrop-filter: blur(var(--blur-intensity));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft), var(--shadow-glow);
}

/* === Card Shine Effect === */
.card-shine {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    border-radius: var(--radius-card);
    background: linear-gradient(
        125deg,
        rgba(255, 255, 255, 0.15) 0%,
        transparent 40%,
        transparent 60%,
        rgba(255, 255, 255, 0.08) 100%
    );
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.card-3d:hover .card-shine { opacity: 1; }

/* === Card Border Glow === */
.card-border-glow {
    position: absolute;
    inset: -1px;
    z-index: 1;
    border-radius: var(--radius-card);
    background: linear-gradient(
        135deg,
        var(--accent) 0%,
        transparent 25%,
        transparent 75%,
        var(--accent-light) 100%
    );
    opacity: 0.4;
    transition: opacity var(--duration-normal);
}

.card-3d:hover .card-border-glow { opacity: 0.6; }

/* === Corner Decoration === */
.card-corner-deco {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    opacity: 0.15;
}

.card-corner-deco::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid var(--accent-light);
    border-radius: 50%;
}

/* ==========================================
   FRONT CARD - Layout
   ========================================== */

.card-left {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
}

.avatar-ring {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    animation: pulse-ring 3s ease-in-out infinite;
}

@keyframes pulse-ring {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.03); opacity: 0.5; }
}

.avatar-img {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--bg-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.avatar-placeholder span {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

/* === Card Right (Info) === */
.card-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.card-logo-wrap {
    margin-bottom: 0.5rem;
}

.card-logo {
    height: 24px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.85;
}

[data-theme="light"] .card-logo {
    filter: none;
    opacity: 1;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.card-name {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-role {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.3;
}

.card-function {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-company {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ==========================================
   BACK CARD - Layout
   ========================================== */

.back-inner {
    flex-direction: row;
    justify-content: space-between;
}

.back-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: 0.75rem;
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--duration-fast);
    padding: 0.25rem 0;
}

.contact-item:hover {
    color: var(--accent);
}

.contact-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    flex-shrink: 0;
}

.contact-icon svg {
    width: 14px;
    height: 14px;
    color: white;
}

.contact-text {
    font-size: 0.8rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-email {
    font-size: 0.75rem;
}

/* === Social Row === */
.social-row {
    display: flex;
    gap: 0.375rem;
    margin-top: auto;
    padding-top: 0.5rem;
}

.social-link {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--duration-fast);
}

.social-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
}

.social-link svg {
    width: 16px;
    height: 16px;
}

/* === Back Right === */
.back-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    text-align: right;
    flex-shrink: 0;
    width: 100px;
}

.back-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    opacity: 0.9;
}

.back-identity {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.back-name {
    font-family: 'Syne', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.back-company {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ==========================================
   ACTION BAR
   ========================================== */

.actions-bar {
    display: flex;
    gap: 0.625rem;
    padding: 0.625rem;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
}

.action-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    border: none;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-normal) var(--ease-spring);
}

.action-btn:hover {
    transform: scale(1.08);
    color: var(--text-primary);
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

.flip-btn:hover { background: var(--accent); color: white; }
.save-btn:hover { background: #22c55e; color: white; }
.share-btn:hover { background: #3b82f6; color: white; }

/* ==========================================
   QR SECTION
   ========================================== */

.qr-section {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 100;
}

.qr-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-normal);
}

.qr-toggle:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.qr-toggle svg {
    width: 16px;
    height: 16px;
}

.qr-popup {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.qr-section.active .qr-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.qr-popup-content {
    padding: 1rem;
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-intensity));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
        display: flex;
        flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.qr-image {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    background: white;
    padding: 0.375rem;
}

.qr-download {
        display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--accent);
    color: white;
    border-radius: 100px;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all var(--duration-normal);
}

.qr-download:hover { background: var(--accent-dark); }
.qr-download svg { width: 14px; height: 14px; }

/* ==========================================
   FOOTER
   ========================================== */

.card-footer {
        display: flex;
        align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.footer-text {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--duration-normal);
}

.footer-brand:hover { color: var(--accent); }

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    border-radius: 5px;
    margin-right: 0.2rem;
}

/* ==========================================
   RESPONSIVE - Mobile
   ========================================== */

@media (max-width: 520px) {
    :root {
        --card-width: 94vw;
    }
    
    .card-wrapper {
        padding: 1rem 0.5rem;
        padding-top: 4rem;
        justify-content: flex-start;
    }
    
    .card-inner {
        padding: 1.25rem;
        gap: 1rem;
    }
    
    .avatar-container {
        width: 70px;
        height: 70px;
    }
    
    .avatar-placeholder span {
        font-size: 1.5rem;
    }
    
    .card-name {
        font-size: 1.15rem;
    }
    
    .card-role {
        font-size: 0.8rem;
    }
    
    .card-function {
        font-size: 0.75rem;
    }
    
    .card-company {
        font-size: 0.7rem;
    }
    
    .card-logo {
        height: 20px;
    }
    
    /* Back */
    .contact-icon {
        width: 24px;
        height: 24px;
    }
    
    .contact-icon svg {
        width: 12px;
        height: 12px;
    }
    
    .contact-text {
        font-size: 0.72rem;
    }
    
    .contact-email {
        font-size: 0.68rem;
    }
    
    .social-link {
        width: 28px;
        height: 28px;
    }
    
    .social-link svg {
        width: 14px;
        height: 14px;
    }
    
    .back-right {
        width: 70px;
    }
    
    .back-logo {
        width: 36px;
        height: 36px;
    }
    
    .back-name {
        font-size: 0.65rem;
    }
    
    .back-company {
        font-size: 0.55rem;
    }
    
    /* Actions */
    .actions-bar {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .action-btn {
        width: 42px;
        height: 42px;
    }
    
    .action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* QR */
    .qr-section {
        bottom: 1rem;
        right: 1rem;
    }
    
    /* Toggle buttons */
    .theme-toggle,
    .edit-link {
        width: 38px;
        height: 38px;
    }
    
    .theme-toggle svg,
    .edit-link svg {
        width: 16px;
        height: 16px;
    }
    
    .card-corner-deco {
        width: 30px;
        height: 30px;
        bottom: 0.75rem;
        right: 0.75rem;
    }
}

@media (max-width: 380px) {
    .card-inner {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .avatar-container {
        width: 60px;
        height: 60px;
    }
    
    .card-name {
        font-size: 1rem;
    }
    
    .back-inner {
        gap: 0.5rem;
    }
    
    .contact-list {
        gap: 0.375rem;
    }
    
    .back-right {
        width: 55px;
    }
    
    .back-logo {
        width: 30px;
        height: 30px;
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-scene {
    animation: fade-in 0.6s var(--ease-out-expo) both;
    animation-delay: 0.1s;
}

.actions-bar {
    animation: fade-in 0.6s var(--ease-out-expo) both;
    animation-delay: 0.2s;
}

.card-footer {
    animation: fade-in 0.6s var(--ease-out-expo) both;
    animation-delay: 0.3s;
}

/* 3D Tilt on hover - Desktop only */
@media (hover: hover) {
    .card-3d:not(.flipped):hover {
        transform: rotateY(-3deg) rotateX(2deg);
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .noise-overlay,
    .ambient-bg,
    .theme-toggle,
    .edit-link,
    .actions-bar,
    .qr-section,
    .card-footer {
        display: none !important;
    }
    
    .card-wrapper {
        padding: 0;
    }
    
    .card-3d {
        transform: none !important;
    }
    
    .card-back {
        display: none;
    }
}
