/* ==========================================================
   canvas.css — prefix: .cv-*
   Canvas shell: header, tray, toolbox, viewport, dot-grid,
   zoom controls, module chips, connections layer.
   Scoped to :root for the prototype.
   In Phalcon: vars move to .cv-shell scope.
   ========================================================== */

:root {
  --cv-brand:           #8a1724;
  --cv-brand-soft:      #c6b67e;
  --cv-brand-soft-tint: #ede5cf;
  --cv-bg:              #faf8f4;
  --cv-surface:         #ffffff;
  --cv-surface-soft:    #f4f1ea;
  --cv-ink:             #1f1d1a;
  --cv-ink-soft:        #5a5550;
  --cv-ink-faint:       #9c9690;
  --cv-line:            #e8e2d6;
  --cv-line-strong:     #d4ccba;
  --cv-ok:              #4a7c59;
  --cv-warn:            #d4922a;

  --cv-shadow-sm:       0 1px 2px rgba(31,29,26,0.04), 0 2px 8px rgba(31,29,26,0.04);
  --cv-shadow-md:       0 2px 4px rgba(31,29,26,0.04), 0 8px 24px rgba(31,29,26,0.06);
  --cv-shadow-lg:       0 4px 8px rgba(31,29,26,0.06), 0 16px 40px rgba(31,29,26,0.1);
  --cv-shadow-brand:    0 4px 16px rgba(138,23,36,0.15);

  --cv-r-sm:  8px;
  --cv-r-md:  14px;
  --cv-r-lg:  20px;
  --cv-r-xl:  28px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* NOTE (embedding edit, CANVAS_DEMO_SPEC §6): the prototype owned the whole
   html/body as a full-page app. Embedded inside the marketing page, those
   rules would kill the page's own scroll and paint a fixed overlay across
   the whole site — so they're scoped to the frame that hosts the canvas
   (.fd-canvas-frame, see demo.css) instead of html/body. */
.fd-canvas-frame {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--cv-ink);
  background: var(--cv-bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

.fd-canvas-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at top right, rgba(198,182,126,0.10), transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(138,23,36,0.03), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Shell ──────────────────────────────────────────────── */
.cv-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Header ─────────────────────────────────────────────── */
.cv-header {
  height: 64px;
  background: rgba(250,248,244,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--cv-line);
  display: flex;
  align-items: center;
  padding: 0 20px 0 16px;
  gap: 14px;
  flex-shrink: 0;
  z-index: 20;
}

.cv-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 24;
  color: var(--cv-ink);
  white-space: nowrap;
  flex-shrink: 0;
}

.cv-mark-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cv-brand);
  box-shadow: 0 0 0 3px var(--cv-brand-soft-tint);
  flex-shrink: 0;
}

.cv-crumb {
  font-size: 12px;
  color: var(--cv-ink-faint);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cv-crumb span { color: var(--cv-ink-soft); }

.cv-spacer { flex: 1; }

/* New task button */
.cv-btn-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  background: var(--cv-brand);
  color: #fff;
  border: none;
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.cv-btn-new:hover { background: #a01c2b; transform: translateY(-1px); }
.cv-btn-new svg { width: 13px; height: 13px; stroke-width: 2.5; }

/* ── Zoom controls ──────────────────────────────────────── */

.cv-zoom-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--cv-ink-soft);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  font-family: 'Inter', sans-serif;
}
.cv-zoom-btn:hover { background: var(--cv-surface-soft); color: var(--cv-ink); }
.cv-zoom-fit { font-size: 14px; }

.cv-zoom-level {
  font-size: 10px;
  font-weight: 600;
  color: var(--cv-ink-faint);
  letter-spacing: 0.02em;
  width: 26px;
  text-align: center;
  padding: 3px 0;
}

/* ── Tray ───────────────────────────────────────────────── */
.cv-tray {
  background: rgba(250,248,244,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--cv-line);
  padding: 0 16px;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 19;
  transition: height 0.25s ease;
}
.cv-tray.cv-tray-open {
  height: 52px;
  overflow-x: auto;
}

.cv-tray-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cv-ink-faint);
  flex-shrink: 0;
  padding-right: 10px;
  border-right: 1px solid var(--cv-line);
}

.cv-tray-task {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px 0 10px;
  background: var(--cv-surface);
  border: 1px solid var(--cv-line);
  border-radius: 100px;
  cursor: grab;
  transition: all 0.15s ease;
  flex-shrink: 0;
  user-select: none;
}
.cv-tray-task:hover {
  border-color: var(--cv-brand);
  box-shadow: var(--cv-shadow-brand);
  transform: translateY(-1px);
}
.cv-tray-task:active { cursor: grabbing; }

