/* ============================================================
   ArtzAIn — theme layer for the operator app.
   Spec: docs/ArtzAIn Design System.md (authoritative).

   Light is the default; [data-theme="dark"] on <html> flips every
   semantic alias (theme.js persists the choice). Load AFTER each
   page's own styles: this file must win the cascade over inline
   page tokens.

   Layout of this file:
     1. Design tokens, verbatim from the spec (both themes).
     2. App extension tokens (values the spec does not name).
     3. Base styles + ported chrome (.theme-toggle).
   Every call site uses the semantic names; the CogNEXUS-era
   legacy bridge that once lived in section 2 is retired.
   ============================================================ */

/* ══ 0 · FONTS ══
   Self-hosted latin variable subsets (spec §4: self-host as latin .woff2
   for offline use). Weight ranges cover every step the system uses. */

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/public/fonts/outfit.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/public/fonts/figtree.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Figtree';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/public/fonts/figtree-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/public/fonts/jetbrains-mono.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ══ 1 · TOKENS (spec §3–§5) ══ */

:root {
  /* ── Brand: Iris ── */
  --iris-50:  #f1efff;
  --iris-100: #e2ddfe;
  --iris-200: #c7bffc;
  --iris-300: #a89bf8;
  --iris-400: #8b76f0;
  --iris-500: #6a55e0;  /* brand primary */
  --iris-600: #5540c9;  /* hover / press, text-safe on light */
  --iris-700: #4331a4;
  --iris-800: #35287c;
  --iris-900: #261d59;

  /* ── Neutrals: warm stone ── */
  --stone-0:   #ffffff;
  --stone-25:  #fcfbf9;
  --stone-50:  #f7f5f2;
  --stone-100: #efece7;
  --stone-200: #e2ded7;
  --stone-300: #cfc9bf;
  --stone-400: #a9a196;
  --stone-500: #837a6e;
  --stone-600: #625a50;
  --stone-700: #47413a;
  --stone-800: #302b26;
  --stone-900: #1e1a17;

  /* ── Dark-theme canvas ── */
  --ink-950: #131118;
  --ink-900: #1a1721;
  --ink-800: #221e2b;
  --ink-700: #2c2737;
  --ink-600: #383144;

  /* ── Verdicts (VIVID, decision state only) ── */
  --allow:  #2e9e5b;
  --deny:   #d4483b;
  --review: #d08010;
  --info:   #2f72c4;
  --allow-bright:  #4ec97e;   /* dark-theme pairs */
  --deny-bright:   #f0705f;
  --review-bright: #eda42c;
  --info-bright:   #5f9ce8;

  /* ── Domains (MUTED, categorical, never state) ── */
  --domain-security:   #4c6e9b;
  --domain-legal:      #6d5ba6;
  --domain-compliance: #3f7d77;
  --domain-privacy:    #8a4f72;
  --domain-financial:  #9a6b3f;
  --domain-context:    #5e8055;
  --domain-governance: #5a5aa8;

  /* ── Maker mark: CogNEXUS Labs teal (credits only, never product UI) ── */
  --cognexus-teal:     #009395;
  --cognexus-teal-ink: #007173;

  /* ══ SEMANTIC ALIASES, light theme (default). PREFER THESE. ══ */
  --bg-page:        var(--stone-25);
  --bg-sunken:      var(--stone-50);
  --surface:        var(--stone-0);
  --surface-raised: var(--stone-0);
  --surface-sunken: var(--stone-50);
  --surface-inset:  var(--stone-100);

  --text-heading: var(--stone-900);
  --text-body:    var(--stone-700);
  /* muted/faint carry their OWN values, not stone-500/400: those ramp steps
     fail 4.5:1 AA on white. Do not "simplify" them back to the ramp. */
  --text-muted:   #6b6358;
  --text-faint:   #7a7167;

  --hairline:        var(--stone-200);
  --hairline-strong: var(--stone-300);

  --accent:         var(--iris-500);
  --accent-hover:   var(--iris-600);
  --accent-text:    var(--iris-600);
  --accent-fill:    var(--iris-50);
  --accent-line:    var(--iris-200);
  --text-on-accent: #ffffff;
  --focus-ring:     rgba(106, 85, 224, 0.32);

  --verdict-allow:  var(--allow);
  --verdict-deny:   var(--deny);
  --verdict-review: var(--review);
  --verdict-info:   var(--info);
  --allow-fill:  #e7f5ec;
  --deny-fill:   #fbeceb;
  --review-fill: #fbf1e0;
  --info-fill:   #e9f1fb;

  /* Verdict INK — small text sitting on the light verdict fills. The vivid
     values are tuned as marks, not as text: at small sizes on their own fills
     they land under the 4.5:1 AA floor. Same hue, lower lightness, following
     the spec's own "-ink" convention (--cognexus-teal-ink). The vivid
     originals stay in use for dots, bars, and solid fills. */
  --allow-ink:  #247b47;
  --deny-ink:   #bd4035;
  --review-ink: #9a5f0c;
  --info-ink:   #2d6cba;

  /* ── Type (spec §4) ── */
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --fw-regular: 400;  --fw-medium: 500;  --fw-semibold: 600;  --fw-bold: 700;

  --text-2xs: 0.6875rem;  /* 11, chip + micro-label */
  --text-xs: 0.75rem;     /* 12, eyebrow, table header, caption */
  --text-sm: 0.8125rem;   /* 13, secondary UI, metadata */
  --text-base: 0.875rem;  /* 14, UI default */
  --text-md: 1rem;        /* 16, body / long-form */
  --text-lg: 1.125rem;    /* 18, card title */
  --text-xl: 1.375rem;    /* 22, panel title */
  --text-2xl: 1.75rem;    /* 28, page title */
  --text-3xl: 2.25rem;    /* 36, section title */
  --text-4xl: 3rem;       /* 48, marketing headline */
  --text-display: clamp(2.25rem, 5vw, 3.75rem);

  --leading-tight: 1.12;
  --leading-snug: 1.28;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  --tracking-tight: -0.022em;
  --tracking-snug: -0.012em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-caps: 0.09em;

  /* ── Space, shape, elevation, motion (spec §5) ── */
  --space-1: 0.25rem;  --space-2: 0.5rem;   --space-3: 0.75rem;
  --space-4: 1rem;     --space-5: 1.25rem;  --space-6: 1.5rem;
  --space-8: 2rem;     --space-10: 2.5rem;  --space-12: 3rem;
  --space-16: 4rem;    --space-20: 5rem;    --space-28: 7rem;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;   /* controls, inputs */
  --radius-lg: 14px;   /* cards */
  --radius-xl: 18px;   /* panels, modals */
  --radius-2xl: 24px;  /* hero surfaces, feature tiles */
  --radius-pill: 9999px;

  --shadow-xs: 0 1px 2px rgba(48, 43, 38, 0.06);
  --shadow-sm: 0 1px 3px rgba(48, 43, 38, 0.07), 0 1px 2px rgba(48, 43, 38, 0.05);
  --shadow-md: 0 4px 12px rgba(48, 43, 38, 0.08), 0 1px 3px rgba(48, 43, 38, 0.05);
  --shadow-lg: 0 12px 28px rgba(48, 43, 38, 0.10), 0 4px 8px rgba(48, 43, 38, 0.05);
  --shadow-xl: 0 24px 56px rgba(48, 43, 38, 0.14), 0 8px 16px rgba(48, 43, 38, 0.06);
  --shadow-accent:    0 6px 20px -6px rgba(106, 85, 224, 0.45);
  --shadow-accent-lg: 0 14px 32px -10px rgba(106, 85, 224, 0.5);

  /* Flock field: the customer's agent fleet, abstracted */
  --flock-size: 22px 22px;
  --flock-dots: radial-gradient(circle at 1px 1px, rgba(106, 85, 224, 0.13) 1px, transparent 0);

  --blur-sm: blur(8px);
  --blur-md: blur(14px);
  --glass: rgba(252, 251, 249, 0.78);

  --ease: cubic-bezier(0.32, 0.72, 0.28, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 0.12s;  --dur: 0.2s;  --dur-slow: 0.45s;
  --transition-base: all 0.2s cubic-bezier(0.32, 0.72, 0.28, 1);

  --container: 1160px;
  --container-wide: 1320px;
  --sidebar-w: 248px;
  --hit-target: 44px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg-page:        var(--ink-950);
  --bg-sunken:      #0e0c12;
  --surface:        var(--ink-900);
  --surface-raised: var(--ink-800);
  --surface-sunken: var(--ink-950);
  --surface-inset:  var(--ink-800);

  --text-heading: #f4f2f7;
  --text-body:    #d6d2de;
  --text-muted:   #948da3;
  --text-faint:   #857d96;

  --hairline:        rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --accent:         var(--iris-400);
  --accent-hover:   var(--iris-300);
  --accent-text:    var(--iris-300);
  --accent-fill:    rgba(139, 118, 240, 0.16);
  --accent-line:    rgba(139, 118, 240, 0.38);
  --text-on-accent: #16121f;
  --focus-ring:     rgba(139, 118, 240, 0.45);

  --verdict-allow:  var(--allow-bright);
  --verdict-deny:   var(--deny-bright);
  --verdict-review: var(--review-bright);
  --verdict-info:   var(--info-bright);
  --allow-fill:  rgba(78, 201, 126, 0.14);
  --deny-fill:   rgba(240, 112, 95, 0.14);
  --review-fill: rgba(237, 164, 44, 0.14);
  --info-fill:   rgba(95, 156, 232, 0.14);
  /* on dark the bright pairs clear AA on their own fills — ink = the vivid value */
  --allow-ink:  var(--allow-bright);
  --deny-ink:   var(--deny-bright);
  --review-ink: var(--review-bright);
  --info-ink:   var(--info-bright);

  /* domains lift so they hold up on dark surfaces */
  --domain-security:   #7fa3d1;
  --domain-legal:      #a08fd8;
  --domain-compliance: #6fb3ab;
  --domain-privacy:    #c283a6;
  --domain-financial:  #cd9d6b;
  --domain-context:    #93b587;
  --domain-governance: #8f8fd8;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.6);
  --shadow-accent:    0 6px 20px -6px rgba(139, 118, 240, 0.5);
  --shadow-accent-lg: 0 14px 32px -10px rgba(139, 118, 240, 0.55);
  --flock-dots: radial-gradient(circle at 1px 1px, rgba(168, 155, 248, 0.11) 1px, transparent 0);
  --glass: rgba(19, 17, 24, 0.78);

  color-scheme: dark;
}

/* ══ 2 · APP EXTENSION TOKENS ══
   Beyond the spec's layer: values this app needs that the spec does not
   name. (The CogNEXUS-era legacy bridge that lived here is retired; every
   call site now uses the semantic names. developers.html keeps its own
   self-contained vocabulary, and .pd-record scopes its --pd-* set.) */

:root {
  --accent-fill-faint: rgba(106, 85, 224, 0.06);
  --hairline-faint: rgba(30, 26, 23, 0.06);
  --scrim-bg: rgba(30, 26, 23, 0.42);
  --glass-solid: rgba(252, 251, 249, 0.97);
}

[data-theme="dark"] {
  --accent-fill-faint: rgba(139, 118, 240, 0.08);
  --hairline-faint: rgba(255, 255, 255, 0.05);
  --scrim-bg: rgba(4, 3, 8, 0.6);
  --glass-solid: rgba(19, 17, 24, 0.97);
}

/* ══ 3 · BASE ══ */

body {
  background: var(--bg-page);
  color: var(--text-body);
}

/* Machine values are always mono (spec §4): ids, hashes, code, keys. */
code, kbd, samp { font-family: var(--font-mono); }

::selection { background: var(--iris-200); color: var(--stone-900); }
[data-theme="dark"] ::selection { background: var(--iris-700); color: #f4f2f7; }

/* Default focus treatment. !important so inline `all:unset` controls
   (view tabs, jump tiles) cannot lose their ring: the focus ring is
   never removed (spec §5). Text controls are excluded: they draw the
   border + halo below instead, and the !important would otherwise beat
   their outline:none and paint both treatments at once. */
:focus-visible:not(input, textarea, select) {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Inputs: focus draws an accent border plus the 3px halo (spec §7).
   Plain :focus, not :focus-visible — text controls always show it. */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* 16px inputs on small screens prevent iOS focus zoom (spec §7).
   !important: page rules set smaller sizes at higher specificity. */
@media (max-width: 900px) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="search"], input[type="number"], input[type="url"],
  textarea, select {
    font-size: 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto !important; }
}

/* ══ GOVERNANCE PRIMITIVES (spec §7) ══
   A decision outcome, a policy domain, and a registry identity are brand
   objects, not generic badges. */

/* Verdict — always lowercase, always mono, vivid. The single most
   important object in the UI. */
.verdict {
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--fw-medium);
  text-transform: lowercase; padding: 0.15rem var(--space-2); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap;
}
/* the dot keeps the vivid value; the label uses the AA-safe ink */
.verdict::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--vivid); }
.verdict.nodot::before { display: none; }
.verdict.allow  { color: var(--allow-ink);  background: var(--allow-fill);  --vivid: var(--verdict-allow); }
.verdict.deny   { color: var(--deny-ink);   background: var(--deny-fill);   --vivid: var(--verdict-deny); }
.verdict.review { color: var(--review-ink); background: var(--review-fill); --vivid: var(--verdict-review); }
.verdict.info   { color: var(--info-ink);   background: var(--info-fill);   --vivid: var(--verdict-info); }
/* amber wants dark ink on solid fills */
.verdict.review.solid { background: var(--review); color: var(--stone-900); }

