/**
 * Yofica Flow - Embeddable Player (LIGHT theme to match the landing).
 * The widget never paints its own dark backgrounds: the panel, bubbles,
 * cards and chips are light/translucent; text is dark. Sans-serif only.
 */

:root {
  --text: #0f172a;
  --text-dim: #64748b;
  --border: rgba(15, 23, 42, 0.1);
  --accent: #9b4f7d; /* brand primary */
  --accent2: #fc6687; /* brand secondary */
  --panel: rgba(255, 255, 255, 0.66);
  --panel-solid: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.flow-embed {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  z-index: 1;
}

/* --- Blueprint chips (scenario selector) --- */
.blueprint-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x;
}

@media (max-width: 760px) {
  .blueprint-bar {
    justify-content: flex-start;
  }
}
.blueprint-bar:active {
  cursor: grabbing;
}

.blueprint-bar::-webkit-scrollbar {
  height: 5px;
}
.blueprint-bar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.blueprint-chip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.blueprint-chip:hover {
  border-color: rgba(155, 79, 125, 0.4);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.blueprint-chip.active {
  border-color: var(--accent);
  background: rgba(155, 79, 125, 0.08);
  box-shadow: 0 4px 18px rgba(155, 79, 125, 0.18);
}

.blueprint-chip .bp-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.blueprint-chip .bp-steps {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.blueprint-chip.active .bp-steps {
  color: var(--accent);
}

/* --- Stage (light frosted panel) --- */
.stage {
  flex: 1;
  position: relative;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 24px;
  border: 1px solid var(--border);
  overflow: hidden;
  background-image: linear-gradient(rgba(155, 79, 125, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 79, 125, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
}

#stageCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.bubble-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: visible;
}

/* --- Speech bubbles (light) --- */
.dom-bubble {
  position: absolute;
  /* Anchor top-left so the JS transform origin is identical in LTR and RTL
     (an absolute element defaults to the right edge under dir=rtl). */
  left: 0;
  top: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 18px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 90px;
  max-width: 250px;
  opacity: 0;
  transform-origin: var(--tri-x, 50%) bottom;
  transition: opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  will-change: transform, opacity;
}

.dom-bubble.has-image {
  max-width: 290px;
  display: block;
}
.dom-bubble.has-image::after {
  content: '';
  display: table;
  clear: both;
}
.dom-bubble.has-image img {
  float: left;
  margin-right: 12px;
  margin-bottom: 4px;
  width: 78px;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dom-bubble.has-image .dom-bubble-text {
  display: inline;
}
.dom-bubble-text {
  flex: 1;
  color: var(--text);
}

/* Pointer triangle: border (uses bubble accent) then white fill to match bg */
.dom-bubble::before {
  content: '';
  position: absolute;
  bottom: -13px;
  left: var(--tri-x, 50%);
  transform: translateX(-50%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 13px solid var(--bubble-color, rgba(15, 23, 42, 0.12));
  pointer-events: none;
}
.dom-bubble::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: var(--tri-x, 50%);
  transform: translateX(-50%);
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 11px solid var(--panel-solid);
  pointer-events: none;
}

/* --- Notifications (light) --- */
.dom-notification {
  position: absolute;
  left: 0;
  top: 0;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 15px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 170px;
  max-width: 290px;
}
.dom-notification .bell {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
}

/* --- System caption under the Yofica Cloud --- */
.cloud-caption {
  position: absolute;
  transform: translate(-50%, 4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 40;
  max-width: 240px;
  text-align: center;
}
.cloud-caption.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.cloud-caption span {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  white-space: nowrap;
}

/* --- Source badge inside a speech bubble (person vs Yofica app) --- */
.bubble-src {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- RTL (Hebrew) --- */
[dir='rtl'] .blueprint-bar {
  direction: rtl;
}
[dir='rtl'] .dom-bubble.has-image img {
  float: right;
  margin-right: 0;
  margin-left: 14px;
}
