/* Keygrip app styles — brand tokens mirror docs/style-guide.md (keygrip.ai). */
@font-face { font-family: 'Plus Jakarta Sans'; src: url("fonts/PlusJakartaSans-400.503e7cbdb484.woff2") format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url("fonts/PlusJakartaSans-500.e5e6761eaecb.woff2") format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url("fonts/PlusJakartaSans-600.79e62f3332cd.woff2") format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url("fonts/PlusJakartaSans-700.5b629bd8abb4.woff2") format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

@font-face { font-family: 'Tid'; src: url("fonts/Tid-Light.3e159c32e3ab.woff2") format('woff2');   font-weight: 300;     font-style: normal; font-display: swap; }
@font-face { font-family: 'Tid'; src: url("fonts/Tid-Regular.8dbd042b1640.woff2") format('woff2'); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Tid'; src: url("fonts/Tid-Bold.791335b80564.woff2") format('woff2');    font-weight: 600 700; font-style: normal; font-display: swap; }

/* clip.cool dark theme (Slate + cyan). Tokens drive the whole app; clips.css references them too. */
:root {
  --kg-cyan: #61D9EF;
  --kg-cyan-strong: #2bb6d1;
  --kg-ink: #e6edf3;        /* near-white text */
  --kg-grey: #8b949e;       /* muted text */
  --kg-canvas: #0d1117;     /* page background (deep slate) */
  --kg-surface: #161b22;    /* cards / header / inputs (raised slate) */
  --kg-surface-2: #1c222b;  /* raised: tags, chips, media placeholders, input fills */
  --kg-line: #2a3038;       /* borders */
  --kg-on-accent: #0b1620;  /* dark text on the light cyan accent */
  --kg-serif: 'Tid', Georgia, "Times New Roman", serif;
  --kg-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --kg-radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--kg-canvas);
  color: var(--kg-ink);
  font-family: var(--kg-sans);
}

/* Content links: the site accent reads on the dark canvas (browser default purple does not). A bare
   `a` rule beats the UA's :visited purple (author > UA), so no :visited selector is needed — and
   adding one would out-specify .kg-btn-primary and paint visited buttons cyan-on-cyan. Buttons,
   nav, and account links keep their own (more-specific) colors. */
a { color: var(--kg-cyan); }
a:hover { color: var(--kg-cyan-strong); }

.kg-shell { margin: auto; width: 100%; max-width: 34rem; padding: 2rem 1.25rem; }

.kg-wordmark {
  font-family: var(--kg-serif);
  font-size: 4rem;
  line-height: 1;
  text-align: center;
  color: var(--kg-ink);
  margin-bottom: 1.75rem;
}

.kg-card {
  background: var(--kg-surface);
  border: 1px solid var(--kg-line);
  border-top: 4px solid var(--kg-cyan);
  border-radius: var(--kg-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 2.25rem 2rem;
}

.kg-title { font-family: var(--kg-serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 0.35rem; }
.kg-sub   { color: var(--kg-grey); margin: 0 0 1.5rem; font-size: 0.95rem; }

.kg-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.65rem 1.1rem; align-items: center; margin: 0 0 1.75rem; }
.kg-meta dt { color: var(--kg-grey); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kg-meta dd { margin: 0; font-weight: 500; word-break: break-word; }

.kg-roles { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.kg-pill {
  background: rgba(97, 217, 239, 0.18);
  border: 1px solid var(--kg-cyan);
  color: var(--kg-ink);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.kg-muted { color: var(--kg-grey); }

.kg-btn {
  font-family: var(--kg-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: transparent;
  color: var(--kg-ink);
  border: 1px solid var(--kg-line);
  border-radius: 8px;
  padding: 0.6rem 1.15rem;
  transition: border-color 0.15s, background 0.15s;
}
.kg-btn:hover { border-color: var(--kg-ink); background: rgba(255, 255, 255, 0.06); }
.kg-btn-ghost { border-color: transparent; color: var(--kg-grey); }
/* Filled accent button for the primary action of a form (Upload, Record, Share). */
.kg-btn-primary { background: var(--kg-cyan); border-color: var(--kg-cyan); color: var(--kg-on-accent); }
.kg-btn-primary:hover { background: var(--kg-cyan-strong); border-color: var(--kg-cyan-strong); }

/* Form fields — shared primitives used by the clip forms (record, upload, caption, edit, builder).
   This is the baseline that finally styles the bare record/upload inputs; the page-scoped rules in
   clips.css (.builder-controls / .clip-edit-form) load later and override these where they differ. */
.kg-field { margin-bottom: 1.15rem; }
.kg-field > label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 600; color: var(--kg-ink); }
.kg-field > input[type="text"],
.kg-field > input[type="file"],
.kg-field > input:not([type]),
.kg-field > textarea,
.kg-field > select {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--kg-sans);
  font-size: 0.95rem;
  color: var(--kg-ink);
  background: var(--kg-surface-2);
  border: 1px solid var(--kg-line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kg-field > input::placeholder,
.kg-field > textarea::placeholder { color: var(--kg-grey); }
.kg-field > input[type="file"] { cursor: pointer; padding: 0.5rem 0.6rem; }
.kg-field > input:focus,
.kg-field > textarea:focus,
.kg-field > select:focus {
  outline: none;
  border-color: var(--kg-cyan);
  box-shadow: 0 0 0 3px rgba(97, 217, 239, 0.18);
}

/* App shell — authenticated multi-tenant layout (header + main) */
.kg-app { width: 100%; min-height: 100vh; display: flex; flex-direction: column; }
.kg-header {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.8rem 1.5rem;
  background: var(--kg-surface); border-bottom: 1px solid var(--kg-line);
}
.kg-brand { font-family: var(--kg-serif); font-size: 1.5rem; color: var(--kg-ink); text-decoration: none; }
.kg-nav { display: flex; gap: 1rem; }
.kg-nav a {
  color: var(--kg-grey); text-decoration: none; font-weight: 600; font-size: 0.9rem;
  padding: 0.2rem 0; border-bottom: 2px solid transparent;
}
.kg-nav a:hover { color: var(--kg-ink); }
.kg-nav a.is-active { color: var(--kg-ink); border-bottom-color: var(--kg-cyan); }
.kg-account { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; font-size: 0.85rem; }
.kg-org { font-weight: 600; }
.kg-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.kg-main { flex: 1; width: 100%; max-width: 60rem; margin: 0 auto; padding: 2rem 1.5rem; }
.kg-page-head { margin-bottom: 1.5rem; }

/* Long-form copy (About and similar static pages). */
.kg-prose { max-width: 42rem; }
.kg-prose h2 {
  font-family: var(--kg-serif); font-weight: 600; font-size: 1.15rem;
  margin: 1.75rem 0 0.5rem;
}
.kg-prose p { margin: 0 0 1rem; line-height: 1.6; color: var(--kg-ink); }
.kg-prose code {
  font-size: 0.88em; background: var(--kg-surface);
  border: 1px solid var(--kg-line); border-radius: 5px; padding: 0.05rem 0.3rem;
}

.kg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.kg-list-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--kg-surface); border: 1px solid var(--kg-line);
  border-radius: 10px; padding: 0.9rem 1.1rem;
}
.kg-list-name { font-weight: 600; }
.kg-empty {
  background: var(--kg-surface); border: 1px dashed var(--kg-line);
  border-radius: var(--kg-radius); padding: 2.5rem 1.5rem; text-align: center;
}
.kg-empty-title { font-family: var(--kg-serif); font-weight: 600; font-size: 1.1rem; margin: 0 0 0.35rem; }

.kg-acct-link { color: var(--kg-grey); text-decoration: none; font-weight: 600; font-size: 0.85rem; }
.kg-acct-link:hover { color: var(--kg-ink); }

/* API credentials page */
.kg-input { font-family: var(--kg-sans); font-size: 0.95rem; padding: 0.55rem 0.8rem; border: 1px solid var(--kg-line); border-radius: 8px; min-width: 18rem; }
.kg-btn-danger { color: #fca5a5; border-color: var(--kg-line); }
.kg-btn-danger:hover { border-color: #f87171; background: rgba(239, 68, 68, 0.12); }
.kg-alert { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; border-radius: 8px; padding: 0.7rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; }
.kg-secret { background: var(--kg-surface); border: 1px solid var(--kg-cyan); border-radius: var(--kg-radius); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.kg-secret-title { font-weight: 600; margin: 0 0 0.75rem; }
.kg-code { background: var(--kg-canvas); border: 1px solid var(--kg-line); border-radius: 8px; padding: 0.8rem 1rem; margin: 0.5rem 0 0; font-size: 0.78rem; line-height: 1.55; overflow-x: auto; white-space: pre; }

/* Temporary testing/identity panel */
.kg-panel { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--kg-line); }
.kg-token {
  display: inline-block; max-width: 100%; overflow-wrap: anywhere; word-break: break-all;
  font-size: 0.72rem; background: var(--kg-canvas); border: 1px solid var(--kg-line);
  border-radius: 6px; padding: 0.4rem 0.55rem;
}

/* Impersonation banner (django-hijack, ADR 0010) — fixed full-width top bar.
   position:fixed takes it out of the (flex) body flow so it spans the top instead of
   becoming a side column; body.kg-imp pads content down to clear it. */
.kg-impersonating {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap;
  background: #21262d; color: #fff;
  padding: 0.5rem 1rem; font-size: 0.85rem;
  border-bottom: 3px solid var(--kg-cyan);
}
.kg-impersonating .kg-btn { background: #fff; }
body.kg-imp { padding-top: 2.75rem; }   /* clear the fixed impersonation bar */

/* Dev-instance banner — fixed full-width top bar shown on local/mc instances only (never prod),
   so a throwaway dev tab is never mistaken for production. Same fixed-out-of-flex-flow trick as
   the impersonation bar; cyan accent on ink text marks it clearly non-prod and on-brand. */
.kg-devbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1001;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--kg-cyan); color: var(--kg-on-accent);
  padding: 0.35rem 1rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em;
  border-bottom: 1px solid var(--kg-cyan-strong);
}
body.kg-dev { padding-top: 2.1rem; }   /* clear the fixed dev bar */
/* When impersonating on a dev instance, stack the two bars: dev on top, imp below it. */
body.kg-dev .kg-impersonating { top: 2.1rem; }
body.kg-dev.kg-imp { padding-top: 4.85rem; }

/* CSP lab page */
.kg-h2 { font-family: var(--kg-serif); font-weight: 600; font-size: 1.05rem; color: var(--kg-ink); margin: 1.6rem 0 0.6rem; }
.kg-row { display: flex; gap: 0.5rem; align-items: center; }
/* Create-credential form: clear separation from the list below (was a CSP-dropped inline style). */
.kg-creds-form { margin: 1.5rem 0 2.5rem; }
.kg-out { margin-top: 0.6rem; padding: 0.6rem 0.8rem; background: var(--kg-canvas); border: 1px solid var(--kg-line); border-radius: 8px; font-size: 0.9rem; }
.kg-back { display: inline-block; margin-top: 1.5rem; }
[x-cloak] { display: none !important; }

/* Clippy — the floating, dismissible clip.cool mascot (markup: _clippy.html) */
.clippy {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  pointer-events: none; /* let clicks fall through the gap; children re-enable */
}
.clippy-full {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}
.clippy-bubble,
.clippy-toggle,
.clippy-restore { pointer-events: auto; }

/* tiny dimmed paperclip shown after "Hide Clippy" — the way back */
.clippy-restore {
  position: absolute;
  right: 0;
  bottom: 0;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  line-height: 0;
  opacity: 0.35;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.clippy-restore:hover { opacity: 1; transform: translateY(-2px); }
.clippy-restore img { width: 28px; height: 28px; }

.clippy-bubble {
  position: relative;
  max-width: 16rem;
  background: var(--kg-surface);
  color: var(--kg-ink);
  border: 1px solid var(--kg-line);
  border-top: 4px solid var(--kg-cyan);
  border-radius: var(--kg-radius);
  padding: 0.85rem 1rem 0.7rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
/* little tail pointing down-right toward the paperclip */
.clippy-bubble::after {
  content: "";
  position: absolute;
  right: 1.75rem;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: var(--kg-surface);
  border-right: 1px solid var(--kg-line);
  border-bottom: 1px solid var(--kg-line);
  transform: rotate(45deg);
}
.clippy-text { margin: 0 0 0.5rem; font-size: 0.9rem; line-height: 1.45; }

.clippy-close {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--kg-grey);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
}
.clippy-close:hover { color: var(--kg-ink); }

.clippy-hide {
  background: none;
  border: none;
  color: var(--kg-grey);
  font-family: var(--kg-sans);
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.clippy-hide:hover { color: var(--kg-ink); }

.clippy-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  transition: transform 0.15s ease;
}
.clippy-toggle:hover { transform: translateY(-3px) rotate(-4deg); }
.clippy-toggle img { width: 72px; height: 72px; }

@media (max-width: 640px) {
  .clippy { right: 0.75rem; bottom: 0.75rem; }
  .clippy-toggle img { width: 56px; height: 56px; }
  .clippy-bubble { max-width: 13rem; }
}