.cv-tray-task-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cv-brand);
  flex-shrink: 0;
}
.cv-tray-task-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cv-ink);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cv-tray-task-meta {
  font-size: 10.5px;
  color: var(--cv-ink-faint);
  padding-left: 6px;
  border-left: 1px solid var(--cv-line);
}

/* ── Stage ──────────────────────────────────────────────── */
.cv-stage {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Dock (module toolbar) ───────────────────────────────── */
.cv-dock {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible;
  pointer-events: none;
}

/* Module chips in dock */
.cv-module-chip {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--cv-brand);
  box-shadow: var(--cv-shadow-sm);
  cursor: grab;
  display: grid;
  place-items: center;
  transition: transform 0.14s cubic-bezier(0.34,1.3,0.64,1);
  user-select: none;
  flex-shrink: 0;
  transform-origin: center center;
  pointer-events: all;
}
.cv-module-chip svg {
  width: 16px;
  height: 16px;
  color: var(--cv-brand);
  stroke-width: 1.8;
  transition: inherit;
}
.cv-module-chip:active { cursor: grabbing; transform: scale(0.9) !important; }

/* Placed — chip fades and dashes */
.cv-module-chip.cv-chip-placed {
  opacity: 0.22;
  border-style: dashed;
  cursor: not-allowed;
  pointer-events: none;
}

/* Label below on hover */
.cv-module-chip::after {
  content: attr(data-label);
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: var(--cv-brand);
  color: var(--cv-brand-soft);
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
  box-shadow: var(--cv-shadow-md);
}
.cv-module-chip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Viewport ────────────────────────────────────────────── */
.cv-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  margin: 12px 14px;
  border-radius: var(--cv-r-xl);
  border: 1px solid var(--cv-line);
  background-color: #fdf9f0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M14 11.3v5.4M11.3 14h5.4' stroke='%23afa591' stroke-opacity='0.55' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: 28px 28px;
  box-shadow: var(--cv-shadow-sm);
  cursor: grab;
}
.cv-viewport:active { cursor: grabbing !important; }
.cv-viewport.cv-drop-active {
  border-color: var(--cv-brand);
  box-shadow: 0 0 0 3px rgba(138,23,36,0.08), var(--cv-shadow-sm);
}

/* ── Canvas (panzoom target) ─────────────────────────────── */
.cv-canvas {
  width: 3200px;
  height: 2200px;
  position: relative;
  transform-origin: 0 0;
}


/* ── Connections SVG ─────────────────────────────────────── */
.cv-connections {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

/* ── Legend (viewport-fixed) ─────────────────────────────── */
.cv-legend {
  position: absolute;
  bottom: 18px;
  right: 18px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--cv-line);
  border-radius: 10px;
  box-shadow: var(--cv-shadow-sm);
  pointer-events: all;
}
.cv-legend-divider {
  width: 20px;
  height: 1px;
  background: var(--cv-line);
  margin: 2px 0;
  flex-shrink: 0;
}

/* ── Empty state ─────────────────────────────────────────── */
.cv-empty {
  position: absolute;
  top: calc(50% + 100px);
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 1;
}
.cv-empty-add {
  pointer-events: all;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--cv-brand);
  background: transparent;
  border: 1.5px solid var(--cv-brand);
  border-radius: var(--radius-md, 6px);
  padding: 8px 20px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}
.cv-empty-add:hover {
  background: var(--cv-brand);
  color: #fff;
}

/* ── Universal side panel ────────────────────────────────── */
.cv-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  background: var(--cv-surface);
  border-left: 1px solid var(--cv-line);
  box-shadow: -6px 0 32px rgba(31,29,26,0.10);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.cv-panel.cv-panel-open {
  transform: translateX(0);
  pointer-events: auto;
}

.cv-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 20px;
  height: 52px;
  border-bottom: 1px solid var(--cv-line);
  flex-shrink: 0;
}
.cv-panel-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 15px;
  font-variation-settings: "opsz" 24;
  color: var(--cv-ink);
  letter-spacing: -0.01em;
}
.cv-panel-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: var(--cv-r-sm);
  color: var(--cv-ink-faint);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cv-panel-close:hover { background: var(--cv-surface-soft); color: var(--cv-ink); }
.cv-panel-close svg { width: 15px; height: 15px; stroke-width: 2; }

