/*
 * cody-design.css — Canonical Cody design system
 * ------------------------------------------------
 * Source of truth for colors, typography, spacing, shadows, motion, and
 * the "Cody personality" layer (sprites + braille thinking).
 *
 * Used by:
 *   - site/app.html (dashboard)
 *   - site/index.html and other marketing pages
 *   - entrypoints/popup (via public/cody-design.css mirror)
 *   - entrypoints/sidepanel (via public/cody-design.css mirror)
 *
 * If you edit this file, also update public/cody-design.css so the
 * extension bundle stays in sync:
 *   cp site/styles/cody-design.css public/cody-design.css
 */

/* ────────────────────────────────────────────────────────────────
 * Design tokens
 * ──────────────────────────────────────────────────────────────── */
:root {
  /* Surfaces — warm, layered, not flat */
  --cody-bg: #FBF7F2;
  --cody-surface: #FFFFFF;
  --cody-surface-warm: #FFF7EF;
  --cody-surface-sunken: #F4ECE2;
  --cody-surface-tint: #F0F9F8;

  /* Ink — deep, confident, readable */
  --cody-ink: #1B1915;
  --cody-ink-strong: #0E0D0A;
  --cody-ink-soft: #5B554E;
  --cody-ink-mute: #938A82;
  --cody-ink-faint: #BAB1A8;

  /* Lines */
  --cody-line: #EADFD1;
  --cody-line-soft: #F2E9DC;
  --cody-line-strong: #D9CCBA;

  /* Brand — teal with depth */
  --cody-teal: #2B8A7E;
  --cody-teal-deep: #1F6B60;
  --cody-teal-bright: #36B3A2;
  --cody-teal-tint: #E6F5F3;
  --cody-teal-soft: #F0F9F8;
  --cody-teal-glow: rgba(43, 138, 126, 0.18);

  /* Severity — calmer, modern hues */
  --cody-block: #DC2626;
  --cody-block-deep: #991B1B;
  --cody-block-tint: #FEE4E4;
  --cody-warn: #EA580C;
  --cody-warn-deep: #9A3412;
  --cody-warn-tint: #FFEDD5;
  --cody-concern: #CA8A04;
  --cody-concern-deep: #854D0E;
  --cody-concern-tint: #FEF3C7;
  --cody-success: #15803D;
  --cody-success-tint: #DCFCE7;

  /* Typography */
  --cody-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cody-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  --fs-micro: 11px;
  --fs-small: 12px;
  --fs-body: 14px;
  --fs-lead: 15px;
  --fs-h4: 16px;
  --fs-h3: 18px;
  --fs-h2: 22px;
  --fs-h1: 28px;
  --fs-display: 40px;
  --fs-impact: 56px;

  /* Radii */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;
  --s-10: 72px;

  /* Shadows — soft, layered, modern */
  --shadow-xs: 0 1px 2px rgba(27, 25, 21, 0.05);
  --shadow-sm: 0 1px 2px rgba(27, 25, 21, 0.04), 0 2px 4px rgba(27, 25, 21, 0.04);
  --shadow: 0 1px 2px rgba(27, 25, 21, 0.04), 0 4px 12px rgba(27, 25, 21, 0.06);
  --shadow-md: 0 2px 4px rgba(27, 25, 21, 0.05), 0 8px 24px -4px rgba(27, 25, 21, 0.10);
  --shadow-lg: 0 4px 8px rgba(27, 25, 21, 0.06), 0 20px 40px -12px rgba(27, 25, 21, 0.16);
  --shadow-focus: 0 0 0 3px var(--cody-teal-glow);
  --shadow-inset: inset 0 1px 2px rgba(27, 25, 21, 0.04);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.7, 0.0, 0.8, 0.3);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 320ms;

  /* Layout */
  --cody-max: 960px;
}

/* ────────────────────────────────────────────────────────────────
 * Base reset + typography
 * ──────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--cody-font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--cody-ink);
  background: var(--cody-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ────────────────────────────────────────────────────────────────
 * Buttons
 * ──────────────────────────────────────────────────────────────── */
.cody-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px 18px;
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1;
  color: var(--cody-ink);
  background: var(--cody-surface);
  border: 1px solid var(--cody-line);
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}

