/* ── Mini Ethan chat ──────────────────────────────────────────────────
   Matches the site: Poppins body / Jost headings, #1665c0 accent,
   square corners, hairline borders, dark #09090b bar like the footer. */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 100; font-display: swap; src: url('../fonts/poppins/poppins-100-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 100; font-display: swap; src: url('../fonts/poppins/poppins-100-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/poppins/poppins-300-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/poppins/poppins-300-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/poppins/poppins-400.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/jost/jost-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Jost'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/jost/jost-500-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

#portfolio-chat-root {
  --chat-accent: #1665c0;
  --chat-accent-strong: #0f4f99;
  --chat-link: #1665c0;
  --chat-bar: #09090b;
  --chat-surface: #ffffff;
  --chat-bubble: #f4f4f5;
  --chat-ink: #18181b;
  --chat-muted: #71717a;
  --chat-line: #e4e4e7;
  --chat-line-strong: #d4d4d8;
  --chat-shadow: 0 24px 60px rgba(9, 9, 11, 0.18), 0 2px 8px rgba(9, 9, 11, 0.06);
  --chat-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --chat-launcher-size: clamp(48px, calc(42px + 2vw), 64px);
  color: var(--chat-ink);
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  font-weight: 300;
  line-height: 1.5;
  position: relative;
  z-index: 2147483000;
}

.colorscheme-dark #portfolio-chat-root {
  --chat-link: #5b9be6;
  --chat-surface: #18181b;
  --chat-bubble: #27272a;
  --chat-ink: #f4f4f5;
  --chat-muted: #a1a1aa;
  --chat-line: #27272a;
  --chat-line-strong: #3f3f46;
  --chat-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

#portfolio-chat-root *,
#portfolio-chat-root *::before,
#portfolio-chat-root *::after {
  box-sizing: border-box;
}

/* Keep the back-to-top button stacked above the launcher. */
.back-to-top {
  right: calc(max(20px, env(safe-area-inset-right)) + 6px);
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + clamp(48px, calc(42px + 2vw), 64px) + 12px);
}

/* ── Launcher ── */
.portfolio-chat-launcher {
  align-items: center;
  background: transparent;
  border: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 0;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  z-index: 2147483000;
}

.portfolio-chat-launcher__avatar {
  background: #fff;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(22, 101, 192, 0.18);
  display: block;
  flex: none;
  height: var(--chat-launcher-size);
  position: relative;
  transition: transform 220ms var(--chat-ease-out);
  width: var(--chat-launcher-size);
}

.portfolio-chat-launcher__avatar img {
  border: 0;
  display: block;
  height: 100%;
  margin: 0;
  padding: 5px;
  transform-origin: 50% 85%;
  transition: transform 260ms var(--chat-ease-out);
  width: 100%;
}

/* A streak of light that keeps circling the avatar to invite a click */
.portfolio-chat-launcher__avatar::before {
  animation: portfolio-chat-spin 1.4s linear infinite;
  background: conic-gradient(
    from 0deg,
    transparent 0turn,
    transparent 0.45turn,
    rgba(66, 165, 245, 0.25) 0.65turn,
    #42a5f5 0.88turn,
    #e3f2fd 0.97turn,
    transparent 1turn
  );
  border-radius: 50%;
  content: "";
  filter: drop-shadow(0 0 4px rgba(66, 165, 245, 0.85));
  inset: -4px;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  pointer-events: none;
  position: absolute;
}

/* Green "new message" dot */
.portfolio-chat-launcher__avatar::after {
  animation: portfolio-chat-ping 2s ease-out infinite;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
  bottom: 0;
  content: "";
  height: clamp(12px, calc(10px + 0.4vw), 15px);
  position: absolute;
  right: 0;
  width: clamp(12px, calc(10px + 0.4vw), 15px);
}

