/* ask-james.css — styles for the Ask James bot page */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'General Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Light Mode (Canary Islands warmth) ─────────────────────── */
:root, [data-theme="light"] {
  --color-bg:             #faf8f4;
  --color-surface:        #ffffff;
  --color-surface-2:      #f5f2ec;
  --color-border:         #e2ddd5;
  --color-border-light:   #ece8e1;

  --color-text:           #1a1814;
  --color-text-muted:     #6b6560;
  --color-text-faint:     #a09a94;

  --color-primary:        #c26a2f;
  --color-primary-hover:  #a85824;
  --color-primary-soft:   #fdf0e6;
  --color-primary-muted:  #e8c9ad;

  --color-accent:         #2a7c6f;
  --color-accent-soft:    #e6f3f0;

  --color-bot-bg:         #ffffff;
  --color-user-bg:        #1a1814;
  --color-user-text:      #faf8f4;

  --shadow-sm: 0 1px 2px rgba(26,24,20,0.05);
  --shadow-md: 0 4px 12px rgba(26,24,20,0.08);
  --shadow-lg: 0 8px 24px rgba(26,24,20,0.1);
}

/* ── Dark Mode ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:             #121110;
  --color-surface:        #1a1918;
  --color-surface-2:      #222120;
  --color-border:         #333231;
  --color-border-light:   #2a2928;

  --color-text:           #e8e4de;
  --color-text-muted:     #8a847e;
  --color-text-faint:     #5a5550;

  --color-primary:        #d4884e;
  --color-primary-hover:  #e09a60;
  --color-primary-soft:   #2a2018;
  --color-primary-muted:  #5a4430;

  --color-accent:         #5ab5a4;
  --color-accent-soft:    #1a2a26;

  --color-bot-bg:         #1a1918;
  --color-user-bg:        #c26a2f;
  --color-user-text:      #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #121110;
    --color-surface:        #1a1918;
    --color-surface-2:      #222120;
    --color-border:         #333231;
    --color-border-light:   #2a2928;
    --color-text:           #e8e4de;
    --color-text-muted:     #8a847e;
    --color-text-faint:     #5a5550;
    --color-primary:        #d4884e;
    --color-primary-hover:  #e09a60;
    --color-primary-soft:   #2a2018;
    --color-primary-muted:  #5a4430;
    --color-accent:         #5ab5a4;
    --color-accent-soft:    #1a2a26;
    --color-bot-bg:         #1a1918;
    --color-user-bg:        #c26a2f;
    --color-user-text:      #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  }
}

/* ── App Layout ─────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--color-bg);
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.logo-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.logo-dot {
  color: var(--color-primary);
}

@media (max-width: 480px) {
  .back-link { display: none; }
}

.back-link {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: 500;
  border: 1px solid var(--color-border);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

.back-link:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.theme-toggle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* ── Chat Area ──────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

/* ── Welcome Screen ─────────────────────────────────────────── */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: var(--space-8) var(--space-4);
}

.welcome.hidden {
  display: none;
}

.welcome-inner {
  text-align: center;
  max-width: 480px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.1;
  margin-bottom: var(--space-2);
}

.welcome-title .accent {
  color: var(--color-primary);
  font-style: italic;
}

.welcome-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  font-weight: 400;
  margin-bottom: var(--space-4);
}

.welcome-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.stat-num {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-primary);
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ── Suggestion Chips ───────────────────────────────────────── */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  padding: 0 var(--space-2) var(--space-4);
  transition: opacity 200ms ease;
}

.suggestions.hidden {
  display: none;
}

/* In-welcome suggestions (initial) */
.welcome .suggestions {
  padding: 0;
  margin-bottom: 0;
}

/* Post-response suggestions (bottom of messages) */
.suggestions--followup {
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.suggestion {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.suggestion:hover {
  border-color: var(--color-primary-muted);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.suggestion:active {
  transform: scale(0.97);
}

/* ── Messages ───────────────────────────────────────────────── */
.messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  padding-bottom: var(--space-6);
}

.message {
  display: flex;
  gap: var(--space-3);
  max-width: 85%;
  animation: msgIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  align-self: flex-end;
}

.message.bot .message-avatar {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.message.user .message-avatar {
  background: var(--color-user-bg);
  color: var(--color-user-text);
  font-size: 12px;
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2xl);
  line-height: 1.55;
  font-size: var(--text-sm);
  word-break: break-word;
}

.message.bot .message-bubble {
  background: var(--color-bot-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border-light);
  border-bottom-left-radius: var(--radius-sm);
}

.message.user .message-bubble {
  background: var(--color-user-bg);
  color: var(--color-user-text);
  border-bottom-right-radius: var(--radius-sm);
}

/* Markdown in bot messages */
.message.bot .message-bubble strong {
  font-weight: 600;
  color: var(--color-text);
}

.message.bot .message-bubble a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message.bot .message-bubble a:hover {
  color: var(--color-primary-hover);
}

.message.bot .message-bubble p {
  margin-bottom: var(--space-2);
  max-width: none;
}

.message.bot .message-bubble p:last-child {
  margin-bottom: 0;
}

.message.bot .message-bubble ul,
.message.bot .message-bubble ol {
  padding-left: var(--space-4);
  margin-bottom: var(--space-2);
}

.message.bot .message-bubble li {
  margin-bottom: var(--space-1);
  max-width: none;
}

.message.bot .message-bubble h2,
.message.bot .message-bubble h3 {
  margin-bottom: var(--space-2);
  margin-top: var(--space-3);
  font-weight: 600;
  color: var(--color-text);
}

.message.bot .message-bubble hr {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-3) 0;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  align-items: center;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-faint);
  animation: typing 1.4s ease-in-out infinite;
}

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

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Input Area ─────────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-surface);
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.input-inner {
  max-width: 720px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}

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

.input-wrapper textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: var(--text-sm);
  line-height: 1.5;
  padding: var(--space-1) 0;
  min-height: 24px;
  max-height: 120px;
  color: var(--color-text);
}

.input-wrapper textarea::placeholder {
  color: var(--color-text-faint);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-lg);
  background: var(--color-primary);
  color: white;
  flex-shrink: 0;
  transition: background var(--transition-interactive), transform var(--transition-interactive), opacity var(--transition-interactive);
}

.send-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: scale(1.04);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.input-hint {
  font-size: 11px;
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-2);
  max-width: none;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .app {
    border-left: 1px solid var(--color-border-light);
    border-right: 1px solid var(--color-border-light);
  }

  .header-inner {
    padding: var(--space-3) var(--space-6);
  }
  
  .messages {
    padding: var(--space-6);
    padding-bottom: var(--space-8);
  }

  .input-area {
    padding: var(--space-4) var(--space-6) var(--space-5);
  }
}

/* ── Scrollbar ──────────────────────────────────────────────── */
.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-faint);
}
