@layer ui-sdk;

@font-face {
  font-family: Inter;
  src: url("./fonts/inter-latin.woff") format("woff");
  font-style: normal;
  font-weight: 460;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #0a0a0a;
  --text: #eeedf1;
  --muted: #adabb3;
  --stroke: #2c2a30;
  --control: #171717;
  --hover-border: #4d4955;
  --card: #0e0f11;
  --card-border: #191a1b;
  --card-hover: #201e25;
  --preview-panel: #0f0f0f;
  --preview-border: #2c2735;
  --preview-shadow: 0 24px 44px -15px rgb(0 0 0 / 82%);
  --orb-color: #ffffff;
  --focus: color-mix(in srgb, var(--orb-color) 48%, white);
  --orb-selection-border: color-mix(in srgb, var(--orb-color) 40%, #55525c);
  --orb-selection-background: color-mix(in srgb, var(--orb-color) 13%, #18171b);
  --orb-selection-text: color-mix(in srgb, var(--orb-color) 45%, white);
  font: 460 15px/1.4 Inter, system-ui, sans-serif;
}

:root[data-green-palette] {
  --focus: #8df5a3;
  --orb-selection-border: #4f875c;
  --orb-selection-background: #19291e;
  --orb-selection-text: #a4f9b5;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: start center;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background-color: var(--background);
}

#signal-app { display: contents; }

.pointer-field {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.demo,
.site-footer__inner {
  width: min(100% - 64px, 880px);
}

.demo {
  position: relative;
  z-index: 1;
  padding-block: 24px clamp(26px, 6vh, 72px);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--stroke);
}

.top-bar__nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-bar__nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding-inline: 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.top-bar__nav a:hover { color: var(--text); }

.top-bar__nav a[aria-current] {
  border-color: var(--stroke);
  background: var(--control);
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.site-title {
  --brand-mark-size: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: clamp(18px, 2.6vw, 22px);
  font-weight: 460;
  letter-spacing: -0.038em;
}

.brand-mark {
  flex: none;
  width: var(--brand-mark-size, 25px);
  height: var(--brand-mark-size, 25px);
  background: radial-gradient(circle at center, currentColor 1.05px, transparent 1.35px) center / 5px 5px;
  mask-image: radial-gradient(circle closest-side at 49% 47%, #000 66%, #000a 81%, transparent 100%);
}

.color-controls {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 12px;
  padding-block: clamp(18px, 3vh, 30px);
}

.preview-chat,
.preview-orb {
  min-width: 0;
  border: 1px solid var(--preview-border);
  border-radius: 16px;
  box-shadow: var(--preview-shadow);
}

.preview-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
}

.preview-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding-inline: clamp(14px, 3vw, 22px);
  border-bottom: 1px solid var(--stroke);
  background: var(--preview-panel);
}

.preview-chat__name { font-size: 14px; }
.preview-chat__hint { color: var(--muted); font-size: 12px; }

.preview-chat__thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 198px;
  padding: 16px clamp(14px, 3vw, 22px) 14px;
}

.preview-chat__message {
  align-self: flex-end;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--stroke);
  border-radius: 13px 13px 4px 13px;
  background: var(--control);
  font-size: 14px;
  line-height: 1.5;
}

.preview-chat__activity {
  --shimmer-position: 0%;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-left: -4px;
}

.preview-chat__reply {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 96px;
}

