/*
 * Primer 2026 design tokens for code components.
 *
 * Code components render inside a shadow root. CSS custom properties inherit
 * through it, so each token reads the matching Webflow variable from the
 * "Primer 2026" collection and falls back to the same literal value. That way
 * a component looks right both on the Webflow page and in the local playground.
 *
 * Fluid type and spacing are literal clamp() values: the Webflow API rejected
 * clamp() for size variables, so the p26-* classes in Webflow use these same
 * values directly. Keep both in sync.
 */
:host,
.p26-root {
  /* Color: aliases of existing brand variables */
  --p26-text-strong: var(--_primer-2026---color--text--strong, #20292c);
  --p26-text-default: var(--_primer-2026---color--text--default, #475a61);
  --p26-text-inverse: var(--_primer-2026---color--text--inverse, #ffffff);
  --p26-surface-base: var(--_primer-2026---color--surface--base, #ffffff);
  --p26-surface-subtle: var(--_primer-2026---color--surface--subtle, #f3f5f6);
  --p26-surface-hover: var(--_primer-2026---color--surface--hover, #f7f9fa);
  --p26-surface-inverse: var(--_primer-2026---color--surface--inverse, #262155);
  --p26-border: var(--_primer-2026---color--border--default, rgba(138, 159, 169, 0.32));
  --p26-accent: var(--_primer-2026---color--accent--primary, #6e37ff);
  --p26-accent-strong: var(--_primer-2026---color--accent--strong, #3c327b);
  --p26-accent-soft: var(--_primer-2026---color--accent--soft, #a8a6ff);
  --p26-accent-blue: var(--_primer-2026---color--accent--blue, #3366ff);
  --p26-highlight: var(--_primer-2026---color--highlight, #ffd966);
  --p26-focus: var(--_primer-2026---color--focus-ring, #0b89fd);

  /* Type */
  --p26-font-display: var(--_primer-2026---font--display, EightiesComeback), Georgia, serif;
  --p26-font-body: var(--_primer-2026---font--body, Rubik), Arial, sans-serif;
  --p26-type-h3: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
  --p26-type-body-lg: clamp(1.125rem, 1.05rem + 0.3vw, 1.25rem);
  --p26-type-body: var(--_primer-2026---type--body, 1rem);
  --p26-type-small: var(--_primer-2026---type--small, 0.875rem);

  /* Space and shape */
  --p26-space-2xs: var(--_primer-2026---space--2xs, 0.25rem);
  --p26-space-xs: var(--_primer-2026---space--xs, 0.5rem);
  --p26-space-sm: var(--_primer-2026---space--sm, 1rem);
  --p26-space-md: var(--_primer-2026---space--md, 1.5rem);
  --p26-space-lg: clamp(2rem, 1.6rem + 1.6vw, 3rem);
  --p26-radius-sm: var(--_primer-2026---radius--sm, 8px);
  --p26-radius-md: var(--_primer-2026---radius--md, 12px);
  --p26-radius-lg: var(--_primer-2026---radius--lg, 20px);

  /* Motion */
  --p26-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --p26-duration-fast: 160ms;
  --p26-duration-base: 320ms;
}

.p26-prompt {
  position: relative;
  width: 100%;
  margin: 0;
  font-family: var(--p26-font-body);
  /* Inherited properties cross the shadow root; don't pick up the hero's centring. */
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

.p26-prompt__card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--p26-space-xs);
  padding: 12px;
  border-radius: 22px;
  background: var(--p26-surface-base);
  box-shadow:
    0 0 0 1px rgba(32, 41, 44, 0.08),
    0 1px 2px rgba(38, 33, 85, 0.06),
    0 24px 48px -16px rgba(38, 33, 85, 0.28);
  cursor: text;
  transition: box-shadow var(--p26-duration-fast) ease;
}

.p26-prompt__card:focus-within {
  box-shadow:
    0 0 0 2px var(--p26-accent),
    0 1px 2px rgba(38, 33, 85, 0.06),
    0 24px 48px -16px rgba(38, 33, 85, 0.32);
}

/* Soft brand glow under the card; wakes up on hover and focus. */
.p26-prompt__glow {
  position: absolute;
  z-index: 0;
  left: 8%;
  right: 8%;
  bottom: -10px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--p26-accent-blue), var(--p26-accent), var(--p26-accent-soft));
  filter: blur(18px);
  opacity: 0.25;
  transition: opacity var(--p26-duration-base) ease;
  pointer-events: none;
}

.p26-prompt:hover .p26-prompt__glow {
  opacity: 0.55;
}

.p26-prompt:focus-within .p26-prompt__glow {
  opacity: 0.85;
}

/* Textarea and suggestion share one grid cell; the taller of the two sets the height. */
.p26-prompt__field {
  display: grid;
  min-height: 56px;
}

.p26-prompt__input,
.p26-prompt__suggestion {
  grid-area: 1 / 1;
  margin: 0;
  padding: 8px 8px 4px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  line-height: 1.5;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.p26-prompt__input {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  max-height: 40svh;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--p26-text-strong);
  caret-color: var(--p26-accent);
  resize: none;
  overflow-y: auto;
}

.p26-prompt__suggestion {
  color: var(--p26-text-default);
  pointer-events: none;
  user-select: none;
}

.p26-prompt__suggestion.is-hidden {
  visibility: hidden;
}

.p26-prompt__suggestion.is-slide {
  animation: p26-suggestion-in 320ms var(--p26-ease-out) both;
}

@keyframes p26-suggestion-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.p26-prompt__actions {
  display: flex;
  justify-content: flex-end;
}

.p26-prompt__submit {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--p26-accent-strong);
  color: var(--p26-text-inverse);
  cursor: pointer;
  transition:
    background-color var(--p26-duration-fast) ease,
    transform var(--p26-duration-fast) ease;
}

/* 48px touch target without a bigger visual. */
.p26-prompt__submit::before {
  content: "";
  position: absolute;
  inset: -4px;
}

.p26-prompt__submit:hover {
  background: var(--p26-accent);
}

.p26-prompt__submit:active {
  transform: scale(0.94);
}

.p26-prompt__submit:focus-visible {
  outline: 3px solid var(--p26-focus);
  outline-offset: 3px;
}

@media (min-width: 768px) {
  .p26-prompt__card {
    padding: 14px;
    border-radius: 28px;
  }

  .p26-prompt__input,
  .p26-prompt__suggestion {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p26-prompt__card,
  .p26-prompt__glow,
  .p26-prompt__submit {
    transition: none;
  }

  .p26-prompt__suggestion.is-slide {
    animation: none;
  }
}

.p26-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

