/* Shared styles for the frontend pages: CSS vars, page scaffolding, and the
   app-shell chrome (fixed top bar + fixed left sidebar, content scrolls) —
   adapted from the bubble repo's css/shell.css, simplified: no auth chrome,
   no per-page nav sections. Load before the page's own <style> block so
   pages can override. Page-specific styles (table, search) stay inline. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --row-hover: #f3f4f6;
  --card: #f9fafb;
  --accent: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --topbar-h: 64px;
  --sidebar-w: 220px;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --brand-j: #e11d2e;            /* the red j of the wordmark */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #262a33;
    --row-hover: #1a1d24;
    --card: #171a21;
    --accent: #60a5fa;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --nav-bg: rgba(15, 17, 21, 0.92);
  }
}
/* inline Lucide icons (glitcjIcon() in js/shell.js) — em-sized so they
   track the row's font size */
.icon-svg {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* ── Top bar — markup injected by js/shell.js ─────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);      /* a plain bar: no colour wash (removed 2026-11-18) */
}
.topbar-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--fg);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 1;
}
.topbar-menu:hover { background: var(--row-hover); }
/* The wordmark, "glitcj" with a red j, centered in the bar — absolute so the
   hamburger can't push it. Set in VT323 (a terminal-style pixel font, SIL
   Open Font Licence, served from this site: fonts/VT323-Regular.ttf, its
   licence beside it); the same class is used on the login card. */
@font-face {
  font-family: "VT323";
  src: url("/core/frontend/fonts/VT323-Regular.ttf") format("truetype");
  font-display: swap;
}
.nav-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  text-decoration: none;
}
.brand-box {
  display: inline-flex;
  align-items: center;
  color: var(--fg);
  font-family: "VT323", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 2.9rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
  /* The 8-bit look: no smoothing, so the font's pixels stay square, and a
     hard shadow in two steps, without blur, in the theme's own grey. */
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  text-shadow: 2px 2px 0 var(--border), 4px 4px 0 var(--row-hover);
}
.nav-brand .brand-box { height: var(--topbar-h); padding: 0 0.42rem; }
.brand-box .brand-j { color: var(--brand-j); }
/* A block cursor after the j, blinking like a terminal's (in whole steps, no
   fading). It stands still when the system asks for less motion. */
.brand-box .brand-cursor {
  display: inline-block;
  width: 0.3em;
  height: 0.5em;
  margin-left: 0.14em;
  background: var(--brand-j);
  box-shadow: 2px 2px 0 var(--border);
  animation: brand-blink 1.1s steps(1) infinite;
}
@keyframes brand-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .brand-box .brand-cursor { animation: none; } }

/* ── Sidebar — markup injected by js/shell.js ─────────────────────────── */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 110;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem 1.5rem;
  /* solid sidebar; the content divider is a background layer — a 1px line
     inset 14px from top and bottom so it never reads as a full wall */
  background:
    linear-gradient(var(--border), var(--border)) right 0 top 14px / 1px calc(100% - 28px) no-repeat,
    var(--card);
  transition: transform 0.15s ease, visibility 0.15s;
}
body.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
  visibility: hidden;
}
.sidebar-section {
  padding: 0.6rem 0;
  /* sections sit inside the sidebar's side padding, so these lines stop
     short of the right-edge divider — no touching corners (bubble pattern) */
  border-top: 1px solid var(--border);
}
.sidebar-section:first-child { border-top: none; padding-top: 0; }
.sidebar-heading {
  padding: 0 0.75rem 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* sidebar rows — Home and one <a> per service folder share the
   style: bubble's icon + label rows, accent highlight on the active one */
.sidebar-link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--row-hover); }
.sidebar-link-icon {
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
}
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.10);
  color: var(--accent);
  font-weight: 600;
}
/* a parent folder's name above the services inside it (generate-ona, crawlers) */
.sidebar-group {
  padding: 0.7rem 0.75rem 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.sidebar-link.grouped { padding-left: 1.4rem; }
/* a service whose page is only a placeholder (no real page yet) */
.sidebar-link.placeholder { color: var(--muted); font-weight: 400; }
.sidebar-link.placeholder.active { color: var(--accent); font-weight: 600; }

/* ── Content ──────────────────────────────────────────────────────────── */
main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 1.25rem) 1.5rem 4rem;
  transition: margin-left 0.15s ease;
}
body.sidebar-collapsed main { margin-left: 0; }
.page {
  max-width: 900px;
  margin: 0 auto;
}
h1 {
  font-size: 1.375rem;
  margin: 0 0 0.25rem;
}
/* the service's icon in front of a page's title, and an icon in front of a
   button's or a heading's text (data-icon, js/shell.js) */
h1 > .icon-svg { margin-right: 0.45em; color: var(--accent); }
[data-icon] > .icon-svg, .btn > .icon-svg { margin-right: 0.4em; }
.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
}
#status {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 1rem 0;
}
#status.error {
  color: var(--danger);
  white-space: pre-wrap;
}
footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Login gate (js/shell.js) — opaque, covers everything until entered ── */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}
#login-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(320px, 90vw);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.login-brand {
  align-self: center;
  font-size: 3.2rem;
}
#login-card input {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9rem;
  font-family: inherit;
}
#login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
#login-card button {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
#login-err {
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 1em;
  text-align: center;
}

/* ── Mobile: the sidebar becomes an off-canvas drawer over the content ── */
@media (max-width: 900px) {
  main,
  body.sidebar-collapsed main { margin-left: 0; }
  #sidebar {
    z-index: 130;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 0 0 30px rgba(20, 38, 58, 0.25);
  }
  /* the drawer ignores the desktop collapse state — open wins */
  body.sidebar-open #sidebar,
  body.sidebar-collapsed.sidebar-open #sidebar {
    transform: none;
    visibility: visible;
  }
  #shell-scrim {
    position: fixed;
    inset: 0;
    z-index: 125;
    background: rgba(20, 38, 58, 0.4);
  }
}

/* an outside link (core/frontend/links.json): a small arrow says it opens elsewhere */
.sidebar-ext { display: inline-flex; margin-left: auto; color: var(--muted); font-size: 0.75rem; }
