/* Portfolio Index assistant */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.portfolio-agent {
  --portfolio-agent-panel-width: min(386px, 100vw);
  --portfolio-agent-panel-surface: #fff;
  --portfolio-agent-chrome-surface: #fff;
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  font-family: "Space Grotesk", sans-serif;
}

.portfolio-agent__launcher {
  position: absolute;
  right: -24px;
  bottom: 24px;
  width: 112px;
  height: 132px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  pointer-events: auto;
  transition: right var(--motion-smooth), transform 160ms ease;
}

.portfolio-agent__launcher:active {
  transform: translateY(1px);
}

.portfolio-agent__launcher:focus-visible {
  outline: 1px solid var(--text-primary);
  outline-offset: 3px;
}

.portfolio-agent__launcher-label {
  position: absolute;
  right: 86px;
  bottom: 20px;
  width: max-content;
  padding: 7px 9px;
  border: 1px solid var(--text-primary);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.portfolio-agent__launcher:hover .portfolio-agent__launcher-label,
.portfolio-agent__launcher:focus-visible .portfolio-agent__launcher-label {
  opacity: 1;
  transform: translateX(0);
}

.portfolio-agent__pet {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
}

.portfolio-agent__pet-image {
  grid-area: 1 / 1;
  display: block;
  max-width: 100%;
  height: 116px;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: 60% 100%;
  transition: opacity 120ms ease, transform var(--motion-smooth);
}

.portfolio-agent__pet-image--thinking {
  opacity: 0;
}

.portfolio-agent__pet-wave {
  grid-area: 1 / 1;
  align-self: end;
  display: block;
  width: 105px;
  height: 116px;
  background-image: var(--portfolio-agent-wave-sprite);
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 1400% 100%;
  opacity: 0;
}

.portfolio-agent[data-state="thinking"] .portfolio-agent__pet-image--idle {
  opacity: 0;
}

.portfolio-agent[data-state="thinking"] .portfolio-agent__pet-image--thinking {
  opacity: 1;
}

.portfolio-agent[data-state="presenting"] .portfolio-agent__pet-image--idle {
  transform: translateX(-5px) rotate(-2deg);
}

.portfolio-agent[data-open="true"] .portfolio-agent__launcher {
  right: calc(var(--portfolio-agent-panel-width) - 34px);
}

.portfolio-agent[data-open="true"] .portfolio-agent__launcher-label {
  display: none;
}

.portfolio-agent[data-open="true"][data-state="thinking"] .portfolio-agent__launcher {
  opacity: 0;
  pointer-events: none;
}

.portfolio-agent__panel {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr) auto;
  width: var(--portfolio-agent-panel-width);
  height: 100dvh;
  box-sizing: border-box;
  border-left: 1px solid rgba(0, 0, 0, 0.24);
  background: var(--portfolio-agent-panel-surface);
  color: var(--text-primary);
  overflow: hidden;
  pointer-events: auto;
  transform: translateX(100%);
  transition: transform var(--motion-smooth);
}

.portfolio-agent[data-open="true"] .portfolio-agent__panel {
  transform: translateX(0);
}

.portfolio-agent__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--portfolio-agent-chrome-surface);
}

.portfolio-agent__header h2,
.portfolio-agent__sources,
.portfolio-agent__form label {
  font-family: "DM Mono", monospace;
}

.portfolio-agent__header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
}

