/*
 * 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;
}

/*
 * Primer app UI for homepage demos. Values from the Figma app frames:
 * Rubik 14/20 body (1em here), UI/900 #20292C, UI/700 #475A61, UI/300 #8A9FA9,
 * borders rgba(138,159,169,.32), panel heads #FAFAFA, Blue/50 #F5F7FF,
 * Blue/300 #99B2FF, Blue/800 #3366FF, Blue/850 #2F55CD, Green/500 #1C8C67.
 * Everything is in em so the whole UI scales with the demo's base size.
 */
.p26-demo {
  --ui-900: #20292c;
  --ui-700: #475a61;
  --ui-300: #8a9fa9;
  --ui-line: rgba(138, 159, 169, 0.32);
  --ui-line-soft: rgba(138, 159, 169, 0.19);
  --ui-head: #fafafa;
  --ui-50: #f3f5f6;
  --blue-50: #f5f7ff;
  --blue-100: #ebefff;
  --blue-200: #d6e4ff;
  --blue-300: #99b2ff;
  --blue-800: #3366ff;
  --blue-850: #2f55cd;
  --green-100: #dcfaeb;
  --green-500: #1c8c67;
  --green-600: #219b78;
  --violet: #7a63e0;
  --orange: #ffaa45;
  --red-100: #fde8e8;
  --red-600: #c9372c;
  --ui-shadow: 0 1px 2px rgba(32, 41, 44, 0.06), 0 12px 32px -12px rgba(38, 33, 85, 0.22);

  container-type: inline-size;
  position: relative;
  width: 100%;
  font-family: var(--p26-font-body, Rubik), Arial, sans-serif;
  color: var(--ui-900);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

/* The stage crops its panels like a window into the product. */
.p26-demo__stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 5 / 4;
  font-size: clamp(10px, 2.25cqw, 13px);
  line-height: 1.43;
}

.p26-demo__layer {
  position: absolute;
  will-change: transform, opacity;
}

.p26-demo p {
  margin: 0;
}

/* Panels (collapsible sections in the app) */
.ui-panel {
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 0.571em;
  background: #fff;
  box-shadow: var(--ui-shadow);
}

.ui-panel__head {
  display: flex;
  align-items: center;
  gap: 0.571em;
  height: 2.571em;
  padding: 0 0.571em 0 1.143em;
  border-bottom: 1px solid var(--ui-line);
  background: var(--ui-head);
  font-weight: 500;
}

.ui-panel__caret {
  color: var(--ui-700);
  font-size: 0.857em;
}

.ui-panel__body {
  padding: 1em 1.143em;
}

/* Chat */
.ui-chat {
  display: flex;
  flex-direction: column;
  gap: 0.857em;
  padding: 1em;
  border: 1px solid var(--ui-line);
  border-radius: 0.857em;
  background: var(--ui-head);
  box-shadow: var(--ui-shadow);
}

.ui-user {
  align-self: flex-end;
  max-width: 88%;
  padding: 0.857em;
  border-radius: 0.571em;
  background: var(--ui-line-soft);
  text-align: right;
}

.ui-assistant {
  padding-right: 2.286em;
}

.ui-steps {
  display: flex;
  flex-direction: column;
  gap: 0.286em;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ui-300);
}

.ui-step {
  display: flex;
  align-items: center;
  gap: 0.286em;
}

.ui-artifact {
  display: flex;
  align-items: center;
  gap: 0.571em;
  padding: 0.857em 1.143em;
  border: 1px solid var(--ui-line);
  border-radius: 0.571em;
  background: #fff;
}

.ui-artifact.is-highlighted {
  border-color: var(--blue-300);
  background: var(--blue-50);
}

.ui-artifact__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.429em;
  height: 3.429em;
  border-radius: 0.571em;
  background: var(--blue-100);
  color: var(--blue-850);
  font-size: 1em;
}

.ui-artifact__icon svg {
  font-size: 1.43em;
}

.ui-artifact__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.ui-artifact__text strong {
  font-size: 1.143em;
  font-weight: 500;
}

.ui-artifact__text span {
  color: var(--ui-300);
}

