/*
 * Pandig base layer
 *
 * Legacy tokens are kept for auth.css and landing.css which reference them.
 * Basecoat handles the main design system via Tailwind theme overrides.
 */

@font-face {
  font-family: "Manrope Variable";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/manrope-latin-11c6feab.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/assets/jetbrains-mono-latin-fed4273c.woff2") format("woff2");
}

:root {
  /* Legacy tokens (used by auth.css, landing.css) */
  --color-bg-app: #f4f7fb;
  --color-bg-surface: #ffffff;
  --color-bg-muted: #eaf0f7;
  --color-border-subtle: #d7e0ea;
  --color-border-strong: #b8c6d8;
  --color-text-primary: #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted: #5b6b82;
  --color-accent: #2457c5;
  --color-accent-hover: #1e47a3;
  --color-accent-soft: #eaf0ff;

  --color-success-text: #166447;
  --color-success-bg: #eaf7f1;
  --color-warning-text: #92400e;
  --color-warning-bg: #fff4e8;
  --color-critical-text: #9f2d24;
  --color-critical-bg: #fdecea;
  --color-info-text: #1e40af;
  --color-info-bg: #eaf0ff;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --shadow-1: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 1px rgb(15 23 42 / 0.04);
  --shadow-2: 0 6px 20px rgb(15 23 42 / 0.08), 0 2px 6px rgb(15 23 42 / 0.05);
  --shadow-3: 0 16px 44px rgb(15 23 42 / 0.14), 0 8px 20px rgb(15 23 42 / 0.08);

  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --text-display: clamp(2rem, 1.8rem + 1vw, 2.5rem);
  --text-title-l: clamp(1.625rem, 1.45rem + 0.6vw, 1.875rem);
  --text-title-m: clamp(1.375rem, 1.26rem + 0.35vw, 1.5rem);
  --text-body: 1rem;
  --text-body-s: 0.875rem;
  --text-meta: 0.75rem;

  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
}

:root[data-color-mode="dark"] {
  color-scheme: dark;

  --color-bg-app: #0d1424;
  --color-bg-surface: #111b30;
  --color-bg-muted: #18253d;
  --color-border-subtle: #2c3b58;
  --color-border-strong: #405173;
  --color-text-primary: #e4ecff;
  --color-text-secondary: #c3cde3;
  --color-text-muted: #9baacc;
  --color-accent: #7ea8ff;
  --color-accent-hover: #9ebdff;
  --color-accent-soft: #1f3359;

  --color-success-text: #7fe2b5;
  --color-success-bg: #183429;
  --color-warning-text: #f8cc8d;
  --color-warning-bg: #3b2814;
  --color-critical-text: #f4a8a1;
  --color-critical-bg: #3f1e23;
  --color-info-text: #b9ccff;
  --color-info-bg: #1a2c52;

  --background: oklch(0.22 0.02 262);
  --foreground: oklch(0.93 0.02 255);
  --card: oklch(0.25 0.02 260);
  --card-foreground: oklch(0.93 0.02 255);
  --popover: oklch(0.25 0.02 260);
  --popover-foreground: oklch(0.93 0.02 255);
  --primary: oklch(0.72 0.12 262);
  --primary-foreground: oklch(0.2 0.02 260);
  --secondary: oklch(0.31 0.02 258);
  --secondary-foreground: oklch(0.93 0.02 255);
  --muted: oklch(0.31 0.02 258);
  --muted-foreground: oklch(0.76 0.02 255);
  --accent: oklch(0.35 0.04 258);
  --accent-foreground: oklch(0.93 0.02 255);
  --destructive: oklch(0.62 0.15 27);
  --border: oklch(0.4 0.03 258);
  --input: oklch(0.46 0.03 258);
  --ring: oklch(0.72 0.12 262);
  --sidebar: oklch(0.25 0.02 260);
  --sidebar-foreground: oklch(0.93 0.02 255);
  --sidebar-primary: oklch(0.72 0.12 262);
  --sidebar-primary-foreground: oklch(0.2 0.02 260);
  --sidebar-accent: oklch(0.33 0.03 258);
  --sidebar-accent-foreground: oklch(0.93 0.02 255);
  --sidebar-border: oklch(0.4 0.03 258);
  --sidebar-ring: oklch(0.72 0.12 262);
}

/* Pandig body background gradient (layered on top of Basecoat's bg-background) */
body.app-body {
  background:
    radial-gradient(circle at right top, rgb(36 87 197 / 0.09), transparent 36rem),
    linear-gradient(180deg, #f8fbff 0%, var(--color-bg-app) 35%, var(--color-bg-app) 100%);
}

:root[data-color-mode="dark"] body.app-body {
  background:
    radial-gradient(circle at right top, rgb(126 168 255 / 0.22), transparent 38rem),
    linear-gradient(180deg, #090f1d 0%, var(--color-bg-app) 40%, #0a1221 100%);
}

/* Markdown editor */
.md-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  overflow: hidden;
}

.md-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-muted);
}

.md-editor__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.md-editor__btn:hover {
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
}

.md-editor__btn:active {
  background: var(--color-accent-soft);
}

.md-editor__btn svg {
  pointer-events: none;
}

.md-editor__sep {
  width: 1px;
  height: 20px;
  margin: 0 2px;
  background: var(--color-border-subtle);
  flex-shrink: 0;
}

.md-editor__textarea {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  resize: vertical;
  min-height: 120px;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 12px !important;
  background: var(--color-bg-surface) !important;
  color: var(--color-text-primary);
  width: 100%;
  box-sizing: border-box;
}

.md-editor__textarea:focus {
  outline: none !important;
  box-shadow: none !important;
}

.md-editor:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
}
