/* ============================================
   Aubrey West — Conversational Portfolio
   Layout: V6 Chat Interface
   Palette: V2 Warm Storyteller
   ============================================ */

/* --- Custom Properties --- */
:root {
  /* Warm palette */
  --cream: #faf9f6;
  --cream-dark: #f5f0ea;
  --terracotta: #c2410c;
  --terracotta-hover: #ea580c;
  --terracotta-bg: #fff7ed;
  --sage: #65a30d;
  --sage-hover: #84cc16;
  --sage-bg: #f7fee7;
  --text-primary: #292524;
  --text-secondary: #57534e;
  --warm-gray: #78716c;
  --warm-gray-dark: #44403c;
  --white: #ffffff;

  /* Chat-specific */
  --sidebar-bg: #44403c;
  --sidebar-text: rgba(255, 255, 255, 0.9);
  --sidebar-text-muted: rgba(255, 255, 255, 0.5);
  --bubble-aubrey-bg: linear-gradient(135deg, rgba(194, 65, 12, 0.06), rgba(101, 163, 13, 0.04));
  --bubble-aubrey-border: rgba(194, 65, 12, 0.15);
  --bubble-visitor-bg: #f5f0ea;
  --input-focus: rgba(194, 65, 12, 0.15);
  --border-subtle: rgba(120, 113, 108, 0.1);

  /* Typography */
  --font-heading: 'Lora', Georgia, serif;
  --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;

  /* Spacing & radius */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-bubble: 18px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(41, 37, 36, 0.06), 0 1px 2px rgba(41, 37, 36, 0.04);
  --shadow-md: 0 4px 12px rgba(41, 37, 36, 0.08), 0 2px 4px rgba(41, 37, 36, 0.04);
}


/* ============================================
   1. Reset & Base
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--cream);
  overflow: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ============================================
   2. Background Orbs
   ============================================ */

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--terracotta);
  top: -120px;
  right: -80px;
  animation: orbFloat 25s ease-in-out infinite;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--sage);
  bottom: -100px;
  left: -60px;
  animation: orbFloat 30s ease-in-out infinite 5s;
}

.orb-3 {
  width: 350px;
  height: 350px;
  background: var(--terracotta-hover);
  top: 40%;
  left: 30%;
  animation: orbFloat 22s ease-in-out infinite 8s;
}

.orb-4 {
  width: 300px;
  height: 300px;
  background: var(--sage-hover);
  bottom: 20%;
  right: 15%;
  animation: orbFloat 28s ease-in-out infinite 12s;
}

@keyframes orbFloat {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(30px, -20px) scale(1.05);
  }
  50% {
    transform: translate(-15px, 25px) scale(0.95);
  }
  75% {
    transform: translate(20px, 15px) scale(1.02);
  }
}


/* ============================================
   3. App Shell
   ============================================ */

.app-shell {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}


/* ============================================
   4. Sidebar
   ============================================ */

.sidebar {
  width: 320px;
  flex-shrink: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-header {
  padding: 24px 24px 0;
}

.sidebar-header h2 {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
}

/* Profile card */
.profile-card {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--terracotta), var(--sage));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.profile-info {
  min-width: 0;
}

.profile-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--white);
  line-height: 1.3;
}

.profile-title {
  font-size: 0.78rem;
  color: var(--sidebar-text-muted);
  line-height: 1.4;
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--sidebar-text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
  }
}

/* Sidebar sections */
.sidebar-section {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.stat-row span:first-child {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
}

.stat-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sidebar-text);
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  margin-bottom: 10px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--terracotta-bg);
  color: var(--terracotta);
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer p {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--sidebar-text-muted);
  line-height: 1.6;
}


/* ============================================
   5. Chat Area
   ============================================ */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(250, 249, 246, 0.85);
  flex-shrink: 0;
  z-index: 10;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: background 0.2s ease;
}

.hamburger-btn:hover {
  background: var(--border-subtle);
}

.hamburger-btn svg {
  width: 20px;
  height: 20px;
}

.chat-header-avatar {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--terracotta), var(--sage));
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-header-info h1 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-header-info p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--warm-gray);
  text-decoration: none;
  transition: color 0.2s ease;
}

.header-link:hover {
  color: var(--terracotta);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--warm-gray);
  transition: background 0.2s ease, color 0.2s ease;
}

.icon-btn:hover {
  background: var(--cream-dark);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}


/* ============================================
   6. Encryption Badge
   ============================================ */

