/* ============================================================
   split-pane.css — Split pane: editor, divider, preview.
   ============================================================ */

/* ---------- Split pane ---------- */

#main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 17px 1fr;
  min-height: 0;
  overflow: hidden;
}

#editor-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

/* Majority-RTL document: RTL base for every line */
#editor-wrap.rtl-doc #editor,
#editor-wrap.rtl-doc #editor-hilite {
  direction: rtl;
  unicode-bidi: embed;
}

/* Highlight layer sits BEHIND the transparent-background textarea */
#editor-hilite {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 14px 28px;
  font: 0.9375rem/1.65 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  unicode-bidi: plaintext;
  color: transparent;
  pointer-events: none;
}

#editor-hilite .find-mark {
  background: rgba(82, 148, 226, 0.32);
  border-radius: 2px;
  color: transparent;
}

#editor-hilite .find-mark.cur {
  background: rgba(235, 165, 70, 0.55);
}

#editor-hilite::after {
  content: '';
  display: block;
  height: 80px;
}

#editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 0.9375rem/1.65 var(--font-mono);
  padding: 14px 28px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  unicode-bidi: plaintext;
  caret-color: var(--accent);
}

#editor::placeholder {
  color: var(--text-faint);
}

#divider {
  position: relative;
  width: 17px;
  flex: none;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

#divider::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  background: var(--border-soft);
  transition: all 0.15s ease;
}

.divider-grip {
  width: 5px;
  height: 32px;
  border-radius: 9999px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  transition: all 0.15s ease;
  z-index: 1;
}

#divider:hover::before {
  background: var(--accent);
  width: 2px;
  opacity: 0.5;
}

#divider:hover .divider-grip {
  background: var(--accent);
  border-color: var(--accent);
  width: 7px;
  height: 40px;
}

#divider.dragging::before {
  background: var(--accent);
  width: 2px;
  opacity: 0.7;
}

#divider.dragging .divider-grip {
  background: var(--accent);
  border-color: var(--accent);
  width: 8px;
  height: 48px;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

body.resizing #editor,
body.resizing #preview {
  pointer-events: none;
}

#preview {
  min-width: 0;
  overflow-y: auto;
  padding: 14px 28px;
  background: var(--bg-panel);
}

/* Solo pane modes: override default 3-column grid (ID selector needs !important) */
#main.preview-hidden,
#main.editor-hidden {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

#main.preview-hidden #divider,
#main.preview-hidden #preview,
#main.editor-hidden #divider,
#main.editor-hidden #editor-wrap {
  display: none;
}

#main.preview-hidden #editor,
#main.preview-hidden #editor-hilite,
#main.editor-hidden #preview {
  padding-left: 28px;
  padding-right: 28px;
}

#toggle-preview.off,
#toggle-editor.off {
  opacity: 0.45;
}

/* Responsive: horizontal split on small screens */
@media (max-width: 767px) {
  #main {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr 17px 1fr;
  }

  #divider {
    width: 100%;
    height: 17px;
    cursor: row-resize;
    flex-direction: row;
  }

  #divider::before {
    top: 50%;
    bottom: auto;
    left: 0;
    right: 0;
    width: auto;
    height: 1px;
    transform: translateY(-50%);
  }

  .divider-grip {
    width: 32px;
    height: 5px;
  }

  #divider:hover::before {
    width: auto;
    height: 2px;
  }

  #divider:hover .divider-grip {
    width: 40px;
    height: 7px;
  }

  #divider.dragging::before {
    width: auto;
    height: 2px;
  }

  #divider.dragging .divider-grip {
    width: 48px;
    height: 8px;
  }

  body.resizing {
    cursor: row-resize;
  }
}
