/* =========================================================
   Ely / Brain Portal — Design Tokens
   Base variant: "Library Warmth" (A)
   Other variants (B/C/D) override a subset via data-direction
   ========================================================= */

:root {
  /* Canvas + surfaces */
  --bg-canvas:       #F5F0E8;
  --bg-canvas-2:     #EFE9DE;
  --bg-card:         #FFFFFF;
  --bg-sidebar:      #F5F0E8;
  --bg-nav-hover:    #ECE6DC;
  --bg-nav-active:   #E6DFD1;
  --bg-muted:        #F0EADC;
  --bg-inset:        #FBF8F2;

  /* Text */
  --text-primary:    #1A1A1A;
  --text-secondary:  #6B6B6B;
  --text-muted:      #9A9A9A;
  --text-subtle:     #B5AFA3;
  --text-inverse:    #FFFFFF;

  /* Borders */
  --border-soft:     #E8E2D6;
  --border-medium:   #DCD4C3;
  --border-strong:   #C9C0AC;
  --border-dashed:   #CFC8BA;

  /* Accent — Claude orange (terracotta) */
  --accent:          #D97757;
  --accent-hover:    #C4654A;
  --accent-active:   #B25439;
  --accent-soft:     #F8E6DE;
  --accent-faint:    #FBEFE8;
  --accent-ink:      #8A3F26;

  /* Warning / review yellow */
  --yellow:          #E8B84B;
  --yellow-bg:       #FEF3D4;
  --yellow-text:     #8B6914;

  /* Status dots (kanban, indicators) */
  --status-backlog:  #9CA3AF;
  --status-progress: #4B7BFF;
  --status-review:   #E8B84B;
  --status-done:     #10B981;
  --status-error:    #C5333A;

  /* Pastel pill tags (bg / text same hue) */
  --tag-research-bg: #E8EDFA;   --tag-research-text: #4A5FA8;
  --tag-perf-bg:     #FCE4E0;   --tag-perf-text:     #B5453A;
  --tag-incident-bg: #C5333A;   --tag-incident-text: #FFFFFF;
  --tag-high-bg:     #C5333A;   --tag-high-text:     #FFFFFF;
  --tag-active-bg:   #DCEFE0;   --tag-active-text:   #1F7A3F;
  --tag-mono-bg:     #F0EADC;   --tag-mono-text:     #6B6B6B;
  --tag-ai-bg:       #F3E7F7;   --tag-ai-text:       #6B3F82;

  /* Typography */
  --font-ui: "Inter", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Inter", ui-sans-serif, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Berkeley Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-serif: "Lora", "Source Serif 4", Georgia, serif;

  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-17: 17px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-28: 28px;
  --fs-32: 32px;
  --fs-40: 40px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;
  --sp-10: 64px;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 14px;
  --r-2xl: 20px;
  --r-full: 999px;

  /* Shadows — whisper-soft */
  --sh-xs: 0 1px 2px rgba(26, 18, 10, 0.04);
  --sh-sm: 0 1px 3px rgba(26, 18, 10, 0.05), 0 1px 2px rgba(26, 18, 10, 0.03);
  --sh-md: 0 4px 14px -4px rgba(26, 18, 10, 0.07), 0 2px 4px rgba(26, 18, 10, 0.04);
  --sh-lg: 0 16px 40px -12px rgba(26, 18, 10, 0.12), 0 4px 12px rgba(26, 18, 10, 0.06);
  --sh-focus: 0 0 0 3px rgba(217, 119, 87, 0.22);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-med: 220ms;
  --dur-slow: 420ms;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --content-max: 1320px;

  /* Density (compact / comfortable / spacious) — overridden by tweaks */
  --density-card-pad: 20px;
  --density-row-h: 44px;
  --density-gap: 16px;
  --density-tile-pad: 20px;

  /* Radius profile */
  --radius-profile-card: var(--r-xl);
  --radius-profile-btn: var(--r-md);
  --radius-profile-input: var(--r-md);
}

/* ----- Density tweaks ----- */
[data-density="compact"] {
  --density-card-pad: 14px;
  --density-row-h: 36px;
  --density-gap: 10px;
  --density-tile-pad: 14px;
}
[data-density="spacious"] {
  --density-card-pad: 28px;
  --density-row-h: 52px;
  --density-gap: 24px;
  --density-tile-pad: 28px;
}

/* ----- Radius tweaks ----- */
[data-radius="sharp"] {
  --radius-profile-card: 4px;
  --radius-profile-btn: 4px;
  --radius-profile-input: 4px;
}
[data-radius="soft"] {
  --radius-profile-card: 20px;
  --radius-profile-btn: 12px;
  --radius-profile-input: 10px;
}

/* ----- Font tweaks ----- */
[data-font="sohne"] {
  --font-ui: "Söhne", "Work Sans", "Inter", ui-sans-serif, sans-serif;
  --font-display: "Söhne", "Work Sans", "Inter", ui-sans-serif, sans-serif;
}
[data-font="system"] {
  --font-ui: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}

