/* ===========================================================================
   AI, Demystified — PLATFORM BRAND SYSTEM
   The single source of truth for the unified shell: dashboard, FTUE, idea
   seeder, auth UI, and (Phase 3) cross-edition chrome.

   Direction: light, warm, museum-bright, friendly. Lowers AI intimidation.
   Scope: tokens live on :root (harmless globally). Components are scoped under
   `.aidp` so they never leak into the 10 bespoke edition designs.
   Capacitor/Cloudflare-safe: no absolute origins, no @import of remote CSS.
   =========================================================================== */

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* surfaces */
  --aidp-bg:        #FBFAF7;   /* warm paper white */
  --aidp-bg-tint:   #F4F1EA;   /* faint warm wash */
  --aidp-surface:   #FFFFFF;
  --aidp-surface-2: #FAF8F3;

  /* ink */
  --aidp-ink:       #1E1B17;   /* warm near-black */
  --aidp-ink-soft:  #6B655C;
  --aidp-ink-faint: #9A938A;

  /* line / border */
  --aidp-line:      #ECE7DD;
  --aidp-line-2:    #DED7C9;

  /* brand accents */
  --aidp-violet:      #6B5BFF;  /* primary brand accent */
  --aidp-violet-deep: #5546E6;
  --aidp-violet-soft: #ECE9FF;
  --aidp-coral:       #FF8A5B;  /* energy / CTA */
  --aidp-coral-deep:  #F26A36;
  --aidp-coral-soft:  #FFE9DF;

  /* status */
  --aidp-ok:    #2E9E6B;
  --aidp-ok-soft:#E3F5EC;
  --aidp-warn:  #C9543B;
  --aidp-warn-soft:#FBE7E1;

  /* radius */
  --aidp-r-xs: 8px;
  --aidp-r-sm: 12px;
  --aidp-r-md: 18px;
  --aidp-r-lg: 26px;
  --aidp-r-xl: 34px;
  --aidp-r-pill: 999px;

  /* spacing scale (8pt-ish) */
  --aidp-s1: 4px;  --aidp-s2: 8px;  --aidp-s3: 12px; --aidp-s4: 16px;
  --aidp-s5: 24px; --aidp-s6: 32px; --aidp-s7: 48px; --aidp-s8: 64px;
  --aidp-s9: 96px;

  /* shadows — diffuse, soft, low-contrast (museum light) */
  --aidp-shadow-soft: 0 1px 2px rgba(30,27,23,.04), 0 8px 24px rgba(30,27,23,.06);
  --aidp-shadow-lift: 0 2px 6px rgba(30,27,23,.06), 0 18px 44px rgba(30,27,23,.12);
  --aidp-shadow-pop:  0 30px 80px rgba(30,27,23,.22);

  /* typography */
  --aidp-font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --aidp-font-body:    "Karla", system-ui, -apple-system, Segoe UI, sans-serif;
  --aidp-font-mono:    ui-monospace, Menlo, Consolas, monospace;

  /* fluid type scale */
  --aidp-t-xs:   12px;
  --aidp-t-sm:   14px;
  --aidp-t-base: 16px;
  --aidp-t-lg:   18px;
  --aidp-t-xl:   clamp(20px, 2.4vw, 24px);
  --aidp-t-2xl:  clamp(24px, 3.2vw, 32px);
  --aidp-t-3xl:  clamp(30px, 4.6vw, 46px);
  --aidp-t-4xl:  clamp(40px, 7vw, 84px);

  /* motion */
  --aidp-ease:   cubic-bezier(.2, .8, .2, 1);
  --aidp-spring: cubic-bezier(.34, 1.56, .64, 1);
  --aidp-dur:    .28s;

  /* layout */
  --aidp-maxw: 1180px;

  /* shared toast theming (consumed by aidemystified.js) on the dashboard */
  --aid-toast-bg: var(--aidp-ink);
  --aid-toast-fg: #FFFFFF;
  --aid-toast-font: var(--aidp-font-body);
  --aid-toast-err: var(--aidp-warn);
  --aid-toast-ok: var(--aidp-ok);
  /* accent the shared collab launcher/dialog pick up */
  --aid-accent: var(--aidp-violet);
}