/* DomainTag — muted, classifies but never judges */
.domain {
  font-family: var(--font-body); font-size: var(--text-2xs); font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide); padding: 0.12rem var(--space-2); border-radius: var(--radius-pill);
  color: var(--d); background: color-mix(in srgb, var(--d) 12%, transparent); white-space: nowrap;
}
.domain.security   { --d: var(--domain-security); }
.domain.legal      { --d: var(--domain-legal); }
.domain.compliance { --d: var(--domain-compliance); }
.domain.privacy    { --d: var(--domain-privacy); }
.domain.financial  { --d: var(--domain-financial); }
.domain.context    { --d: var(--domain-context); }
.domain.governance { --d: var(--domain-governance); }

/* StatusDot — liveness is not a verdict */
.status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
.status .dot { width: 8px; height: 8px; border-radius: var(--radius-pill); flex-shrink: 0; }
.status.live .dot { background: var(--verdict-allow); box-shadow: 0 0 0 3px color-mix(in srgb, var(--verdict-allow) 22%, transparent); }
.status.degraded .dot { background: var(--verdict-review); box-shadow: 0 0 0 3px color-mix(in srgb, var(--verdict-review) 22%, transparent); }
.status.paused .dot { background: var(--text-faint); }
.status.retired .dot { background: var(--hairline-strong); }

/* Chip — uppercase mono micro-label on a sunken surface */
.chip {
  font-family: var(--font-mono); font-size: var(--text-2xs); font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted);
  background: var(--surface-sunken); padding: 0.15rem var(--space-2); border-radius: var(--radius-sm);
}

/* Flock field motif — always masked, always behind content (spec §5).
   The spec snippet names this `.field`, but that name is taken in the app:
   login.html uses .field as its form-field wrapper, and this layer loads
   after page styles — so the spec name would absolutely-position every
   form field over its nearest positioned ancestor and disable its pointer
   events. Renamed here; the motif itself is verbatim. (The marketing
   site's own site.css keeps the spec name in its separate scope.) */
.flock-field {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--flock-dots);
  background-size: var(--flock-size);
  mask-image: radial-gradient(ellipse 70% 70% at 80% 10%, #000, transparent);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 80% 10%, #000, transparent);
}

/* Theme toggle control (ported from theme.css; markup lives in the topbar).
   Shows the icon of the theme you would switch to. */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-base);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--hairline-strong); color: var(--text-body); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; display: block; }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