/* ----- Direction variants (within VisualDNA) ----- */
/* A — Library Warmth (default, cream + terracotta, Inter) */
[data-direction="A"] {
  --bg-canvas: #F5F0E8;
  --bg-canvas-2: #EFE9DE;
  --accent: #D97757;
  --accent-hover: #C4654A;
  --accent-soft: #F8E6DE;
  --border-soft: #E8E2D6;
}
/* B — Paper & Tea (lighter, ivory, more whitespace, subtler accent) */
[data-direction="B"] {
  --bg-canvas: #FAF6EE;
  --bg-canvas-2: #F2ECE0;
  --bg-nav-active: #EBE4D3;
  --accent: #C5653F;
  --accent-hover: #A9502D;
  --accent-soft: #F6E3D6;
  --border-soft: #EDE6D7;
}
/* C — Editorial Calm (cooler cream, slightly more serif emphasis, warmer shadows) */
[data-direction="C"] {
  --bg-canvas: #F2EEE5;
  --bg-canvas-2: #ECE6D9;
  --bg-nav-active: #E3DCC9;
  --accent: #CC6A46;
  --accent-hover: #B35635;
  --accent-soft: #F4DFD1;
  --border-soft: #E2DBC9;
  --font-display: "Lora", "Source Serif 4", "Inter", serif;
}
/* D — Clay Studio (deeper canvas, stronger terracotta, chunkier rhythm) */
[data-direction="D"] {
  --bg-canvas: #EFE7D5;
  --bg-canvas-2: #E8DFC8;
  --bg-nav-active: #DED3B8;
  --bg-card: #FBF7EE;
  --accent: #D36A43;
  --accent-hover: #B9542E;
  --accent-soft: #F3D9C9;
  --border-soft: #DED3B8;
  --border-medium: #C9BA99;
}

/* ================== Globals ================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-sm); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: var(--r-full); border: 2px solid var(--bg-canvas); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ================== Primitives ================== */
.mono { font-family: var(--font-mono); font-feature-settings: "ss01", "zero"; letter-spacing: 0.01em; }
.muted { color: var(--text-secondary); }
.subtle { color: var(--text-muted); }

.hstack { display: flex; align-items: center; gap: var(--sp-2); }
.vstack { display: flex; flex-direction: column; gap: var(--sp-2); }
.grow { flex: 1 1 auto; min-width: 0; }

.card {
  background: var(--bg-card);
  border-radius: var(--radius-profile-card);
  box-shadow: var(--sh-xs);
  border: 1px solid var(--border-soft);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-profile-btn);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-nav-hover); }
.btn .icon { width: 16px; height: 16px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

.btn-outline { background: var(--bg-card); border-color: var(--border-medium); }
.btn-outline:hover { background: var(--bg-nav-hover); border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-nav-hover); color: var(--text-primary); }

.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-12); }
.btn-xs { height: 22px; padding: 0 8px; font-size: var(--fs-11); }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--fs-14); }
.btn-icon { width: 34px; padding: 0; justify-content: center; }

/* Pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-11);
  font-weight: 500;
  line-height: 1.6;
  background: var(--bg-muted);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pill.solid { color: #fff; }
.pill-high { background: var(--tag-high-bg); color: var(--tag-high-text); }
.pill-med { background: var(--yellow-bg); color: var(--yellow-text); }
.pill-low { background: var(--tag-mono-bg); color: var(--tag-mono-text); }
.pill-active { background: var(--tag-active-bg); color: var(--tag-active-text); }
.pill-review { background: var(--yellow-bg); color: var(--yellow-text); }
.pill-error { background: var(--tag-incident-bg); color: var(--tag-incident-text); }
.pill-research { background: var(--tag-research-bg); color: var(--tag-research-text); }
.pill-perf { background: var(--tag-perf-bg); color: var(--tag-perf-text); }
.pill-ai { background: var(--tag-ai-bg); color: var(--tag-ai-text); }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--status-backlog);
  flex-shrink: 0;
}
.dot.progress { background: var(--status-progress); }
.dot.review { background: var(--status-review); }
.dot.done { background: var(--status-done); }
.dot.error { background: var(--status-error); }

/* Inputs */
.input, .textarea, .select {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-profile-input);
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--fs-13);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  width: 100%;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.15);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; line-height: 1.5; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border-medium);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1;
}

/* Section labels */
.eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Divider */
.hr { height: 1px; background: var(--border-soft); border: 0; margin: var(--sp-4) 0; }
.vr { width: 1px; background: var(--border-soft); align-self: stretch; }

/* Utility text */
.h1 { font-size: var(--fs-32); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; color: var(--text-primary); font-family: var(--font-display); }
.h2 { font-size: var(--fs-24); font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; font-family: var(--font-display); }
.h3 { font-size: var(--fs-17); font-weight: 600; letter-spacing: -0.005em; line-height: 1.3; }
.sub { font-size: var(--fs-14); color: var(--text-secondary); line-height: 1.5; }
.meta { font-size: var(--fs-12); color: var(--text-muted); }
.ticket { font-family: var(--font-mono); font-size: var(--fs-11); letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); }

/* Helpers */
.clip-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clip-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Scrollbar hide */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* Screen transition */
.fade-enter { animation: fadeIn var(--dur-med) var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Signature pattern background slot */
.pattern-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
}
