/* ==========================================================================
   FO VISION LAB — BUILDER HQ — Base Styles (locked system v4, exact spec)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=Anybody:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; scroll-behavior: smooth; }

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ---- Ambient: single gold halo top of viewport + faint terminal grid ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(oklch(1 0 0 / 0.025) 1px, transparent 1px),
    linear-gradient(90deg, oklch(1 0 0 / 0.025) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 480px;
  z-index: -1;
  pointer-events: none;
  background: var(--gradient-ambient);
}

/* ---- Typography: Anton is ALWAYS italic for headings + stat numerals ---- */
h1, h2, h3, h4, h5, h6, .display {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 0.95;
}
h1 { font-size: var(--text-display-lg); }
h2 { font-size: var(--text-display-md); }
h3 { font-size: 1.15rem; }

em { font-style: italic; color: var(--gold); }

.text-gold { color: var(--gold); }
.bg-gold { background: var(--gradient-gold); }

p { color: var(--muted-foreground); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font-body); }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* Eyebrow — mono, 11px, 0.16em tracking, uppercase, muted. Precedes every
   section title. The ONLY place uppercase belongs. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-eyebrow);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* Chip — eyebrow styling inside a hairline pill */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--text-eyebrow);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  background: oklch(1 0 0 / 0.02);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Mono — system-output text: timestamps, units, shortcuts, numeric columns */
.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }

/* Big stat — Anton italic figure + trailing mono unit */
.stat-number { font-family: var(--font-display); font-style: italic; font-size: 1.9rem; color: var(--foreground); line-height: 1; }
.stat-number.gold { color: var(--gold); }
.stat-unit { font-family: var(--font-mono); font-size: var(--text-eyebrow); color: var(--muted-foreground); margin-left: 4px; }

.text-muted { color: var(--muted-foreground); }
.text-caption { font-size: var(--text-caption); color: var(--muted-foreground); }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring-gold); border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Grid-bg utility (explicit, for elements that want it locally) ---- */
.grid-bg {
  background-image:
    linear-gradient(oklch(1 0 0 / 0.025) 1px, transparent 1px),
    linear-gradient(90deg, oklch(1 0 0 / 0.025) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}

/* ---- Motion: restraint theater ---- */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.pulse-dot { animation: pulse-dot 2s ease-in-out infinite; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.5s var(--ease-out) both; }

/* ==========================================================================
   App Shell — persistent sidebar + main content
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--background);
  z-index: 45;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2); margin-bottom: var(--sp-4); }
.sidebar-badge {
  width: 36px; height: 36px;
  border-radius: var(--radius-btn);
  background: var(--gradient-gold);
  color: var(--background);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-brand-text h2 { font-size: 1.1rem; line-height: 1; }
.sidebar-brand-text .eyebrow { display: block; margin-top: 3px; }
.sidebar-close { display: none; margin-left: auto; width: 32px; height: 32px; align-items: center; justify-content: center; color: var(--muted-foreground); }
.sidebar-close svg { width: 18px; height: 18px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-btn);
  color: var(--muted-foreground);
  font-size: 0.875rem;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; stroke-width: 1.5; }
.sidebar-link:hover { background: var(--surface); color: var(--foreground); }
.sidebar-link.active { background: var(--surface); color: var(--foreground); font-weight: 600; }
.sidebar-link.active .sidebar-dot { display: inline-block; }
.sidebar-dot { display: none; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); margin-left: auto; }

.sidebar-section-label { padding: var(--sp-3) 0.7rem var(--sp-1); display: block; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.6);
  z-index: 44;
}
.sidebar-backdrop.open { display: block; }

/* ---- Main content column ---- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); }

.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  background: oklch(0.10 0.008 60 / 0.85);
  backdrop-filter: blur(8px);
}
.topbar-crumb { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted-foreground); white-space: nowrap; }
.topbar-crumb strong { color: var(--foreground); font-weight: 500; }
.topbar-search {
  flex: 1;
  display: flex; align-items: center; gap: var(--sp-1);
  background: var(--panel-inset-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 0.5rem 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  max-width: 480px;
}
.topbar-search svg { width: 15px; height: 15px; flex-shrink: 0; stroke-width: 1.5; }
.topbar-search kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--muted-foreground);
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--muted-foreground);
  position: relative;
  flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--foreground); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.5; }

.avatar-menu { position: relative; }
.avatar-dropdown {
  position: absolute; top: 44px; right: 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  padding: 4px;
  min-width: 140px;
  display: none;
  z-index: 30;
}
.avatar-dropdown.open { display: block; }
.avatar-dropdown button {
  width: 100%; text-align: left;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 6px;
}
.avatar-dropdown button:hover { background: var(--surface); }

/* ---- Notifications ---- */
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 3px;
  background: var(--gold);
  color: var(--background);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  align-items: center; justify-content: center;
}
.notif-dropdown { min-width: 300px; max-width: 340px; padding: 0; }
.notif-dropdown-header { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) var(--sp-2) var(--sp-1); }
.notif-dropdown-header button { color: var(--muted-foreground); }
.notif-dropdown-header button:hover { color: var(--gold); }
.notif-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: var(--sp-2);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.notif-item:hover { background: var(--surface); }
.notif-item.unread { color: var(--foreground); }
.notif-item.unread .notif-message::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: middle; }
.notif-icon { flex-shrink: 0; }

