/* docs.css — Document editor styles */

/* Editor layout */
.docs-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.docs-editor-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
}

.document-view {
  width: 100%;
  max-width: 720px;
}

@media (min-width: 1440px) {
  .document-view { max-width: 840px; }
}
@media (min-width: 2560px) {
  .document-view { max-width: 960px; }
}

/* Document title */
.doc-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-6);
  outline: none;
  border: none;
  width: 100%;
}

.doc-title:empty::before {
  content: "Untitled";
  color: var(--color-text-muted);
}

/* Block styles */
.block-wrapper {
  position: relative;
  padding: 2px 0;
  margin: 2px 0;
  border-radius: 4px;
  transition: background-color var(--transition-fast);
}

.block-wrapper:hover {
  background: var(--color-surface-0);
}

.block-wrapper:hover .block-drag-handle {
  opacity: 1;
}

.block-drag-handle {
  position: absolute;
  left: -28px;
  top: 4px;
  width: 20px;
  height: 20px;
  opacity: 0;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--color-text-muted);
  transition: opacity var(--transition-fast);
}

.block-drag-handle:hover {
  background: var(--color-surface-1);
}

.block-content {
  outline: none;
  min-height: 1.5em;
  line-height: 1.5;
}

.block-content:empty::before {
  content: "Type / for commands";
  color: var(--color-text-muted);
}

/* Block type-specific styles */
.block-heading-1 { font-size: 1.953rem; font-weight: 700; line-height: 1.2; margin: var(--space-5) 0 var(--space-2); }
.block-heading-2 { font-size: 1.563rem; font-weight: 600; line-height: 1.2; margin: var(--space-4) 0 var(--space-2); }
.block-heading-3 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; margin: var(--space-3) 0 var(--space-2); }
.block-heading-4 { font-size: 1rem; font-weight: 600; line-height: 1.3; margin: var(--space-3) 0 var(--space-1); }
.block-heading-5 { font-size: 0.8rem; font-weight: 600; line-height: 1.3; margin: var(--space-2) 0 var(--space-1); }
.block-heading-6 { font-size: 0.64rem; font-weight: 600; line-height: 1.3; text-transform: uppercase; letter-spacing: 0.05em; margin: var(--space-2) 0 var(--space-1); }

.block-bullet-list,
.block-numbered-list {
  padding-left: var(--space-6);
}

.block-bullet-list { list-style-type: disc; }
.block-numbered-list { list-style-type: decimal; }

.block-todo {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.block-todo input[type="checkbox"] {
  margin-top: 0.35em;
  accent-color: var(--color-primary);
}

.block-todo.checked .block-content {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.block-code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.875em;
  background: var(--color-surface-1);
  border-radius: 8px;
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  white-space: pre-wrap;
  tab-size: 2;
}

.block-quote {
  border-left: 3px solid var(--color-primary);
  padding-left: var(--space-4);
  color: var(--color-text-muted);
  font-style: italic;
}

.block-callout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.block-callout-info { background: oklch(0.95 0.03 230); }
.block-callout-warning { background: oklch(0.95 0.05 85); }
.block-callout-error { background: oklch(0.95 0.05 25); }
.block-callout-success { background: oklch(0.95 0.05 145); }

.block-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

.block-image {
  max-width: 100%;
  border-radius: 8px;
}

.block-image.align-center { margin: 0 auto; display: block; }
.block-image.align-full { width: 100%; }

.block-image-wrapper {
  position: relative;
  display: inline-block;
}

.block-image-wrapper .resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border: 1px solid white;
  border-radius: 50%;
  cursor: nwse-resize;
}

/* Table blocks */
.block-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-2) 0;
}

.block-table td {
  border: 1px solid var(--color-border);
  padding: var(--space-1) var(--space-2);
  min-width: 80px;
  outline: none;
}

.block-table td:focus {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Indentation levels */
.block-indent-1 { margin-left: var(--space-6); }
.block-indent-2 { margin-left: calc(var(--space-6) * 2); }
.block-indent-3 { margin-left: calc(var(--space-6) * 3); }

/* Toggle block */
.block-toggle > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.block-toggle > summary::before {
  content: "▶";
  font-size: 0.75em;
  transition: transform var(--transition-fast);
}

.block-toggle[open] > summary::before {
  transform: rotate(90deg);
}

/* Inline marks */
.mark-bold { font-weight: 700; }
.mark-italic { font-style: italic; }
.mark-underline { text-decoration: underline; }
.mark-strikethrough { text-decoration: line-through; }
.mark-code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.875em;
  background: var(--color-surface-1);
  padding: 1px 4px;
  border-radius: 3px;
}
.mark-link {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

/* Slash menu */
.slash-menu {
  position: absolute;
  z-index: 50;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.15);
  backdrop-filter: blur(20px);
  padding: var(--space-1);
}

.slash-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.slash-menu-item:hover,
.slash-menu-item.active {
  background: var(--color-surface-1);
}

.slash-menu-item-icon {
  width: 20px;
  text-align: center;
  color: var(--color-text-muted);
}

/* Floating formatting toolbar */
.floating-toolbar {
  position: absolute;
  z-index: 40;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.12);
  backdrop-filter: blur(20px);
}

.floating-toolbar button {
  padding: 4px 8px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.floating-toolbar button:hover {
  background: var(--color-surface-1);
}

.floating-toolbar button.active {
  background: var(--color-primary);
  color: white;
}

/* Top toolbar */
.docs-top-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-0);
  flex-wrap: wrap;
}

.docs-top-toolbar .toolbar-group {
  display: flex;
  gap: 2px;
  padding: 0 var(--space-2);
  border-right: 1px solid var(--color-border);
}

.docs-top-toolbar .toolbar-group:last-child {
  border-right: none;
}

.docs-top-toolbar .word-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.docs-top-toolbar .save-status {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Find bar */
.find-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border);
}

.find-bar input {
  flex: 1;
  max-width: 300px;
}

.find-bar .match-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.find-highlight {
  background: oklch(0.9 0.1 90);
  border-radius: 2px;
}

.find-highlight-current {
  background: oklch(0.8 0.15 50);
}

/* Context menu */
.block-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.15);
  backdrop-filter: blur(20px);
  padding: var(--space-1);
}

.block-context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition-fast);
}

.block-context-menu-item:hover {
  background: var(--color-surface-1);
}

.block-context-menu-separator {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-1) 0;
}

/* Selection highlight */
::selection {
  background: oklch(0.8 0.1 260 / 0.3);
}

/* Block-level selection */
.block-wrapper.block-selected {
  background: oklch(0.9 0.05 260 / 0.2);
  border-radius: 4px;
}

/* Dark mode adjustments */
.dark .block-code {
  background: var(--color-surface-1);
}

.dark .block-callout-info { background: oklch(0.25 0.03 230); }
.dark .block-callout-warning { background: oklch(0.25 0.05 85); }
.dark .block-callout-error { background: oklch(0.25 0.05 25); }
.dark .block-callout-success { background: oklch(0.25 0.05 145); }

.dark .find-highlight {
  background: oklch(0.4 0.1 90);
}

.dark .find-highlight-current {
  background: oklch(0.5 0.15 50);
}
