/* ============================================================
   WILL JEDRZEJCZAK — CHATBOT PORTFOLIO
   Claude-inspired design system
   ============================================================ */

/* ── VARIABLES ──────────────────────────────────────────────── */
:root {
  /* Light theme (default) */
  --bg:            #faf9f7;
  --sidebar-bg:    #f0ede8;
  --sidebar-hover: #e5e1da;
  --sidebar-active:#ddd8cf;
  --border:        #ddd8cf;
  --text:          #1a1917;
  --text-2:        #6b6760;
  --text-3:        #9c9891;
  --accent:        #d97757;
  --accent-hover:  #c96848;
  --accent-faint:  #fdf1ec;
  --user-bg:       #eceae4;
  --input-bg:      #ffffff;
  --input-border:  #d5d1c8;
  --card-hover:    #f5f2ec;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-input:  0 0 0 1px var(--input-border), 0 2px 8px rgba(0,0,0,.06);
  --shadow-focus:  0 0 0 2px rgba(217,119,87,.35);
  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --sidebar-w:     260px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg:            #1c1917;
  --sidebar-bg:    #111110;
  --sidebar-hover: #27251f;
  --sidebar-active:#322f28;
  --border:        #2d2b25;
  --text:          #e8e2d8;
  --text-2:        #9c9488;
  --text-3:        #6b6356;
  --accent:        #d97757;
  --accent-hover:  #e88464;
  --accent-faint:  #2a1c14;
  --user-bg:       #2a2722;
  --input-bg:      #25221d;
  --input-border:  #3d3a32;
  --card-hover:    #221f1a;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow-input:  0 0 0 1px var(--input-border), 0 2px 8px rgba(0,0,0,.3);
  --shadow-focus:  0 0 0 2px rgba(217,119,87,.4);
}

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

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── APP LAYOUT ─────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: transform 0.25s ease;
  z-index: 200;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px 6px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--sidebar-active);
  color: var(--text);
  font-weight: 500;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-social {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}

.sidebar-social:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

/* ── ICON BUTTONS ───────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

/* Theme toggle visibility */
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"]  .sun-icon  { display: none; }

/* ── MOBILE SIDEBAR OVERLAY ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.25s;
}

.sidebar-overlay.show {
  opacity: 1;
}

/* ── MAIN AREA ──────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ── MOBILE HEADER ──────────────────────────────────────────── */
.mobile-hdr {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.mobile-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── CHAT MODE TOGGLE ───────────────────────────────────────── */
/* Welcome shown by default, messages hidden.                    */
/* .chat-mode swaps them.                                        */
.main .welcome   { display: flex; }
.main .messages  { display: none; }
.main.chat-mode .welcome  { display: none; }
.main.chat-mode .messages { display: block; }

/* ── WELCOME SCREEN ─────────────────────────────────────────── */
.welcome {
  flex: 1;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.welcome-inner {
  max-width: 680px;
  width: 100%;
  text-align: center;
}

.will-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 20px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  border: 3px solid var(--border);
}

.will-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.will-avatar.avatar-fallback::after {
  content: 'W';
}

.welcome-h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  line-height: 1.2;
}

.welcome-tagline {
  font-size: 14px;
  color: var(--text-2);
  font-weight: 450;
  margin-bottom: 10px;
}

.welcome-desc {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 28px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

/* Prompt card grid */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  text-align: left;
}

.prompt-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  font-family: var(--font);
}

.prompt-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.prompt-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.35;
}

.prompt-card-desc {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.4;
}

/* ── MESSAGES ───────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px 10px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Message row */
.msg {
  display: flex;
  max-width: 760px;
  margin: 0 auto 24px;
  animation: msgIn 0.18s ease;
}

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

/* User message */
.msg-user {
  justify-content: flex-end;
}

.msg-bubble {
  background: var(--user-bg);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.55;
  max-width: 75%;
  word-break: break-word;
}

/* Bot message */
.msg-bot {
  align-items: flex-start;
  gap: 12px;
}

.bot-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}
.bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.msg-body {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  padding-top: 2px;
}

/* ── MESSAGE MARKDOWN STYLES ────────────────────────────────── */
/* Serif font for bot response text — matches Claude's Copernicus feel */
.msg-content {
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  font-size: 15.5px;
  line-height: 1.75;
}

