/* SPY Camps Tracker — Mobile theme tokens (shared across variants A/B/C) */
:root {
  --ink-950: #05070d;
  --ink-900: #0b0f17;
  --ink-800: #11161f;
  --ink-700: #1a212d;
  --ink-600: #27303f;
  --ink-500: #3a4456;
  --line: #1f2733;
  --fg: #e6ecf5;
  --fg-2: #9ba8bd;
  --fg-3: #6b7588;
  --brand-500: #2563EB;
  --brand-400: #3B82F6;
  --brand-300: #60a5fa;
  --accent: #F97316;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #60a5fa;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--ink-950); color: var(--fg);
  font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.num { font-family: 'Fira Code', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ===== Phone frame ===== */
.phone {
  width: 375px; height: 812px;
  border-radius: 36px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 0 0 6px var(--ink-950);
  overflow: hidden;
  position: relative;
  background: var(--ink-900);
}
.notch {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 28px; background: var(--ink-950);
  border-radius: 18px; z-index: 50;
}
.screen {
  position: absolute; inset: 0; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen.hidden { display: none; }

/* ===== Layout primitives ===== */
.h-stack { display: flex; align-items: center; gap: 8px; }
.v-stack { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; }
.hairline { border-bottom: 1px solid var(--line); }
.label-eyebrow { color: var(--fg-2); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.muted { color: var(--fg-2); }
.muted-sm { color: var(--fg-3); font-size: 11px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== Sticky header ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  padding: 48px 16px 12px;
  background: rgba(11,15,23,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.app-header .sub { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* ===== Status pills ===== */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; line-height: 1.2; }
.pill.ok    { background: rgba(34,197,94,0.13); color: #4ade80; }
.pill.warn  { background: rgba(245,158,11,0.14); color: #fbbf24; }
.pill.err   { background: rgba(239,68,68,0.13); color: #f87171; }
.pill.info  { background: rgba(37,99,235,0.16); color: var(--brand-300); }
.pill.muted { background: var(--ink-800); color: var(--fg-2); }

/* ===== Live dot (pulse) ===== */
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 999px;
  background: var(--ok);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* ===== KPI tile ===== */
.kpi {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.kpi .lbl { font-size: 11px; color: var(--fg-3); margin-bottom: 4px; }
.kpi .val { font-size: 22px; font-weight: 600; font-family: 'Fira Code', monospace; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 11px; margin-top: 2px; font-family: 'Fira Code', monospace; }
.kpi.danger .val { color: var(--err); }
.kpi.warn .val { color: var(--warn); }

/* ===== Card row (list item) ===== */
.row {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  transition: background 150ms ease, border-color 150ms ease;
  cursor: pointer;
}
.row:active { background: var(--ink-700); border-color: var(--ink-600); }
.row .title { font-size: 13.5px; font-weight: 500; color: var(--fg); }
.row .sub { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.row .meta { font-family: 'Fira Code', monospace; font-size: 11px; color: var(--fg-2); }

/* ===== Progress bar ===== */
.bar { height: 6px; background: var(--ink-700); border-radius: 999px; overflow: hidden; }
.bar > .fill { height: 100%; background: var(--brand-400); border-radius: 999px; transition: width 250ms ease; }
.bar.ok > .fill { background: var(--ok); }
.bar.warn > .fill { background: var(--warn); }
.bar.err > .fill { background: var(--err); }

/* ===== Card with image ===== */
.media-card {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.media-card .thumb {
  aspect-ratio: 4 / 5;
  background: linear-gradient(135deg, var(--ink-700), var(--ink-600));
  position: relative;
  overflow: hidden;
}
.media-card .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-card .body { padding: 8px 10px 10px; }
.media-card .body .h { font-size: 12px; font-weight: 500; line-height: 1.3; }
.media-card .body .m { font-size: 10px; color: var(--fg-3); margin-top: 4px; font-family: 'Fira Code', monospace; }
.media-card .pill-tl { position: absolute; top: 8px; left: 8px; }
.media-card .pill-tr { position: absolute; top: 8px; right: 8px; }
.media-card .pill-bl { position: absolute; bottom: 8px; left: 8px; }
.media-card .pill-br { position: absolute; bottom: 8px; right: 8px; }

/* When image fails, show a fallback gradient with first letter */
.thumb-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  color: var(--fg-3);
  background: linear-gradient(135deg, var(--ink-700), var(--ink-600));
  text-align: center;
  padding: 12px;
}

/* ===== Bottom nav ===== */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(5,7,13,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 40;
  padding-bottom: 18px; /* safe area */
}
.bottom-nav .grid { display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px 0; }
.bottom-nav button {
  background: none; border: none; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--fg-2); cursor: pointer;
  font-family: inherit;
}
.bottom-nav .lbl { font-size: 10px; }
.bottom-nav .ind { width: 22px; height: 2px; border-radius: 2px; background: transparent; }
.bottom-nav button.active { color: var(--brand-300); }
.bottom-nav button.active .lbl { color: var(--fg); font-weight: 600; }
.bottom-nav button.active .ind { background: var(--brand-300); }

/* ===== FAB ===== */
.fab {
  position: absolute; right: 16px; bottom: 86px; z-index: 35;
  height: 52px; padding: 0 18px;
  background: var(--brand-500); color: white;
  border: none; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.4);
  cursor: pointer;
}
.fab:active { transform: scale(0.97); }

/* ===== Filter chips row ===== */
.chips { display: flex; gap: 6px; padding: 12px 16px 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .pill { white-space: nowrap; flex-shrink: 0; padding: 4px 10px; font-size: 12px; }

/* ===== Segmented control ===== */
.seg { display: flex; gap: 2px; background: var(--ink-800); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button {
  flex: 1; height: 32px; border: none; background: transparent;
  color: var(--fg-2); font-weight: 500; font-size: 12px; border-radius: 9px;
  cursor: pointer; font-family: inherit;
}
.seg button.active { background: var(--ink-700); color: var(--fg); font-weight: 600; }
.seg.scrollable { display: flex; overflow-x: auto; gap: 4px; padding: 4px; }
.seg.scrollable::-webkit-scrollbar { display: none; }
.seg.scrollable button { flex: 0 0 auto; padding: 0 12px; height: 32px; white-space: nowrap; }

/* ===== Live event log ===== */
.log { background: var(--ink-800); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.log .item { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.log .item:last-child { border-bottom: none; }
.log .dot { width: 8px; height: 8px; border-radius: 999px; margin-top: 6px; flex-shrink: 0; }
.log .dot.running, .log .dot.funnel { background: var(--brand-300); }
.log .dot.completed { background: var(--ok); }
.log .dot.queued { background: var(--warn); }
.log .dot.cloaked, .log .dot.failed { background: var(--err); }
.log .text { flex: 1; min-width: 0; }
.log .text .t { font-family: 'Fira Code', monospace; font-size: 12px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .text .m { font-family: 'Fira Code', monospace; font-size: 10px; color: var(--fg-3); margin-top: 1px; }

/* ===== Section spacing ===== */
.section { padding: 0 16px; margin-top: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-title h3 { margin: 0; font-size: 13px; font-weight: 600; }
.section-title a, .section-title button { background: none; border: none; color: var(--brand-300); font-size: 12px; cursor: pointer; font-family: inherit; }

/* Bottom safe pad (so content doesn't hide under nav) */
.pad-bottom { padding-bottom: 110px; }

/* ===== Hero card (variant B) ===== */
.hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--ink-800);
  margin: 0 16px;
}
.hero .img { aspect-ratio: 16 / 10; position: relative; background: linear-gradient(135deg, var(--ink-700), var(--ink-600)); overflow: hidden; }
.hero .img img { width: 100%; height: 100%; object-fit: cover; }
.hero .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,7,13,0.92) 0%, rgba(5,7,13,0.4) 50%, rgba(5,7,13,0) 100%);
  padding: 16px;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 6px;
}
.hero .overlay .h { font-size: 16px; font-weight: 600; line-height: 1.3; }
.hero .overlay .m { font-family: 'Fira Code', monospace; font-size: 11px; color: var(--fg-2); }

/* ===== Rail (horizontal scroll) ===== */
.rail { display: flex; gap: 10px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: 0 0 auto; scroll-snap-align: start; }

/* ===== Masonry grid (2-col) ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 12px;
}
.grid-2 .media-card { width: 100%; }

/* ===== Settings/grouped list (variant C More) ===== */
.group { background: var(--ink-800); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.group > .item { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.group > .item:last-child { border-bottom: none; }
.group > .item .icon { width: 32px; height: 32px; border-radius: 8px; background: var(--ink-700); display: grid; place-items: center; color: var(--brand-300); }
.group > .item .body { flex: 1; min-width: 0; }
.group > .item .body .t { font-size: 13px; }
.group > .item .body .m { font-size: 11px; color: var(--fg-3); }
.group > .item .chev { color: var(--fg-3); }

/* ===== Status strip (variant A) ===== */
.status-strip { display: flex; gap: 10px; align-items: center; font-size: 11px; color: var(--fg-2); padding-top: 6px; flex-wrap: wrap; }
.status-strip .sep { color: var(--ink-500); }

/* ===== Content feed row (v2: replaces KPI-led home) ===== */
.feed-row {
  display: flex; gap: 10px; padding: 10px;
  background: var(--ink-800); border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; transition: background 150ms ease;
}
.feed-row:active { background: var(--ink-700); }
.feed-thumb {
  width: 64px; height: 80px; border-radius: 8px; flex-shrink: 0;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--ink-700), var(--ink-600));
}
.feed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.feed-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.feed-title { font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--fg); }
.feed-sub { font-size: 11px; color: var(--fg-3); font-family: 'Fira Code', monospace; }
.feed-pills { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.feed-pills .pill { font-size: 10px; padding: 1px 6px; }
.feed-pills .feed-time { color: var(--fg-3); font-size: 10px; margin-left: auto; }

/* Cloaked overlay tint on cards */
.cloaked-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(239,68,68,0.10), rgba(239,68,68,0));
  pointer-events: none;
}

/* Compact "feed feed feed" container — tight 8px gaps */
.feed-list { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }

/* Variant A terminal-style feed row override */
.a-feed-row .feed-title { font-family: 'Fira Code', monospace; font-size: 12.5px; }
.a-feed-row .feed-thumb { width: 56px; height: 70px; }

/* ===== Filter chips bar (functional) ===== */
.chip-filter-btn {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; border: none;
  font-family: inherit;
  font-size: 11px; font-weight: 500;
}
.chip-filter-btn svg { width: 12px; height: 12px; }
.chips button { cursor: pointer; border: none; font-family: inherit; }

/* ===== Filter bottom sheet ===== */
.filter-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 220;
  background: var(--ink-900);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px max(env(safe-area-inset-bottom), 16px);
  max-height: 78dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}
body.sheet-open .filter-sheet { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 4px;
  background: var(--ink-500);
  margin: 4px auto 12px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.sheet-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-clear {
  background: none; border: none;
  color: var(--brand-300);
  font-size: 12px; cursor: pointer; font-family: inherit;
}
.sheet-section { margin-bottom: 18px; }
.sheet-label {
  font-size: 11px; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin: 0 0 8px;
}
.sheet-label .muted {
  text-transform: none; letter-spacing: 0; font-weight: 400;
  color: var(--fg-3); font-size: 11px;
}
.filter-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.filter-pill {
  background: var(--ink-800);
  border: 1px solid var(--line);
  color: var(--fg-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: all 150ms ease;
  display: inline-flex; align-items: center; gap: 4px;
}
.filter-pill:active { transform: scale(0.96); }
.filter-pill.on {
  background: rgba(37,99,235,0.18);
  border-color: var(--brand-400);
  color: var(--fg);
}
.filter-pill .check { color: var(--brand-300); font-weight: 700; }
.sheet-apply {
  position: sticky; bottom: 0;
  width: 100%;
  padding: 14px;
  background: var(--brand-500); color: white;
  border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  margin-top: 8px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.4);
}
.sheet-scrim {
  position: fixed; inset: 0; z-index: 219;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease;
}
body.sheet-open .sheet-scrim {
  opacity: 1; pointer-events: auto;
}

/* In desktop preview the phone has overflow:hidden so absolute keeps sheet within frame.
   On real mobile the .phone IS the viewport, so absolute=fixed effectively. */
@media (min-width: 768px) {
  .phone .filter-sheet,
  .phone .sheet-scrim {
    position: absolute;
  }
}

/* Findings segmented control: bigger touch targets */
.findings-seg {
  margin-top: 10px;
}
.findings-seg button {
  padding: 0 14px; height: 36px;
}

/* Hide scrollbar globally inside phone */
.phone * { scrollbar-width: none; }
.phone *::-webkit-scrollbar { display: none; }

/* Index page (multi-phone layout) */
.lab {
  min-height: 100vh;
  padding: 32px;
  background: radial-gradient(ellipse at top, #0b0f17, #05070d 70%);
}
.lab header { margin-bottom: 32px; max-width: 1400px; }
.lab header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 6px; }
.lab header p { color: var(--fg-2); font-size: 13px; margin: 0; }
.lab .row-3 { display: flex; gap: 32px; flex-wrap: wrap; justify-content: center; }
.lab .col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lab .col .vlbl { font-size: 11px; color: var(--brand-300); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
.lab .col .name { font-size: 16px; font-weight: 600; }
.lab .col .desc { font-size: 12px; color: var(--fg-2); max-width: 360px; text-align: center; line-height: 1.5; }

/* ============================================================
   MOBILE OVERRIDE — drop showcase chrome, render UI full-bleed
   ============================================================ */
@media (max-width: 767px) {
  /* Hide the variant-page lab chrome (header copy, descriptor) */
  .lab {
    padding: 0 !important;
    background: var(--ink-950);
    min-height: 100dvh;
  }
  .lab > header,
  .lab > p:last-child {
    display: none;
  }
  .lab > div:has(.phone) {
    margin-top: 0 !important;
    display: block !important;
  }

  /* Phone frame becomes the actual viewport — content flows in body scroll */
  html, body {
    overflow-x: hidden;
    overscroll-behavior-y: contain;
  }
  .phone {
    width: 100% !important;
    height: auto !important;
    min-height: 100dvh;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: var(--ink-950);
    overflow: visible !important;       /* let body do the scrolling */
    position: static !important;
  }
  .phone::before { content: none; }
  .notch { display: none !important; }

  /* Pad header for actual safe-area on mobile (notch/status bar) */
  .app-header {
    padding-top: max(env(safe-area-inset-top), 16px) !important;
  }

  /* Bottom nav: fixed to viewport bottom so it stays visible while scrolling */
  .bottom-nav {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    padding-bottom: max(env(safe-area-inset-bottom), 12px) !important;
  }

  /* Screens flow naturally with body scroll — no internal scroll container */
  .screen {
    position: static !important;
    inset: auto !important;
    overflow: visible !important;
    min-height: auto !important;
  }
  .screen.hidden { display: none !important; }

  /* Add bottom padding to ensure content isn't covered by fixed nav */
  .pad-bottom {
    padding-bottom: calc(80px + max(env(safe-area-inset-bottom), 12px)) !important;
  }

  /* FAB stays above bottom nav, follows viewport */
  .fab {
    position: fixed !important;
    bottom: calc(80px + max(env(safe-area-inset-bottom), 12px)) !important;
    right: 16px !important;
  }

  /* Filter sheet: position: fixed (already overridden out of @min-width:768) */
  .filter-sheet, .sheet-scrim { position: fixed !important; }

  /* Horizontal scroll regions — momentum on iOS, hide scrollbar */
  .rail, .chips, .seg.scrollable {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
  }

  /* Sticky app-header stays at top of viewport when scrolling */
  .app-header {
    position: sticky !important;
    top: 0;
    z-index: 30;
  }
}
