/* BerryNote — daisyUI customizations & editor styles */

/* ============================================================
   Two-pane editor layout
   ============================================================ */
.bn-editor {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4rem);
}

/* Inner editor toolbar — override daisyUI navbar min-height */
.bn-editor > .navbar {
  min-height: 0;
  height: auto;
  padding: 0.5rem 1rem;
}

.bn-panes {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 1px;
  background: hsl(var(--b3));
}

/* Each pane fills half the viewport; scrolls independently */
.bn-pane {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: hsl(var(--b1));
  outline: none;
  transition: box-shadow 0.1s;
  overflow: hidden;
}

/* Active pane: thin primary inset border on the top */
.bn-pane.bn-pane-active {
  box-shadow: inset 0 2px 0 0 hsl(var(--p));
}

/* File drawer */
.bn-drawer {
  flex: 0 0 auto;
  background: hsl(var(--b2));
  border-top: 1px solid hsl(var(--b3));
  display: flex;
  flex-direction: column;
  max-height: 180px;
}
.bn-drawer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid hsl(var(--b3));
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  background: hsl(var(--b2));
}
.bn-tree {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.4rem 0.75rem;
  min-height: 2.2rem;
  overflow-y: auto;
}

/* Pane-label pills above each pane */
.bn-pane-label {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.35rem 1rem;
  background: hsl(var(--b1));
  border-bottom: 1px solid hsl(var(--b3));
  color: hsl(var(--bc) / 0.55);
  display: block;
}

/* Scrollable pane body */
.bn-pane-body {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 1rem 2rem 1.5rem 3.25rem;
  min-height: 0;
}

/* ============================================================
   Blocks
   ============================================================ */
.bn-block {
  position: relative;
  border-radius: 0.375rem;
  /* Extend leftward to include the gutter so :hover covers it.
     The pane has padding-left:3.25rem; we pull the block 2.75rem back
     into that space and restore it as padding so text stays in place. */
  margin: 0 -0.5rem 0 -2.75rem;
  padding: 0.25rem 0.5rem 0.25rem 2.75rem;
  cursor: text;
}
.bn-block:hover,
.bn-block.bn-gutter-open {
  background: hsl(var(--b2));
}
.bn-block.bn-editing {
  background: hsl(var(--b2));
  cursor: auto;
}

/* Drag states */
.bn-block.bn-dragging {
  opacity: 0.4;
}
.bn-block.bn-drop-above,
.bn-block.bn-drop-below {
  border: none;
}
.bn-block.bn-drop-above::before,
.bn-block.bn-drop-below::after {
  content: '';
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 20;
}
.bn-block.bn-drop-above::before { top: -1px; }
.bn-block.bn-drop-below::after  { bottom: -1px; }

.bn-source {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  outline: none;
  width: 100%;
  margin: 0;
  background: transparent;
}

/* Rendered AsciiDoc */
.bn-block h1,
.bn-block h2,
.bn-block h3 { font-weight: 700; line-height: 1.2; }
.bn-block h1 { font-size: 1.75rem; margin: 0.5rem 0; }
.bn-block h2 { font-size: 1.4rem; margin: 0.5rem 0; }
.bn-block h3 { font-size: 1.15rem; margin: 0.4rem 0; }
.bn-block p  { margin: 0.4rem 0; line-height: 1.6; }
.bn-block ul,
.bn-block ol { margin: 0.4rem 0 0.4rem 1.5rem; }
.bn-block ul { list-style: disc; }
.bn-block ol { list-style: decimal; }
.bn-block li { display: list-item; }
.bn-block pre {
  background: hsl(var(--b2));
  padding: 0.75rem;
  border-radius: 0.375rem;
  overflow-x: auto;
}

/* ============================================================
   Block gutter (left-side hover widgets)
   ============================================================ */
.bn-gutter {
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 10;
}

.bn-block:hover .bn-gutter,
.bn-block.bn-gutter-open .bn-gutter {
  opacity: 1;
  pointer-events: auto;
}



/* Common widget button style */
.bn-w-type,
.bn-w-props,
.bn-w-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.3rem;
  border: none;
  background: transparent;
  color: hsl(var(--bc) / 0.45);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.bn-w-type:hover,
.bn-w-props:hover {
  background: hsl(var(--b3));
  color: hsl(var(--bc));
}
.bn-w-type svg,
.bn-w-props svg,
.bn-w-drag svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.bn-w-drag {
  cursor: grab;
}
.bn-w-drag:hover {
  background: hsl(var(--b3));
  color: hsl(var(--bc));
}
.bn-w-drag:active {
  cursor: grabbing;
}

/* Type dropdown wrapper */
.bn-w-type-wrap {
  position: relative;
}

/* Type dropdown menu */
.bn-type-menu {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 0.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  min-width: 11rem;
  z-index: 100;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.bn-type-menu.hidden {
  display: none;
}

.bn-type-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.35rem;
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.75);
  cursor: pointer;
  text-align: left;
  font-size: 0.82rem;
  width: 100%;
  transition: background 0.1s;
}
.bn-type-item:hover {
  background: rgba(0, 0, 0, 0.06);
  color: hsl(var(--bc));
}
.bn-type-item-active {
  background: rgba(0, 0, 0, 0.06);
  color: hsl(var(--p));
  font-weight: 600;
}
.bn-type-item-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.bn-type-item-icon svg {
  width: 1rem;
  height: 1rem;
}

/* ============================================================
   Insert-between slots
   ============================================================ */
.bn-insert-slot {
  /* Real height for hover target, cancelled by negative margins so blocks don't move */
  position: relative;
  height: 8px;
  margin: -4px -0.5rem -4px -2.75rem;
  overflow: visible;
  z-index: 4;
}

.bn-insert-btn {
  /* Always rendered at opacity 0 — no display toggle means no reflow */
  display: flex;
  opacity: 0;
  pointer-events: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1.5px solid hsl(var(--p));
  background: hsl(var(--b1));
  color: hsl(var(--p));
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: absolute;
  left: 2.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  transition: opacity 0.1s, background 0.1s, transform 0.1s;
}
.bn-insert-btn svg {
  width: 0.75rem;
  height: 0.75rem;
}
.bn-insert-slot:hover .bn-insert-btn {
  opacity: 1;
  pointer-events: auto;
}
.bn-insert-btn:hover {
  background: hsl(var(--p));
  color: hsl(var(--pc));
  transform: translateY(-50%) scale(1.1);
}
.bn-insert-slot:hover::after {
  content: '';
  position: absolute;
  left: 2.75rem;
  right: 0;
  top: 50%;
  height: 1px;
  background: hsl(var(--p) / 0.25);
  pointer-events: none;
}

/* ============================================================
   Focus / layout modes
   ============================================================ */
.bn-panes.bn-focus-single #bn-pane-1 { display: none; }

.bn-panes.bn-focus-left  #bn-pane-0 { flex: 3 1 0; }
.bn-panes.bn-focus-left  #bn-pane-1 { flex: 1 1 0; }

.bn-panes.bn-focus-right #bn-pane-0 { flex: 1 1 0; }
.bn-panes.bn-focus-right #bn-pane-1 { flex: 3 1 0; }

/* Conflict banner */
.bn-conflict-banner {
  margin: 0.5rem;
  animation: bn-flash 0.3s ease;
}
@keyframes bn-flash {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* File path labels in navbar */
#bn-filelabel-0,
#bn-filelabel-1 {
  font-size: 0.8rem;
  color: hsl(var(--bc) / 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
#bn-filelabel-1:not(.hidden)::before {
  content: '·';
  margin-right: 0.5rem;
  opacity: 0.4;
}
