/* ========================================================================
   base.css, global tokens, reset, stage scaling
   ======================================================================== */

:root {
  /* Emirates brand */
  --ek-red: #D71921;
  --ek-red-deep: #A8111A;
  --ek-gold: #C8A55B;
  --ek-cream: #F5EFE6;

  /* Surface (light) */
  --surface-0: #FAFAF8;
  --surface-1: #FFFFFF;
  --surface-2: #F4F4F0;
  --line: #E5E2DA;
  --line-soft: #EDEAE2;

  /* Surface (dark, assistant + director) */
  --d-bg: #0E1116;
  --d-bg-2: #161A21;
  --d-bg-3: #1E232C;
  --d-line: #2A2F38;
  --d-line-soft: #21252D;

  /* Text */
  --ink: #14161B;
  --ink-2: #3A3F47;
  --ink-3: #6B7079;
  --ink-4: #9AA0AA;
  --ink-on-d: #F2F3F5;
  --ink-on-d-2: #B7BCC5;
  --ink-on-d-3: #7C828D;

  /* Semantic */
  --good: #1B8A5A;
  --warn: #B57803;
  --bad: #C0392B;
  --info: #2563A8;

  /* Wonderful (Safe AI) */
  --w-blue: #4A6FE3;
  --w-purple: #7B6FE3;
  --w-aqua: #2EB5C5;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Misc */
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --radius-xl: 22px;
  --shadow-card: 0 1px 2px rgba(20,22,27,0.04), 0 8px 24px rgba(20,22,27,0.06);
  --shadow-elev: 0 4px 12px rgba(20,22,27,0.08), 0 24px 48px rgba(20,22,27,0.12);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #0a0c10;
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  width: 100%; height: 100%;
  overflow: hidden;
}

button { font-family: inherit; }

/* Stage + scaling, 1680x945 reference, scale to fit viewport.
   Was 1920x1080, shrinking the reference makes every device/text/graphic
   read ~14% bigger on screen while keeping the same uniform-scale responsiveness. */
#root {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: #0a0c10;
}

.stage {
  position: relative;
  width: 1680px; height: 945px;
  background: #0a0c10;
  transform-origin: center center;
  flex-shrink: 0;
  overflow: hidden;
}

.stage-content {
  position: absolute; inset: 0;
  display: flex;
}

.canvas {
  position: absolute;
  inset: 0;
  background: var(--surface-0);
  overflow: hidden;
}

/* When director is open the canvas is narrower */
.stage[data-rail="open"] .canvas { margin-right: 0; }

/* Helpers */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.center { display: flex; align-items: center; justify-content: center; }
.dim { color: var(--ink-3); }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }

.uppercase { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

/* Subtle ambient for canvas backgrounds */
.canvas-paper {
  background:
    radial-gradient(1200px 700px at 30% -10%, rgba(215,25,33,0.025), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(200,165,91,0.04), transparent 60%),
    var(--surface-0);
}

/* Reusable pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.pill--good   { color: var(--good); background: #E8F4ED; border-color: #C9E4D5; }
.pill--warn   { color: var(--warn); background: #FCF1DC; border-color: #EFD5A6; }
.pill--info   { color: var(--info); background: #E5EEF8; border-color: #C4D5EA; }
.pill--ek     { color: white;       background: var(--ek-red); border-color: var(--ek-red-deep); }
.pill--ai     { color: var(--w-blue); background: #EEF1FC; border-color: #D4DBF6; }

/* "Dot" status */
.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.dot--g { background: var(--good); box-shadow: 0 0 0 3px rgba(27,138,90,0.18); }
.dot--w { background: var(--warn); }
.dot--b { background: var(--bad);  }
.dot--ai { background: var(--w-blue); box-shadow: 0 0 0 3px rgba(74,111,227,0.18); }

/* Phase tag (top-left of canvas) */
.phase-tag {
  position: absolute; top: 28px; left: 28px;
  z-index: 30;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(20,22,27,0.85);
  color: white;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  backdrop-filter: blur(10px);
}
.phase-tag .ek-mark {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: var(--ek-red);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0;
}

/* Loading dots (used in chat "typing") */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 999px;
  background: currentColor; opacity: 0.4;
  animation: tdot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tdot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-3px); opacity: 0.9; }
}

/* Soft fade in, just opacity:1, animations were getting stuck */
.fade-in {
  opacity: 1;
}
@keyframes fadeIn {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: none; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.fade-in-slow { animation: fadeIn 0.7s ease both; }

.pulse-ai {
  animation: pulseAI 1.6s infinite ease-in-out;
}
@keyframes pulseAI {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,111,227,0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(74,111,227,0); }
}

/* "Listening" radial wave (used in the assistant) */
.wave-ring {
  position: relative;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: var(--w-blue);
}
.wave-ring::before, .wave-ring::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 999px;
  border: 1.5px solid var(--w-blue);
  animation: wave 2s infinite ease-out;
}
.wave-ring::after { animation-delay: 1s; }
@keyframes wave {
  from { opacity: 0.7; transform: scale(1); }
  to   { opacity: 0;   transform: scale(3.4); }
}

/* Soft hairline */
.hr { height: 1px; background: var(--line); border: 0; }
.hr-d { height: 1px; background: var(--d-line); border: 0; }