.portfolio-chat-launcher__label {
  background: var(--chat-bar);
  color: #fff;
  font-family: "Jost", "Poppins", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0;
  padding: 7px 11px;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 150ms ease, transform 220ms var(--chat-ease-out);
  white-space: nowrap;
}

.portfolio-chat-launcher:hover .portfolio-chat-launcher__label,
.portfolio-chat-launcher:focus-visible .portfolio-chat-launcher__label {
  opacity: 1;
  transform: translateX(0);
}

.portfolio-chat-launcher:hover .portfolio-chat-launcher__avatar img,
.portfolio-chat-launcher:focus-visible .portfolio-chat-launcher__avatar img {
  transform: rotate(-8deg) scale(1.06);
}

.portfolio-chat-launcher:active .portfolio-chat-launcher__avatar {
  transform: scale(0.94);
}

.portfolio-chat-launcher:focus-visible {
  outline: none;
}

.portfolio-chat-launcher:focus-visible .portfolio-chat-launcher__avatar {
  outline: 2px solid #42a5f5;
  outline-offset: 3px;
}

/* Loading state while the chat bundle downloads */
.portfolio-chat-launcher:disabled {
  cursor: wait;
}

.portfolio-chat-launcher:disabled .portfolio-chat-launcher__avatar::before {
  animation-duration: 500ms;
}

.portfolio-chat-launcher[data-state="error"] .portfolio-chat-launcher__label {
  opacity: 1;
  transform: none;
}

