/* ==========================================================================
   Digital business card (/card)
   Mobile-first. Uses the site tokens from site.css: ivory card on a stone page,
   espresso header, crimson for the actions.
   ========================================================================== */

body.card-page { background: var(--secondary); }
.card-page .site-header { background: color-mix(in oklab, var(--background) 94%, transparent); }
.card-page .site-footer { background: transparent; border-top-color: color-mix(in oklab, var(--foreground) 10%, transparent); }

.card-shell { width: min(100% - 1.5rem, 28rem); margin-inline: auto; padding-block: 1.25rem 2.5rem; }

.bcard {
  overflow: hidden; background: var(--background); border: 1px solid color-mix(in oklab, var(--foreground) 10%, transparent);
  border-radius: 1.25rem; box-shadow: 0 1px 2px rgb(23 20 18 / 0.06), 0 24px 48px -28px rgb(23 20 18 / 0.35);
}

/* Identity ------------------------------------------------------------------- */
.bcard-head {
  position: relative; padding: 1.5rem 1.5rem 1.75rem; background: var(--foreground); color: var(--background);
  border-top: 4px solid var(--primary);
}
.bcard-brand { font-family: "Instrument Serif", Georgia, serif; font-size: 1.2rem; line-height: 1; color: color-mix(in oklab, var(--background) 78%, transparent); text-align: start; }
.bcard-brand::after { content: "."; color: var(--primary-on-dark); }
[dir="rtl"] .bcard-brand { text-align: right; }
.bcard-mark {
  margin-top: 1.5rem; width: 4rem; height: 4rem; display: grid; place-items: center; border-radius: 50%;
  background: var(--primary); color: var(--primary-foreground); font-family: "Instrument Serif", Georgia, serif; font-size: 1.75rem;
}
.bcard-name { margin-top: 1rem; font-size: 2.5rem; line-height: 1.05; }
:root[lang="ar"] .bcard-name { line-height: 1.35; }
.bcard-role { margin-top: 0.45rem; font-size: 0.95rem; font-weight: 500; }
.bcard-tagline { margin-top: 0.35rem; font-size: 0.85rem; line-height: 1.5; color: color-mix(in oklab, var(--background) 70%, transparent); }
.bcard-location { margin-top: 1rem; display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: color-mix(in oklab, var(--background) 70%, transparent); }
.bcard-location .icon { color: var(--primary-on-dark); }

.bcard-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.25rem; padding: 1rem 0.75rem; border-bottom: 1px solid var(--border); }
.bcard-actions a { display: grid; justify-items: center; gap: 0.4rem; padding: 0.25rem; font-size: 0.7rem; font-weight: 500; color: var(--muted-foreground); text-align: center; }
.bcard-actions a span {
  width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--foreground); transition: border-color .15s, color .15s, background-color .15s;
}
.bcard-actions a:hover span, .bcard-actions a:active span { border-color: var(--primary); color: var(--primary); }

/* Steps ---------------------------------------------------------------------- */
.bcard-step { padding: 1.5rem; border-bottom: 1px solid var(--border); scroll-margin-top: 5.5rem; }
.bcard-step:last-of-type { border-bottom: 0; }
.step-label { font-size: 0.68rem; font-weight: 600; color: var(--primary); text-transform: var(--kicker-transform); letter-spacing: var(--kicker-tracking); }
:root[lang="ar"] .step-label { font-size: 0.8rem; }
.step-title { margin-top: 0.4rem; font-size: 1.75rem; line-height: 1.1; }
:root[lang="ar"] .step-title { line-height: 1.4; }
.step-body { margin-top: 0.5rem; font-size: 0.9rem; line-height: 1.6; color: var(--muted-foreground); }

.bcard-cta { margin-top: 1.25rem; display: grid; gap: 0.6rem; }
.card-page .btn-lg { min-height: 3.25rem; font-size: 0.95rem; white-space: normal; text-align: center; }
.bcard-note { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.85rem; line-height: 1.5; color: var(--success); }
.bcard-note .icon { margin-top: 0.2rem; }

/* Step 2 lights up after "Save contact" */
.bcard-exchange { position: relative; transition: background-color .4s ease; }
.bcard-exchange.is-invited { background: var(--card); box-shadow: inset 0 0 0 2px var(--primary); }
@media (prefers-reduced-motion: no-preference) {
  .bcard-exchange.is-invited { animation: invite-pulse 1.6s ease-out 2; }
}
@keyframes invite-pulse {
  0% { box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 2px color-mix(in oklab, var(--primary) 40%, transparent); }
  100% { box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 14px transparent; }
}

.exchange-form { margin-top: 1.25rem; gap: 1rem; }
.exchange-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
/* 16px or larger, otherwise iOS zooms the page when a field is focused */
.card-page .input { min-height: 3rem; font-size: 1rem; background: var(--card); }
.exchange-form .btn { width: 100%; margin-top: 0.25rem; }

