@import "./runtime-primitives-deploy.css";

@font-face {
  font-family: "Alternate Gothic No3";
  src: url("./fonts/AlternateGotNo3D.ttf") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: normal;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.runtime-app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
}

/* City mode keeps these four HUD anchors until product direction changes: logo, cell telemetry, Agent Chat, and bottom controls. */
.runtime-app.is-city-only > :not(.runtime-world):not(.runtime-loading):not(#projectFolderInput):not(.cn-shell-brand):not(.runtime-telemetry):not(.runtime-inspector):not(.runtime-toolbar) {
  display: none;
}

.runtime-project-folder {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 220px;
  padding: 0;
  border: 0;
  color: var(--color-text-dim);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.runtime-project-folder:hover,
.runtime-project-folder:focus-visible {
  color: var(--color-text);
}

.runtime-project-folder:focus-visible {
  outline: 1px solid var(--color-border-active);
  outline-offset: 3px;
}

.runtime-project-folder-icon {
  flex: 0 0 auto;
  color: var(--color-border-active);
  font-size: 13px;
  line-height: 1;
  transform: translateY(-1px);
}

.runtime-project-folder #projectSubtitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-telemetry {
  top: 94px;
}

.runtime-world {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(rgb(84 68 52 / 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgb(84 68 52 / 0.1) 1px, transparent 1px),
    var(--color-bg);
  background-size: 64px 64px;
}

#worldCanvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.runtime-zone-signage {
  position: absolute;
  z-index: var(--z-world-labels);
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.world-plaque {
  --plaque-color: var(--color-border-active);
  --plaque-rgb: 190 150 92;
  position: relative;
  display: grid;
  align-content: center;
  min-width: 0;
  border: 1px solid var(--plaque-color);
  border-radius: var(--radius-panel);
  color: var(--plaque-color);
  text-align: center;
  background:
    linear-gradient(180deg, rgb(var(--plaque-rgb) / 0.22), rgb(var(--plaque-rgb) / 0.08)),
    rgb(8 7 5 / 0.9);
  box-shadow:
    inset 0 0 0 1px rgb(var(--plaque-rgb) / 0.24),
    inset 0 -14px 22px rgb(var(--plaque-rgb) / 0.08),
    0 0 12px rgb(var(--plaque-rgb) / 0.12);
  backdrop-filter: blur(1.5px);
}

.world-plaque::before,
.world-plaque::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 4px;
}

.world-plaque::before {
  inset: 6px;
  background:
    radial-gradient(circle at 0 0, rgb(var(--plaque-rgb) / 0.55) 0 2px, transparent 3px),
    radial-gradient(circle at 100% 0, rgb(var(--plaque-rgb) / 0.55) 0 2px, transparent 3px),
    radial-gradient(circle at 0 100%, rgb(var(--plaque-rgb) / 0.55) 0 2px, transparent 3px),
    radial-gradient(circle at 100% 100%, rgb(var(--plaque-rgb) / 0.55) 0 2px, transparent 3px);
}

.world-plaque::after {
  inset: 4px;
  border: 1px solid rgb(var(--plaque-rgb) / 0.18);
}

.world-plaque strong {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  color: var(--plaque-color);
  font-family: var(--font-mono);
  font-size: var(--type-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: var(--line-label);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.signage-plaque {
  position: absolute;
  top: 0;
  left: 0;
  width: max-content;
  max-width: 100%;
  min-height: 34px;
  padding: 7px 12px;
  will-change: transform;
}

.runtime-onboarding {
  position: absolute;
  z-index: var(--z-modal);
  inset: 0;
  display: grid;
  place-items: center;
  padding: 96px 392px 96px 24px;
  background: rgb(0 0 0 / 0.38);
  backdrop-filter: blur(2px);
}

.runtime-onboarding[hidden] {
  display: none;
}

.runtime-onboarding-panel {
  display: grid;
  gap: var(--space-6);
  width: min(100%, 560px);
  padding: var(--space-6);
  border: var(--border-default);
  border-radius: var(--radius-shell);
  background: linear-gradient(180deg, rgb(var(--color-panel-rgb) / 0.97), rgb(14 12 10 / 0.96));
  box-shadow: var(--shadow-shell);
}

.runtime-onboarding-heading {
  display: grid;
  gap: var(--space-2);
}

.runtime-onboarding-heading h1 {
  margin: 0;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: normal;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.runtime-onboarding-actions {
  display: grid;
  gap: var(--space-3);
}

.runtime-start-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  min-height: 88px;
  padding: var(--space-3);
  border: var(--border-default);
  border-radius: var(--radius-panel);
  color: var(--color-text);
  text-align: left;
  background: rgb(var(--color-surface-rgb) / 0.72);
}

.runtime-start-card:hover,
.runtime-start-card:focus-visible {
  border-color: var(--color-ember);
  outline: none;
}

.runtime-start-card.is-new {
  border-color: var(--color-border);
  background: rgb(var(--color-surface-rgb) / 0.72);
}

.runtime-start-card.is-load {
  border-color: var(--color-border);
  color: var(--color-text);
  background: rgb(var(--color-surface-rgb) / 0.72);
}

.runtime-start-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid currentColor;
  border-radius: var(--radius-panel);
  font-size: 24px;
}

.runtime-start-card span:last-child {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.runtime-start-card strong {
  font-family: var(--font-heading);
  font-size: var(--type-h3);
  font-weight: normal;
  letter-spacing: 0.04em;
  line-height: var(--line-h3);
  text-transform: uppercase;
}

.runtime-start-card small {
  overflow: hidden;
  font-size: var(--type-ui-compact);
  line-height: var(--line-ui-compact);
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}

.runtime-inspector {
  bottom: 76px;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.runtime-inspector.is-collapsed {
  top: var(--space-4);
  bottom: auto;
  width: 70px;
  height: 70px;
  padding: var(--space-3);
}

.runtime-inspector.is-collapsed .runtime-chat-log,
.runtime-inspector.is-collapsed .runtime-chat-identity,
.runtime-inspector.is-collapsed #chatInput,
.runtime-inspector.is-collapsed #sendTask {
  display: none;
}

.runtime-inspector.is-collapsed .runtime-pane {
  display: none;
}

.runtime-inspector.is-collapsed .runtime-chat-header {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
  padding-bottom: 0;
  border-bottom: 0;
}

.runtime-inspector.is-collapsed .runtime-chat-label {
  display: none;
}

.runtime-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-touch);
  padding-bottom: var(--space-3);
}