/* ── Scoped base ─────────────────────────────────────────────────────────── */
.aidp,
.aidp *,
.aidp *::before,
.aidp *::after { box-sizing: border-box; }

.aidp {
  font-family: var(--aidp-font-body);
  color: var(--aidp-ink);
  font-size: var(--aidp-t-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.aidp ::selection { background: var(--aidp-violet); color: #fff; }

.aidp :focus-visible {
  outline: 3px solid var(--aidp-violet);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Page canvas helper (dashboard body) ─────────────────────────────────── */
.aidp-page {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--aidp-violet-soft), transparent 60%),
    radial-gradient(720px 520px at -6% 108%, var(--aidp-coral-soft), transparent 55%),
    var(--aidp-bg);
  min-height: 100vh;
  min-height: 100dvh;
}
.aidp-wrap { max-width: var(--aidp-maxw); margin: 0 auto; padding: 0 var(--aidp-s5); }

/* ── Typography helpers ──────────────────────────────────────────────────── */
.aidp-display { font-family: var(--aidp-font-display); font-weight: 560; letter-spacing: -.02em; line-height: .98; }
.aidp-kicker {
  font: 600 var(--aidp-t-xs)/1 var(--aidp-font-body);
  letter-spacing: .34em; text-transform: uppercase; color: var(--aidp-ink-soft);
}
.aidp-lede { font-size: var(--aidp-t-lg); color: var(--aidp-ink-soft); line-height: 1.6; max-width: 60ch; }
.aidp-eyebrow {
  display: inline-flex; align-items: center; gap: var(--aidp-s2);
  font: 700 var(--aidp-t-xs)/1 var(--aidp-font-body);
  letter-spacing: .14em; text-transform: uppercase; color: var(--aidp-violet);
}
.aidp-em { font-style: italic; color: var(--aidp-violet); }

/* ── Wordmark ────────────────────────────────────────────────────────────── */
.aidp-wordmark {
  display: inline-flex; align-items: baseline; gap: .12em;
  font-family: var(--aidp-font-display); font-weight: 600;
  letter-spacing: -.02em; color: var(--aidp-ink); text-decoration: none;
  font-size: var(--aidp-t-xl);
}
.aidp-wordmark .mk-em { font-style: italic; color: var(--aidp-violet); }

/* ── Global nav (mountTopbar) ───────────────────────────────────────────── */
.aidp-topbar { border-bottom: 1px solid var(--aidp-line); background: color-mix(in srgb, var(--aidp-bg) 86%, transparent); position: sticky; top: 0; z-index: 90; backdrop-filter: saturate(1.1) blur(8px); }
.aidp-nav { display: flex; align-items: center; gap: var(--aidp-s3); flex-wrap: wrap; padding-top: 7px; padding-bottom: 7px; }
.aidp-nav .aidp-wordmark { font-size: var(--aidp-t-lg); }
.aidp-nav__links { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.aidp-navlink { text-decoration: none; color: var(--aidp-ink-soft); font: 600 13px/1 var(--aidp-font-body); padding: 6px 10px; border-radius: var(--aidp-r-pill); white-space: nowrap; transition: color .15s, background .15s; }
.aidp-navlink:hover { color: var(--aidp-ink); background: var(--aidp-bg-tint); }
.aidp-navlink.is-active { color: var(--aidp-violet); background: var(--aidp-violet-soft); }
.aidp-nav__status { margin-left: auto; }
.aidp-nav__auth { flex: none; }
.aidp-nav__toggle { display: none; margin-left: auto; border: 1px solid var(--aidp-line-2); background: var(--aidp-surface); color: var(--aidp-ink); border-radius: var(--aidp-r-sm); padding: 8px 13px; font-size: 16px; line-height: 1; cursor: pointer; }
@media (max-width: 880px) {
  .aidp-nav__toggle { display: inline-flex; }
  .aidp-nav__status { display: none; }
  .aidp-nav__links { display: none; order: 5; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; margin-top: var(--aidp-s2); }
  .aidp-topbar.nav-open .aidp-nav__links { display: flex; }
  .aidp-navlink { padding: 11px 12px; }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.aidp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  font: 700 var(--aidp-t-sm)/1 var(--aidp-font-body);
  padding: 12px 20px; min-height: 44px;
  border-radius: var(--aidp-r-pill); border: 1.5px solid transparent;
  background: var(--aidp-ink); color: #fff; cursor: pointer;
  transition: transform var(--aidp-dur) var(--aidp-ease),
              box-shadow var(--aidp-dur) var(--aidp-ease),
              background var(--aidp-dur) var(--aidp-ease),
              border-color var(--aidp-dur) var(--aidp-ease),
              filter var(--aidp-dur) var(--aidp-ease);
  text-decoration: none; white-space: nowrap;
}
.aidp-btn:hover { transform: translateY(-2px); box-shadow: var(--aidp-shadow-lift); }
.aidp-btn:active { transform: translateY(0); }
.aidp-btn[disabled] { cursor: not-allowed; filter: grayscale(.4) opacity(.55); transform: none; box-shadow: none; }

.aidp-btn--cta { background: var(--aidp-coral); color: #2a1a12; }
.aidp-btn--cta:hover { background: var(--aidp-coral-deep); color: #fff; }

.aidp-btn--brand { background: var(--aidp-violet); }
.aidp-btn--brand:hover { background: var(--aidp-violet-deep); }

.aidp-btn--ghost {
  background: var(--aidp-surface); color: var(--aidp-ink);
  border-color: var(--aidp-line-2); box-shadow: var(--aidp-shadow-soft);
}
.aidp-btn--ghost:hover { border-color: var(--aidp-violet); color: var(--aidp-violet); }

.aidp-btn--sm { min-height: 36px; padding: 8px 14px; font-size: var(--aidp-t-xs); }
.aidp-btn--lg { min-height: 52px; padding: 15px 28px; font-size: var(--aidp-t-base); }

/* ── Chips (selectable presets) ──────────────────────────────────────────── */
.aidp-chip {
  display: inline-flex; align-items: center; gap: .4em;
  font: 600 var(--aidp-t-sm)/1 var(--aidp-font-body);
  padding: 9px 14px; min-height: 38px;
  border-radius: var(--aidp-r-pill);
  border: 1.5px solid var(--aidp-line-2); background: var(--aidp-surface);
  color: var(--aidp-ink-soft); cursor: pointer;
  transition: all var(--aidp-dur) var(--aidp-ease);
}
.aidp-chip:hover { border-color: var(--aidp-violet); color: var(--aidp-ink); }
.aidp-chip[aria-pressed="true"],
.aidp-chip.is-on {
  background: var(--aidp-violet-soft); border-color: var(--aidp-violet);
  color: var(--aidp-violet-deep);
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.aidp-card {
  background: var(--aidp-surface); border: 1px solid var(--aidp-line);
  border-radius: var(--aidp-r-md); box-shadow: var(--aidp-shadow-soft);
  transition: transform var(--aidp-dur) var(--aidp-ease),
              box-shadow var(--aidp-dur) var(--aidp-ease),
              border-color var(--aidp-dur) var(--aidp-ease);
}
.aidp-card--link { display: block; text-decoration: none; color: inherit; overflow: hidden; }
.aidp-card--link:hover { transform: translateY(-6px); box-shadow: var(--aidp-shadow-lift); border-color: var(--aidp-line-2); }
.aidp-card__pad { padding: var(--aidp-s5); }

/* ── Pills / badges (status) ─────────────────────────────────────────────── */
.aidp-pill {
  display: inline-flex; align-items: center; gap: .5em;
  font: 600 var(--aidp-t-xs)/1 var(--aidp-font-body);
  padding: 7px 12px; border-radius: var(--aidp-r-pill);
  border: 1px solid var(--aidp-line-2); color: var(--aidp-ink-soft);
  background: var(--aidp-surface);
}
.aidp-pill b { color: var(--aidp-ink); font-weight: 700; }
.aidp-pill.is-on  { border-color: #BFE6CF; color: #1d7a4f; background: var(--aidp-ok-soft); }
.aidp-pill.is-off { border-color: #F0C9BF; color: #b14a34; background: var(--aidp-warn-soft); }
.aidp-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.aidp-tag {
  font: 700 var(--aidp-t-xs)/1 var(--aidp-font-body);
  letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 10px; border-radius: var(--aidp-r-xs);
  background: var(--aidp-violet-soft); color: var(--aidp-violet-deep);
}
.aidp-tag--soon { background: var(--aidp-bg-tint); color: var(--aidp-ink-faint); }

/* ── Form fields ─────────────────────────────────────────────────────────── */
.aidp-field {
  width: 100%; font: 400 var(--aidp-t-base)/1.5 var(--aidp-font-body);
  color: var(--aidp-ink); background: var(--aidp-surface);
  border: 1.5px solid var(--aidp-line-2); border-radius: var(--aidp-r-sm);
  padding: 12px 14px; transition: border-color var(--aidp-dur) var(--aidp-ease), box-shadow var(--aidp-dur) var(--aidp-ease);
}
.aidp-field::placeholder { color: var(--aidp-ink-faint); }
.aidp-field:focus { outline: none; border-color: var(--aidp-violet); box-shadow: 0 0 0 3px var(--aidp-violet-soft); }
textarea.aidp-field { min-height: 84px; resize: vertical; }
.aidp-label { display: block; font: 700 var(--aidp-t-xs)/1 var(--aidp-font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--aidp-ink-soft); margin-bottom: var(--aidp-s2); }

/* ── Section header ──────────────────────────────────────────────────────── */
.aidp-section { padding: var(--aidp-s8) 0; }
.aidp-section__head { margin-bottom: var(--aidp-s6); }
.aidp-section__title { font-family: var(--aidp-font-display); font-weight: 580; font-size: var(--aidp-t-2xl); letter-spacing: -.01em; margin: var(--aidp-s2) 0 var(--aidp-s2); }
.aidp-section__sub { color: var(--aidp-ink-soft); max-width: 64ch; }

/* ── Overlay / modal shell (FTUE + auth) ─────────────────────────────────── */
.aidp-overlay {
  position: fixed; inset: 0; z-index: 10050;
  display: grid; place-items: center; padding: var(--aidp-s5);
  background: rgba(30, 27, 23, .42); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity var(--aidp-dur) var(--aidp-ease), visibility var(--aidp-dur);
}
.aidp-overlay.is-open { opacity: 1; visibility: visible; }
.aidp-sheet {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: var(--aidp-surface); border-radius: var(--aidp-r-lg);
  box-shadow: var(--aidp-shadow-pop); border: 1px solid var(--aidp-line);
  transform: translateY(10px) scale(.99);
  transition: transform var(--aidp-dur) var(--aidp-spring);
  padding: var(--aidp-s7);
}
.aidp-overlay.is-open .aidp-sheet { transform: translateY(0) scale(1); }
.aidp-sheet__close {
  position: absolute; top: 14px; right: 14px;
  min-width: 38px; height: 38px; padding: 0 14px; border-radius: var(--aidp-r-pill);
  border: 1px solid var(--aidp-line-2); background: var(--aidp-surface);
  color: var(--aidp-ink-soft); cursor: pointer; font-size: 14px; line-height: 1;
  white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
}
.aidp-sheet__close:hover { color: var(--aidp-ink); border-color: var(--aidp-violet); }

/* ── Dots / steppers ─────────────────────────────────────────────────────── */
.aidp-dots { display: inline-flex; gap: var(--aidp-s2); }
.aidp-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--aidp-line-2); transition: all var(--aidp-dur) var(--aidp-ease); }
.aidp-dots i.is-on { background: var(--aidp-violet); width: 22px; border-radius: var(--aidp-r-pill); }

/* ── Account chip ────────────────────────────────────────────────────────── */
.aidp-account { display: inline-flex; align-items: center; gap: var(--aidp-s2); }
.aidp-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--aidp-violet); color: #fff; display: grid; place-items: center;
  font: 700 13px/1 var(--aidp-font-body); object-fit: cover; overflow: hidden;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.aidp-row { display: flex; gap: var(--aidp-s3); align-items: center; flex-wrap: wrap; }
.aidp-spread { justify-content: space-between; }
.aidp-stack > * + * { margin-top: var(--aidp-s4); }
.aidp-muted { color: var(--aidp-ink-soft); }
.aidp-hide { display: none !important; }
.aidp-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: aidp-spin .7s linear infinite; vertical-align: -3px; }
@keyframes aidp-spin { to { transform: rotate(360deg); } }
@keyframes aidp-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .aidp *, .aidp *::before, .aidp *::after { transition: none !important; animation: none !important; }
}
