/**
 * Production Canvas V5 host chrome (Excalidraw single scene).
 * Node card styles live in tent-embeddable-prototype.css (shared with prototype).
 */

.tn-canvas-v5-host {
  position: relative;
  container-type: inline-size;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--tn-color-stage-bg);
}

.tn-canvas-v5-host__scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tn-canvas-v5-host__scene .excalidraw,
.tn-canvas-v5-host__scene .excalidraw-container {
  width: 100%;
  height: 100%;
}

.tn-canvas-subtree-lines {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.tn-canvas-subtree-lines__path {
  fill: none;
  stroke: color-mix(in srgb, var(--tn-color-text-faint) 42%, var(--tn-color-stage-bg));
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: none;
}

/* Composite the complete base tree once so sibling paths can share their
   short trunk without darkening it where identical segments overlap. */
.tn-canvas-subtree-lines__base {
  opacity: .34;
}

.tn-canvas-subtree-lines__highlights {
  opacity: .88;
}

.tn-canvas-subtree-lines__path--highlight {
  stroke: color-mix(in srgb, var(--tn-color-text-secondary) 82%, var(--tn-color-stage-bg));
  stroke-width: 1.25;
  stroke-dasharray: none;
}

.tn-canvas-subtree-controls,
.tn-canvas-placement-actions {
  position: absolute;
  z-index: 34;
  pointer-events: none;
}

.tn-canvas-subtree-controls,
.tn-canvas-placement-actions {
  opacity: 0;
  transition: opacity var(--tn-motion-duration-fast) var(--tn-motion-ease-out);
}

.tn-canvas-subtree-controls[data-interactive="true"],
.tn-canvas-placement-actions[data-interactive="true"] {
  opacity: 1;
}

.tn-canvas-subtree-controls__button,
.tn-canvas-subtree-controls__menu-button,
.tn-canvas-placement-actions .tn-ui-icon-btn {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-color: color-mix(in srgb, var(--tn-color-border) 78%, transparent);
  background: color-mix(in srgb, var(--tn-color-elevated-bg) 94%, transparent);
  box-shadow: none;
  pointer-events: none;
}

.tn-canvas-subtree-controls[data-interactive="true"] .tn-canvas-subtree-controls__button,
.tn-canvas-placement-actions[data-interactive="true"] .tn-ui-icon-btn {
  pointer-events: auto;
}

.tn-canvas-subtree-controls__button,
.tn-canvas-placement-actions .tn-ui-icon-btn {
  position: absolute;
}

.tn-canvas-subtree-controls__button[data-direction="up"] {
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tn-canvas-subtree-controls__button[data-direction="right"] {
  top: 50%;
  right: 0;
  transform: translate(50%, -50%);
}

.tn-canvas-subtree-controls__button[data-direction="down"] {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
}

.tn-canvas-subtree-controls__button[data-direction="left"] {
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
}

.tn-canvas-subtree-controls__pending {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  min-width: 16px;
  padding: 2px 4px;
  border: 1px solid var(--tn-color-border);
  border-radius: var(--tn-radius-sm);
  background: var(--tn-color-elevated-bg);
  color: var(--tn-color-text-secondary);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
  transform: translateX(-50%);
}

.tn-canvas-placement-actions .tn-ui-icon-btn {
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
}

/* Default Excalidraw embeddable hint covers Tent cards — hide it; card footer carries the cue. */
.tn-canvas-v5-host__scene .excalidraw__embeddable-hint {
  display: none !important;
}

/* The shell already names the single Canvas; keep Excalidraw's toolbar free of onboarding copy. */
.tn-canvas-v5-host__scene .welcome-screen-decor-hint--toolbar,
.tn-canvas-v5-host__scene .HintViewer {
  display: none !important;
}

.tn-canvas-node-preview {
  position: absolute;
  z-index: 35;
  display: grid;
  width: 236px;
  max-height: 126px;
  gap: 6px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid var(--tn-color-border-strong);
  border-radius: var(--tn-radius-md);
  background: color-mix(in srgb, var(--tn-color-elevated-bg) 96%, transparent);
  box-shadow: var(--tn-shadow-float);
  color: var(--tn-color-text-primary);
  pointer-events: none;
}

.tn-canvas-node-preview > span {
  color: var(--tn-color-text-faint);
  font-size: 10px;
}

.tn-canvas-node-preview > strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-canvas-node-preview > p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--tn-color-text-secondary);
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* Tent Node commands live in Focus. Excalidraw's generic shape styling remains
 * available for user drawings, but must not become a second Node inspector. */
.tn-canvas-v5-host[data-tent-node-focused="true"]
  .selected-shape-actions {
  display: none !important;
}

.tn-canvas-v5-host__chrome {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.tn-canvas-v5-host__projection-sync {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 26px;
  padding: 1px 3px;
  border: 1px solid transparent;
  border-radius: var(--tn-radius-sm);
  background: color-mix(in srgb, var(--tn-color-chrome-bg) 82%, transparent);
  color: var(--tn-color-text-secondary);
  backdrop-filter: blur(10px);
}

.tn-canvas-v5-host__projection-sync[data-state="pending"] {
  border-style: dashed;
  border-color: var(--tn-color-border-strong);
  color: var(--tn-color-text-primary);
}

.tn-canvas-v5-host__projection-sync > span {
  min-width: 14px;
  padding-right: 3px;
  font-size: 10px;
  text-align: center;
}

.tn-canvas-v5-host__settings {
  position: relative;
}

.tn-canvas-v5-host__settings > button {
  min-height: 30px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--tn-radius-sm);
  background: color-mix(
    in srgb,
    var(--tn-color-chrome-bg) 82%,
    transparent
  );
  color: var(--tn-color-text-primary);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: none;
  backdrop-filter: blur(10px);
}

.tn-canvas-v5-host__settings > button:hover,
.tn-canvas-v5-host__settings > button[aria-expanded="true"] {
  border-color: var(--tn-color-border);
  background: var(--tn-color-elevated-bg);
}

.tn-canvas-v5-host__settings-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 210px;
  max-width: calc(100cqw - 20px);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--tn-color-border);
  border-radius: var(--tn-radius-md);
  background: var(--tn-color-elevated-bg);
  box-shadow: var(--tn-shadow-float);
}

.tn-canvas-v5-host__settings-popover fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

.tn-canvas-v5-host__settings-popover legend {
  margin-bottom: 4px;
  color: var(--tn-color-text-secondary);
  font-size: 11px;
}

.tn-canvas-v5-host__hidden-list {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--tn-color-border);
}

.tn-canvas-v5-host__hidden-list > span {
  color: var(--tn-color-text-secondary);
  font-size: 11px;
}

.tn-canvas-v5-host__hidden-list .tn-ui-btn {
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-canvas-v5-host__banner {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 45;
  max-width: min(420px, calc(100% - 140px));
  padding: 8px 10px;
  border: 1px solid var(--tn-color-warning-border);
  border-radius: 6px;
  background: var(--tn-color-warning-soft);
  color: var(--tn-color-warning);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: auto;
}

.tn-canvas-v5-host__banner[data-kind="error"] {
  border-color: var(--tn-color-danger-border);
  background: var(--tn-color-danger-soft);
  color: var(--tn-color-danger);
}

@container (max-width: 420px) {
  .tn-canvas-v5-host__chrome {
    top: 58px;
  }

  .tn-canvas-v5-host__settings-popover {
    min-width: min(210px, calc(100cqw - 20px));
  }

  .tn-canvas-v5-host__banner {
    right: 10px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tn-canvas-v5-host * {
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
  }
}