.runtime-chat-label {
  min-width: 0;
}

#collapseInspector {
  flex: 0 0 auto;
}

.runtime-chat-identity {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.runtime-chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  overflow: visible;
}

.runtime-chat-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.runtime-chat-identity > div:last-child {
  display: grid;
  gap: 2px;
}

.runtime-chat-name-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}

.runtime-chat-name-row .cn-panel-title {
  flex: 0 0 auto;
}

.runtime-lian-dynamic {
  display: block;
  width: fit-content;
  max-width: 230px;
  margin-top: 3px;
}

.runtime-chat-role {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-dim);
  font-family: var(--font-mono);
  font-size: var(--type-label);
  line-height: var(--line-label);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-chat-prompt {
  display: block;
  max-width: 230px;
  overflow: hidden;
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: var(--type-ui-compact);
  line-height: var(--line-ui-compact);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-chat-prompt.is-changing {
  animation: lian-quote-change 520ms ease-out;
}

.runtime-chat-prompt[hidden] {
  display: none;
}

.runtime-lian-status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  max-width: 230px;
  overflow: hidden;
  color: var(--color-text-dim);
  font-family: var(--font-mono);
  font-size: var(--type-label);
  line-height: var(--line-label);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runtime-lian-status > span:first-child {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-jade);
  box-shadow: 0 0 8px var(--color-jade);
}

.runtime-lian-status > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.runtime-lian-status[hidden] {
  display: none;
}

.runtime-lian-action {
  display: block;
}

.runtime-lian-action[hidden] {
  display: none;
}

.runtime-lian-action strong {
  display: none;
}

.runtime-lian-action > span {
  display: none;
}

.runtime-lian-action > div {
  display: flex;
  align-items: center;
  gap: 4px;
}

.runtime-lian-dynamic .runtime-approval-button {
  width: 24px;
  min-width: 24px;
  min-height: 22px;
  height: 22px;
  padding: 0;
}

.runtime-lian-dynamic .runtime-deny-button {
  width: 24px;
  height: 22px;
  min-height: 22px;
  color: var(--color-danger);
}

.runtime-lian-quick-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.runtime-lian-quick-actions[hidden] {
  display: none;
}

.runtime-lian-dynamic .runtime-lian-quick-button {
  min-height: 22px;
  height: 22px;
  padding: 1px 7px;
  font-size: var(--type-label);
  line-height: var(--line-label);
}

.runtime-pane {
  min-height: 0;
  overflow: hidden;
}

.runtime-stack {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  gap: 0;
}

.runtime-chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  padding-top: var(--space-3);
  border-bottom: 0;
  overflow: auto;
}

.runtime-chat-log:empty::before {
  content: "Start a conversation with Lian.";
  margin: auto;
  color: var(--color-text-dim);
  font-size: var(--type-ui-compact);
  line-height: var(--line-ui-compact);
  text-align: center;
}

.runtime-message {
  display: grid;
  gap: var(--space-1);
  max-width: 92%;
  padding: var(--space-2) var(--space-3);
  border: var(--border-default);
  border-radius: var(--radius-panel);
  color: var(--color-text);
  background: rgb(var(--color-surface-rgb) / 0.55);
  font-size: var(--type-ui-compact);
  line-height: var(--line-ui-compact);
  animation: runtime-message-enter 420ms ease-out both;
}

