/* AR Business Card — Design System
   Tokens matched from chrischowen.com main.css */

:root {
  --bg: #0a0a0f;
  --bg-surface: #141419;
  --bg-elevated: #1e1e26;
  --border: #2a2a35;
  --border-hover: #3a3a48;
  --text: #e8e6e1;
  --text-bright: #f5f3ee;
  --text-muted: #8a8780;
  --accent: #d4a04a;
  --accent-hover: #e8b45e;
  --accent-soft: rgba(212, 160, 74, 0.1);
  --accent-2: #6ba3d6;
  --accent-3: #e07a5f;
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);

  /* AR-specific */
  --glass-bg: rgba(20, 20, 25, 0.75);
  --glass-border: rgba(212, 160, 74, 0.12);
  --glass-blur: 20px;
  --state-listening: #3b82f6;
  --state-thinking: #8b5cf6;
  --state-speaking: var(--accent);
  --state-error: var(--accent-3);
}

/* ——— Reset ——— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body { background: var(--bg); }

/* ——— A-Frame overrides ——— */
.a-enter-vr, .a-enter-ar,
#arjsDebugUIContainer,
.arjs-loader { display: none !important; }
a-scene { position: fixed; inset: 0; z-index: 0; }
/* Ensure any A-Frame permission dialogs appear above our UI */
.a-modal, .a-dialog { z-index: 99999 !important; }

/* Surface fallback background (iOS / no-WebXR path) */
body[data-mode="surface"] a-scene {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-surface) 50%, var(--bg-elevated) 100%) !important;
}

/* ——— UI Root ——— */
#ar-ui-root {
  position: fixed; inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#ar-ui-root > * { pointer-events: auto; }

/* ——— Glass card ——— */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--shadow-lg);
}

/* ——— Overlays ——— */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 24px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.overlay[hidden] {
  opacity: 0; visibility: hidden; pointer-events: none;
  display: flex;
}

/* ——— LOADING overlay ——— */
#loading-overlay {
  background: var(--bg);
}
.loading-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.loading-subtitle {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 40px;
  line-height: 1.2;
}
.loading-bar-track {
  width: 220px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover), var(--accent));
  background-size: 200% 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  animation: shimmer 1.5s ease-in-out infinite;
}
.loading-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 48px;
}

/* Tap prompt */
.tap-prompt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 28px;
  background: var(--glass-bg);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  animation: pulse-glow 2s ease-in-out infinite;
  transition: background 0.2s, opacity 0.3s;
}
.tap-prompt:active { background: var(--accent-soft); }
.tap-prompt:disabled {
  opacity: 0.35;
  pointer-events: none;
  animation: none;
}

/* Loading hint — contextual tip below tap button */
.loading-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ——— SCANNING overlay ——— */
#scanning-overlay {
  background: rgba(10, 10, 15, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.scan-graphic {
  position: relative;
  width: 140px; height: 140px;
  margin-bottom: 24px;
}
.scan-graphic img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 12px;
}
.scan-ring {
  position: absolute; inset: -12px;
  border: 2px solid var(--accent);
  border-radius: 16px;
  animation: pulse 2s ease-in-out infinite;
  opacity: 0.6;
}
.scan-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 6px;
}
.scan-detail {
  font-size: 13px;
  color: var(--text-muted);
}
.no-card-link {
  margin-top: 32px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  font-family: inherit;
}
.no-card-link:active { opacity: 1; }

/* ——— FAB (Talk to Chris) ——— */
#fab-container {
  position: fixed;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  z-index: 20;
  pointer-events: auto;
}
#fab-container[hidden] { display: none; }
.fab {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease;
  transition: background 0.2s, transform 0.15s;
}
.fab:active { transform: scale(0.96); }
.fab-icon { font-size: 18px; }

/* ——— Status card (conversation HUD) ——— */
#status-card {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 20;
  max-width: 380px;
  margin: 0 auto;
}
#status-card[hidden] { display: none; }
.status-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.status-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-bright);
}
.status-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 18px;
}

/* Status dot colours by state */
body[data-state="connecting"] .status-dot { background: var(--state-thinking); }
body[data-state="listening"]  .status-dot { background: var(--state-listening); }
body[data-state="thinking"]   .status-dot { background: var(--state-thinking); }
body[data-state="speaking"]   .status-dot { background: var(--state-speaking); }

/* ——— Audio visualiser ——— */
.audio-viz {
  display: flex; align-items: flex-end; gap: 2px;
  height: 24px;
  margin-top: 8px; margin-left: 18px;
}
.audio-viz[hidden] { display: none; }
.audio-viz__bar {
  width: 3px;
  min-height: 2px;
  border-radius: 1px;
  transition: height 0.08s ease;
}
body[data-state="speaking"] .audio-viz__bar { background: var(--state-speaking); }
body[data-state="listening"] .audio-viz__bar { background: var(--state-listening); }

/* ——— Thinking dots ——— */
.thinking-dots {
  display: flex; gap: 6px;
  margin-top: 10px; margin-left: 18px;
}
.thinking-dots[hidden] { display: none; }
.thinking-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

/* ——— End button ——— */
.end-btn {
  display: block;
  margin: 12px auto 0;
  padding: 8px 24px;
  background: transparent;
  border: 1px solid var(--accent-3);
  border-radius: 999px;
  color: var(--accent-3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.end-btn:active { transform: scale(0.96); }

/* ——— ENDED overlay ——— */
#ended-overlay {
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#ended-overlay[hidden] { display: flex; }

.ended-card {
  text-align: center;
  max-width: 320px;
  width: 100%;
}
.ended-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 4px;
}
.ended-duration {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.ended-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.ended-action-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 12px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.ended-action-btn:active { transform: scale(0.96); }
.ended-action-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.ended-action-icon { font-size: 20px; }
.ended-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.ended-link:hover { color: var(--accent-hover); }

/* User transcription display */
.user-transcript-flash {
  color: var(--accent-2) !important;
  font-style: italic;
}

/* Portfolio showcase — topic-based project cards */
.portfolio-showcase {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  width: 100%;
}
.portfolio-showcase[hidden] { display: none; }
.portfolio-showcase::before {
  content: 'Based on your conversation';
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.portfolio-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.15s;
}
.portfolio-card:active { transform: scale(0.98); }
.portfolio-card:hover { border-color: var(--accent); }
.portfolio-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.portfolio-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ——— ERROR overlay ——— */
#error-overlay {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#error-overlay[hidden] { display: flex; }
.error-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--state-error);
  margin-bottom: 12px;
}
.error-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 6px;
}
.error-message {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.retry-btn {
  padding: 10px 24px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.retry-btn:active { background: var(--accent-soft); transform: scale(0.96); }

/* ——— Animations ——— */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 160, 74, 0.3); }
  50% { box-shadow: 0 0 20px 4px rgba(212, 160, 74, 0.15); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.06); opacity: 0.3; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ——— Open-page toast notification ——— */
.open-toast {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(212, 160, 74, 0.06);
  animation: toast-in 0.35s ease;
  max-width: calc(100vw - 48px);
  width: auto;
  min-width: 220px;
}
.open-toast-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 4px 14px 18px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}
.open-toast-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.open-toast-url {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.open-toast-dismiss {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  margin-right: 8px;
  transition: color 0.2s, background 0.2s;
}
.open-toast-dismiss:active {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.06);
}