.page-content { padding: var(--sp-4); flex: 1; }

/* ---- Panels ---- */
.panel, .card {
  background: var(--gradient-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--sp-4);
  box-shadow: var(--shadow-lift);
}
.panel-inset {
  background: var(--panel-inset-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
}

.card-eyebrow { display: flex; align-items: center; gap: 6px; margin-bottom: var(--sp-2); }
.card-eyebrow svg { width: 13px; height: 13px; color: var(--muted-foreground); stroke-width: 1.5; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 0.85rem;
  transition: filter var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn svg { width: 15px; height: 15px; stroke-width: 1.5; }
.btn:hover .btn-arrow { transform: translateX(3px); }
.btn-arrow { display: inline-block; transition: transform var(--dur-fast) var(--ease-out); }

.btn-gold, .btn-primary {
  background: var(--gradient-gold);
  color: var(--background);
  box-shadow: 0 8px 24px -12px oklch(0.75 0.11 78 / 0.6);
}
.btn-gold:hover, .btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  border: 1px solid var(--border-strong);
  color: var(--foreground);
  background: transparent;
}
.btn-ghost:hover { background: oklch(1 0 0 / 0.04); }

.btn-pill { padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.75rem; }

/* ---- Progress bar ---- */
.bar-track { height: 3px; background: var(--panel-inset-bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--gradient-gold); border-radius: 999px; transition: width 0.6s var(--ease-out); }

/* ---- Status bar footer ---- */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.status-bar .signal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal-green); display: inline-block; margin-right: 6px; vertical-align: middle; }

.empty-state { color: var(--muted-foreground); font-size: var(--text-caption); }
.signal-ok { color: var(--signal-green); }
.signal-warn { color: var(--destructive); }

/* ---- Inputs ---- */
input[type="text"], input[type="file"], textarea {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
textarea:focus, input:focus { outline: none; box-shadow: 0 0 0 3px var(--ring-gold); }

/* ---- Mobile hamburger ---- */
.nav-hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 36px; height: 36px; flex-shrink: 0; }
.nav-hamburger span { display: block; width: 20px; height: 1.5px; background: var(--foreground); }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 46;
    transform: translateX(-100%);
    transition: transform var(--dur-med) var(--ease-out);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    width: min(var(--sidebar-width), 80vw);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .nav-hamburger { display: flex; }
  .main-col { border-left: none; }
  .topbar-crumb { display: none; }
}

@media (max-width: 640px) {
  .page-content { padding: var(--sp-3); }
  .panel, .card { padding: var(--sp-3); }
  .field-row { flex-direction: column; gap: 0; }
  .evidence-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { gap: var(--sp-2); padding: 0 var(--sp-3); }
  .topbar-search span, .topbar-search kbd { display: none; }
  .topbar-search { max-width: 42px; padding: 0.5rem; justify-content: center; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 0.6rem; }
}

/* Real small phones (~375px and under) — headings were sizing/spacing
   for tablet-width mobile, not actual phone width. Tighten further. */
@media (max-width: 480px) {
  h1 { font-size: 1.6rem; line-height: 1.15; margin-bottom: var(--sp-2); }
  h2 { font-size: 1.3rem; line-height: 1.15; }
  h3 { font-size: 1.05rem; }
  p { margin-top: var(--sp-1); }
  .page-content { padding: var(--sp-2); }
  .panel, .card { padding: var(--sp-3) var(--sp-2); }
  .hero-row, .priorities-row, .two-col { gap: var(--sp-3); }
  .btn { padding: 0.6rem 0.9rem; font-size: 0.8rem; }
  .stat-number { font-size: 1.5rem; }
}