.portfolio-agent__close {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.portfolio-agent__close:focus-visible,
.portfolio-agent__starter:focus-visible,
.portfolio-agent__sources summary:focus-visible,
.portfolio-agent__sources a:focus-visible,
.portfolio-agent__input-row input:focus-visible,
.portfolio-agent__input-row button:focus-visible {
  outline: 1px solid var(--text-primary);
  outline-offset: 3px;
}

.portfolio-agent__body {
  min-height: 0;
  padding: 0 28px 40px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.portfolio-agent__welcome {
  padding-top: 42px;
}

.portfolio-agent__welcome > p {
  max-width: 26ch;
  margin: 0;
  font-size: 19px;
  font-weight: 400;
  line-height: 1.45;
}

.portfolio-agent__starters {
  display: grid;
  gap: 14px;
  margin-top: 36px;
}

.portfolio-agent__starter {
  position: relative;
  width: fit-content;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(0, 0, 0, 0.68);
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.28);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.portfolio-agent__starter:hover {
  color: #000;
  text-decoration-color: #000;
}

.portfolio-agent__result {
  padding-top: 40px;
}

.portfolio-agent__result[hidden],
.portfolio-agent__welcome[hidden],
.portfolio-agent__thinking-scene[hidden],
.portfolio-agent__answer-block[hidden],
.portfolio-agent__sources[hidden] {
  display: none;
}

.portfolio-agent__question {
  margin: 0 0 28px;
  color: rgba(0, 0, 0, 0.5);
  font-size: 12px;
  line-height: 1.45;
}

.portfolio-agent__question::before {
  content: "You asked: ";
}

.portfolio-agent[data-state="thinking"] .portfolio-agent__question {
  display: none;
}

.portfolio-agent__thinking-scene {
  display: grid;
  align-content: start;
  justify-items: center;
  box-sizing: border-box;
  min-height: 360px;
  padding: 58px 0 12px;
  font-family: "DM Mono", monospace;
}

.portfolio-agent__thought-orbit {
  position: relative;
  width: 220px;
  aspect-ratio: 1;
}

.portfolio-agent__thought-orbit-image,
.portfolio-agent__thought-active,
.portfolio-agent__thinking-pet {
  position: absolute;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.portfolio-agent__thought-orbit-image {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.88;
}

.portfolio-agent__thought-active {
  top: -2px;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translateX(-50%);
  transform-origin: center;
}

.portfolio-agent__thinking-pet {
  left: 50%;
  bottom: 32px;
  width: 74px;
  height: 108px;
  transform: translateX(-50%);
  transform-origin: center bottom;
}

.portfolio-agent__thinking-label {
  margin: 6px 0 0;
  color: rgba(0, 0, 0, 0.52);
  font-size: 9px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-align: center;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: no-preference) {
  .portfolio-agent[data-state="thinking"] .portfolio-agent__thought-active {
    animation: portfolio-agent-thought-pulse 920ms cubic-bezier(0.22, 1, 0.36, 1) infinite alternate;
  }

  .portfolio-agent[data-state="thinking"] .portfolio-agent__thinking-pet {
    animation: portfolio-agent-think 1.45s ease-in-out infinite alternate;
  }

  .portfolio-agent[data-state="thinking"] .portfolio-agent__thought-orbit-image {
    animation: portfolio-agent-orbit-breathe 2.8s ease-in-out infinite alternate;
  }
}

@media (max-height: 780px) and (min-width: 701px) {
  .portfolio-agent__thinking-scene {
    min-height: min(310px, max(270px, calc(100dvh - 340px)));
    padding-top: 24px;
  }

  .portfolio-agent__thought-orbit {
    width: 190px;
  }

  .portfolio-agent__thought-active {
    width: 56px;
    height: 56px;
  }

  .portfolio-agent__thinking-pet {
    bottom: 28px;
    width: 66px;
    height: 96px;
  }

  .portfolio-agent__thinking-label {
    margin-top: -10px;
  }
}

.portfolio-agent__answer-block {
  padding: 0 0 30px;
}

.portfolio-agent__answer {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
}

.portfolio-agent__sources {
  width: fit-content;
  color: rgba(0, 0, 0, 0.58);
  font-size: 10px;
}

.portfolio-agent__sources summary {
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.28);
  text-underline-offset: 4px;
}

.portfolio-agent__sources > div {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.portfolio-agent__sources a {
  display: block;
  width: fit-content;
  color: rgba(0, 0, 0, 0.68);
  font-size: 10px;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.24);
  text-underline-offset: 3px;
}

.portfolio-agent__sources a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.portfolio-agent__form {
  padding: 18px 28px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--portfolio-agent-chrome-surface);
}

.portfolio-agent__input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.portfolio-agent__input-row input {
  min-width: 0;
  height: 46px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-right: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-primary);
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px;
}

.portfolio-agent__input-row input::placeholder {
  color: rgba(0, 0, 0, 0.56);
}

.portfolio-agent__input-row button {
  min-width: 64px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #111;
  border-radius: 0;
  background: #111;
  color: #fff;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  cursor: pointer;
}

