/* ═══════════════════════════════════════════════════════════════
   CLOTO NAV — Unified Header Bar + Legacy Sidebar
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   UNIFIED HEADER BAR (48px, full width, replaces sidebar + topbar)
   ══════════════════════════════════════════════════════════════ */

.cloto-unibar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--cloto-surface);
  border-bottom: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
  z-index: var(--cloto-z-header);
  gap: 12px;
}

.cloto-unibar__left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.cloto-unibar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cloto-unibar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s;
}
.cloto-unibar__logo:hover {
  opacity: 0.8;
  background: rgba(94, 198, 198, 0.08);
}
.cloto-unibar__logo svg {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
}

.cloto-unibar__sep {
  color: var(--cloto-text-20);
  font-size: 14px;
  flex-shrink: 0;
}

.cloto-unibar__breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.cloto-unibar__crumb {
  font-size: 13px;
  color: var(--cloto-text-50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-xs, 3px);
  transition: color 0.15s, background 0.15s;
}
.cloto-unibar__crumb:hover {
  color: var(--cloto-text-100);
  background: var(--cloto-surface-hover, rgba(255,255,255,.06));
}
.cloto-unibar__crumb:last-child {
  font-weight: 600;
  color: var(--cloto-text-70);
}
.cloto-unibar__crumb--project {
  cursor: default;
  font-weight: 500;
}

.cloto-unibar__crumb-sep {
  color: var(--cloto-text-20);
  font-size: 13px;
  margin: 0 1px;
  flex-shrink: 0;
}

.cloto-unibar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--cloto-text-40);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.cloto-unibar__icon-btn:hover {
  color: var(--cloto-text-70);
  background: var(--cloto-surface-hover, rgba(255,255,255,.06));
}

/* Light mode */
body.fd-light .cloto-unibar__logo:hover,
body.fd-light .cloto-unibar__crumb:hover,
body.fd-light .cloto-unibar__icon-btn:hover {
  background: rgba(0,0,0,.05);
}

/* No-sidebar layout: main takes full width */
.cloto-main--no-sidebar {
  margin-left: 0 !important;
}

/* Hide unibar in prefunnel (wizard intro phases) */
body:has(.fbw-outline-v2.is-prefunnel) .cloto-unibar {
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms ease-out;
}
body:has(.fbw-outline-v2) .cloto-unibar {
  transition: opacity 600ms ease-out 300ms;
}

/* ══════════════════════════════════════════════════════════════
   SAVE STATUS DOT (used in unified header)
   ══════════════════════════════════════════════════════════════ */

.cloto-sidebar-save-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  margin-bottom: var(--space-4);
  transition: background var(--duration-slow) var(--ease-default),
              box-shadow var(--duration-slow) var(--ease-default);
}

.cloto-sidebar-save-dot.is-saving {
  background: var(--cloto-gold);
  box-shadow: var(--shadow-glow-gold);
  animation: cloto-save-pulse 0.8s ease-in-out infinite;
}

.cloto-sidebar-save-dot.is-flash {
  background: var(--cloto-success);
  box-shadow: 0 0 6px var(--cloto-success-a50);
  animation: cloto-dot-flash 1.5s var(--ease-default) forwards;
}

/* Theme toggle — show correct icon per theme (unibar) */
.cloto-unibar__icon-btn[data-section="theme"] .fd-theme-icon--light { display: block; }
.cloto-unibar__icon-btn[data-section="theme"] .fd-theme-icon--dark  { display: none; }
body.fd-light .cloto-unibar__icon-btn[data-section="theme"] .fd-theme-icon--light { display: none; }
body.fd-light .cloto-unibar__icon-btn[data-section="theme"] .fd-theme-icon--dark  { display: block; }

/* ══════════════════════════════════════════════════════════════
   MAIN WRAPPER (margin-left for sidebar)
   ══════════════════════════════════════════════════════════════ */

.cloto-main {
  margin-left: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.cloto-content {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Section roots: hidden by default, shown with .is-active */
.cloto-content > [id$="-root"] {
  display: none;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.cloto-content > [id$="-root"].is-active {
  display: flex;
  flex-direction: column;
}

/* Outline root: no scroll here — grid children handle their own scroll */
#fbw-outline-root.is-active {
  overflow: hidden;
}

/* Splash root: full-viewport overlay when active
   z-index between header (300) and modal (500) so prompts appear on top
   IMPORTANT: display:block overrides the flex from section-root rule —
   splash content scrolls naturally as a block child */
#fbw-splash-root.is-active {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: var(--cloto-z-drawer);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--fc-bg);
}

/* Nebulae layers — REMOVED (clean void) */
#fbw-splash-root.is-active::before,
#fbw-splash-root.is-active::after {
  display: none;
}

/* Roots that need flex column layout when active */
#fbw-outline-root.is-active,
#fbw-wizard-root.is-active {
  display: flex;
  flex-direction: column;
}

/* Wizard + outline roots: no overflow on root — children scroll internally */
#fbw-wizard-root.is-active,
#fbw-outline-root.is-active {
  overflow: hidden;
}

/* Draft root: placeholder only, never competes for flex space */
#fbw-draft-root.is-active {
  flex: none;
}

/* ══════════════════════════════════════════════════════════════
   ADJUSTMENTS — Existing content adapts to new wrapper
   ══════════════════════════════════════════════════════════════ */

/* Outline container fills content area via flex */
#fbw-outline-root > .fbw-outline-container {
  flex: 1 1 0;
  min-height: 0;
}

/* Characters/Locations fill content */
.cloto-main #fbw-characters-root,
.cloto-main #fbw-locations-root {
  padding: var(--space-8);
}

/* ══════════════════════════════════════════════════════════════
   SECTION TRANSITION (fade on switch)
   ══════════════════════════════════════════════════════════════ */

.cloto-content > [id$="-root"] {
  opacity: 0;
  transition: opacity 150ms ease;
}

.cloto-content > [id$="-root"].is-active {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════
   THEME CROSS-FADE TRANSITION
   ══════════════════════════════════════════════════════════════ */

/* (sidebar theme transition removed — element no longer in DOM) */

/* ══════════════════════════════════════════════════════════════
   WIZARD CARD BREADCRUMB (topbar center)
   ══════════════════════════════════════════════════════════════ */

.wiz-card-breadcrumb {
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-40);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT V2 — Topbar hidden, kanban gets its own header
   ══════════════════════════════════════════════════════════════ */

/* Workspace header removed — breadcrumb now in unified header */
.fbw-v2-workspace-header {
  display: none !important;
}

/* Kanban header removed — project title now in unified header bar */

/* ══════════════════════════════════════════════════════════════
   LAYOUT V2 — Responsive breakpoints
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .fbw-outline-v2 {
    grid-template-columns: 250px 1fr;
  }
  .fbw-outline-v2 .fbw-col {
    flex: 0 0 180px;
    width: 180px;
  }
}

@media (max-width: 768px) {
  .fbw-outline-v2 {
    grid-template-columns: 1fr;
    transition: none;
  }
  .fbw-outline-v2 .fbw-v2-kanban {
    display: none;
  }
}
