@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@500;600&family=Hanken+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* AR Business Card design system */

:root {
  /* Surface */
  --bg:           #121210;
  --bg-surface:   #1a1c1a;
  --bg-elevated:  #1F2C40;
  --border:       rgba(244, 243, 238, 0.10);
  --border-hover: rgba(244, 243, 238, 0.22);

  /* Text */
  --text:         #F4F3EE;
  --text-bright:  #F4F3EE;
  --text-muted:   #8AA0BC;
  --text-dim:     #65635A;

  /* Accent (burnt orange) */
  --accent:       #E5481E;
  --accent-deep:  #B83814;
  --accent-soft:  #F5A57F;
  --accent-wash:  #F8DCC7;
  --accent-hover: #F5A57F;

  /* Cool */
  --cool:         #1F2C40;
  --cool-2:       #3E536F;
  --cool-soft:    #8AA0BC;

  /* State colours */
  --state-listening: #8AA0BC;
  --state-thinking:  #F5A57F;
  --state-speaking:  #E5481E;
  --state-error:     #B83814;

  /* Glass */
  --glass-bg:     rgba(18, 20, 16, 0.78);
  --glass-blur:   16px;
  --glass-border: rgba(244, 243, 238, 0.08);

  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45);

  /* Fonts */
  --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
  --font-ui:      'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

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

/* Cursor block brand mark */
.cb {
  display: inline-block;
  width: 0.5em;
  height: 0.92em;
  background: var(--accent);
  vertical-align: -0.08em;
}
.cb.live { animation: cb-blink 1.05s steps(2) infinite; }
.cb.cool { background: var(--cool-soft); }
.cb.paper { background: var(--text); }
.cb.sm { width: 0.42em; height: 0.85em; }
@keyframes cb-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cb.live { animation: none; } }

/* A-Frame overrides */
.a-enter-vr, .a-enter-ar,
#arjsDebugUIContainer,
.arjs-loader { display: none !important; }
a-scene { position: fixed; inset: 0; z-index: 0; }
.a-modal, .a-dialog { z-index: 99999 !important; }

/* Surface fallback background */
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-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.loading-title .cb {
  background: var(--accent);
}
.loading-subtitle {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 40px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.loading-bar-track {
  width: 220px;
  height: 3px;
  background: rgba(244, 243, 238, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft), 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-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 48px;
  letter-spacing: 0.02em;
}

/* Tap prompt */
.tap-prompt {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px;
  padding: 14px 28px;
  background: var(--glass-bg);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--text-bright);
  font-family: var(--font-ui);
  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: rgba(229, 72, 30, 0.12); }
.tap-prompt:disabled {
  opacity: 0.35;
  pointer-events: none;
  animation: none;
}

.loading-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.75;
}

/* SCANNING overlay */
#scanning-overlay {
  background: rgba(18, 18, 16, 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-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}
.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.85;
  transition: opacity 0.2s;
  font-family: var(--font-ui);
  min-height: 44px;
  padding: 8px 4px;
}
.no-card-link:active { opacity: 1; }

/* FAB */
#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;
  min-height: 48px;
  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-family: var(--font-ui);
  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 .cb { vertical-align: -0.06em; }

/* Status card */
#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-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: 0.02em;
}
.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-soft);
  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; }

/* Status controls */
.status-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.control-btn:active { transform: scale(0.92); }
.control-btn.muted {
  background: rgba(184, 56, 20, 0.18);
  border-color: rgba(184, 56, 20, 0.5);
  color: var(--accent-deep);
}

/* End button */
.end-btn {
  min-height: 44px;
  padding: 10px 24px;
  background: transparent;
  border: 1px solid var(--accent-deep);
  border-radius: 999px;
  color: var(--accent-deep);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  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(18, 18, 16, 0.72);
  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: 340px;
  width: 100%;
}
.ended-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 4px;
  letter-spacing: -0.005em;
}
.ended-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.ended-duration {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}
.ended-duration .duration-label {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.16em;
  margin-right: 6px;
}
.ended-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.ended-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.ended-action-btn:active { transform: scale(0.97); }
.ended-action-btn:hover { border-color: var(--accent); background: rgba(229, 72, 30, 0.08); }
.ended-action-btn .cb { flex-shrink: 0; }
.ended-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-height: 44px;
  padding: 12px 4px;
}
.ended-link:hover { color: var(--accent-soft); }

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

/* Portfolio showcase */
.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-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  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-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}
.portfolio-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ERROR overlay */
#error-overlay {
  background: rgba(18, 18, 16, 0.82);
  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-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-bright);
  margin-bottom: 6px;
}
.error-message {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.retry-btn {
  min-height: 44px;
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.retry-btn:active { background: rgba(229, 72, 30, 0.12); transform: scale(0.96); }
a.retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* CAMERA ERROR overlay — same treatment as the generic error overlay */
#camera-error-overlay {
  background: rgba(18, 18, 16, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
}

/* Desktop gate — QR handoff for non-touch, desktop-sized viewports */
.desktop-gate {
  z-index: 1000;
  background: rgba(18, 18, 16, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.desktop-gate-card {
  text-align: center;
  max-width: 340px;
}
.desktop-gate-qr {
  display: block;
  margin: 8px auto 12px;
  padding: 8px;
  background: #fff;
  border-radius: 12px;
}

/* Animations */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 30, 0.3); }
  50% { box-shadow: 0 0 20px 4px rgba(229, 72, 30, 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 */
.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(229, 72, 30, 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-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.open-toast-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.open-toast-dismiss {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  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: 6px;
  transition: color 0.2s, background 0.2s;
}
.open-toast-dismiss:active {
  color: var(--text-bright);
  background: rgba(244, 243, 238, 0.06);
}