/* Hand-off switch: deliberately quiet */
.handoff { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: start; margin-top: 0.5rem; padding-top: 1rem; border-top: 1px dashed var(--border); cursor: pointer; }
.handoff input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.handoff-switch { position: relative; width: 2.5rem; height: 1.5rem; margin-top: 0.1rem; border-radius: 999px; background: var(--input); transition: background-color .2s; }
.handoff-switch::after { content: ""; position: absolute; top: 0.2rem; inset-inline-start: 0.2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--card); transition: transform .2s; }
.handoff input:checked + .handoff-switch { background: var(--primary); }
.handoff input:checked + .handoff-switch::after { transform: translateX(1rem); }
[dir="rtl"] .handoff input:checked + .handoff-switch::after { transform: translateX(-1rem); }
.handoff input:focus-visible + .handoff-switch { outline: 2px solid var(--ring); outline-offset: 2px; }
.handoff-text { display: grid; gap: 0.15rem; }
.handoff-text strong { font-size: 0.85rem; font-weight: 600; }
.handoff-text small { font-size: 0.75rem; line-height: 1.5; color: var(--muted-foreground); }

/* Confirmation --------------------------------------------------------------- */
.exchange-done:focus { outline: none; }
.exchange-done .step-title { margin-top: 1rem; }
.status-pill { margin-top: 1rem; display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; line-height: 1.4; }
.status-pill::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.status-pill.is-synced { background: color-mix(in oklab, var(--success) 12%, var(--card)); color: var(--success); }
.status-pill.is-offline { background: var(--secondary); color: var(--ink-soft); }

.qr-figure { margin-top: 1.25rem; display: grid; gap: 0.9rem; justify-items: center; padding: 1.25rem; border: 1px solid var(--border); border-radius: 0.9rem; background: var(--card); text-align: center; }
.qr-figure figcaption { display: grid; gap: 0.3rem; font-size: 0.85rem; line-height: 1.55; color: var(--muted-foreground); }
.qr-figure figcaption strong { font-family: var(--font-heading); font-weight: 400; font-size: 1.3rem; color: var(--foreground); }
/* QR codes are always dark on pure white, whatever surrounds them: scanners need the contrast. */
.qr-frame { width: min(100%, 15.5rem); aspect-ratio: 1; background: #FFFFFF; border-radius: 0.5rem; }
.qr-frame svg { display: block; width: 100%; height: 100%; }
.qr-frame-lg { width: min(100%, 19rem, 46svh); }

/* Outbox --------------------------------------------------------------------- */
.bcard-queue { background: var(--secondary); }
.queue-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.queue-title { font-family: var(--font-body); font-size: 0.95rem; font-weight: 600; line-height: 1.4; }
.queue-head .btn { flex: none; background: var(--background); border: 1px solid var(--input); }
.queue-list { margin-top: 1rem; display: grid; gap: 0.5rem; }
.queue-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.85rem; border-radius: 0.6rem; background: var(--background); border: 1px solid var(--border); }
.queue-list li > div:first-child { display: grid; min-width: 0; }
.queue-list strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list small { font-size: 0.75rem; color: var(--muted-foreground); }
.queue-list small.is-rejected { color: var(--destructive); }
.queue-actions { display: flex; flex: none; }

.bcard-install { display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; align-items: start; }
.install-icon { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: 50%; background: var(--secondary); color: var(--primary); }
.install-title { font-size: 0.95rem; font-weight: 600; }
.bcard-install .btn { margin-top: 0.75rem; border: 1px solid var(--input); }

.bcard-state { padding: 0.7rem 1.5rem; background: var(--foreground); color: var(--background); font-size: 0.8rem; text-align: center; }

/* QR drawer ------------------------------------------------------------------ */
.qr-drawer {
  width: 100%; max-width: 28rem; max-height: 100dvh; margin: auto auto 0; padding: 0; border: 0; overflow: auto;
  border-radius: 1.25rem 1.25rem 0 0; background: var(--background); color: var(--foreground);
  box-shadow: 0 -20px 60px -20px rgb(23 20 18 / 0.5);
}
.qr-drawer::backdrop { background: rgb(23 20 18 / 0.6); }
.qr-drawer.is-fallback { position: fixed; inset: auto 0 0 0; z-index: 80; }
.qr-drawer-inner { display: grid; justify-items: center; gap: 0.9rem; padding: 1rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .qr-drawer[open] { animation: drawer-up .28s ease-out; }
}
@keyframes drawer-up { from { transform: translateY(2rem); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .qr-drawer { margin: auto; border-radius: 1.25rem; }
}

.segmented { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; padding: 0.25rem; border-radius: 0.8rem; background: var(--secondary); }
.segmented button { display: grid; gap: 0.1rem; padding: 0.6rem 0.5rem; border-radius: 0.6rem; color: var(--muted-foreground); line-height: 1.3; transition: background-color .15s, color .15s, box-shadow .15s; }
.segmented strong { font-size: 0.8rem; font-weight: 600; }
.segmented small { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: inherit; opacity: 0.8; }
:root[lang="ar"] .segmented small { letter-spacing: 0; text-transform: none; font-size: 0.72rem; }
.segmented button[aria-checked="true"] { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgb(23 20 18 / 0.12); }
.segmented button[aria-checked="true"] small { color: var(--primary); opacity: 1; }

.qr-title { margin-top: 0.35rem; font-size: 1.75rem; }
.qr-name { display: grid; gap: 0.1rem; font-size: 0.8rem; color: var(--muted-foreground); }
.qr-name strong { font-size: 1rem; color: var(--foreground); }
.qr-caption { max-width: 22rem; font-size: 0.82rem; line-height: 1.55; color: var(--muted-foreground); min-height: 3.9em; }
.qr-drawer .btn { width: 100%; }

@media print {
  .site-header, .site-footer, .bcard-exchange, .bcard-queue, .bcard-install, .bcard-cta { display: none; }
}