.msg-content p {
  margin-bottom: 0.85em;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content strong {
  font-weight: 620;
  color: var(--text);
}

.msg-content em {
  font-style: italic;
  color: var(--text-2);
  font-size: 13.5px;
}

.msg-content .mh {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  margin: 1.3em 0 0.45em;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.msg-content .mh:first-child {
  margin-top: 0;
}

.msg-content .mh4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0.9em 0 0.3em;
}

.msg-content .mhr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.1em 0;
}

.msg-content .mul {
  margin: 0.4em 0 0.9em 1.1em;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-content .mul li {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  padding-left: 2px;
}

.msg-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-content a:hover {
  color: var(--accent-hover);
}

/* ── INTRO OVERLAY ───────────────────────────────────────────── */
#intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}
#intro.fade-out {
  opacity: 0;
  pointer-events: none;
}
#intro-text {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  text-align: center;
  padding: 0 1.5rem;
}
.intro-line {
  font-family: 'Lora', Georgia, serif;
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  font-weight: 400;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.intro-line:first-child {
  font-size: clamp(1.25rem, 2.8vw, 1.9rem);
  font-weight: 500;
  color: var(--text-1);
}
.intro-line::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 3px;
  vertical-align: text-bottom;
  animation: blink 1.1s ease-in-out infinite;
}
.intro-line.done::after {
  display: none;
}

/* ── BLOCK STREAM ANIMATION ─────────────────────────────────── */
/* Each block (p, h3, hr, ul) fades + slides in sequentially.   */
/* This avoids blank-line artifacts from invisible text nodes.   */
@keyframes blockIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Blinking cursor */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1.1s ease-in-out infinite;
  border-radius: 1px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  45%, 55% { opacity: 0; }
}

/* ── EVENT IMAGES ────────────────────────────────────────────── */
figure.event-img {
  margin: 6px 0 2px;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 480px;
}
figure.event-img img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
}

/* ── THINKING INDICATOR ─────────────────────────────────────── */
.thinking-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 0;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 60%, 100% { transform: scale(0.65); opacity: 0.3; }
  30%            { transform: scale(1);   opacity: 1; }
}

/* ── INPUT AREA ─────────────────────────────────────────────── */
.input-area {
  padding: 0 20px 16px;
  flex-shrink: 0;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Suggestion chips */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.suggestion-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 20px;
  padding: 5px 13px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 450;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  line-height: 1.4;
}

.suggestion-chip:hover {
  background: var(--accent-faint);
  border-color: var(--accent);
  color: var(--accent);
}

/* Input box */
.input-box {
  display: flex;
  align-items: flex-end;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-input);
  padding: 10px 10px 10px 16px;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  resize: none;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.input-box textarea::placeholder {
  color: var(--text-3);
}

/* Send button */
.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, opacity 0.12s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  background: var(--border);
  color: var(--text-3);
  cursor: not-allowed;
}

/* Stop button */
.stop-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.stop-btn:hover {
  background: var(--border);
  color: var(--text-1);
}

/* Disclaimer */
.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.4;
}

/* ── RESPONSIVE — MOBILE ────────────────────────────────────── */
@media (max-width: 680px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.show {
    pointer-events: auto;
  }

  .mobile-hdr {
    display: flex;
  }

  /* Bigger tap targets on mobile */
  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .nav-btn {
    padding: 10px 10px;
    font-size: 14px;
  }

  .welcome {
    padding: 24px 16px;
    align-items: flex-start;
  }

  .welcome-inner {
    text-align: left;
  }

  .will-avatar {
    margin: 0 0 16px 0;
  }

  .welcome-h1 {
    font-size: 24px;
  }

  .welcome-desc {
    margin-left: 0;
    margin-right: 0;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .messages {
    padding: 16px 14px 8px;
  }

  .msg-bubble {
    max-width: 92%;
  }

  /* Safe area inset for iPhone home bar */
  .input-area {
    padding: 0 12px calc(14px + env(safe-area-inset-bottom));
  }

  .suggestion-chip {
    font-size: 12px;
    padding: 6px 12px;
  }

  /* Slightly larger send/stop buttons for touch */
  .send-btn, .stop-btn {
    width: 38px;
    height: 38px;
  }

  /* Event images full width on mobile */
  figure.event-img {
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .welcome-h1 { font-size: 22px; }
  .prompt-card { padding: 12px 14px; }
  .msg-content { font-size: 15px; }
}

/* ── GLOBAL SCROLLBAR (webkit) ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── SELECTION ──────────────────────────────────────────────── */
::selection {
  background: rgba(217, 119, 87, 0.2);
  color: var(--text);
}

/* ── FOCUS VISIBLE ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