.cody-btn:hover {
  border-color: var(--cody-line-strong);
  background: var(--cody-surface-warm);
}

.cody-btn:active {
  transform: translateY(1px);
}

.cody-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--cody-teal);
}

.cody-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Primary — teal, confident, the CTA */
.cody-btn--primary {
  color: #fff;
  background: var(--cody-teal);
  border-color: var(--cody-teal);
  box-shadow: var(--shadow-sm);
}

.cody-btn--primary:hover {
  background: var(--cody-teal-deep);
  border-color: var(--cody-teal-deep);
  box-shadow: var(--shadow);
}

/* Ghost — minimal, for secondary actions */
.cody-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--cody-ink-soft);
}

.cody-btn--ghost:hover {
  background: var(--cody-surface-warm);
  color: var(--cody-ink);
}

/* Danger */
.cody-btn--danger {
  color: var(--cody-block);
  background: transparent;
  border-color: var(--cody-block-tint);
}

.cody-btn--danger:hover {
  background: var(--cody-block-tint);
  border-color: var(--cody-block);
}

/* Size variants */
.cody-btn--sm {
  padding: 6px 12px;
  font-size: var(--fs-small);
  border-radius: var(--r-sm);
}

.cody-btn--lg {
  padding: 14px 24px;
  font-size: var(--fs-lead);
  border-radius: var(--r-lg);
}

/* ────────────────────────────────────────────────────────────────
 * Cards
 * ──────────────────────────────────────────────────────────────── */
.cody-card {
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}

.cody-card--raised {
  box-shadow: var(--shadow);
}

.cody-card--interactive {
  cursor: pointer;
}

.cody-card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--cody-line);
}

.cody-card__body {
  padding: var(--s-5) var(--s-6);
}

.cody-card__header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--cody-line-soft);
}

/* ────────────────────────────────────────────────────────────────
 * Inputs
 * ──────────────────────────────────────────────────────────────── */
.cody-input {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: var(--fs-body);
  color: var(--cody-ink);
  background: var(--cody-surface);
  border: 1px solid var(--cody-line);
  border-radius: var(--r);
  outline: none;
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.cody-input::placeholder {
  color: var(--cody-ink-mute);
}

.cody-input:hover {
  border-color: var(--cody-line-strong);
}

.cody-input:focus {
  border-color: var(--cody-teal);
  box-shadow: var(--shadow-focus);
}

/* ────────────────────────────────────────────────────────────────
 * Badges (severity pills)
 * ──────────────────────────────────────────────────────────────── */
.cody-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--fs-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--r-pill);
  background: var(--cody-surface-sunken);
  color: var(--cody-ink-soft);
}

.cody-badge--block   { background: var(--cody-block-tint);   color: var(--cody-block-deep); }
.cody-badge--warn    { background: var(--cody-warn-tint);    color: var(--cody-warn-deep); }
.cody-badge--concern { background: var(--cody-concern-tint); color: var(--cody-concern-deep); }
.cody-badge--ok      { background: var(--cody-success-tint); color: var(--cody-success); }
.cody-badge--brand   { background: var(--cody-teal-tint);    color: var(--cody-teal-deep); }

/* ────────────────────────────────────────────────────────────────
 * Stat — the "impact" display
 *
 * Used for "scams blocked" / "team members" / "active devices".
 * The display variant is large and celebratory.
 * ──────────────────────────────────────────────────────────────── */