.encryption-badge {
  text-align: center;
  padding: 14px 16px 6px;
  font-size: 0.68rem;
  color: var(--warm-gray);
  flex-shrink: 0;
}

.encryption-badge svg {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-right: 4px;
  opacity: 0.6;
}


/* ============================================
   7. Messages Container
   ============================================ */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 0 32px 24px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.messages::-webkit-scrollbar {
  width: 5px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(120, 113, 108, 0.2);
  border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 113, 108, 0.35);
}


/* ============================================
   8. Date Divider
   ============================================ */

.date-divider {
  text-align: center;
  padding: 20px 0 12px;
  font-size: 0.7rem;
  color: var(--warm-gray);
  font-weight: 500;
}


/* ============================================
   9. Message Rows & Bubbles
   ============================================ */

.message-row {
  display: flex;
  margin-bottom: 4px;
  animation: messageIn 0.4s ease both;
}

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

/* Visitor messages: right-aligned */
.message-row.visitor {
  justify-content: flex-end;
}

/* Aubrey messages: left-aligned */
.message-row.aubrey {
  justify-content: flex-start;
  gap: 10px;
}

/* Aubrey avatar in messages */
.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--terracotta), var(--sage));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 0.55rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}

/* Avatar placeholder for grouped messages (keeps alignment) */
.message-avatar-spacer {
  width: 28px;
  flex-shrink: 0;
}

/* Bubbles */
.bubble {
  max-width: 520px;
  padding: 12px 16px;
  line-height: 1.55;
  font-size: 0.88rem;
  position: relative;
}

.bubble p + p {
  margin-top: 8px;
}

/* Visitor bubble */
.visitor .bubble {
  background: var(--bubble-visitor-bg);
  color: var(--text-secondary);
  border-radius: var(--radius-bubble) var(--radius-bubble) 6px var(--radius-bubble);
}

/* Aubrey bubble */
.aubrey .bubble {
  background: var(--bubble-aubrey-bg);
  border: 1px solid var(--bubble-aubrey-border);
  color: var(--text-primary);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 6px;
}

/* Timestamps inside bubbles */
.bubble-time {
  display: block;
  font-size: 0.65rem;
  color: var(--warm-gray);
  margin-top: 6px;
  opacity: 0.7;
}

/* Bubble grouping: consecutive messages from same sender */
/* First in group (has avatar) */
.message-row.aubrey.group-first .bubble {
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 6px;
}

/* Middle of group */
.message-row.aubrey.group-middle .bubble {
  border-radius: 6px var(--radius-bubble) var(--radius-bubble) 6px;
}

/* Last in group */
.message-row.aubrey.group-last .bubble {
  border-radius: 6px var(--radius-bubble) var(--radius-bubble) var(--radius-bubble);
}

/* Visitor grouping */
.message-row.visitor.group-first .bubble {
  border-radius: var(--radius-bubble) var(--radius-bubble) 6px var(--radius-bubble);
}

.message-row.visitor.group-middle .bubble {
  border-radius: var(--radius-bubble) 6px 6px var(--radius-bubble);
}

.message-row.visitor.group-last .bubble {
  border-radius: var(--radius-bubble) 6px var(--radius-bubble) var(--radius-bubble);
}

/* Space between different senders */
.message-row + .message-row:not(.visitor) + .message-row.visitor,
.message-row.visitor + .message-row.aubrey {
  margin-top: 12px;
}


/* ============================================
   10. Typing Indicator
   ============================================ */

.typing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 4px;
  animation: messageIn 0.4s ease both;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 20px;
  background: var(--bubble-aubrey-bg);
  border: 1px solid var(--bubble-aubrey-border);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 6px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warm-gray);
  animation: dotBounce 1.4s ease-in-out infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.15s;
}

.dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dotBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}


/* ============================================
   11. Project Cards (inside bubbles)
   ============================================ */

.project-cards {
  display: flex;
  flex-direction: row;
  gap: 10px;
  margin-top: 10px;
}

.project-card {
  flex: 1;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(120, 113, 108, 0.04);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--bubble-aubrey-border);
}

.project-card-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.project-card-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.project-card-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 500;
  background: var(--terracotta-bg);
  color: var(--terracotta);
}


/* ============================================
   12. Testimonial (inside bubbles)
   ============================================ */

.testimonial {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(120, 113, 108, 0.03);
  border-left: 3px solid var(--terracotta);
  margin-top: 10px;
}