/* ── Panel ── */
.portfolio-chat-panel {
  background: var(--chat-surface);
  border: 1px solid var(--chat-line-strong);
  bottom: max(20px, env(safe-area-inset-bottom));
  box-shadow: var(--chat-shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(560px, calc(100dvh - 40px));
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  transform-origin: right bottom;
  width: min(380px, calc(100vw - 40px));
  z-index: 2147483000;
}

.portfolio-chat-panel[data-entering="true"] {
  animation: portfolio-chat-enter 280ms var(--chat-ease-out) both;
}

.portfolio-chat-panel button:focus-visible,
.portfolio-chat-panel textarea:focus-visible,
.portfolio-chat-panel a:focus-visible {
  outline: 2px solid #42a5f5;
  outline-offset: 2px;
}

/* ── Header ── */
.portfolio-chat-header {
  align-items: center;
  background: var(--chat-bar);
  color: #fff;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 12px 14px;
  position: relative;
}

.portfolio-chat-header h2 {
  padding-right: 72px;
}

.portfolio-chat-header__avatar {
  background: #fff;
  border-radius: 50%;
  display: block;
  flex: none;
  height: 40px;
  padding: 3px;
  width: 40px;
}

.portfolio-chat-header__avatar img {
  border: 0;
  display: block;
  height: 100%;
  margin: 0;
  width: 100%;
}

.portfolio-chat-header h2 {
  color: #fff;
  font-family: "Jost", "Poppins", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0;
}

.portfolio-chat-header__sub {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 4px;
  white-space: nowrap;
}

.portfolio-chat-chip__button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0;
  color: #fff;
  cursor: help;
  font-family: "Poppins", system-ui, sans-serif;
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 4px 6px 3px;
  text-transform: uppercase;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.portfolio-chat-chip--beta .portfolio-chat-chip__button {
  background: var(--chat-accent);
  border-color: var(--chat-accent);
}

.portfolio-chat-chip--caution .portfolio-chat-chip__button:hover,
.portfolio-chat-chip--caution .portfolio-chat-chip__button:focus-visible {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.portfolio-chat-chip--beta .portfolio-chat-chip__button:hover,
.portfolio-chat-chip--beta .portfolio-chat-chip__button:focus-visible {
  background: var(--chat-accent-strong);
  border-color: var(--chat-accent-strong);
}

/* Tooltip spans the panel width just under the header so it never clips. */
.portfolio-chat-chip__tip {
  background: var(--chat-bar);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 32px rgba(9, 9, 11, 0.28);
  color: rgba(255, 255, 255, 0.86);
  display: block;
  font-size: 12.5px;
  font-weight: 300;
  left: 12px;
  line-height: 1.5;
  opacity: 0;
  padding: 11px 13px 12px;
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: calc(100% + 6px);
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 200ms var(--chat-ease-out), visibility 0s linear 150ms;
  visibility: hidden;
  white-space: normal;
  z-index: 3;
}

.portfolio-chat-chip__tip-title {
  color: #fff;
  display: block;
  font-family: "Jost", "Poppins", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 3px;
}

.portfolio-chat-chip--beta .portfolio-chat-chip__tip-title {
  color: #5b9be6;
}

.colorscheme-dark .portfolio-chat-chip__tip {
  background: #27272a;
  border-color: #3f3f46;
}

.portfolio-chat-chip:hover .portfolio-chat-chip__tip,
.portfolio-chat-chip:focus-within .portfolio-chat-chip__tip {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 150ms ease, transform 200ms var(--chat-ease-out), visibility 0s;
  visibility: visible;
}

.portfolio-chat-header__actions {
  display: flex;
  gap: 2px;
  position: absolute;
  right: 8px;
  top: 8px;
}

.portfolio-chat-icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  transition: color 150ms ease, background-color 150ms ease;
  width: 32px;
}

.portfolio-chat-icon-button svg {
  height: 16px;
  width: 16px;
}

.portfolio-chat-icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── Messages ── */
.portfolio-chat-messages {
  background: var(--chat-surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  scrollbar-color: var(--chat-line-strong) transparent;
  scrollbar-width: thin;
}

.portfolio-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.portfolio-chat-message--assistant {
  align-self: flex-start;
}

.portfolio-chat-message--user {
  align-self: flex-end;
}

.portfolio-chat-message__label {
  color: var(--chat-muted);
  font-family: "Jost", "Poppins", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}

.portfolio-chat-message--user .portfolio-chat-message__label {
  text-align: right;
}

.portfolio-chat-message__bubble {
  background: var(--chat-bubble);
  color: var(--chat-ink);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.portfolio-chat-message__bubble strong {
  font-weight: 400;
}

.portfolio-chat-message--user .portfolio-chat-message__bubble {
  background: var(--chat-accent);
  color: #fff;
}

.portfolio-chat-message--error .portfolio-chat-message__bubble {
  border-left: 2px solid #b42318;
  color: #b42318;
}

.colorscheme-dark .portfolio-chat-message--error .portfolio-chat-message__bubble {
  color: #f97066;
}

.portfolio-chat-cursor {
  animation: portfolio-chat-blink 900ms steps(1, end) infinite;
  background: var(--chat-accent);
  display: inline-block;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.13em;
  width: 2px;
}

.portfolio-chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
}

.portfolio-chat-sources a {
  border: 0;
  color: var(--chat-link);
  font-size: 11.5px;
  font-weight: 400;
  text-decoration: none;
}

.portfolio-chat-sources a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.portfolio-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portfolio-chat-suggestions__label {
  color: var(--chat-muted);
  font-family: "Jost", "Poppins", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin: 2px 0 0;
}

.portfolio-chat-suggestion {
  align-items: center;
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--chat-line-strong);
  border-radius: 999px;
  color: var(--chat-ink);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 12.5px;
  gap: 8px;
  line-height: 1.4;
  padding: 7px 14px 7px 12px;
  text-align: left;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.portfolio-chat-suggestion__icon {
  color: var(--chat-muted);
  flex: none;
  height: 14px;
  transition: color 150ms ease;
  width: 14px;
}

.portfolio-chat-suggestion:hover .portfolio-chat-suggestion__icon {
  color: var(--chat-link);
}

.portfolio-chat-suggestion:hover {
  border-color: var(--chat-accent);
  color: var(--chat-link);
}

.portfolio-chat-suggestion:active {
  transform: scale(0.98);
}

/* ── Composer ── */
.portfolio-chat-composer {
  background: var(--chat-surface);
  border-top: 1px solid var(--chat-line);
  padding: 10px 12px 12px;
}

.portfolio-chat-composer__row {
  align-items: flex-end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.portfolio-chat-composer textarea {
  background: var(--chat-bubble);
  border: 1px solid transparent;
  border-radius: 0;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  margin: 0;
  max-height: 116px;
  min-height: 42px;
  padding: 10px 11px;
  resize: none;
  transition: border-color 150ms ease;
  width: 100%;
}

.portfolio-chat-composer textarea:focus {
  border-color: var(--chat-accent);
  outline: none;
}

.portfolio-chat-composer textarea::placeholder {
  color: var(--chat-muted);
}

.portfolio-chat-send {
  align-items: center;
  background: var(--chat-accent);
  border: 0;
  border-radius: 0;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  padding: 0;
  transition: background-color 150ms ease, opacity 150ms ease;
  width: 42px;
}

.portfolio-chat-send svg {
  height: 17px;
  width: 17px;
}

.portfolio-chat-send:hover:not(:disabled) {
  background: var(--chat-accent-strong);
}

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

.portfolio-chat-composer__meta {
  align-items: center;
  color: var(--chat-muted);
  display: flex;
  font-size: 10.5px;
  font-weight: 100;
  justify-content: space-between;
  margin: 5px 1px 0;
}

.portfolio-chat-conversation-limit {
  align-self: center;
  border: 1px solid var(--chat-line);
  color: var(--chat-muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin: 4px auto 2px;
  max-width: 88%;
  padding: 9px 11px;
  text-align: center;
}

@keyframes portfolio-chat-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes portfolio-chat-mobile-enter {
  from { opacity: 0; transform: translateY(24px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes portfolio-chat-spin {
  to { transform: rotate(360deg); }
}

.portfolio-chat-sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Greeting typewriter cursor: 2px block, toggles every 530ms */
.portfolio-chat-typecursor {
  animation: portfolio-chat-blink 1060ms steps(1, end) infinite;
  background: var(--chat-accent);
  display: inline-block;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  width: 2px;
}

/* Suggestions rise in one after another */
.portfolio-chat-suggestions > * {
  animation: portfolio-chat-rise 420ms var(--chat-ease-out) both;
  animation-delay: calc(var(--rise-index, 0) * 120ms);
}

@keyframes portfolio-chat-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes portfolio-chat-ping {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

@keyframes portfolio-chat-blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

/* Phones: a bottom sheet that leaves the page visible above it. */
@media (max-width: 640px) {
  .portfolio-chat-launcher {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
  }

  .portfolio-chat-launcher__label {
    display: none;
  }

  .back-to-top {
    right: calc(max(16px, env(safe-area-inset-right)) + 6px);
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + clamp(48px, calc(42px + 2vw), 64px) + 12px);
  }

  .portfolio-chat-panel {
    bottom: max(10px, env(safe-area-inset-bottom));
    height: min(560px, 74dvh);
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    transform-origin: bottom center;
    width: auto;
  }

  .portfolio-chat-panel[data-entering="true"] {
    animation: portfolio-chat-mobile-enter 260ms var(--chat-ease-out) both;
  }

  .portfolio-chat-message {
    max-width: 92%;
  }

  .portfolio-chat-composer textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-chat-panel[data-entering="true"],
  .portfolio-chat-cursor,
  .portfolio-chat-suggestions > *,
  .portfolio-chat-launcher__avatar::before,
  .portfolio-chat-launcher__avatar::after {
    animation: none;
  }

  .portfolio-chat-launcher__avatar,
  .portfolio-chat-launcher__avatar img,
  .portfolio-chat-launcher__label,
  .portfolio-chat-chip__tip {
    transition: none;
  }
}