.cv-panel-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* panel — list view */
.cv-panel-toolbar {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--cv-line);
  flex-shrink: 0;
}
.cv-panel-add-btn {
  width: 100%;
  height: 34px;
  background: var(--cv-brand);
  color: #fff;
  border: none;
  border-radius: var(--cv-r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s;
}
.cv-panel-add-btn:hover { background: #a01c2b; }

.cv-panel-list { flex: 1; overflow-y: auto; }
.cv-panel-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--cv-line);
  cursor: pointer;
  transition: background 0.12s;
}
.cv-panel-list-row:hover { background: var(--cv-surface-soft); }
.cv-panel-list-info { flex: 1; min-width: 0; }
.cv-panel-list-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--cv-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-panel-list-sub {
  display: block;
  font-size: 10.5px;
  color: var(--cv-ink-faint);
  text-transform: capitalize;
  margin-top: 1px;
}
.cv-panel-list-arrow {
  width: 14px;
  height: 14px;
  color: var(--cv-ink-faint);
  stroke-width: 2;
  flex-shrink: 0;
}
.cv-panel-empty {
  padding: 36px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--cv-ink-faint);
  font-style: italic;
  font-family: 'Fraunces', serif;
}

/* panel — edit form */
.cv-panel-back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 14px 16px 0;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--cv-brand);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.12s;
}
.cv-panel-back:hover { opacity: 1; }
.cv-panel-back svg { width: 14px; height: 14px; stroke-width: 2.5; }

.cv-panel-avatar-section {
  display: flex;
  justify-content: center;
  padding: 20px 0 14px;
}
.cv-panel-form { padding: 4px 16px 0; flex: 1; }
.cv-panel-field { margin-bottom: 13px; }
.cv-panel-field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--cv-ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.cv-panel-field input,
.cv-panel-field select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--cv-surface-soft);
  border: 1px solid var(--cv-line);
  border-radius: var(--cv-r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--cv-ink);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.cv-panel-field input:focus,
.cv-panel-field select:focus {
  border-color: var(--cv-brand);
  background: #fff;
}
.cv-panel-form-actions {
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-top: 1px solid var(--cv-line);
  margin-top: 8px;
  flex-shrink: 0;
}
.cv-panel-save {
  height: 36px;
  background: var(--cv-brand);
  color: #fff;
  border: none;
  border-radius: var(--cv-r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.cv-panel-save:hover { background: #a01c2b; }
.cv-panel-delete {
  height: 32px;
  background: transparent;
  color: var(--cv-ink-faint);
  border: 1px solid var(--cv-line);
  border-radius: var(--cv-r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cv-panel-delete:hover { color: var(--cv-brand); border-color: var(--cv-brand); }

/* ── Module minimise tray ────────────────────────────────── */
.cv-mod-tray {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 12px;
  background: rgba(253,249,240,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--cv-line);
  border-radius: 100px;
  box-shadow: var(--cv-shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
  cursor: default;
}
.cv-mod-tray.cv-mod-tray-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.cv-mod-tray-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cv-ink-faint);
  padding-right: 10px;
  border-right: 1px solid var(--cv-line);
  flex-shrink: 0;
}

.cv-mod-tray-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px 0 7px;
  background: var(--cv-surface);
  border: 1px solid var(--cv-line);
  border-radius: 100px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--cv-ink-soft);
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}
.cv-mod-tray-chip:hover {
  border-color: var(--cv-brand);
  background: var(--cv-brand-soft-tint);
  color: var(--cv-brand);
  transform: translateY(-3px);
  box-shadow: var(--cv-shadow-brand);
}
.cv-mod-tray-chip svg {
  width: 12px;
  height: 12px;
  color: currentColor;
  stroke-width: 1.8;
  flex-shrink: 0;
}

/* ── Subtask drop-up menu ────────────────────────────────── */
.cv-stask-menu {
  position: fixed;
  z-index: 9999;
  background: var(--cv-surface);
  border: 1px solid var(--cv-line);
  border-radius: var(--cv-r-md);
  box-shadow: var(--cv-shadow-lg);
  min-width: 220px;
  overflow: hidden;
  padding: 4px;
}

.cv-stask-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: var(--cv-r-sm);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cv-ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.cv-stask-menu-item:hover { background: var(--cv-surface-soft); }

.cv-stask-menu-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cv-brand-soft);
  flex-shrink: 0;
}
.cv-stask-menu-item--on .cv-stask-menu-dot { background: var(--cv-ok); }

.cv-stask-menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cv-stask-menu-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cv-ink-faint);
  background: var(--cv-surface-soft);
  padding: 1px 6px;
  border-radius: 100px;
  flex-shrink: 0;
}

.cv-stask-menu-divider {
  height: 1px;
  background: var(--cv-line);
  margin: 4px 0;
}

.cv-stask-menu-item--add { color: var(--cv-brand); font-weight: 600; }
.cv-stask-menu-item--add:hover { background: rgba(138,23,36,0.05); }
.cv-stask-menu-item--add svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
  flex-shrink: 0;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cv-line-strong); border-radius: 100px; }