.cody-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-5) var(--s-6);
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.cody-stat__value {
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 1.05;
  color: var(--cody-ink-strong);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cody-stat__label {
  font-size: var(--fs-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cody-ink-mute);
}

.cody-stat--hero .cody-stat__value {
  font-size: var(--fs-impact);
  color: var(--cody-teal-deep);
  background: linear-gradient(135deg, var(--cody-teal) 0%, var(--cody-teal-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cody-stat--hero {
  background: linear-gradient(180deg, var(--cody-teal-soft) 0%, var(--cody-surface) 60%);
  border-color: var(--cody-teal-tint);
}

/* ────────────────────────────────────────────────────────────────
 * Hero — dashboard impact section with Cody
 *
 * Left: Cody sprite in a soft glow
 * Right: Big stat + warm one-liner
 * ──────────────────────────────────────────────────────────────── */
.cody-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-6);
  align-items: center;
  padding: var(--s-6) var(--s-7);
  background:
    radial-gradient(1200px 200px at 10% 0%, var(--cody-teal-soft), transparent 70%),
    linear-gradient(180deg, var(--cody-surface) 0%, var(--cody-surface-warm) 100%);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.cody-hero__sprite {
  width: 112px;
  height: 112px;
  border-radius: var(--r-lg);
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.cody-hero__sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cody-hero__body {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.cody-hero__eyebrow {
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cody-teal);
}

.cody-hero__headline {
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--cody-ink-strong);
  margin: 0;
}

.cody-hero__headline .count {
  background: linear-gradient(135deg, var(--cody-teal) 0%, var(--cody-teal-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
}

.cody-hero__sub {
  font-size: var(--fs-body);
  color: var(--cody-ink-soft);
  margin: 0;
}

@media (max-width: 640px) {
  .cody-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: var(--s-6);
  }
  .cody-hero__sprite {
    justify-self: center;
    width: 96px;
    height: 96px;
  }
}

/* ────────────────────────────────────────────────────────────────
 * Cody sprite — the personality asset
 *
 * Uses the v2 spritesheet GIFs from /cody-v2/ or site/images/cody-v2/.
 * Wrap in .cody-sprite for sizing + soft glow.
 * ──────────────────────────────────────────────────────────────── */
.cody-sprite {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  background: var(--cody-surface);
  overflow: hidden;
  flex-shrink: 0;
}

.cody-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cody-sprite--sm { width: 32px;  height: 32px;  border-radius: var(--r-sm); }
.cody-sprite--md { width: 56px;  height: 56px; }
.cody-sprite--lg { width: 96px;  height: 96px;  border-radius: var(--r-lg); }
.cody-sprite--xl { width: 128px; height: 128px; border-radius: var(--r-lg); }

.cody-sprite--glow {
  background:
    radial-gradient(circle at 50% 55%, var(--cody-teal-soft) 0%, var(--cody-surface) 70%);
  box-shadow: 0 0 0 1px var(--cody-line-soft), var(--shadow-sm);
}

/* ────────────────────────────────────────────────────────────────
 * Braille thinking indicator
 *
 * The "Cody is thinking" experience. Two parts:
 *   1. .cody-braille — an animated monospace glyph that cycles through
 *      10 braille frames. Driven by JS (see components/BrailleSpinner).
 *   2. .cody-thinking — the composed row: sprite + braille + label.
 * ──────────────────────────────────────────────────────────────── */
.cody-braille {
  display: inline-block;
  font-family: var(--cody-mono);
  font-size: 1em;
  line-height: 1;
  color: var(--cody-teal);
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
  text-align: center;
}

.cody-thinking {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 14px;
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-body);
  color: var(--cody-ink-soft);
}

.cody-thinking__label {
  font-weight: 500;
}

.cody-thinking__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cody-teal-bright);
  animation: cody-pulse 1.4s var(--ease) infinite;
}

@keyframes cody-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

/* Fallback braille animation using CSS content (for contexts without JS).
   Most surfaces should use the JS BrailleSpinner for crisp stepping. */
.cody-braille--css::before {
  content: "⠋";
  display: inline-block;
  animation: cody-braille 1s steps(10, end) infinite;
}

@keyframes cody-braille {
  0%   { content: "⠋"; }
  10%  { content: "⠙"; }
  20%  { content: "⠹"; }
  30%  { content: "⠸"; }
  40%  { content: "⠼"; }
  50%  { content: "⠴"; }
  60%  { content: "⠦"; }
  70%  { content: "⠧"; }
  80%  { content: "⠇"; }
  90%  { content: "⠏"; }
  100% { content: "⠋"; }
}

/* ────────────────────────────────────────────────────────────────
 * Divider
 * ──────────────────────────────────────────────────────────────── */
.cody-divider {
  height: 1px;
  background: var(--cody-line-soft);
  border: none;
  margin: var(--s-6) 0;
}

/* ────────────────────────────────────────────────────────────────
 * Tab bar
 * ──────────────────────────────────────────────────────────────── */
.cody-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--cody-surface-warm);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-inset);
}

