/* ============================================================
   SECTIONS
   ============================================================ */

.section-block {
    margin-bottom: 2px;
    position: relative;
    border-radius: var(--radius);
    transition: background var(--dur);
}


.section-inner {
    padding: 12px 20px;
    border-radius: var(--radius);
    transition: background var(--dur);
}
.section-inner:hover { background: var(--doc-hover-subtle); }

.section-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

/* Section header tool buttons get a small top margin so they align with the title baseline */
.section-header .insert-fig-header-btn,
.section-header .meta-toggle-btn { margin-top: 3px; }

/* Section metadata panel — collapse transition + .meta-divider styling
   come from the COLLAPSIBLE PANELS + DOC DIVIDER blocks in components.css */
.section-meta-panel { padding: 4px 0 0; margin: 0 0 4px; max-height: 200px; }

/* Summary visual comes from FIELDS block in components.css */
.meta-summary-input { min-height: 48px; }

/* Meta controls row (level picker + reorder + delete) */
.meta-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
.meta-controls-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Level picker — dropdown style */
.meta-level-picker {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--dur);
}
.meta-level-picker:hover { background: var(--doc-hover); }
.meta-level-label {
    font: 12px var(--sans);
    color: var(--td3);
}
.meta-level-picker svg { color: var(--td3); flex-shrink: 0; }
.meta-level-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 150px;
}
.meta-level-menu .dropdown-item.active { background: var(--chrome-hover); color: var(--t1); }

/* Section number sits inline as the first flex item — gives a proper
   hanging indent on multi-line titles instead of the old text-indent hack. */
.section-number {
    font-family: var(--serif);
    color: var(--doc-ochre);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}
.section-number[data-level="1"] { font-size: 26px; font-weight: 300; line-height: 1.25; }
.section-number[data-level="2"] { font-size: 23px; font-weight: 300; line-height: 1.3; }
.section-number[data-level="3"] { font-size: 20px; font-weight: 300; line-height: 1.35; }

/* Section title flex layout (visual from FIELDS block in components.css) */
.section-title-input { flex: 1; min-width: 0; }

/* Section body — visual from FIELDS block; only structural rules here */
.section-body-input { white-space: pre-wrap; word-wrap: break-word; min-height: 28px; }

/* Read-only body (contenteditable) — visual from FIELDS block */
.section-body { white-space: pre-wrap; word-wrap: break-word; cursor: text; }
.section-body p { margin-bottom: 16px; }
/* Inline math being edited: its $source$, shown as editable code so you can see
   you're in the LaTeX. Folds back to the rendered SVG on blur. */
.math-src { font-family: var(--mono); font-size: .92em; color: var(--doc-accent); background: var(--doc-accent-dim); border-radius: 3px; padding: 0 1px; }
.section-body p:last-child { margin-bottom: 0; }
.section-body:empty::before {
    content: 'Start writing...';
    color: var(--td3);
    opacity: 0.4;
    font-style: italic;
}


/* ---- Add section buttons ---- */
.add-row {
    position: relative;
    height: 22px;
    margin: 0;
    z-index: var(--z-section);
}
.previewing .add-row { visibility: hidden; }
.preview-section-spacer { height: 28px; }
.add-row.first-visible {
    height: auto;
    margin: 0 0 12px;
}

.add-line { display: none; }

/* buttons float over the gap, hidden until hover */
.add-row .add-btns {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms;
}
.add-row:hover .add-btns {
    opacity: 1;
    pointer-events: auto;
}

/* first-visible row is always shown, static layout */
.add-row.first-visible .add-btns {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    justify-content: center;
    padding: 0;
}

.add-section-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--doc-border-strong);
    color: var(--td2);
    font: 500 12px var(--sans);
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    white-space: nowrap;
}
.add-section-btn:hover {
    border-color: var(--doc-ochre);
    color: var(--doc-ochre);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}


/* ---- Delete section confirm ---- */
.section-delete-confirm {
    position: absolute;
    top: 0; right: 0;
    background: var(--chrome-bg2);
    border: 1px solid var(--chrome-border);
    border-radius: var(--radius);
    padding: 10px 14px;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: var(--fs-sm);
    color: var(--t2);
}
