/* Instructed Intelligence — shared app component layer (pure CSS, framework-agnostic).
 * Pairs with tokens.css: every value comes from a var(--token), so this drops into
 * any tool (Tailwind or not) and themes automatically. For a Tailwind tool, you can
 * also add preset.ts for theme-aware utilities. See styleguide.html for the visuals.
 *
 * Register: sovereign operations console. Cards carry a faint top-edge highlight; the
 * accent glows on focus/active; the atmospheric ground + notched .hud-panel give the
 * futuristic instrument feel. Reference implementation: Cornerstone (web/).
 */

/* The ii mark, generated from the approved SVGs (branding rule 2). Never redraw it:
 * run `python brand/sync-brand-to-app.py brand/app-ui` instead. */
@import "./ii-mark.css";

.ii-app { font-family: var(--font-sans); color: var(--ink); background: var(--app-bg); background-attachment: fixed; }

/* Cinematic film grain over the ground — the "Vanilla Sky" texture. Fixed, behind content
 * (give your content a higher stacking context), only shows in the negative space. */
.app-atmosphere {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .06; mix-blend-mode: overlay;
}

/* Command bar — glass chrome over the atmosphere, hairline base + faint teal seam. */
.appbar {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: saturate(1.2) blur(12px);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--primary) 12%, transparent);
}

/* ---- labels ---- */
.eyebrow {
  font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: .14em; font-size: 11px; font-weight: 500; color: var(--faint);
}

/* ---- card ---- */
.card {
  position: relative; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  padding: 16px 18px; box-shadow: var(--shadow), var(--edge);
  transition: box-shadow .15s, border-color .15s;
}
.card-link:hover { box-shadow: var(--shadow-lift), var(--edge); border-color: var(--line-strong); }

/* HUD corner-ticks — a restrained targeting-reticle detail; opt in with .hud on a command surface. */
.hud { position: relative; }
.hud::before, .hud::after {
  content: ""; position: absolute; width: 9px; height: 9px; pointer-events: none;
  border-color: var(--hud); border-style: solid; border-width: 0;
}
.hud::before { top: -1px; left: -1px; border-top-width: 1.5px; border-left-width: 1.5px; border-top-left-radius: 4px; }
.hud::after { bottom: -1px; right: -1px; border-bottom-width: 1.5px; border-right-width: 1.5px; border-bottom-right-radius: 4px; }

/* Notched HUD panel — the clipped sci-fi corner that reads instrument, not card. The inset ring
 * is the border (follows the clip), with a faint teal edge-light; a drawn diagonal on the cut.
 * Reserve for a hero/command panel — once per view, not on every card. */
.hud-panel {
  position: relative;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--line-strong),
    inset 0 1px 0 rgba(255,255,255,.05),
    inset 0 0 30px -10px color-mix(in srgb, var(--primary) 35%, transparent);
}
.hud-panel::after {
  content: ""; position: absolute; top: 0; right: 0; width: 26px; height: 26px; pointer-events: none;
  background: linear-gradient(225deg, color-mix(in srgb, var(--primary) 55%, transparent) 0 1.5px, transparent 1.5px);
}

/* ---- chip ---- */
.chip {
  display: inline-flex; align-items: center; border-radius: 6px;
  border: 1px solid var(--line); padding: 2px 8px; font-size: 12px; color: var(--muted);
}

/* ---- type indicator: an 8px square dot + uppercase mono-ish label ---- */
.type-label {
  display: inline-flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; font-weight: 700; color: var(--muted);
}
.type-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--tc, var(--muted)); box-shadow: 0 0 8px -1px var(--tc, transparent); }

/* ---- semantic state pills (colour separate from the accent) ---- */
.state {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 9px; font-size: 11px; font-weight: 650;
}
.state-ok { color: var(--ok); background: var(--ok-tint); }
.state-warn { color: var(--warn); background: var(--warn-tint); }
.state-restrict { color: var(--restrict); background: var(--restrict-tint); }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 14px; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-accent { border: 0; background: var(--primary); color: var(--on-primary); font-weight: 600; }
.btn-accent:hover { background: var(--primary-hover); border: 0; box-shadow: var(--glow); }

/* ---- nav links ---- */
.navlink {
  border-radius: 7px; padding: 7px 12px; font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none; transition: color .15s, background .15s;
}
.navlink:hover { color: var(--ink); background: var(--surface-2); }
.navlink-active { color: var(--primary); background: var(--primary-tint); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---- search bar ---- */
.searchbar {
  position: relative; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 10px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow), var(--edge);
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within { border-color: var(--primary); box-shadow: var(--glow), var(--shadow); }

/* ---- inputs ---- */
.input {
  width: 100%; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
  padding: 9px 12px; outline: 0; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--primary); box-shadow: var(--glow); }

/* ---- data table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: .06em; font-size: 11px; font-weight: 500; color: var(--faint);
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }

/* ---- readable keyboard focus everywhere ---- */
.ii-app :where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) { .ii-app * { transition: none !important; } }