.ui-button {
  flex: none;
  padding: 0.143em 1.143em;
  border: 1px solid var(--ui-line);
  border-radius: 0.571em;
  background: #fff;
  box-shadow: inset 0 -1px 2px rgba(32, 41, 44, 0.24);
  color: var(--ui-700);
}

/* Tags, badges, labels */
.ui-tag {
  display: inline-flex;
  padding: 0.286em;
  border: 1px solid var(--ui-line);
  border-radius: 0.286em;
  background: var(--ui-50);
  white-space: nowrap;
}

.ui-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.143em;
}

.ui-badge {
  display: inline-flex;
  padding: 0.143em 0.357em;
  border: 1px solid rgba(28, 140, 103, 0.3);
  border-radius: 0.286em;
  background: var(--green-100);
  color: var(--green-500);
  font-size: 0.857em;
  line-height: 1.33;
  white-space: nowrap;
}

.ui-label {
  display: flex;
  align-items: center;
  gap: 0.286em;
  font-size: 0.857em;
  font-weight: 500;
  letter-spacing: 0.025em;
  line-height: 1.33;
  text-transform: uppercase;
}

.ui-label svg {
  color: var(--ui-300);
  font-size: 1.33em;
}

/* Channel logos keep the Figma SVG proportions inside a 1.43em box. */
.ui-logo {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.43em;
  height: 1.43em;
}

.ui-logo img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Destinations */
.ui-dests {
  display: flex;
  flex-direction: column;
  gap: 0.286em;
}

.ui-dest {
  display: flex;
  align-items: center;
  gap: 0.571em;
  padding: 0.429em 0.571em;
  border: 1px solid var(--ui-line-soft);
  border-radius: 0.286em;
  color: var(--ui-700);
}

.ui-dest.is-checked {
  border-color: var(--blue-300);
  background: var(--blue-50);
}

.ui-dest__name {
  flex: 1;
}

.ui-dest__tag {
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: #efedff;
  color: #5a3da9;
  font-size: 0.75em;
  font-weight: 500;
  line-height: 1.5;
}

.ui-dest__box {
  position: relative;
  display: grid;
  width: 1.143em;
  height: 1.143em;
  font-size: 1.143em;
}

.ui-dest__box svg {
  grid-area: 1 / 1;
}

.ui-dest__on {
  color: var(--blue-800);
  opacity: 0;
}

.ui-dest.is-checked .ui-dest__on {
  opacity: 1;
}

.ui-dest.is-checked .ui-dest__off {
  opacity: 0;
}

/* Filter criteria */
.ui-criteria {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-criteria li {
  line-height: 1.43;
}

.ui-criteria b {
  font-weight: 500;
}

.ui-criteria .op {
  color: var(--ui-300);
}

.ui-criteria i {
  font-style: italic;
}

.ui-criteria .join {
  color: var(--ui-300);
  font-weight: 500;
}

.ui-criteria .nested {
  padding-left: 2.6em;
}

/* Distribution bars */
.ui-bars {
  display: flex;
  flex-direction: column;
  gap: 0.143em;
  padding: 0.286em;
  border: 1px solid var(--ui-line);
  border-radius: 0.571em;
}

.ui-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 4em 2.6em 0.5em;
  align-items: center;
  gap: 0.286em;
  height: 2.286em;
  padding: 0 0.143em 0 0.43em;
  color: var(--ui-700);
}

.ui-bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0.286em 0 0 0.286em;
  background: rgba(51, 102, 255, 0.1);
  transform-origin: left center;
}

.ui-bar > span:not(.ui-bar__fill) {
  position: relative;
}

.ui-bar__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-bar__share,
.ui-bar__rate {
  text-align: right;
}

.ui-conf {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.143em;
}

.ui-conf i {
  width: 0.214em;
  height: 0.214em;
  background: var(--ui-line);
}

