/* EditorPage.css - Refactored for a Clean & Professional Look */

:root {
  /*
    Assuming these variables are defined in a global stylesheet (e.g., index.css)
    --background-primary: #f8f9fa;
    --background-secondary: #ffffff;
    --border-color: #dee2e6;
    --shadow-color-soft: rgba(0, 0, 0, 0.05);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --accent-primary: #007bff;
    --accent-primary-hover: #0056b3;
    --accent-highlight-soft: #e7f3ff;
    --text-on-accent: #ffffff;
  */
}

/* ==========================================================================
   Page Layout
   ========================================================================== */

/* Full-bleed container for the entire editor page */
.editor-page-container {
  background-color: var(--background-primary);
  min-height: 100vh;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Fixed header bar for controls */
.editor-header {
  padding: 0.75rem 2rem; /* Adjusted padding */
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--background-secondary);
  z-index: 1000;
  height: 64px; /* Set a fixed height for easier calculations */
  box-sizing: border-box;
}

/* Main title in the header */
.editor-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600; /* Semi-bold for titles as recommended */
  font-family: var(--font-ui); /* Explicitly use Inter for UI */
  color: var(--text-primary);
}

/* User greeting in the header - styled subtly */
.editor-header .editor-user-greeting {
  margin: 0;
  font-size: 0.9rem;
  font-family: var(--font-ui); /* Explicitly use Inter for UI */
  color: var(--text-secondary);
}

/* Container for the main editor and sidebar area */
.editor-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  /* Account for the fixed 64px header */
  height: calc(100vh - 64px);
  margin-top: 64px;
}

/* Collaboration Sidebar */
.collaboration-sidebar {
  width: 250px;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.collaboration-sidebar > * {
  flex-shrink: 0;
}

/* Editor Content Area */
.editor-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 820px; /* Slightly wider for modern screens */
  width: 100%;
  margin: 0 auto;
  padding: 3rem 4rem; /* Generous padding for focus */
  background-color: var(--background-secondary);
  box-shadow: 0 4px 12px var(--shadow-color-soft); /* Softer, more modern shadow */
  border-radius: 8px; /* Subtle rounding */
  margin-top: 2rem;
  margin-bottom: 2rem;
  box-sizing: border-box;
  height: calc(100% - 4rem); /* Full height minus top/bottom margins */
}

/* ==========================================================================
   ProseMirror Editor Typography
   ========================================================================== */

.ProseMirror {
  outline: none;
  line-height: 1.7; /* Optimal for long-form reading */
  font-size: 17px;
  font-family: var(--font-content); /* Source Serif Pro for content */
  color: var(--text-primary);
  text-align: left;
}

/* Placeholder for an empty editor */
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--text-secondary);
  opacity: 0.6;
  pointer-events: none;
  height: 0;
  font-family: var(--font-content); /* Match content font for placeholder */
}

/* Headings */
.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3,
.ProseMirror h4,
.ProseMirror h5,
.ProseMirror h6 {
  font-family: var(--font-content); /* Source Serif Pro for headings */
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

.ProseMirror h1 { font-size: 2.25rem; }
.ProseMirror h2 { font-size: 1.75rem; }
.ProseMirror h3 { font-size: 1.4rem; }

/* Paragraphs */
.ProseMirror p {
  margin: 0;
  font-family: var(--font-content); /* Source Serif Pro for paragraphs */
}

.ProseMirror p + p {
  margin-top: 1em; /* Consistent space between paragraphs */
}

/* Highlighted text for comments */
.comment-mark {
  background-color: var(--accent-highlight-soft);
  cursor: pointer;
  /* Soften the start and end of a highlight sequence */
  border-radius: 3px;
  /* This ensures highlighting works well across line breaks */
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* 
  When Tiptap creates multiple spans, only the first and last
  should have rounded corners. This makes it look like one element.
*/
.comment-mark:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.comment-mark:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* The active comment gets a distinct, brighter background */
.comment-mark-active {
  background-color: #fffb8b; /* A classic yellow highlight */
}

/* Ensure figure captions are centered */
.quarto-block-output figure figcaption {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-top: 0.5em;
}

/* Author Info in Sidebar */
.author-info {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.author-info h4 {
  margin: 0 0 8px 0;
  color: #495057;
  font-size: 14px;
  font-weight: 600;
}

.author-info p {
  margin: 0 0 12px 0;
  color: #6c757d;
  font-size: 12px;
  line-height: 1.4;
}