/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
    --accent: #4a6b53;
    --accent-dark: #37513e;
    --accent-soft: #eef3ef;

    --cream: #f8f5ee;
    --back-bg: #faf8f3;

    --ink: #252e28;
    --ink-muted: #6b7a6f;
    --white: #faf9f6;

    --page-bg: #faf9f6;
    --shadow: 0 8px 28px rgba(74,107,83,.08);
    --shadow-hover: 0 14px 38px rgba(74,107,83,.14);
    --radius: 10px;

    --curve-fill: rgba(255,255,255,.08);
}

body.dark-theme {
    --accent-soft: #263029;
    --cream: #191f1b;
    --back-bg: #1a201c;
    --ink: #e8ede9;
    --ink-muted: #8ea494;
    --page-bg: #0e1210;
    --white: #e8ede9;
    --shadow: 0 8px 30px rgba(0,0,0,.30);
    --shadow-hover: 0 14px 42px rgba(0,0,0,.40);
    --curve-fill: rgba(255,255,255,.04);
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--page-bg);
    color: var(--ink);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background .3s, color .3s;
}

/* ============================================
   APP SHELL
   ============================================ */
.app-container {
    width: 100%;
    max-width: 540px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* soft ambient blobs */
.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); opacity: .12; z-index: 0; pointer-events: none; }
.pattern-1 { width: 320px; height: 320px; background: var(--accent); top: -40px; right: -40px; }
.pattern-2 { width: 420px; height: 420px; background: #e2dbd0; bottom: -80px; left: -80px; }
body.dark-theme .pattern-2 { background: #192119; }

/* ============================================
   HEADER
   ============================================ */
header { text-align: center; margin-bottom: 26px; width: 100%; }

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    max-width: 100%;
    margin-bottom: 3px;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent);
    transition: color .3s;
}
body.dark-theme .logo-text { color: var(--white); }

.theme-toggle-btn {
    position: absolute; right: 0;
    background: none;
    border: 1px solid rgba(74,107,83,.18);
    color: var(--accent);
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: grid; place-items: center;
    transition: all .25s;
}
body.dark-theme .theme-toggle-btn { border-color: rgba(255,255,255,.1); color: var(--white); }
.theme-toggle-btn:hover { background: var(--accent-soft); transform: scale(1.05); }

.subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: .78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-muted);
    font-weight: 400;
}

/* ============================================
   CARD SCENE — RESPONSIVE ASPECT RATIO
   ============================================ */
.card-viewer { width: 100%; display: flex; flex-direction: column; align-items: center; }

.card-scene {
    width: 100%;
    max-width: 460px;
    /* Use padding-bottom trick for universal aspect ratio support */
    aspect-ratio: 1.75;
    perspective: 1100px;
    margin-bottom: 22px;
}
/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 1.75) {
    .card-scene { height: 0; padding-bottom: 57.14%; position: relative; }
    .card-scene > .business-card { position: absolute; top: 0; left: 0; }
}

.business-card {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .75s cubic-bezier(.22,.61,.36,1.05);
    cursor: pointer;
}
.business-card.flipped { transform: rotateY(180deg); }

/* ============================================
   CARD FACE (shared)
   ============================================ */
.card-face {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow .3s, background .3s, border-color .3s;
    overflow: hidden;
}
.card-face:hover { box-shadow: var(--shadow-hover); }

/* ============================================
   FRONT FACE
   ============================================ */
.card-face.front {
    background: var(--accent);
    color: var(--white);
    border: none;
}

/* --- SVG Decorative Curves --- */
.curve-deco { position: absolute; width: 100%; pointer-events: none; }
.curve-deco path { fill: var(--curve-fill); }

.curve-top { top: 0; height: 40%; }
.curve-bottom { bottom: 0; height: 35%; }

/* --- Front Grid Layout --- */
.front-grid {
    position: relative; z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 22px 26px;
}

.front-meta-top, .front-meta-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.meta-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: .56rem;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,.50);
    font-weight: 300;
    text-transform: uppercase;
}

/* Name block — left-aligned */
.front-main {
    text-align: left;
    padding: 0;
}

.front-name {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 700;
    letter-spacing: .5px;
    line-height: 1.15;
    color: var(--white);
    margin-bottom: 5px;
}

.front-tagline {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(.72rem, 2vw, .82rem);
    font-weight: 300;
    letter-spacing: .5px;
    color: rgba(255,255,255,.80);
}

.flip-hint {
    font-family: 'Inter', sans-serif;
    font-size: .62rem;
    color: rgba(255,255,255,.45);
    letter-spacing: .4px;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 5px;
    transition: color .25s;
}
.business-card:hover .flip-hint { color: rgba(255,255,255,.85); }

/* ============================================
   BACK FACE
   ============================================ */