.ui-conf.is-high i { background: #25ae80; }
.ui-conf.is-medium i:nth-child(-n + 2) { background: #4da6ff; }
.ui-conf.is-low i:first-child { background: var(--orange); }

/* Metrics */
.ui-metric {
  display: flex;
  flex: 1;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.571em;
  min-width: 0;
  padding: 0.857em 1.143em;
  border: 1px solid var(--ui-line);
  border-radius: 0.571em;
  background: #fff;
  white-space: nowrap;
}

.ui-metric strong {
  display: block;
  font-size: 1.286em;
  font-weight: 500;
  line-height: 1.33;
}

.ui-metric__detail {
  display: flex;
  flex-direction: column;
  gap: 0.43em;
  padding: 0.2em 0;
  color: var(--ui-300);
  font-size: 0.714em;
  line-height: 1.2;
}

.ui-metric__detail b {
  color: var(--ui-900);
  font-size: 1.2em;
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  .p26-demo__layer {
    will-change: auto;
  }
}

/* Screen-reader-only text (descriptions). Each code component renders in its
   own shadow root, so this must live in every component's stylesheet. */
.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;
}

/*
 * Plan demo layout. Default positions are the FINISHED composition:
 * builder (back left), research shrunk to the top right, estimate in front.
 * The timeline animates from the opening state back to this.
 */
.plan-chat {
  left: 4%;
  top: 5%;
  width: 60%;
  /* Hidden in the finished composition; the timeline brings it in first. */
  opacity: 0;
  visibility: hidden;
}

.plan-chat .ui-artifact {
  transform-origin: left center;
}

.plan-research {
  right: 3%;
  top: 4%;
  width: 62%;
  transform: scale(0.72);
  transform-origin: top right;
  z-index: 2;
}

.plan-research .ui-panel__body {
  display: flex;
  flex-direction: column;
  gap: 0.857em;
}

.plan-research__source {
  display: flex;
  align-items: center;
  gap: 0.286em;
}

.plan-ads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.571em;
}

.plan-ad {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5em;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  padding: 0.75em;
  border: 1px solid var(--ui-line);
  border-radius: 0.286em;
  color: #fff;
}

.plan-ad img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plan-ad.tone-a { background: linear-gradient(150deg, #262155, #3c327b 70%, #5a3da9); }
.plan-ad.tone-b { background: linear-gradient(150deg, #ffd966, #ffaa45); color: #20292c; }
.plan-ad.tone-c { background: linear-gradient(150deg, #2f55cd, #4da6ff); }

.plan-ad__brand {
  font-size: 0.75em;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.plan-ad__headline {
  font-family: var(--p26-font-display, EightiesComeback), Georgia, serif;
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.12;
}


.plan-builder {
  left: 3%;
  top: 5%;
  width: 50%;
  z-index: 1;
}

.plan-builder .ui-panel__body {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.plan-estimate {
  right: 2%;
  bottom: -16%;
  width: 44%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.857em;
  padding: 1em;
  box-shadow: 0 1px 2px rgba(32, 41, 44, 0.08), 0 24px 48px -16px rgba(38, 33, 85, 0.35);
}

.plan-match {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1.2em;
  padding-bottom: 0.857em;
  border-bottom: 1px solid var(--ui-line);
}

.plan-match__item {
  display: inline-flex;
  align-items: center;
  gap: 0.286em;
  white-space: nowrap;
}

.plan-match__item b {
  font-weight: 500;
}

.plan-estimate__metrics {
  display: flex;
  gap: 0.571em;
}

.plan-estimate__head {
  display: flex;
  justify-content: space-between;
  padding: 0 3.6em 0.4em 0;
  color: var(--ui-700);
  font-size: 0.857em;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

/* Narrow cards (phones, stacked tablet): a taller crop that stacks the story. */
@container (max-width: 479px) {
  .p26-demo--plan .p26-demo__stage {
    aspect-ratio: 4 / 5;
    font-size: clamp(10px, 3cqw, 12.5px);
  }

  .plan-chat {
    left: 5%;
    width: 90%;
  }

  /* Shown during research only; not part of the narrow finished composition. */
  .plan-research {
    right: 5%;
    top: 4%;
    width: 90%;
    transform: none;
    opacity: 0;
    visibility: hidden;
  }

  .plan-ads {
    grid-template-columns: repeat(2, 1fr);
  }

  .plan-ad:nth-child(3) {
    display: none;
  }

  .plan-builder {
    left: 5%;
    top: 4%;
    width: 90%;
  }

  .plan-dests {
    display: none;
  }

  .plan-estimate {
    right: 5%;
    bottom: -10%;
    width: 84%;
  }

  .plan-estimate .ui-bar:nth-child(n + 4) {
    display: none;
  }
}