.testimonial-text {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.testimonial-author {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--warm-gray);
  margin-top: 8px;
}


/* ============================================
   13. Contact Actions (inside bubbles)
   ============================================ */

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.contact-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.contact-btn:active {
  transform: translateY(0);
}

.contact-btn svg {
  width: 14px;
  height: 14px;
}

/* Primary: terracotta gradient */
.contact-btn.primary {
  background: linear-gradient(135deg, var(--terracotta), var(--terracotta-hover));
  color: var(--white);
}

.contact-btn.primary:hover {
  opacity: 0.9;
}

/* Secondary: sage tint */
.contact-btn.secondary {
  background: var(--sage-bg);
  color: var(--sage);
}

.contact-btn.secondary:hover {
  background: rgba(101, 163, 13, 0.15);
}

/* Tertiary: subtle border */
.contact-btn.tertiary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.contact-btn.tertiary:hover {
  border-color: rgba(120, 113, 108, 0.25);
  background: rgba(120, 113, 108, 0.03);
}


/* ============================================
   14. Input Bar
   ============================================ */

.input-bar {
  padding: 16px 32px 24px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  background: rgba(250, 249, 246, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 20px;
  border-radius: 28px;
  background: var(--cream-dark);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--input-focus);
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.4;
  padding: 8px 0;
}

#messageInput::placeholder {
  color: var(--warm-gray);
  opacity: 0.6;
}

#messageInput:disabled {
  cursor: default;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--terracotta), var(--sage));
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.25);
}

.send-btn:active {
  transform: scale(0.97);
}

.send-btn svg {
  width: 18px;
  height: 18px;
}


/* ============================================
   15. System Message
   ============================================ */

.system-message {
  text-align: center;
  font-size: 0.72rem;
  color: var(--warm-gray);
  padding: 12px 0;
  font-style: italic;
}


/* ============================================
   16. Streaming Text (cursor blink)
   ============================================ */

.bubble.streaming::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--terracotta);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s steps(2) infinite;
}

@keyframes cursorBlink {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}


/* ============================================
   17. Mobile Overlay
   ============================================ */

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(41, 37, 36, 0.5);
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.mobile-overlay.show {
  display: block;
  opacity: 1;
}


/* ============================================
   18. Responsive: max-width 768px
   ============================================ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    height: 100vh;
    transition: left 0.3s ease;
    z-index: 25;
  }

  .sidebar.open {
    left: 0;
  }

  .hamburger-btn {
    display: flex;
  }

  .chat-header-avatar.mobile-only {
    display: flex;
  }

  .messages {
    padding: 0 16px 20px;
  }

  .bubble {
    max-width: 85vw;
  }

  .project-cards {
    flex-direction: column;
  }

  .contact-actions {
    flex-direction: column;
  }

  .contact-btn {
    justify-content: center;
  }

  .input-bar {
    padding: 12px 16px 20px;
  }

  .chat-header {
    padding: 14px 16px;
  }

  .encryption-badge {
    padding: 10px 16px 4px;
  }
}


/* ============================================
   19. Responsive: max-width 480px
   ============================================ */

@media (max-width: 480px) {
  body {
    font-size: 0.85rem;
  }

  .chat-header-info h1 {
    font-size: 0.9rem;
  }

  .chat-header-info p {
    font-size: 0.68rem;
  }

  .bubble {
    font-size: 0.84rem;
    padding: 10px 14px;
  }

  #messageInput {
    font-size: 0.84rem;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }

  .input-wrapper {
    padding: 4px 4px 4px 16px;
  }

  .message-avatar {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 0.5rem;
  }

  .message-avatar-spacer {
    width: 24px;
  }

  .project-card {
    padding: 10px 12px;
  }
}


/* ============================================
   20. Selection Color
   ============================================ */

::selection {
  background: rgba(194, 65, 12, 0.2);
  color: var(--text-primary);
}

::-moz-selection {
  background: rgba(194, 65, 12, 0.2);
  color: var(--text-primary);
}


/* ============================================
   21. Utility: Hidden
   ============================================ */

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 8px 16px;
  background: var(--terracotta);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 16px;
}

/* Error bubble */
.error-bubble {
  background: rgba(220, 38, 38, 0.06) !important;
  border-color: rgba(220, 38, 38, 0.15) !important;
  color: #991b1b !important;
}

/* Status indicator in sidebar */
.status-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s ease-in-out infinite;
}

.hidden {
  display: none !important;
}
