/* ── Document Typography (UI Spec Section 5) ─────
   Styles for rendered content inside page frames.
   The layout engine positions elements; this CSS defines their appearance.
   Uses data-role attributes set by dom-projection.ts. */

/* ── Page content base ───────────────────────── */

.page-content {
  font-family: var(--font-document);
  font-size: 13.5px;
  line-height: 22px;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Rendered lines ──────────────────────────── */

.rendered-line {
  position: absolute;
  white-space: pre;
}

/* ── Inline styles ───────────────────────────── */

[data-style="bold"] { font-weight: 700; }
[data-style="italic"] { font-style: italic; }
[data-style="bolditalic"] { font-weight: 700; font-style: italic; }
[data-style="mono"] {
  font-family: var(--font-document-mono);
  font-size: 0.9em;
}
[data-style="smallcaps"] {
  font-variant: small-caps;
}

/* ── Links ───────────────────────────────────── */

a[data-href] {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
a[data-href]:hover {
  text-decoration: underline;
}

/* ── Mathematics ─────────────────────────────── */

[data-role="math-inline"] {
  color: var(--color-math);
  font-size: inherit;
}

[data-role="math-display"] {
  color: var(--color-math);
}

/* ── Code and verbatim ───────────────────────── */

[data-block-kind="verbatim"],
[data-block-kind="lstlisting"] {
  font-family: var(--font-document-mono);
  font-size: 11.5px;
  line-height: 18px;
}

/* ── Captions ────────────────────────────────── */

[data-block-kind="figurecaption"],
[data-block-kind="tablecaption"] {
  font-size: 11px;
  line-height: 16px;
  color: var(--text-secondary);
}

/* ── Footnotes ───────────────────────────────── */

.footnote-area {
  font-size: 9.5px;
  line-height: 14px;
  color: var(--text-secondary);
}

.footnote sup {
  font-size: 7px;
  vertical-align: super;
  line-height: 0;
}

/* ── List markers ────────────────────────────── */

.block-prefix {
  color: var(--text-secondary);
}

/* ── Block quotes ────────────────────────────── */

[data-block-kind="quote"],
[data-block-kind="quotation"] {
  font-style: italic;
  color: var(--text-secondary);
}

[data-block-kind="verse"] {
  font-style: italic;
}

/* ── Abstract ────────────────────────────────── */

[data-block-kind="abstract"] {
  font-size: 12px;
  line-height: 18px;
}

/* ── TOC ─────────────────────────────────────── */

[data-block-kind="toc-entry"] {
  font-variant-numeric: tabular-nums;
}

/* ── Tables ──────────────────────────────────── */

.rendered-table table {
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 22px;
}

.rendered-table td {
  padding: var(--space-1, 4px) var(--space-4, 16px);
}

/* ── Page frame ──────────────────────────────── */

.page-frame {
  position: relative;
  background: var(--surface-page);
  border-radius: var(--radius-page);
  box-shadow: var(--shadow-page);
  overflow: hidden;
  flex-shrink: 0;
}

/* ── Page number ─────────────────────────────── */

.page-number {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ── Cursor overlay ──────────────────────────── */

#preview-cursor {
  position: absolute;
  width: 2px;
  background: var(--cursor-color);
  border-radius: 1px;
  pointer-events: none;
  z-index: var(--z-cursor);
  animation: preview-cursor-blink 1s step-end infinite;
}

#preview-cursor.passive {
  border-radius: 3px;
  background: rgba(196, 153, 58, 0.12);
  box-shadow: inset 0 0 0 1px rgba(160, 120, 28, 0.08);
  animation: none;
}

/* ── Selection highlights ────────────────────── */

.preview-selection-highlight {
  position: absolute;
  background: var(--selection-preview);
  pointer-events: none;
  z-index: var(--z-selection, 5);
  border-radius: 2px;
}

/* ── Block highlight ─────────────────────────── */

#preview-block-highlight {
  position: absolute;
  background: var(--selection-preview);
  pointer-events: none;
  z-index: var(--z-selection);
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(45, 100, 210, 0.25);
}

/* ── Block edge affordance (UI Spec S8) ─────── */

.block-affordance {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: var(--z-block-affordance, 15);
}

.block-affordance.visible {
  pointer-events: auto;
  opacity: 1;
}

.block-affordance-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full, 999px);
  background: var(--surface-overlay, #fff);
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: color 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.block-affordance-btn:hover {
  color: var(--text-secondary);
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* ── Contextual format bar (Editor Spec S4) ──── */

#preview-format-bar {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  background: var(--surface-overlay, #fff);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg, 8px);
  box-shadow: var(--shadow-float);
  z-index: var(--z-format-bar, 20);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

#preview-format-bar.visible {
  opacity: 1;
  transform: translateY(0);
}

#preview-format-bar button {
  padding: 4px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font: 600 12px var(--font-ui, sans-serif);
  color: var(--text-secondary);
  transition: background 0.1s ease, color 0.1s ease;
}

#preview-format-bar button:hover {
  background: var(--hover-overlay);
  color: var(--text-primary);
}
