/* Core theme styles copied from the original WordPress theme */

/* View transitions & page animations */
@view-transition {
  navigation: auto;
}

.site-header + .block-columns,
.post-content {
  animation: 0.25s slide-in ease-out forwards;
}

@keyframes slide-in {
  from {
    transform: translateY(var(--space-md));
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@font-face {
  font-family: "Manrope";
  src: local("Manrope"),
       url("/fonts/Manrope-Regular.woff2") format("woff2"),
       url("/fonts/Manrope-Regular.woff") format("woff");
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

/* Override Seedlet-style variables with values from experimental-theme.json */
:root {
  --global--font-primary: 'Manrope', Helvetica, Arial, sans-serif;
  --global--font-secondary: 'Manrope', Helvetica, Arial, sans-serif;
  --entry-content--font-family: 'Manrope', Helvetica, Arial, sans-serif;

  --global--font-size-xs: 14px;
  --global--font-size-sm: 16px;
  --global--font-size-md: 20px;
  --global--font-size-lg: 24px;
  --global--font-size-xl: 28px;
  --global--font-size-xxl: 32px;
  --global--font-size-xxxl: 48px;

  --global--color-background: #222;
  --global--color-foreground: #FFF;
  --global--color-primary: cyan;
  --global--color-secondary: cyan;
  --global--color-tertiary: #FAFBF6;

  /* Theme colors and typography */
  --color-background: #222;
  --color-foreground: #FFF;
  --color-primary: cyan;
  --font-size-base: 20px;
  --font-size-display: 48px;
  --line-height-body: 1.6;
  --line-height-large: 1.3;
  --line-height-tight: 1.1;

  /* Spacing scale */
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
}

/* Core layout and typography from kjellr-blocks/style.css */
body {
  background-color: var(--color-background);
  color: var(--color-foreground);
  font-family: "Manrope", Helvetica, Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
}

.site-main {
  margin: 2.5vw;
  font-size: var(--global--font-size-md);
  line-height: 1.6;
}

.site-main > * {
  max-width: 100%;
}

.site-main > article > *,
.site-main > .not-found > *,
.entry-content > *,
[class*="block-group__inner"] > *,
.template-part > *,
.widget-area > *,
.widget-column > * {
  margin-top: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* Home page */
.home .site-main,
.page-title {
  font-size: 9vw;
  line-height: 1.2;
}

.home .page-title {
  text-indent: -99999px;
  height: 0;
  width: 0;
  margin: 0;
}

.home .entry-content {
  margin-top: 40vw;
}

.home .entry-content > * {
  margin-top: calc(4 * var(--space-lg));
  margin-bottom: calc(4 * var(--space-lg));
}

@media screen and (min-width: 580px) {
  .home .entry-content {
    margin-top: 20vw;
  }
}

/* Site Header */
.site-title {
  text-indent: -99999999px;
  height: 0;
  min-height: 0;
  width: 0;
  font-size: var(--font-size-display);
  margin-top: 0;
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

@media screen and (min-width: 580px) {
  .site-title {
    margin-bottom: var(--space-lg);
  }
}

.site-header {
  margin: 0;
  padding: 0;
}

.site-header p {
  position: absolute;
  margin-top: 0;
  margin-bottom: 0;
}

/* Make the header sticky on the homepage. */
.home .site-header p {
  z-index: 9999;
  position: fixed;
}

.site-header svg {
  height: 10vw;
  min-height: 72px;
  width: auto;
}

.home-link svg {
  animation: rotate 10s linear infinite;
  transition: transform 10s ease-out;
}

.home-link:hover svg {
  animation-play-state: paused;
  transform: rotate(-1turn);
}

.site-header svg path {
  transition: 0.25s fill ease-in-out;
}

.site-header svg:hover path {
  fill: #FFF;
}

.site-header svg:hover circle {
  transition: 0.25s stroke ease-in-out;
}

.site-header svg:hover circle {
  stroke: #FFF;
}

.home .site-header .home-link::after {
  display: none;
}

/* Site Footer */
.block-group.site-footer,
.block-group.site-footer .block-group__inner {
  width: 100%;
}

.site-footer {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: var(--space-md);
  width: 100%;
  font-size: var(--global--font-size-sm);
}

.site-footer * {
  margin: 0;
  padding: 0;
}

.site-footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.site-footer-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--space-md);
}

@media screen and (min-width: 580px) {
  .site-footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .site-footer-right {
    justify-content: flex-end;
  }
}

.footer-icon-link,
.footer-icon-link:hover {
  color: inherit;
}

.footer-icon-link::after {
  display: none;
}

.site-main .site-footer .footer-links {
  color: #fff;
}

.site-main .site-footer .footer-links:hover {
  color: var(--color-primary);
}

.site-main .site-footer .footer-links::after {
  display: none;
}

/* Links */
a {
  text-decoration: none;
  border-bottom: none;
  color: var(--color-primary);
  position: relative;
  transition: 0.25s color ease-in-out;
}

a:hover {
  color: currentColor;
}

.home .site-main a::after {
  display: inline-block;
  position: absolute;
  left: 0;
  top: 60%;
  content: "";
  width: 100%;
  border-bottom: 2px solid var(--color-primary);
  transform: rotate(.0111turn) translateZ(0);
  animation: rotate 40s linear infinite;
  backface-visibility: hidden;
}

/* Only show on child pages. */
.all-projects-link + .page-title {
  margin-top: 0.25em;
}

body:not(.page-child):not(.single-post) .all-projects-link {
  display: none;
}

body:not(.page-child):not(.single-post) .all-projects-link + .page-title {
  margin-top: 0;
}

@media screen and (min-width: 580px) {
  .home .site-main a {
    color: var(--color-primary);
  }

  .home .site-main a:hover {
    color: var(--color-foreground);
  }

  .home .site-main a::after {
    border-width: 4px;
    transition: 5s transform ease-in-out;
  }

  .home .site-main a:hover::after {
    animation-play-state: paused;
    transform: rotate(-1turn);
  }
}

@keyframes rotate {
  to {
    rotate: 1turn;
  }
}

@media (prefers-reduced-motion) {
  .home .site-main a::after,
  .site-header svg {
    animation: none;
    transition: none !important;
  }
}

/* "Random" rotations */
.home .site-main .a-wordpress::after {
  animation-duration: 60s;
}

.home .site-main .a-twentynineteen::after {
  animation-duration: 80s;
}

.home .site-main .a-pratt::after {
  animation-duration: 70s;
}

.home .site-main .a-razorfish::after {
  animation-duration: 50s;
}

.home .site-main .a-isobar::after {
  animation-duration: 80s;
}

.home .site-main .a-projects::after {
  animation-duration: 120s;
}

.home .site-main .a-write::after {
  animation-duration: 50s;
}

.home .site-main .a-present::after {
  animation-duration: 40s;
}

.page-title {
  margin-top: 40vw;
}

.entry-content {
  margin-top: var(--space-lg);
}

/* Everywhere: cyan links, white on hover */
.entry-content a {
  color: var(--color-primary);
}
.entry-content a:hover {
  color: var(--color-foreground);
}

/* Grids: keep figcaption links white, cyan on figure hover */
.entry-content figure figcaption a {
  color: var(--color-foreground);
}
.entry-content figure:hover figcaption a {
  color: var(--color-primary);
}

body:not(.home) .entry-content {
  max-width: 1100px;
}

body:not(.home) .entry-content > *:not([class*="alignwide"]) {
  max-width: 700px;
}

@media screen and (min-width: 580px) {
  .page-title {
    margin-top: 20vw;
  }

  .entry-content {
    margin-top: calc(2 * var(--space-md));
  }
}

.site-main .entry-content > ul:not(.social-links) {
  list-style-type: none;
  padding-left: 0;
}

.site-main .entry-content > ul:not(.social-links) li {
  margin-bottom: var(--space-sm);
}

/* Blog listing: larger title, date under each */
.site-main .entry-content ul.blog-post-list .blog-post-list__item {
  margin-bottom: calc(2 * var(--space-lg));
}
.site-main .entry-content ul.blog-post-list .blog-post-list__item:last-child {
  margin-bottom: 0;
}
.blog-post-list__title {
  font-size: var(--global--font-size-xl);
  line-height: var(--line-height-tight);
  display: block;
}
.blog-post-list__date {
  font-size: var(--global--font-size-sm);
  display: block;
  margin-top: var(--space-sm);
  color: var(--color-foreground);
  opacity: 0.85;
}

/* Single post: date under title */
.post-date {
  margin-top: 0;
  margin-bottom: 0;
  font-size: var(--global--font-size-sm);
  opacity: 0.85;
}
.post-date + .entry-content {
  margin-top: var(--space-lg);
}

.site-main .entry-content > *:last-child {
  margin-bottom: calc(2 * var(--space-lg));
}

/* Project grids and all entry-content columns */
.entry-content .block-columns {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: calc(2 * var(--space-md));
  row-gap: calc(2 * var(--space-md));
  width: 100%;
  max-width: 1100px;
  margin-right: auto;
}

.entry-content .block-columns.alignfull {
  max-width: none;
}

/* Homepage: all entry-content can go full width */
.home .entry-content,
.home .entry-content .block-columns,
.home .entry-content figure.block-image.alignwide,
.home .entry-content figure.block-video {
  max-width: none;
}

/* Horizon Theme section */
.horizon-section__title {
  margin-top: 0;
  margin-bottom: var(--space-md);
  font-weight: inherit;
}
.horizon-section figure.block-image.alignwide {
  max-width: 100%;
}
.horizon-section .block-image {
  margin-top: 0;
}
.horizon-section {
  padding-bottom: var(--space-lg);
}
.entry-content .horizon-section figcaption a {
  color: var(--color-primary);
}
.entry-content .horizon-section figcaption a:hover {
  color: var(--color-foreground);
}

.entry-content .block-columns .block-column {
  min-width: 0;
  margin: 0;
  padding: 0;
}

.entry-content .block-columns .block-image img {
  max-width: 100%;
  height: auto;
  display: block;
}

.entry-content figure.block-image.alignwide {
  max-width: 1100px;
}

.entry-content figure.block-image.alignwide img {
  max-width: 100%;
  height: auto;
  display: block;
}

body:not(.home) .entry-content figure.block-image:not(.alignwide) {
  max-width: 700px;
}

body:not(.home) .entry-content figure.block-image:not(.alignwide) img {
  max-width: 100%;
  height: auto;
  display: block;
}

.entry-content figure.block-video {
  max-width: 1100px;
}

.entry-content figure.block-video video {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-main figure {
  margin: 0;
  padding: 0;
}

.entry-content > figure.block-image {
  margin-bottom: var(--space-lg);
}

.site-main figcaption {
  margin-top: var(--space-sm);
}

/* Gallery grid – use .columns-1, .columns-2, .columns-3 or .columns-default (3-col) on .block-gallery */
.entry-content .block-gallery,
.block-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  width: 100%;
}

.entry-content .block-gallery.alignwide {
  max-width: 1100px;
}

.entry-content .block-gallery .block-image,
.entry-content .block-gallery figure,
.block-gallery .block-image,
.block-gallery figure {
  min-width: 0;
  margin: 0;
  padding: 0;
}

.block-gallery img {
  max-width: 100%;
  height: auto;
  display: block;
}

.entry-content .block-gallery.columns-1,
.block-gallery.columns-1 {
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.block-gallery.columns-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.block-gallery.columns-3,
.block-gallery.columns-default {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media screen and (max-width: 699px) {
  .block-gallery.columns-2,
  .block-gallery.columns-3,
  .block-gallery.columns-default {
    grid-template-columns: 1fr;
  }
}

@media screen and (min-width: 700px) and (max-width: 999px) {
  .block-gallery.columns-3,
  .block-gallery.columns-default {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Jetpack tiled gallery – same gap and image constraints */
.block-tiled-gallery .tiled-gallery__gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.block-tiled-gallery .tiled-gallery__row {
  display: flex;
  gap: var(--space-sm);
}

.block-tiled-gallery .tiled-gallery__col {
  min-width: 0;
}

.block-tiled-gallery .tiled-gallery__item,
.block-tiled-gallery .tiled-gallery__item figure {
  margin: 0;
  padding: 0;
  min-width: 0;
}

.block-tiled-gallery .tiled-gallery__item img {
  max-width: 100%;
  height: auto;
  display: block;
}

@media screen and (min-width: 700px) {
  .entry-content .block-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media screen and (min-width: 1000px) {
  .entry-content .block-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Reduced Motion handled above for header and homepage links */

/* View mode: SVG filters applied to main content only; mode button stays unfiltered */
.view-mode-svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

#view-mode-wrapper {
  position: relative;
  min-height: 100%;
}

.halftone-wrapper {
  background-color: var(--color-background);
  min-height: 100vh;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

html.view-mode-agent .halftone-wrapper {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* Chat trigger: fixed upper right, visible in both default and agent mode */
.chat-trigger {
  position: fixed;
  top: 2.5vw;
  right: 2.5vw;
  z-index: 10000;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.35rem 0.75rem 0.35rem 0.9rem;
  border-radius: 9999px;
  cursor: pointer;
  color: #888;
  transition: color 0.15s ease, transform 0.15s ease;
}

/* Pill background: above sparkles, animates in/out with label (0.25s) */
.chat-trigger::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 9999px;
  background: #252525;
  opacity: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0);
  transition: opacity 0.25s ease, box-shadow 0.25s ease, background 0.15s ease;
  pointer-events: none;
}

.chat-trigger:hover::before {
  opacity: 1;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  background: #1a1a1a;
}

.chat-trigger:active {
  transform: translateY(1px);
}

.chat-trigger:active::before {
  background: #151515;
}

/* Agent mode: no pill, gradient, or sparkles on hover */
.chat-trigger.is-active:hover::before {
  opacity: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0);
}
.chat-trigger.is-active:hover::after {
  opacity: 0;
  transform: scale(0.4);
}
.chat-trigger.is-active:hover .chat-trigger__sparkle {
  animation: none;
  opacity: 0;
}

/* Radial cyan gradient: under sparkles, fades in and grows from top left on hover */
.chat-trigger::after {
  content: "";
  position: absolute;
  top: -2.5vw;
  right: -2.5vw;
  width: 48vw;
  height: 40vh;
  min-width: 280px;
  min-height: 200px;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(
    ellipse 100% 100% at 100% 0%,
    rgba(0, 255, 255, 0.14) 0%,
    rgba(0, 255, 255, 0.06) 35%,
    transparent 65%
  );
  opacity: 0;
  transform: scale(0.4);
  transform-origin: top right;
  transition: opacity 0.3s ease, transform 0.35s ease;
}

.chat-trigger:hover::after {
  opacity: 1;
  transform: scale(1);
}

.chat-trigger:hover {
  color: var(--color-foreground);
}

.chat-trigger__label,
.chat-trigger .chat-trigger__icon {
  position: relative;
  z-index: 1;
}

/* Sparkles: behind pill and content, masked to a circle with feathered edges */
.chat-trigger__sparkles {
  position: absolute;
  top: -2.5vw;
  right: -2.5vw;
  width: 48vw;
  height: 40vh;
  min-width: 280px;
  min-height: 200px;
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(
    circle at 85% 35%,
    black 0%,
    black 42%,
    transparent 72%
  );
  mask-image: radial-gradient(
    circle at 85% 35%,
    black 0%,
    black 42%,
    transparent 72%
  );
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.chat-trigger__sparkle {
  position: absolute;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0;
  box-shadow: 0 0 6px var(--color-primary), 0 0 12px rgba(0, 255, 255, 0.3);
}

.chat-trigger:hover .chat-trigger__sparkle {
  animation: chat-trigger-sparkle-twinkle 1.5s ease-in-out infinite;
}

@keyframes chat-trigger-sparkle-twinkle {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-trigger:hover .chat-trigger__sparkle {
    animation: none;
  }
  .chat-trigger:hover .chat-trigger__sparkle {
    opacity: 0.5;
  }
  html.view-mode-agent .agent-chat__sparkle {
    animation: none;
  }
  html.view-mode-agent .agent-chat__sparkle {
    opacity: 0.4;
  }
}

.chat-trigger__label {
  font-size: var(--global--font-size-sm);
  font-family: var(--global--font-primary);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(12px);
  clip-path: inset(0 0 0 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 100%);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  transition: opacity 0.25s ease, transform 0.25s ease, clip-path 0.25s ease;
  pointer-events: none;
}

.chat-trigger:hover .chat-trigger__label {
  opacity: 1;
  transform: translateX(0);
  clip-path: inset(0 0 0 0);
  -webkit-mask-image: none;
  mask-image: none;
}

/* Hide label when close icon is showing (agent mode active) */
.chat-trigger.is-active .chat-trigger__label {
  opacity: 0;
  transform: translateX(12px);
  clip-path: inset(0 0 0 100%);
  pointer-events: none;
}

.chat-trigger.is-active {
  color: var(--color-foreground);
}

.chat-trigger.is-active:hover {
  color: #888;
}

.chat-trigger .chat-trigger__icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.chat-trigger .chat-trigger__icon--close {
  display: none;
}

.chat-trigger.is-active .chat-trigger__icon--chat {
  display: none;
}

.chat-trigger.is-active .chat-trigger__icon--close {
  display: block;
}

.view-controls__control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
  padding-left: 6px;
}

.view-controls__control label {
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--color-foreground);
}

.view-controls__control input[type="range"] {
  --range-percent: 0%;
  width: 100%;
  height: 6px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.view-controls__control input[type="range"]:focus {
  outline: none;
}

/* Track: square edges, no border; fill bar from 0 to current value */
.view-controls__control input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(
    to right,
    var(--color-primary) 0%,
    var(--color-primary) var(--range-percent, 0%),
    rgba(255, 255, 255, 0.2) var(--range-percent, 0%),
    rgba(255, 255, 255, 0.2) 100%
  );
  border: none;
  border-radius: 0;
}

.view-controls__control input[type="range"]::-moz-range-track {
  height: 6px;
  background: linear-gradient(
    to right,
    var(--color-primary) 0%,
    var(--color-primary) var(--range-percent, 0%),
    rgba(255, 255, 255, 0.2) var(--range-percent, 0%),
    rgba(255, 255, 255, 0.2) 100%
  );
  border: none;
  border-radius: 0;
}

/* Thumb: height of track, width 100% (square); grows vertically on hover */
.view-controls__control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 6px;
  height: 6px;
  margin-top: 0;
  background: var(--color-primary);
  border: none;
  border-radius: 0;
  cursor: pointer;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.view-controls__control input[type="range"]:hover::-webkit-slider-thumb {
  transform: scaleY(1.5);
}

.view-controls__control input[type="range"]::-moz-range-thumb {
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border: none;
  border-radius: 0;
  cursor: pointer;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.view-controls__control input[type="range"]:hover::-moz-range-thumb {
  transform: scaleY(1.5);
}

/* ── Agent / Chat mode ──────────────────────────────────────────────────── */

.agent-chat {
  position: fixed;
  inset: 0;
  background: var(--color-background);
  z-index: 50;
  /* Hidden until agent mode is active */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-sizing: border-box;
  /* Scroll container: only messages scroll; form/sparkles/overlay stay fixed */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sparkles: fixed to viewport so they don’t scroll */
.agent-chat__sparkles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none !important;
}

@media (max-width: 768px) {
  .agent-chat__sparkles {
    display: none;
  }
}

.agent-chat__radial-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none !important;
  background: radial-gradient(
    ellipse 80% 70% at 50% 50%,
    var(--color-background) 0%,
    var(--color-background) 45%,
    transparent 75%
  );
}

.agent-chat__sparkle {
  position: absolute;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0;
  box-shadow: 0 0 4px var(--color-primary), 0 0 10px rgba(0, 255, 255, 0.25);
}

html.view-mode-agent .agent-chat__sparkle {
  animation: chat-trigger-sparkle-twinkle 1.5s ease-in-out infinite;
}

html.view-mode-agent .agent-chat__messages {
  position: relative;
  z-index: 2;
}

html.view-mode-agent .agent-chat__form {
  z-index: 2;
}

html.view-mode-agent .agent-chat {
  opacity: 1;
  pointer-events: auto;
}

html.view-mode-agent body {
  overflow: hidden;
}

@keyframes agent-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html.view-mode-agent .agent-chat:not(.agent-chat--empty) .agent-chat__messages {
  animation: agent-slide-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.05s;
}

/* Form uses transform for positioning; skip slide-in to avoid overriding translateX(-50%) */

@keyframes agent-slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

.agent-chat.is-exiting .agent-chat__messages {
  animation: agent-slide-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Form exit: fade only so we don't override translateX(-50%) and cause a flash */
.agent-chat.is-exiting .agent-chat__form {
  animation: agent-form-fade-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes agent-form-fade-out {
  to {
    opacity: 0;
  }
}

/* Empty state: hide messages, center form in viewport */
.agent-chat--empty .agent-chat__messages {
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.agent-chat__messages {
  min-width: 0;
  padding: 2.5vw;
  padding-bottom: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: flex-end;
  max-width: min(580px, 100%);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  transition: opacity 0.35s ease;
}

/* With messages: in-flow so agent-chat scrolls; min-height so scroll container has height */
.agent-chat:not(.agent-chat--empty) .agent-chat__messages {
  min-height: 100vh;
  padding-bottom: 6rem;
  position: relative;
}

/* Fade at bottom so message text fades under the form (not clipped) */
.agent-chat:not(.agent-chat--empty) .agent-chat__messages::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2rem;
  background: linear-gradient(to bottom, transparent, var(--color-background));
  pointer-events: none;
}

.agent-chat__intro {
  display: none;
}

.agent-chat__message {
  max-width: 75%;
  min-width: 0;
  line-height: 1.5;
  font-size: var(--global--font-size-sm);
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.agent-chat__message--user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 1rem 1rem 0.25rem 1rem;
}

.agent-chat__message--user.agent-message--enter {
  animation: agent-message-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
  transform: translateY(10px);
}

.agent-chat__message--agent {
  align-self: flex-start;
  color: white;
  margin: 0;
}

.agent-chat__message--agent img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  display: block;
  margin: 0.5rem 0 0;
}

.agent-chat__message--agent img:first-child {
  margin-top: 0;
}

.agent-chat__message--agent .agent-chat__image-link {
  display: inline-block;
  text-decoration: none;
  margin-top: 0.5rem;
}

.agent-chat__message--agent .agent-chat__image-link:first-child {
  margin-top: 0;
}

/* Zero margins so height comes only from growing wrappers, not reserved space */
.agent-chat__message--agent p {
  margin: 0;
}

.agent-chat__message--agent p + p {
  margin-top: 0.5em;
}

.agent-chat__message--agent p:first-child {
  margin-top: 0;
}

.agent-chat__message--agent p:last-child {
  margin-bottom: 0;
}

/* Bullets/numbers fade in after list content (::before so animation works reliably) */
.agent-chat__message--agent ul {
  list-style: none;
  padding-left: 1.5em;
}

.agent-chat__message--agent ul li {
  position: relative;
  padding-left: 0.25em;
}

.agent-chat__message--agent ul li::before {
  content: "•";
  position: absolute;
  left: -1em;
  opacity: 0;
  animation: agent-bullet-fade-in 0.35s ease-out var(--marker-delay, 1.5s) forwards;
}

.agent-chat__message--agent ol {
  list-style: none;
  counter-reset: agent-list-item;
  padding-left: 2em;
}

.agent-chat__message--agent ol li {
  position: relative;
  counter-increment: agent-list-item;
  padding-left: 0.25em;
}

.agent-chat__message--agent ol li::before {
  content: counter(agent-list-item) ".";
  position: absolute;
  left: -1.5em;
  opacity: 0;
  animation: agent-bullet-fade-in 0.35s ease-out var(--marker-delay, 1.5s) forwards;
}

@keyframes agent-bullet-fade-in {
  to {
    opacity: 1;
  }
}

/* Paragraph wrapper: starts collapsed so message height grows as each paragraph reveals */
.agent-chat__message--agent .agent-paragraph-wrapper {
  max-height: 0;
  overflow: hidden;
  animation: agent-paragraph-grow linear forwards;
}

.agent-chat__message--agent .agent-paragraph-wrapper + .agent-paragraph-wrapper {
  margin-top: 0.5em;
}

@keyframes agent-paragraph-grow {
  to {
    max-height: 2000px;
  }
}

.agent-chat__message--agent .agent-word {
  display: inline;
  opacity: 0;
  transform: translateY(4px);
  animation: agent-word-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}


.agent-chat__message--agent.agent-message--enter {
  opacity: 1;
}

/* Word-by-word: wrapper grows, word fades in (delay set in JS) */
.agent-chat__message--agent .agent-word-wrapper {
  display: inline-block;
  vertical-align: top;
  max-height: 0;
  overflow: hidden;
  animation: agent-wrapper-grow 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Image wrapper grows in sequence with words; image fades in */
.agent-chat__message--agent .agent-image-wrapper {
  max-height: 0;
  overflow: hidden;
  animation: agent-image-wrapper-grow 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  display: block;
}

.agent-chat__message--agent img.agent-image-reveal {
  opacity: 0;
  transform: translateY(4px);
  animation: agent-word-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes agent-wrapper-grow {
  to {
    max-height: 2em;
  }
}

@keyframes agent-image-wrapper-grow {
  to {
    max-height: 2000px;
  }
}

@keyframes agent-message-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes agent-word-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.agent-chat__message--error {
  align-self: flex-start;
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
}

.agent-chat__message--loading {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
}

.agent-chat__message--loading .agent-loading-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: agent-loading-bounce 0.6s ease-in-out infinite both;
}

.agent-chat__message--loading .agent-loading-dot:nth-child(2) {
  animation-delay: 0.1s;
}

.agent-chat__message--loading .agent-loading-dot:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes agent-loading-bounce {
  0%, 80%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-2px) scale(1.15); }
}

/* Form fixed at bottom at all times (stays in place when agent-chat scrolls). On iOS, --agent-keyboard-offset moves it above the keyboard. */
.agent-chat__form {
  position: fixed;
  left: 50%;
  bottom: var(--agent-keyboard-offset, 0);
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  box-sizing: border-box;
  padding: 1rem 2.5vw;
  padding-top: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  max-width: min(580px, 100%);
  width: 100%;
  background-color: var(--color-background);
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.2s ease-out;
}

/* Fade overlay on top 1rem of form so scrolling messages fade under it */
.agent-chat__form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1rem;
  background: linear-gradient(to bottom, transparent, var(--color-background));
  pointer-events: none;
  z-index: 1;
}

/* When opening agent: form fades in */
.agent-chat__form.agent-chat__form--enter,
.agent-chat__form.agent-chat__form--enter-empty {
  animation: agent-form-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.05s;
}

@keyframes agent-form-enter {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 600px) {
  .agent-chat:not(.agent-chat--empty) .agent-chat__messages {
    padding-bottom: 6rem;
  }
  .agent-chat__messages {
    padding: 1rem;
    padding-bottom: 4rem;
  }

  .agent-chat__form {
    padding: 0.75rem 1rem;
    padding-top: 1rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .agent-chat:not(.agent-chat--empty) .agent-chat__messages {
    padding-bottom: 6rem;
  }
  .agent-chat__messages {
    padding-bottom: 3.5rem;
  }
}

.agent-chat__input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  color: white;
  font-family: inherit;
  font-size: max(16px, var(--global--font-size-sm));
  padding: 0.6rem 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.agent-chat__input:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.agent-chat__input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.agent-chat__input:disabled {
  opacity: 0.5;
}

.agent-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 0.5rem;
  color: #000;
  cursor: pointer;
  font-family: inherit;
  padding: 0.4rem 1rem;
  line-height: 1;
  transition: filter 0.15s, opacity 0.15s;
}

.agent-chat__send svg {
  display: block;
}

.agent-chat__send:hover:not(:disabled) {
  filter: brightness(1.1);
}

.agent-chat__send:disabled {
  opacity: 0.35;
  cursor: default;
}

.agent-chat__limit {
  text-align: center;
  padding: 0.5rem 0 0;
  color: rgba(255, 255, 255, 0.3);
  font-size: var(--global--font-size-xs);
  align-self: center;
}

/* Demo mode: only when ?agent-demo=1, for testing animations */
.agent-chat__demo-btn {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: var(--global--font-size-xs);
  color: rgba(255, 255, 255, 0.45);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.25rem;
  cursor: pointer;
  white-space: nowrap;
  z-index: 10;
}

.agent-chat__demo-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.4);
}