.preview-chat__answer {
  max-width: 41ch;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.thinking__orb {
  display: block;
  flex: none;
  width: 48px;
  height: 48px;
}

.preview-orb {
  --shimmer-position: 0%;
  --orb-size: clamp(116px, 16vw, 136px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 204px;
  padding: 12px 16px 18px;
  background: var(--preview-panel);
}

.preview-orb .thinking__orb {
  width: var(--orb-size);
  height: var(--orb-size);
}

.thinking__text {
  --orb-text-base: color-mix(in srgb, var(--orb-color) 23%, #9a97a0);
  --orb-shimmer-glow: color-mix(in srgb, var(--orb-color) 82%, white);
  --orb-shimmer-start: color-mix(in srgb, var(--orb-color) 18%, white);
  --orb-shimmer-mid: color-mix(in srgb, var(--orb-color) 46%, white);
  --orb-shimmer-end: color-mix(in srgb, var(--orb-color) 24%, white);
  --light-width: 52%;
  --light-crest: 2%;
  position: relative;
  isolation: isolate;
  width: max-content;
  color: var(--orb-text-base);
  font-size: clamp(26px, 7.1vw, 50px);
  line-height: 1.12;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.preview-orb .thinking__text {
  font-size: clamp(28px, 3.9vw, 38px);
  text-align: center;
}

:root[data-green-palette] .preview-orb .thinking__text,
.editor-artboard[data-green-palette] .thinking__text {
  --orb-text-base: #849489;
  --orb-shimmer-glow: #54eb78;
  --orb-shimmer-start: #e5ffe9;
  --orb-shimmer-mid: #a7ffb8;
  --orb-shimmer-end: #ddffe5;
}

.editor-artboard[data-background="light"] .thinking__text {
  --orb-text-base: color-mix(in srgb, var(--orb-color) 19%, #3e4941);
  --orb-shimmer-glow: color-mix(in srgb, var(--orb-color) 88%, #526860);
  --orb-shimmer-start: color-mix(in srgb, var(--orb-color) 42%, #173f27);
  --orb-shimmer-mid: color-mix(in srgb, var(--orb-color) 43%, #091d13);
  --orb-shimmer-end: color-mix(in srgb, var(--orb-color) 36%, #143825);
}

.preview-chat__activity .thinking__text {
  --orb-shimmer-start: var(--text);
  --orb-shimmer-mid: var(--text);
  --orb-shimmer-end: var(--text);
  color: var(--muted);
  font-size: 15px;
  letter-spacing: -0.012em;
}

.thinking__text::before,
.thinking__text::after {
  position: absolute;
  inset: 0 0 -0.22em;
  background-clip: text;
  color: transparent;
  content: attr(data-label);
}

.thinking__text::before {
  z-index: -1;
  background-image: linear-gradient(90deg,
    transparent calc(var(--shimmer-position) - var(--light-width)),
    var(--orb-shimmer-glow) var(--shimmer-position),
    transparent calc(var(--shimmer-position) + var(--light-width)));
  filter: blur(0.15em);
  opacity: 0.73;
}

.thinking__text::after {
  background-image: linear-gradient(var(--orb-shimmer-start) 8%, var(--orb-shimmer-mid) 55%, var(--orb-shimmer-end) 93%);
  mask-image: linear-gradient(90deg,
    transparent calc(var(--shimmer-position) - var(--light-width)),
    #000 calc(var(--shimmer-position) - var(--light-crest)),
    #000 calc(var(--shimmer-position) + var(--light-crest)),
    transparent calc(var(--shimmer-position) + var(--light-width)));
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.state {
  --thumb-size: 44px;
  position: relative;
  display: grid;
  grid-template-columns: var(--thumb-size) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 7px 12px;
  border: 1px solid var(--card-border);
  border-radius: 13px;
  background-color: var(--card);
  color: var(--muted);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}

.state__preview,
.state__preview canvas {
  display: block;
  width: var(--thumb-size);
  height: var(--thumb-size);
}

.state[data-checked] {
  border-color: var(--orb-selection-border);
  background-color: var(--orb-selection-background);
  color: var(--orb-selection-text);
}

.state:focus-visible,
.top-bar__nav a:focus-visible,
.site-footer a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  border-top: 1px solid var(--card-border);
  background-color: var(--background);
}

.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) repeat(2, minmax(96px, 0.65fr));
  align-items: start;
  gap: clamp(24px, 6vw, 72px);
  margin-inline: auto;
  padding-block: clamp(42px, 6vw, 72px);
}

.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 17px;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.site-footer__identity p {
  max-width: 30ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.site-footer__group h2 {
  margin: 3px 0 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 460;
}

.site-footer__group ul {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__group a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  text-underline-offset: 4px;
}

.site-footer__group a:is(:hover, :focus-visible) {
  color: var(--text);
  text-decoration: underline;
}

@media (hover: hover) and (pointer: fine) {
  .state:not([data-checked]):hover {
    border-color: var(--hover-border);
    background-color: var(--card-hover);
    color: var(--text);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .state-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .top-bar { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding-bottom: 10px; }
  .top-bar__nav { grid-column: 1 / -1; grid-row: 2; }
  .top-bar .color-controls { grid-column: 2; grid-row: 1; }
}

@media (max-width: 620px) {
  .demo, .site-footer__inner { width: calc(100% - 32px); }
  .demo { padding-block: 16px 28px; }
  .site-footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 20px; }
  .site-footer__identity { grid-column: 1 / -1; }
  .stage { display: contents; }
  .preview-chat { margin-block: 12px; box-shadow: none; }
  .preview-orb {
    position: sticky;
    top: 12px;
    z-index: 1;
    min-height: 176px;
    margin-block-end: 12px;
    box-shadow: 0 0 0 12px var(--background);
  }
  .preview-chat__thread { min-height: 188px; padding-block: 12px 8px; }
  .state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .state {
    --thumb-size: 34px;
    min-height: 62px;
    gap: 7px;
    padding-inline: 8px;
    font-size: clamp(13px, 3.6vw, 14px);
  }
  .state__name { letter-spacing: -0.018em; }
  .state { scroll-margin-top: 220px; }
}

@media (max-width: 420px) {
  .color-controls__label { display: none; }
}

@media (max-width: 620px) and (max-height: 460px) {
  .preview-orb { position: static; box-shadow: none; }
  .state { scroll-margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pointer-field { display: none; }
  .state { transition: none; }
}
