/* ═══════════════════════════════════════════════════════════════════════════
   FIELDCHAT WIDGET OFFSET — PLAYGROUND PAGES
   ─────────────────────────────────────────────────────────────────────────
   The fieldchat widget uses --fc-top-offset to know where to start its
   bottom-sheet on mobile. Playground pages have two stacked navbars:
     • Site nav (≈ 60–64px)
     • Workspace nav (.pg-workspace-nav, 48px)
   Total ≈ 108–112px.

   Using :root:has(.pg-workspace-nav) means this only applies when the
   workspace nav is actually rendered on the page. Pages without the
   workspace nav fall back to the default 60px defined in ask_ai.css.
   ─────────────────────────────────────────────────────────────────────────
   Browser support: :has() is supported in Safari 15.4+, Chrome 105+,
   Firefox 121+. Older browsers fall back to the 60px default gracefully.
   ═══════════════════════════════════════════════════════════════════════════ */

:root:has(.pg-workspace-nav) {
  --fc-top-offset: 108px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PLAYGROUND SHARED WORKSPACE SHELL  v1.0
   Workspace navigation, mode tabs, session context bar, collapsible intro,
   and cross-tool mobile layout primitives.

   Loaded by: fieldvision_playground.html, fieldkb_playground.html,
              fieldmap_playground.html
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── WORKSPACE NAV ───────────────────────────────────────────────────────── */
.pg-workspace-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(7, 10, 18, 0.97);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.pg-workspace-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 48px;
  gap: 1rem;
}

/* Mode tabs */
.pg-mode-tabs {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}

.pg-mode-tabs::-webkit-scrollbar { display: none; }

.pg-mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.8rem;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.65);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
  line-height: 1;
}

.pg-mode-tab:hover {
  background: rgba(148, 163, 184, 0.07);
  color: #e2e8f0;
  text-decoration: none;
}

.pg-mode-tab.active {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.28);
  color: #34d399;
}

.pg-mode-tab i {
  font-size: 0.72rem;
  opacity: 0.9;
}

/* ── Dev / in-progress tab variant ────────────────────────────────────────── */
.pg-mode-tab--dev {
  position: relative;
}
.pg-mode-tab--dev .pg-tab-dev-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
  line-height: 1.5;
  vertical-align: middle;
  margin-left: 2px;
  text-transform: uppercase;
}

/* ── Dev notice banner (FieldAudio playground) ─────────────────────────────── */
.pg-dev-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0 1.5rem 0;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.22);
  font-size: 0.8rem;
  line-height: 1.55;
  color: #cbd5e1;
}
.pg-dev-notice i {
  color: #fbbf24;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.pg-dev-notice strong {
  color: #fbbf24;
  font-weight: 600;
}

/* Right-side workspace actions (theme toggle, etc.) */
.pg-workspace-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── SESSION CONTEXT BAR ─────────────────────────────────────────────────── */
.pg-context-bar {
  background: rgba(10, 15, 26, 0.72);
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  padding: 0.38rem 1.5rem;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 0;
}

.pg-context-bar::-webkit-scrollbar { display: none; }

.pg-ctx-item {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  padding-right: 1rem;
  margin-right: 1rem;
  border-right: 1px solid rgba(148, 163, 184, 0.09);
  font-size: 0.7rem;
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  color: rgba(100, 116, 139, 0.85);
  white-space: nowrap;
  flex-shrink: 0;
}

.pg-ctx-item:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}

.pg-ctx-label { opacity: 0.65; }

.pg-ctx-value {
  color: #34d399;
  font-weight: 600;
}

.pg-ctx-value.muted {
  color: rgba(100, 116, 139, 0.55);
  font-weight: 400;
}

/* ── COMPACT TOOL HEADER ─────────────────────────────────────────────────── */
.pg-tool-header {
  padding: 0.9rem 1.5rem 0.7rem;
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

.pg-tool-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0 0 0.18rem;
  font-family: 'IBM Plex Sans', 'DM Sans', system-ui, sans-serif;
  line-height: 1.3;
}

.pg-tool-desc {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.68);
  max-width: 560px;
  line-height: 1.5;
  margin: 0;
  font-family: 'IBM Plex Sans', 'DM Sans', system-ui, sans-serif;
}

.pg-tool-about-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: rgba(100, 116, 139, 0.75);
  background: none;
  border: 1px solid rgba(148, 163, 184, 0.11);
  border-radius: 6px;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  transition: all 0.15s ease;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.02em;
  margin-top: 0.1rem;
}

.pg-tool-about-btn:hover {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.05);
}

.pg-tool-about-btn i {
  font-size: 0.65rem;
}

/* ── COLLAPSIBLE INTRO ───────────────────────────────────────────────────── */
.pg-tool-intro {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid transparent;
}

.pg-tool-intro.expanded {
  max-height: 2400px;
  border-bottom-color: rgba(148, 163, 184, 0.07);
}

/* ── MOBILE  < 640px ─────────────────────────────────────────────────────── */
@media (max-width: 639px) {

  .pg-workspace-inner {
    padding: 0 1rem;
    height: 44px;
    gap: 0.5rem;
  }

  .pg-mode-tab {
    padding: 0.28rem 0.6rem;
    font-size: 0.73rem;
    gap: 0.3rem;
  }

  .pg-mode-tab i { display: none; }   /* icon-only or text-only on tiny screens */

  .pg-context-bar {
    padding: 0.32rem 1rem;
  }

  .pg-ctx-item {
    font-size: 0.65rem;
    padding-right: 0.65rem;
    margin-right: 0.65rem;
  }

  .pg-tool-header {
    padding: 0.65rem 1rem 0.5rem;
    gap: 0.5rem;
  }

  .pg-tool-title { font-size: 0.9rem; }
  .pg-tool-desc  { font-size: 0.72rem; }

  .pg-tool-about-btn { font-size: 0.68rem; }
}

/* ── TABLET  640–1023px ──────────────────────────────────────────────────── */
@media (min-width: 640px) and (max-width: 1023px) {
  .pg-mode-tab {
    padding: 0.32rem 0.72rem;
    font-size: 0.77rem;
  }
}