.card-face.back {
    background: var(--back-bg);
    color: var(--ink);
    transform: rotateY(180deg);
    border: 1px solid rgba(74,107,83,.08);
}
body.dark-theme .card-face.back { border-color: rgba(255,255,255,.04); }

.back-grid {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 22px 26px;
}

.back-header { margin-bottom: 2px; }

.back-name {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.1rem, 3.5vw, 1.35rem);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
}

.back-title {
    font-family: 'Outfit', sans-serif;
    font-size: .7rem;
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .8px;
}
body.dark-theme .back-title { color: var(--ink-muted); }

.divider {
    border: none;
    height: 1px;
    background: var(--accent);
    opacity: .10;
    margin: 8px 0;
}
body.dark-theme .divider { background: var(--white); opacity: .06; }

/* --- Contact Rows --- */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    justify-content: center;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background .2s;
    cursor: pointer;
}
.row.static { cursor: default; }
.row:not(.static):hover { background: var(--accent-soft); }

.row-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.row-label {
    font-size: .55rem;
    text-transform: uppercase;
    color: var(--ink-muted);
    letter-spacing: .5px;
    font-weight: 600;
    margin-bottom: 1px;
}

.row-value {
    font-size: clamp(.72rem, 2vw, .8rem);
    color: var(--ink);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row:not(.static):hover .row-value.link {
    color: var(--accent);
    text-decoration: underline;
}
body.dark-theme .row:not(.static):hover .row-value.link { color: #fff; }

.row-action {
    font-size: .75rem;
    color: var(--ink-muted);
    opacity: 0;
    margin-left: 8px;
    flex-shrink: 0;
    transition: opacity .2s, color .2s;
}
.row-action.visible { opacity: .5; }
.row:hover .row-action { opacity: .65; }
.row-action:hover { color: var(--accent); }
body.dark-theme .row-action:hover { color: #fff; }

.back-footer { text-align: center; margin-top: 4px; }

.footer-tagline {
    font-family: 'Outfit', sans-serif;
    font-style: italic;
    font-size: .72rem;
    font-weight: 300;
    color: var(--ink-muted);
}

/* ============================================
   BUTTONS
   ============================================ */
.controls { display: flex; gap: 10px; }

.btn {
    font-family: 'Outfit', sans-serif;
    padding: 9px 18px;
    border: none;
    border-radius: 18px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all .25s;
}

.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
body.dark-theme .btn-primary { background: var(--white); color: var(--page-bg); }
body.dark-theme .btn-primary:hover { background: #fff; }

.btn-secondary {
    background: var(--cream);
    color: var(--ink);
    border: 1px solid rgba(74,107,83,.12);
}
.btn-secondary:hover { background: #f0ece2; transform: translateY(-1px); }
body.dark-theme .btn-secondary { border-color: rgba(255,255,255,.08); background: transparent; }
body.dark-theme .btn-secondary:hover { background: rgba(255,255,255,.04); }

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed; bottom: 24px;
    background: var(--ink); color: var(--white);
    padding: 9px 18px; border-radius: 18px;
    font-size: .78rem; font-weight: 500;
    opacity: 0; transform: translateY(14px);
    transition: all .3s cubic-bezier(.17,.88,.32,1.2);
    z-index: 10; pointer-events: none;
}
body.dark-theme .toast { background: #fff; color: var(--page-bg); }
.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================
   QR MODAL OVERLAY
   ============================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--back-bg);
    border: 1px solid rgba(74,107,83,.1);
    border-radius: 14px;
    padding: 28px 24px;
    width: 90%;
    max-width: 340px;
    text-align: center;
    position: relative;
    transform: scale(.92) translateY(12px);
    transition: transform .35s cubic-bezier(.22,.61,.36,1.05);
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
body.dark-theme .modal-card { border-color: rgba(255,255,255,.06); }
.modal-overlay.open .modal-card {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 14px; right: 14px;
    background: none; border: none;
    color: var(--ink-muted);
    font-size: 1rem;
    cursor: pointer;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    transition: background .2s, color .2s;
}
.modal-close:hover { background: var(--accent-soft); color: var(--ink); }

.modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

.modal-desc {
    font-size: .75rem;
    color: var(--ink-muted);
    line-height: 1.5;
    margin-bottom: 18px;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 18px;
}

.qr-container canvas {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

.modal-actions {
    display: flex;
    justify-content: center;
}

/* ============================================
   FOOTER
   ============================================ */
footer { margin-top: 26px; font-size: .7rem; color: var(--ink-muted); text-align: center; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .front-grid, .back-grid { padding: 18px 20px; }
    .controls { gap: 8px; }
    .btn { padding: 9px 14px; font-size: .74rem; }
}

@media (max-width: 360px) {
    .front-grid, .back-grid { padding: 14px 16px; }
    .front-name { font-size: 1.6rem; }
    .row { padding: 4px 6px; }
    .modal-card { padding: 22px 18px; }
}
