/**
 * Revealation — layout editor affordances
 * =======================================
 *
 * Purpose: make structural blocks visible in WYSIWYG without changing reveal
 * presentation geometry. All structural borders use outline/inset painting and
 * therefore do not consume layout space.
 */

.sr-layout {
  display: grid;
  width: 100%;
  min-width: 0;
  margin: 0;
}
.sr-layout-slot { min-width: 0; min-height: 0; position: relative; }
.sr-layout-content { min-width: 0; min-height: 0; }

/* Presentation output has no editor labels/borders. */
.reveal .sr-layout-slot,
.reveal .sr-layout-content { min-width: 0; }
.reveal .sr-layout img,
.reveal .sr-layout video { max-width: 100%; max-height: 62vh; object-fit: contain; }

/* Structural editor blocks. */
.slide-editor .sr-layout {
  position: relative;
  border-radius: 4px;
}
.slide-editor .sr-layout-slot {
  border-radius: 4px;
  padding: 0;
}
.slide-editor .sr-layout-slot::before {
  content: attr(data-slot);
  position: absolute;
  z-index: 4;
  top: 2px;
  right: 2px;
  width: max-content;
  margin: 0;
  padding: 1px 4px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--muted);
  font: 8px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  pointer-events: none;
  opacity: .78;
}
.slide-editor .sr-layout-content {
  min-height: 1.2em;
  outline: 1px dashed color-mix(in srgb, currentColor 30%, transparent);
  outline-offset: -1px;
  border-radius: 4px;
}
.slide-editor .sr-layout-content:focus,
.slide-editor .sr-layout-content:focus-within {
  outline-style: solid;
  outline-color: var(--accent);
}

/* Only real editing hosts are outlined. Paragraphs/headings/lists inside a
   host are ordinary content, not structural blocks, and intentionally have no
   editor border of their own. */

/* Picker cards are generated from the registry. */
.layout-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.layout-choices .layout-choice {
  display: flex; flex-direction: column; align-items: stretch; gap: 7px;
  min-height: 92px; padding: 9px; text-align: left;
}
.layout-choice-preview { display: grid; flex: 1; min-height: 48px; gap: 3px; }
.layout-choice-preview > i { display: block; min-width: 0; min-height: 12px; border: 1px solid currentColor; border-radius: 2px; opacity: .55; }
.layout-choice strong { font-size: 11px; }
.layout-choice small { color: var(--muted); font-size: 9px; line-height: 1.25; }

.layout-choices .layout-choice.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent) inset;
  background: color-mix(in srgb, var(--accent) 10%, var(--input-bg));
}
.layout-choice-current {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .02em;
}

/* Markdown diagnostics are paint-only so caret/highlight metrics stay identical. */
.markdown-highlight .md-layout { color: #c084fc; background: color-mix(in srgb, #c084fc 8%, transparent); }
.markdown-highlight .md-block { color: #60a5fa; }
.markdown-highlight .md-invalid {
  color: #f87171;
  background: color-mix(in srgb, #ef4444 12%, transparent);
  box-shadow: inset 3px 0 #ef4444;
  text-decoration: underline wavy #ef4444;
}

.markdown-mode .markdown-status { max-width: 46%; white-space: normal; line-height: 1.25; }

/* 3.3: the editor root is the implicit single/body block. Multi-block layouts
   replace that body structurally; no editable content may live beside them. */
.slide-editor:not(:has(> .sr-layout)) {
  outline: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  outline-offset: -1px;
}

/* Explicit raw HTML escape hatch. It is protected in WYSIWYG and serializes
   only through `::: html`; arbitrary DOM can never silently become Markdown. */
.slide-editor .sr-html-block {
  position: relative;
  outline: 1px dashed color-mix(in srgb, #f59e0b 65%, transparent);
  outline-offset: 2px;
}
.slide-editor .sr-html-block::before {
  content: "raw html";
  position: absolute;
  z-index: 8;
  top: 2px;
  right: 2px;
  padding: 1px 4px;
  border-radius: 3px;
  background: color-mix(in srgb, #f59e0b 82%, var(--panel));
  color: #111;
  font: 8px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  pointer-events: none;
}
.slide-editor .sr-html-content { pointer-events: none; }
.reveal .sr-html-block,
.reveal .sr-html-content { display: contents; }
.thumbnail-surface .sr-html-block::before { display: none !important; }

/* Slot edges are layout boundaries: child block margins must not create large
   invisible gutters against them. Interior margins remain theme-controlled. */
.sr-layout-content > :first-child { margin-top: 0 !important; }
.sr-layout-content > :last-child { margin-bottom: 0 !important; }

.slide-editor:not(:has(> .sr-layout))::before {
  content: "body";
  position: absolute;
  z-index: 6;
  top: 2px;
  right: 2px;
  padding: 1px 4px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--muted);
  font: 8px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  pointer-events: none;
  opacity: .7;
}
.thumbnail-surface.slide-editor::before { display: none !important; }
