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

:root {
  --color-bg: #faf6f1;
  --color-surface: #fff8f2;
  --color-text: #3b2f2f;
  --color-text-muted: #8b7355;
  --color-accent: #e8854a;
  --color-accent-hover: #d4713a;
  --color-border: #e6d5c3;
  --color-nav-bg: #3b2f2f;
  --color-nav-text: #c9b9a8;
  --color-nav-active: #fff8f2;
  --max-width: 1400px;
  --radius: 8px;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Header ──────────────────────────────────── */
header {
  background: var(--color-nav-bg);
  color: #fff;
  padding: 2.5rem 1.5rem 1.5rem 3rem;
}

.header-inner {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.headshot {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-title a {
  color: #fff;
  text-decoration: none;
}

.site-subtitle {
  color: var(--color-nav-text);
  font-size: 1rem;
  margin-top: 0.25rem;
}

.header-socials {
  margin-left: auto;
  margin-right: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.header-socials a {
  color: var(--color-nav-text);
  transition: color 0.15s;
  display: flex;
}

.header-socials a:hover {
  color: #fff;
  text-decoration: none;
}

/* ── Navigation ──────────────────────────────── */
nav {
  background: var(--color-nav-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0;
  padding-left: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

nav a {
  color: var(--color-nav-text);
  text-decoration: none;
  padding: 0.75rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  border-bottom: 6px solid transparent;
}

nav a:hover {
  color: var(--color-nav-active);
  text-decoration: none;
}

nav a.active {
  color: var(--color-nav-active);
  border-bottom-color: var(--color-accent);
}

/* ── Main ────────────────────────────────────── */
main {
  flex: 1;
  max-width: var(--max-width);
  min-width: 0;
  padding: 2.5rem 1.5rem 2.5rem 3rem;
}

/* ── Chat Toggle ─────────────────────────────── */
.chat-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateX(-100%) translateY(-50%);
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.75rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius) 0 0 var(--radius);
  writing-mode: vertical-lr;
  font-family: inherit;
  letter-spacing: 0.05em;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  transition: background 0.15s;
}

.chat-toggle:hover {
  background: var(--color-accent-hover);
}

/* ── Chat Sidebar (Drawer) ───────────────────── */
.chat-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 350px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 200;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.chat-sidebar.open {
  transform: translateX(0);
}

/* ── Chat Close Button ───────────────────────── */
.chat-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.chat-close:hover {
  color: var(--color-text);
  background: var(--color-border);
}

.chat-sidebar h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.page-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.page-section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.page-section p {
  margin-bottom: 1rem;
  color: var(--color-text);
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 6px solid transparent;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: border-left-color 0.15s;
}

.card:hover {
  border-left-color: var(--color-accent);
}

.card h3 {
  margin-top: 0;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.projects-grid .card {
  margin-bottom: 0;
}

.project-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

/* ── CV ──────────────────────────────────────── */
.cv-list {
  list-style: none;
  padding: 0;
}

.cv-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.cv-list li:last-child {
  border-bottom: none;
}

.cv-date {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.cv-list p {
  margin-top: 0.35rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ── Contact ─────────────────────────────────── */
.contact-list {
  list-style: none;
  padding: 0;
}

.contact-list li {
  padding: 0.5rem 0;
}

/* ── Agent Chat ──────────────────────────────── */
.agent-chat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-window {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.chat-message {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  max-width: 80%;
  font-size: 0.95rem;
  line-height: 1.5;
}

.chat-message.agent {
  background: #f0e6d8;
  color: var(--color-text);
}

.chat-message.user {
  background: var(--color-accent);
  color: #fff;
  margin-left: auto;
}

.chat-input-form {
  display: flex;
  border-top: 1px solid var(--color-border);
}

.chat-input-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
}

.chat-input-form button {
  padding: 0.75rem 1.5rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.chat-input-form button:hover {
  background: var(--color-accent-hover);
}

.muted {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ── Typing Indicator ───────────────────────── */
.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--color-text-muted);
  border-radius: 50%;
  margin-right: 4px;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
  margin-right: 0;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Disabled Chat Form ─────────────────────── */
.chat-input-form.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.chat-input-form input:disabled {
  background: var(--color-bg);
}

.chat-input-form button:disabled {
  cursor: not-allowed;
  background: var(--color-text-muted);
}

/* ── Footer ──────────────────────────────────── */
footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  header {
    padding: 1.5rem 1rem 1rem;
  }

  .nav-inner {
    gap: 0;
  }

  nav a {
    padding: 0.6rem 0.65rem;
    font-size: 0.8rem;
  }

  main {
    padding: 1.5rem 1rem;
  }

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

  .chat-sidebar {
    width: 100vw;
  }
}