.runtime-message.is-user {
  align-self: flex-end;
  border-color: var(--color-border-active);
  color: var(--color-text);
  background: rgb(var(--color-surface-rgb) / 0.94);
}

.runtime-message.is-lian {
  color: var(--color-text);
}

.runtime-message.is-lian .runtime-message-label {
  color: var(--color-text);
}

.runtime-message-title {
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.runtime-message-copy {
  display: block;
  color: var(--color-text);
}

.runtime-message.is-lian .runtime-message-copy {
  color: var(--color-text);
}

.runtime-message-list {
  display: grid;
  gap: 4px;
  margin: var(--space-1) 0 0;
  padding: 0 0 0 16px;
  color: var(--color-text);
}

.runtime-message-list li::marker {
  color: currentColor;
}

.runtime-message-section-title,
.runtime-message-action-text {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text);
}

.runtime-message-section-title {
  font-size: 13px;
  font-weight: 700;
}

.runtime-message-link {
  width: fit-content;
  color: var(--color-ember);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.runtime-message-link:hover,
.runtime-message-link:focus-visible {
  color: var(--color-text);
}

.signage-plaque.is-linked-focus {
  animation: linked-zone-focus 1.8s ease-out both;
}

@keyframes linked-zone-focus {
  0%,
  100% {
    filter: none;
  }
  25%,
  65% {
    filter: drop-shadow(0 0 14px rgb(var(--plaque-rgb) / 0.95));
  }
}

@keyframes runtime-message-enter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lian-quote-change {
  from {
    opacity: 0.25;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .runtime-message,
  .runtime-chat-prompt.is-changing {
    animation: none;
  }

  .runtime-chat-log {
    scroll-behavior: auto;
  }
}

.runtime-message.is-system {
  align-self: center;
  border-style: dashed;
  color: var(--color-text);
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--type-label);
  line-height: var(--line-label);
}

.runtime-message-label {
  display: block;
  margin-bottom: 0;
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: var(--type-label);
  font-weight: 600;
  line-height: var(--line-label);
  text-transform: uppercase;
}

.runtime-message.is-researcher .runtime-message-label {
  color: var(--color-cyan);
}

.runtime-message.is-coder .runtime-message-label {
  color: var(--color-jade);
}

.runtime-message.is-planner .runtime-message-label {
  color: var(--color-danger);
}

.runtime-chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 0 !important;
}

.runtime-chat-compose textarea {
  min-height: 64px;
  padding: var(--space-2);
  resize: none;
}

.runtime-send-button {
  width: var(--control-touch);
  min-width: var(--control-touch);
  height: var(--control-touch);
  min-height: var(--control-touch);
  border-color: var(--color-ember);
  color: var(--color-cta-text);
  background: var(--color-ember);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.runtime-send-button:hover,
.runtime-send-button:focus-visible {
  border-color: var(--color-ember);
  color: var(--color-cta-text);
  background: var(--color-ember);
  box-shadow: var(--focus-ring);
}

.runtime-chat-footer {
  margin: 0 calc(var(--space-3) * -1) calc(var(--space-3) * -1);
  border-top: 0 !important;
  background: transparent;
}

.runtime-chat-footer .runtime-chat-identity {
  min-height: 72px;
  padding: var(--space-2) var(--space-3);
}

.runtime-inspector.is-collapsed .runtime-chat-footer {
  display: none;
}

.runtime-toolbar {
  justify-content: space-between;
}

.runtime-toolbar-section,
.runtime-map-controls,
.runtime-status-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.runtime-toolbar .cn-button,
.runtime-toolbar .cn-icon-button {
  min-height: var(--control-primary);
  height: var(--control-primary);
}

.runtime-toolbar .cn-button {
  min-width: 88px;
  padding: 0 var(--space-3);
}

.runtime-zoom-readout,
.runtime-status-line {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--type-code);
  line-height: var(--line-code);
}

.runtime-status-line {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.runtime-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-jade);
  box-shadow: 0 0 10px var(--color-jade);
}

#cellMetric {
  color: var(--color-text-dim);
}

.runtime-save-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.runtime-loading {
  position: absolute;
  z-index: calc(var(--z-modal) + 1);
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.52);
}

.runtime-loading[hidden] {
  display: none;
}

.runtime-loading span {
  padding: var(--space-3) var(--space-5);
  border: var(--border-default);
  border-radius: var(--radius-panel);
  color: var(--color-text);
  background: var(--color-panel);
  font-family: var(--font-heading);
  font-size: var(--type-h4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .runtime-onboarding {
    padding-right: 24px;
  }

  .runtime-status-line {
    display: none;
  }
}

@media (max-width: 760px) {
  .runtime-telemetry {
    display: grid;
    top: 92px;
    left: 10px;
    width: 220px;
  }

  .runtime-inspector {
    top: 258px;
    bottom: 132px;
  }

  .runtime-inspector.is-collapsed {
    top: 258px;
  }
}