.cody-tab {
  flex: 1;
  padding: 8px 16px;
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--cody-ink-mute);
  background: transparent;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}

.cody-tab:hover {
  color: var(--cody-ink);
}

.cody-tab[aria-selected="true"],
.cody-tab.active {
  color: var(--cody-teal-deep);
  background: var(--cody-surface);
  box-shadow: var(--shadow-xs);
}

/* ────────────────────────────────────────────────────────────────
 * Event row (activity feed)
 * ──────────────────────────────────────────────────────────────── */
.cody-event {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: start;
  padding: var(--s-4) var(--s-5);
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-lg);
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}

.cody-event + .cody-event {
  margin-top: var(--s-2);
}

.cody-event:hover {
  border-color: var(--cody-line);
  box-shadow: var(--shadow-sm);
}

.cody-event__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.cody-event__icon--block   { background: var(--cody-block-tint);   color: var(--cody-block-deep); }
.cody-event__icon--warn    { background: var(--cody-warn-tint);    color: var(--cody-warn-deep); }
.cody-event__icon--concern { background: var(--cody-concern-tint); color: var(--cody-concern-deep); }

.cody-event__body {
  min-width: 0;
}

.cody-event__label {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--cody-ink);
  margin: 0 0 2px;
}

.cody-event__desc {
  font-size: var(--fs-small);
  color: var(--cody-ink-soft);
  margin: 0;
}

.cody-event__meta {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: var(--fs-micro);
  color: var(--cody-ink-mute);
}

.cody-event__time {
  font-size: var(--fs-micro);
  color: var(--cody-ink-mute);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ────────────────────────────────────────────────────────────────
 * Avatar / member card
 * ──────────────────────────────────────────────────────────────── */
.cody-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--cody-surface-sunken);
  flex-shrink: 0;
}

.cody-avatar--lg,
.cody-avatar__placeholder.cody-avatar--lg { width: 64px; height: 64px; font-size: 22px; }

.cody-avatar--sm,
.cody-avatar__placeholder.cody-avatar--sm { width: 28px; height: 28px; font-size: 11px; }

.cody-avatar__placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--cody-teal-deep);
  background: var(--cody-teal-tint);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────────
 * Empty states
 * ──────────────────────────────────────────────────────────────── */
.cody-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-8) var(--s-6);
  text-align: center;
  background: var(--cody-surface);
  border: 1px dashed var(--cody-line);
  border-radius: var(--r-xl);
}

.cody-empty__sprite {
  width: 120px;
  height: 120px;
}

.cody-empty__title {
  font-size: var(--fs-h2);
  font-weight: 700;
  color: var(--cody-ink);
  margin: 0;
}

.cody-empty__desc {
  font-size: var(--fs-body);
  color: var(--cody-ink-soft);
  margin: 0;
  max-width: 42ch;
}

/* ────────────────────────────────────────────────────────────────
 * Sidebar (sheet) — used by profile-edit and other light overlays.
 * Simpler than the old modal; a single card with a dim backdrop.
 * ──────────────────────────────────────────────────────────────── */
.cody-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(14, 13, 10, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: var(--s-6);
  animation: cody-fade-in var(--dur) var(--ease);
}

.cody-sheet__card {
  width: 100%;
  max-width: 420px;
  background: var(--cody-surface);
  border: 1px solid var(--cody-line-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--s-7);
  animation: cody-scale-in var(--dur-slow) var(--ease-out);
}

@keyframes cody-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes cody-scale-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ────────────────────────────────────────────────────────────────
 * Utilities
 * ──────────────────────────────────────────────────────────────── */
.cody-row  { display: flex; align-items: center; gap: var(--s-3); }
.cody-col  { display: flex; flex-direction: column; gap: var(--s-3); }
.cody-grow { flex: 1; min-width: 0; }
.cody-mute { color: var(--cody-ink-mute); }
.cody-soft { color: var(--cody-ink-soft); }

.cody-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
