/* ==========================================================================
   Adda — design tokens & base
   Theme colors (--accent, --out, --in and their *-ink pairs) are written at
   runtime by js/theme.js. Everything else derives from them with color-mix,
   so changing two hex values re-tints the whole product.
   ========================================================================== */

:root {
  /* ---- Runtime theme inputs (defaults; overwritten by theme.js) ---- */
  --accent: #2f6b5a;
  --accent-ink: #ffffff;
  --out: #dcefe6;
  --out-ink: #10241d;
  --in: #ffffff;
  --in-ink: #16140f;

  /* ---- Neutrals (warm) ---- */
  --paper: #fbfaf8;
  --white: #ffffff;
  --text: #16140f;
  --text-2: #57534b;
  --text-3: #8b867c;
  --text-4: #b3aea4;
  --line: rgba(28, 24, 16, 0.08);
  --line-2: rgba(28, 24, 16, 0.13);
  --danger: #c2412d;
  --danger-soft: #fbece8;
  --warn: #a96a12;
  --warn-soft: #fbf1e0;
  --ok: #2c7a4b;
  --ok-soft: #e5f3ea;

  /* ---- Derived from accent ---- */
  --bg: color-mix(in oklab, var(--accent) 2.5%, var(--paper));
  --surface: var(--white);
  --surface-2: color-mix(in oklab, var(--accent) 4%, #f6f4f0);
  --surface-3: color-mix(in oklab, var(--accent) 7%, #efece6);
  --chat-bg: color-mix(in oklab, var(--accent) 5%, #f5f3ee);
  --accent-soft: color-mix(in oklab, var(--accent) 11%, white);
  --accent-softer: color-mix(in oklab, var(--accent) 6%, white);
  --accent-line: color-mix(in oklab, var(--accent) 28%, white);
  --accent-text: color-mix(in oklab, var(--accent) 88%, black);
  --focus: color-mix(in oklab, var(--accent) 45%, transparent);

  /* Bubble metadata colours derive from the ink so they always contrast */
  --out-meta: color-mix(in oklab, var(--out-ink) 55%, var(--out));
  --in-meta: color-mix(in oklab, var(--in-ink) 50%, var(--in));
  --out-quote: color-mix(in oklab, var(--out-ink) 8%, var(--out));
  --in-quote: color-mix(in oklab, var(--in-ink) 5%, var(--in));
  --out-edge: color-mix(in oklab, var(--out-ink) 10%, var(--out));
  --in-edge: color-mix(in oklab, var(--in-ink) 9%, var(--in));

  /* ---- Type ---- */
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14px;
  --fs-base: 14.5px;
  --fs-lg: 16px;
  --fs-xl: 19px;
  --fs-2xl: 24px;

  /* ---- Space (4pt) ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* ---- Radius ---- */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;
  --r-bubble: 22px;
  --r-bubble-tight: 10px;
  --r-island: 28px;

  /* ---- Elevation (minimal) ---- */
  --sh-1: 0 1px 1px rgba(28, 24, 16, 0.04);
  --sh-2: 0 1px 2px rgba(28, 24, 16, 0.05), 0 4px 14px rgba(28, 24, 16, 0.06);
  --sh-3: 0 2px 6px rgba(28, 24, 16, 0.06), 0 16px 40px rgba(28, 24, 16, 0.12);
  --sh-island: 0 12px 28px -8px rgba(28, 24, 16, 0.10), 0 4px 10px -2px rgba(28, 24, 16, 0.05);
  --sh-bubble: 0 8px 22px -8px rgba(28, 24, 16, 0.08), 0 2px 6px -2px rgba(28, 24, 16, 0.04);

  /* ---- Motion ---- */
  --motion-fast: 120ms;
  --motion-normal: 200ms;
  --motion-smooth: 280ms;
  --motion-slow: 380ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-exit: cubic-bezier(0.3, 0, 0.8, 0.15);

  /* ---- Layout ---- */
  --sidebar-w: 352px;
  --info-w: 340px;
  --header-h: 64px;
  --app-h: 100dvh;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* Ember — cool sculptural chrome (parallel to warm paper defaults) */
html[data-theme-mode="ember"] {
  --paper: #f7f8fc;
  --white: #ffffff;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --text-4: #94a3b8;
  --line: rgba(15, 23, 42, 0.08);
  --line-2: rgba(15, 23, 42, 0.13);
  --bg: #e7eaf0;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e8ebf2;
  --chat-bg: #f7f8fc;
  --accent-soft: color-mix(in oklab, var(--accent) 14%, white);
  --accent-softer: color-mix(in oklab, var(--accent) 8%, white);
  --accent-line: color-mix(in oklab, var(--accent) 32%, white);
  --accent-text: color-mix(in oklab, var(--accent) 82%, black);
  --warn-soft: #fff8ee;
  --sh-1: 0 1px 1px rgba(15, 23, 42, 0.04);
  --sh-2: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(15, 23, 42, 0.06);
  --sh-3: 0 2px 6px rgba(15, 23, 42, 0.06), 0 16px 40px rgba(15, 23, 42, 0.12);
  --sh-island: 0 20px 38px -8px rgba(15, 23, 42, 0.12), 0 6px 14px -3px rgba(15, 23, 42, 0.06);
  --sh-bubble: 0 12px 30px -6px rgba(15, 23, 42, 0.07), 0 4px 10px -2px rgba(15, 23, 42, 0.03);
  color-scheme: light;
}

/* Ember Night — same brand, dark mode */
html[data-theme-mode="ember-night"] {
  --paper: #12151f;
  --white: #181c2a;
  --text: #e8eaf2;
  --text-2: #a8b0c4;
  --text-3: #7b849c;
  --text-4: #5a637a;
  --line: rgba(232, 234, 242, 0.08);
  --line-2: rgba(232, 234, 242, 0.14);
  --danger: #f07167;
  --danger-soft: #3a2224;
  --warn: #f0b45a;
  --warn-soft: #3a2e1c;
  --ok: #5dce9a;
  --ok-soft: #1c322a;
  --bg: #0c0e16;
  --surface: #181c2a;
  --surface-2: #1f2436;
  --surface-3: #272d42;
  --chat-bg: #12151f;
  --accent-soft: color-mix(in oklab, var(--accent) 22%, #181c2a);
  --accent-softer: color-mix(in oklab, var(--accent) 12%, #181c2a);
  --accent-line: color-mix(in oklab, var(--accent) 45%, #181c2a);
  --accent-text: color-mix(in oklab, var(--accent) 70%, white);
  --sh-1: 0 1px 1px rgba(0, 0, 0, 0.28);
  --sh-2: 0 1px 2px rgba(0, 0, 0, 0.32), 0 4px 14px rgba(0, 0, 0, 0.28);
  --sh-3: 0 2px 6px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.45);
  --sh-island: 0 20px 38px -8px rgba(0, 0, 0, 0.45), 0 6px 14px -3px rgba(0, 0, 0, 0.3);
  --sh-bubble: 0 12px 30px -6px rgba(0, 0, 0, 0.35), 0 4px 10px -2px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms; --motion-normal: 0ms; --motion-smooth: 0ms; --motion-slow: 0ms;
  }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }
.icon--sm { width: 16px; height: 16px; }
.icon--xs { width: 14px; height: 14px; }
.icon--lg { width: 24px; height: 24px; }

/* Thin, quiet scrollbars */
.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.scroll:hover::-webkit-scrollbar-thumb { background-color: rgba(28, 24, 16, 0.16); }

/* Boot veil */
.boot {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg);
  transition: opacity var(--motion-slow) var(--ease-standard), visibility 0s linear var(--motion-slow);
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot__mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent);
  animation: boot-pulse 1.1s var(--ease-standard) infinite alternate;
}
@keyframes boot-pulse { from { transform: scale(0.92); opacity: .65; } to { transform: scale(1); opacity: 1; } }
