/* ==========================================================================
   Sabari Nathan — Digital Business Card
   Design tokens
   ========================================================================== */

:root {
  --bg: #0F172A;
  --bg-deep: #0B1220;
  --accent: #38BDF8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --accent-glow: rgba(56, 189, 248, 0.45);

  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 14px 32px rgba(0, 0, 0, 0.45);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ==========================================================================
   Ambient backdrop — quiet radial glow, not a gradient cliché
   ========================================================================== */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(56, 189, 248, 0.16) 0%, rgba(56, 189, 248, 0) 55%),
    radial-gradient(90% 50% at 85% 105%, rgba(56, 189, 248, 0.08) 0%, rgba(56, 189, 248, 0) 60%),
    var(--bg-deep);
}

/* ==========================================================================
   Card shell — fits one viewport, no scroll
   ========================================================================== */

.card {
  position: relative;
  z-index: 1;
  width: min(420px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  padding: clamp(14px, 4.2vh, 28px) clamp(16px, 5vw, 24px) clamp(10px, 2.4vh, 18px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(10px, 1.8vh, 16px);
}

/* ==========================================================================
   Identity block
   ========================================================================== */

.identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(4px, 1vh, 8px);
  flex-shrink: 0;
}

.avatar-ring {
  position: relative;
  width: clamp(104px, 30vw, 135px);
  height: clamp(104px, 30vw, 135px);
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 180deg, var(--accent), rgba(56, 189, 248, 0.15), var(--accent));
  margin-bottom: clamp(10px, 1.8vh, 16px);
  animation: ring-glow 3.6s ease-in-out infinite;
}

.avatar-ring::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  opacity: 0.55;
  z-index: -1;
  filter: blur(6px);
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--bg-deep);
  border: 2.5px solid var(--bg);
}

@keyframes ring-glow {
  0%, 100% { filter: drop-shadow(0 0 6px var(--accent-glow)); }
  50%      { filter: drop-shadow(0 0 14px var(--accent-glow)); }
}

.name {
  font-size: clamp(19px, 5.6vw, 24px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: clamp(6px, 1.2vh, 9px);
  padding: clamp(6px, 1.4vh, 8px) clamp(14px, 4vw, 18px);
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: var(--accent);
  font-size: clamp(11px, 2.9vw, 12.5px);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.3;
  max-width: 26ch;
  text-align: center;
}

.greeting {
  font-size: clamp(11px, 2.9vw, 12px);
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: clamp(6px, 1.2vh, 9px);
  max-width: 28ch;
}

/* ==========================================================================
   Action grid — Apple Wallet style cards
   ========================================================================== */

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(9px, 2vw, 12px);
  flex: 1;
  align-content: center;
}

.action-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.4vh, 9px);
  padding: clamp(10px, 2.6vw, 14px) clamp(8px, 2vw, 12px);
  min-height: clamp(58px, 10.5vh, 76px);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  text-align: center;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease);
  opacity: 0;
  transform: translateY(10px);
}

.action-card::before {
  content: "";
  position: absolute;
  top: -60%;
  left: -20%;
  width: 60%;
  height: 220%;
  background: linear-gradient(115deg, rgba(255,255,255,0.10), transparent 60%);
  transform: rotate(12deg);
  pointer-events: none;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(38px, 10.5vw, 46px);
  height: clamp(38px, 10.5vw, 46px);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: clamp(16px, 4.4vw, 19px);
  flex-shrink: 0;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}

.action-label {
  font-size: clamp(10px, 2.7vw, 11px);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-secondary);
}

.action-card:active {
  transform: scale(0.96) translateY(0);
}

@media (hover: hover) {
  .action-card:hover {
    transform: translateY(-5px);
    border-color: var(--glass-border-strong);
    box-shadow: var(--shadow-lift), 0 0 18px rgba(56, 189, 248, 0.22), 0 0 0 1px rgba(56, 189, 248, 0.14);
  }
  .action-card:hover .action-icon {
    background: var(--accent);
    color: var(--bg);
    transform: scale(1.1);
  }
  .action-card:hover .action-label {
    color: var(--text-primary);
  }
}

/* ==========================================================================
   Save contact — primary, full-width
   ========================================================================== */

.save-contact-wrap {
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(10px);
}

.save-contact {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: clamp(13.5px, 3.6vw, 15px);
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--accent), #7DD3FC);
  border: none;
  border-radius: var(--radius-md);
  padding: clamp(12px, 3.2vh, 15px) 18px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.28);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), filter 0.3s var(--ease);
}

.save-contact .action-icon {
  background: rgba(15, 23, 42, 0.14);
  color: var(--bg-deep);
  width: 22px;
  height: 22px;
  font-size: 13px;
}

.save-contact:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .save-contact:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(56, 189, 248, 0.38);
    filter: brightness(1.04);
  }
}

.save-contact.saved {
  background: linear-gradient(135deg, #34D399, #6EE7B7);
  box-shadow: 0 10px 26px rgba(52, 211, 153, 0.28);
}

/* ==========================================================================
   Status line + Footer
   ========================================================================== */

.status-line {
  flex-shrink: 0;
  text-align: center;
  font-size: clamp(10px, 2.7vw, 11px);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.03em;
  opacity: 0;
  margin-top: -4px;
}

.footer {
  flex-shrink: 0;
  text-align: center;
  opacity: 0;
}

.footer p {
  font-size: clamp(9.5px, 2.6vw, 10.5px);
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Entrance animation — one orchestrated sequence, not scattered effects
   ========================================================================== */

[data-animate] {
  animation: rise-in 0.7s var(--ease) forwards;
}

.identity        { animation-delay: 0.05s; }
.actions .action-card { animation-delay: calc(0.16s + var(--i, 0) * 0.05s); }
.save-contact-wrap { animation-delay: 0.5s; }
.status-line      { animation-delay: 0.6s; }
.footer           { animation-delay: 0.68s; }

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

.identity { opacity: 0; transform: translateY(10px); }

/* ==========================================================================
   Accessibility
   ========================================================================== */

.action-card:focus-visible,
.save-contact:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .avatar-ring { animation: none; }
}

/* ==========================================================================
   Small-screen safety net — keep everything within one screen
   ========================================================================== */

@media (max-height: 700px) {
  .greeting { display: none; }
}

@media (max-height: 560px) {
  .company { display: none; }
}

@media (max-height: 620px) {
  .role-pill { font-size: 10.5px; padding: 5px 12px; }
  .avatar-ring { width: 88px; height: 88px; margin-bottom: 8px; }
  .status-line { display: none; }
}

/* ==========================================================================
   Company line, QR button and QR sheet
   ========================================================================== */

.company {
  font-size: clamp(11px, 2.9vw, 12.5px);
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: clamp(6px, 1.2vh, 9px);
  max-width: 32ch;
}

.save-contact-wrap {
  display: flex;
  gap: 10px;
}
.save-contact-wrap .save-contact { flex: 1 1 auto; }

.qr-button {
  flex: 0 0 auto;
  width: clamp(48px, 13vw, 54px);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--accent);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}
.qr-button:active { transform: scale(0.95); }
@media (hover: hover) {
  .qr-button:hover { border-color: var(--accent); transform: translateY(-2px); }
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 10, 20, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.qr-modal[hidden] { display: none; }

.qr-sheet {
  width: min(320px, 100%);
  text-align: center;
  padding: 24px 22px 18px;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--shadow-lift);
}

.qr-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.qr-image {
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 14px;
  background: #fff;
}

.qr-url {
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.qr-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.qr-link {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.qr-close {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}