.portfolio-agent__input-row button:active {
  transform: translateY(1px);
}

.portfolio-agent__input-row button:disabled,
.portfolio-agent__input-row input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

@media (prefers-reduced-motion: no-preference) {
  .portfolio-agent[data-open="false"] .portfolio-agent__pet-image--idle {
    animation: portfolio-agent-breathe 4.8s ease-in-out infinite;
  }

  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:hover .portfolio-agent__pet-image--idle,
  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:focus-visible .portfolio-agent__pet-image--idle {
    animation: none;
    opacity: 0;
    transition: none;
  }

  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:hover .portfolio-agent__pet-wave,
  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:focus-visible .portfolio-agent__pet-wave {
    animation: portfolio-agent-wave-strip 1.35s steps(13, end) forwards;
    opacity: 1;
  }
}

@keyframes portfolio-agent-breathe {
  0%, 82%, 100% { transform: translateY(0) rotate(0deg); }
  88% { transform: translateY(-2px) rotate(-1deg); }
  94% { transform: translateY(0) rotate(1deg); }
}

@keyframes portfolio-agent-wave-strip {
  from { background-position: 0 0; }
  to { background-position: 100% 0; }
}

@keyframes portfolio-agent-thought-pulse {
  from { transform: translateX(-50%) scale(0.96); }
  to { transform: translateX(-50%) scale(1.06); }
}

@keyframes portfolio-agent-think {
  from { transform: translateX(-50%) translateY(0) rotate(-0.8deg); }
  to { transform: translateX(-50%) translateY(-3px) rotate(0.8deg); }
}

@keyframes portfolio-agent-orbit-breathe {
  from { opacity: 0.72; transform: scale(0.995); }
  to { opacity: 0.92; transform: scale(1.005); }
}

@media (max-width: 700px) {
  .portfolio-agent {
    --portfolio-agent-panel-width: 100%;
  }

  .portfolio-agent__launcher {
    right: -30px;
    bottom: 12px;
    width: 104px;
    height: 120px;
  }

  .portfolio-agent__pet-image {
    height: 104px;
  }

  .portfolio-agent__pet-wave {
    width: 94px;
    height: 104px;
  }

  .portfolio-agent[data-open="true"] .portfolio-agent__launcher {
    opacity: 0;
    pointer-events: none;
  }

  .portfolio-agent__panel {
    grid-template-rows: 64px minmax(0, 1fr) auto;
  }

  .portfolio-agent__header,
  .portfolio-agent__body,
  .portfolio-agent__form {
    padding-right: 20px;
    padding-left: 20px;
  }

  .portfolio-agent__body {
    padding-bottom: 28px;
  }

  .portfolio-agent__welcome {
    padding-top: 28px;
  }

  .portfolio-agent__welcome > p,
  .portfolio-agent__answer {
    font-size: 16px;
  }

  .portfolio-agent__thinking-scene {
    min-height: min(320px, max(270px, calc(100dvh - 330px)));
    padding-top: 28px;
  }

  .portfolio-agent__thought-orbit {
    width: min(100%, 200px);
  }

  .portfolio-agent__thought-active {
    width: 58px;
    height: 58px;
  }

  .portfolio-agent__thinking-pet {
    bottom: 29px;
    width: 68px;
    height: 98px;
  }

  .portfolio-agent__thinking-label {
    margin-top: 2px;
  }

  body.portfolio-agent-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-agent__launcher,
  .portfolio-agent__launcher-label,
  .portfolio-agent__pet-image,
  .portfolio-agent__pet-wave,
  .portfolio-agent__panel,
  .portfolio-agent__starter,
  .portfolio-agent__thought-orbit-image,
  .portfolio-agent__thought-active,
  .portfolio-agent__thinking-pet {
    animation: none;
    transition: none;
  }

  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:hover .portfolio-agent__pet-image--idle,
  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:focus-visible .portfolio-agent__pet-image--idle {
    opacity: 0;
  }

  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:hover .portfolio-agent__pet-wave,
  .portfolio-agent[data-open="false"] .portfolio-agent__launcher:focus-visible .portfolio-agent__pet-wave {
    background-position: 100% 0;
    opacity: 1;
  }
}
