/* ─────────────────────────────────────────────────────────────
   Karlic — shared theme ("The Margin Note")
   Three-layer tokens: primitives → semantics → legacy aliases.
   Legacy names (--navy, --cyan, --violet, --slate-*) are kept
   because inline JS styles across pages reference them.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Primitives */
  --brand: #5046E5;
  --brand-dark: #4338CA;
  --brand-deep: #3730A3;
  --brand-light: #EEF2FF;
  --brand-200: #C7D2FE;
  --brand-hover: #6159F0;
  --ink-950: #16152E;
  --ink-900: #1C1B3A;
  --ink-800: #232145;
  --ink-700: #3B3963;
  --ink-600: #4C4A72;
  --ink-500: #6B6990;
  --ink-400: #9A98B5;
  --ink-300: #C6C5DA;
  --ink-200: #E5E4F0;
  --ink-100: #F1F0F7;
  --ink-50:  #F8F8FC;
  --cyan-500: #06B6D4;
  --cyan-050: #E9FAFE;
  --violet-500: #6C5CE7;
  --violet-050: #F0EDFF;
  --green-500: #10B981;
  --amber-500: #F59E0B;
  --red-500: #EF4444;

  /* Semantics */
  --paper: #F7F7FB;
  --surface: #FFFFFF;
  --line: #E7E6F2;
  --text: var(--ink-800);
  --text-muted: var(--ink-500);
  --text-faint: var(--ink-400);
  --focus-ring: 0 0 0 3px rgba(80, 70, 229, 0.18);

  /* Legacy aliases — DO NOT REMOVE (inline JS depends on these names) */
  --navy: var(--brand);
  --navy-light: var(--brand-hover);
  --navy-dark: var(--ink-950);
  --cyan: var(--cyan-500);
  --cyan-light: var(--brand-light);
  --violet: var(--violet-500);
  --violet-light: var(--violet-050);
  --verified: var(--green-500);
  --missing: var(--amber-500);
  --danger: var(--red-500);
  --bg: var(--paper);
  --slate-50: var(--ink-50);
  --slate-100: var(--ink-100);
  --slate-200: var(--ink-200);
  --slate-300: var(--ink-300);
  --slate-400: var(--ink-400);
  --slate-500: var(--ink-500);
  --slate-600: var(--ink-600);
  --slate-700: var(--ink-700);
  --slate-800: var(--ink-800);
  --slate-900: var(--ink-950);

  --shadow-sm: 0 1px 2px rgba(28, 27, 58, 0.06);
  --shadow-md: 0 4px 10px -2px rgba(28, 27, 58, 0.08), 0 2px 4px -2px rgba(28, 27, 58, 0.05);
  --shadow-lg: 0 12px 24px -6px rgba(28, 27, 58, 0.10), 0 4px 8px -4px rgba(28, 27, 58, 0.05);
  --shadow-xl: 0 24px 48px -12px rgba(28, 27, 58, 0.16), 0 8px 16px -8px rgba(28, 27, 58, 0.06);
  --shadow-brand: 0 6px 18px -6px rgba(80, 70, 229, 0.45);

  --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-voice: 'Newsreader', Georgia, 'Times New Roman', serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-move: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::placeholder { color: var(--text-faint); }
::selection { background: rgba(80, 70, 229, 0.16); }

a { color: inherit; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* The buddy voice — Karlic speaking */
.voice, .voice-quote {
  font-family: var(--font-voice);
  font-style: italic;
  letter-spacing: 0;
}

/* ── Keyframes (inline JS assigns several of these by name — keep all) ── */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut  { to { opacity: 0; } }
@keyframes pop      { 0% { transform: scale(0.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spin     { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse-ring { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes shimmer  { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
@keyframes float    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bounceDown { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(6px); } }
@keyframes pageEnter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Page-transition polish: gentle enter, never intercepts exit/redirects */
body { animation: pageEnter 0.28s var(--ease-out) both; }

/* ── Shared chrome: language toggle ── */
.lang-toggle {
  display: flex; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
}
.lang-btn {
  padding: 5px 11px; font-size: 12px; font-weight: 700;
  border: none; cursor: pointer; font-family: inherit;
  background: transparent; color: var(--text-faint);
  transition: background 0.18s var(--ease-move), color 0.18s var(--ease-move);
}
.lang-btn:hover { color: var(--brand); }
.lang-btn.active { background: var(--brand); color: white; }

/* ── Shared chrome: avatars ── */
.avatar, .avatar-nav, .user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
  text-decoration: none; flex-shrink: 0;
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s var(--ease-move);
}
.avatar { cursor: pointer; }
.avatar:hover { transform: scale(1.06); box-shadow: var(--focus-ring); }
.user-avatar { width: 32px; height: 32px; }

/* ── Shared chrome: mobile bottom tabs ── */
.mobile-tabs {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
}
.mobile-tabs-inner { display: flex; justify-content: space-around; align-items: center; max-width: 400px; margin: 0 auto; }
.mobile-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 16px; border-radius: 10px; text-decoration: none;
  color: var(--text-faint); font-size: 11px; font-weight: 600;
  transition: color 0.18s var(--ease-move);
}
.mobile-tab.active { color: var(--brand); }
.mobile-tab svg { width: 22px; height: 22px; }

/* ── Micro-interaction primitives ── */
button { touch-action: manipulation; }
.press, .analyze-btn, .submit-btn, .oauth-btn, .add-btn, .new-btn, .notify-btn,
.chat-send, .empty-cta, .cta-btn, .carousel-btn, .onboard-next,
.nav-signup, .google-btn, .apple-btn {
  transition: transform 0.16s var(--ease-out), box-shadow 0.2s var(--ease-move),
              background 0.2s var(--ease-move), border-color 0.2s var(--ease-move),
              color 0.2s var(--ease-move), opacity 0.2s var(--ease-move);
}
.press:active, .analyze-btn:active, .submit-btn:active, .oauth-btn:active,
.add-btn:active, .new-btn:active, .notify-btn:active, .chat-send:active,
.empty-cta:active, .cta-btn:active, .carousel-btn:active, .onboard-next:active,
.nav-signup:active, .google-btn:active, .apple-btn:active { transform: scale(0.97); }

/* Cheap hover shadow: painted once on ::after, only opacity animates */
.lift { position: relative; }
.lift::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity 0.22s var(--ease-move);
}
.lift:hover::after { opacity: 1; }

/* Inline icon helper (lucide-style strokes) */
.ic { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.12em; }

/* ── Reduced motion: collapse everything to final states ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
