/* ==========================================================================
   Alistair Rendall — rendall.scot
   Modern Glassmorphic Contact Card
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);

  /* Color Palette - Dark Luxury Glass */
  --bg-dark: #07090e;
  --card-bg: rgba(15, 20, 32, 0.65);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-border-hover: rgba(255, 255, 255, 0.18);
  --card-shadow: 0 30px 70px -10px rgba(0, 0, 0, 0.75), 0 0 1px 1px rgba(255, 255, 255, 0.05);

  --item-bg: rgba(255, 255, 255, 0.035);
  --item-bg-hover: rgba(255, 255, 255, 0.065);
  --item-border: rgba(255, 255, 255, 0.06);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;

  --btn-primary-bg: linear-gradient(135deg, #2563eb, #4f46e5);
  --btn-primary-hover: linear-gradient(135deg, #3b82f6, #6366f1);
  --btn-primary-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.45);

  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-border: rgba(255, 255, 255, 0.12);
  --btn-secondary-hover: rgba(255, 255, 255, 0.1);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Box sizing and reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  width: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 1.5rem 1rem;
}

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

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.45;
  will-change: transform;
}

.orb-1 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.8) 0%, rgba(37, 99, 235, 0) 70%);
  top: -100px;
  left: calc(50% - 320px);
  animation: orbDrift1 18s ease-in-out infinite alternate;
}

.orb-2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.7) 0%, rgba(99, 102, 241, 0) 70%);
  bottom: -120px;
  right: calc(50% - 340px);
  animation: orbDrift2 22s ease-in-out infinite alternate;
}

.orb-3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.4) 0%, rgba(16, 185, 129, 0) 70%);
  top: 40%;
  left: calc(50% - 160px);
  animation: orbPulse 12s ease-in-out infinite alternate;
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
}

@keyframes orbDrift1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 60px) scale(1.08); }
  100% { transform: translate(-30px, 30px) scale(0.95); }
}

@keyframes orbDrift2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -40px) scale(1.1); }
  100% { transform: translate(25px, -60px) scale(0.92); }
}

@keyframes orbPulse {
  0% { transform: scale(0.9) opacity(0.2); }
  100% { transform: scale(1.15) opacity(0.45); }
}

/* ==========================================================================
   Main Container & Glass Card
   ========================================================================== */
.page-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-wrapper {
  width: 100%;
  perspective: 1000px;
}

.glass-card {
  position: relative;
  background: var(--card-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  padding: 2.25rem 2rem;
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
  overflow: hidden;
}

.glass-card:hover {
  border-color: var(--card-border-hover);
  box-shadow: 0 35px 80px -10px rgba(0, 0, 0, 0.8), 0 0 25px rgba(56, 189, 248, 0.08);
}

/* Subtle top edge glare line */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  pointer-events: none;
}

/* ==========================================================================
   Card Header / Monogram
   ========================================================================== */
.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.brand-logo {
  width: auto;
  max-width: 175px;
  height: auto;
  max-height: 84px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 24px rgba(0, 114, 255, 0.28));
  transition: transform var(--transition-bounce), filter var(--transition-normal);
  user-select: none;
  -webkit-user-drag: none;
}

.brand-logo:hover {
  transform: scale(1.06) translateY(-2px);
  filter: drop-shadow(0 14px 32px rgba(56, 189, 248, 0.5));
}

.person-name {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0;
  line-height: 1.2;
}

/* ==========================================================================
   Contact Items List
   ========================================================================== */
.contact-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  transition: all var(--transition-fast);
}

.contact-item:hover {
  background: var(--item-bg-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.item-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-blue);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.item-icon {
  width: 20px;
  height: 20px;
}

.item-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.item-label {
  font-size: 0.725rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.item-value {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

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

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Action Buttons (Copy / Open) */
.action-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
  transform: scale(1.04);
}

.action-btn:active {
  transform: scale(0.96);
}

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

/* Copy State Transitions */
.copy-btn .icon-check {
  display: none;
  color: var(--accent-emerald);
}

.copy-btn.copied {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}

.copy-btn.copied .icon-copy {
  display: none;
}

.copy-btn.copied .icon-check {
  display: block;
}

/* ==========================================================================
   Card Footer & Primary Buttons
   ========================================================================== */
.card-footer {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-normal);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: #ffffff;
  box-shadow: var(--btn-primary-shadow);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: 0 12px 30px -5px rgba(37, 99, 235, 0.6);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   QR Code Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay[hidden] {
  display: none;
  opacity: 0;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: rgba(17, 23, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85), 0 0 20px rgba(56, 189, 248, 0.1);
  padding: 2rem;
  text-align: center;
  animation: modalPopIn var(--transition-bounce);
}

@keyframes modalPopIn {
  from {
    transform: scale(0.92) translateY(12px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-close-btn {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.modal-close-btn svg {
  width: 16px;
  height: 16px;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 1.5rem;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.qr-code-frame {
  padding: 1rem;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code-frame svg,
.qr-code-frame canvas {
  display: block;
  width: 200px;
  height: 200px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
}

.toast.toast-fadeout {
  animation: toastFadeOut 0.3s forwards;
}

.toast-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-emerald);
  flex-shrink: 0;
}

@keyframes toastSlideUp {
  from {
    transform: translateY(18px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 440px) {
  body {
    padding: 1rem 0.75rem;
  }

  .glass-card {
    padding: 1.75rem 1.25rem;
    border-radius: var(--radius-lg);
  }

  .person-name {
    font-size: 1.5rem;
  }

  .card-footer {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 1.5rem 1.25rem;
  }

  .qr-code-frame svg,
  .qr-code-frame canvas {
    width: 180px;
    height: 180px;
  }
}

/* Respect user preferences for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
