/* Tool-specific: Markdown ↔ HTML Converter
   Three-region layout (task 0185): top row = [source | raw-output] side-by-side,
   bottom row = full-width [preview]. The `minmax(0, 1fr)` columns are critical —
   they refuse to grow past their share when the preview pane contains intrinsically
   wide content (long headings, fenced code, tables). Plain `1fr` alone respects
   intrinsic content width and was the root cause of the input-pane squeeze bug.
   Uses tokens from src/shared/css/base.css only — no new color literals. */

/* Mode toggle — horizontal radio row (matches JSON↔YAML pattern). */
.mode-toggle {
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-2);
  padding: var(--space-2) var(--space-3);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.mode-toggle .option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  font-size: 0.9375rem;
}

/* Visually hidden but available to screen readers (mode-toggle legend). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Top row: source on the left, raw-output on the right — both as <textarea>s.
   `minmax(0, 1fr)` is the load-bearing rule — without the `minmax(0, ...)` floor
   each column would respect its intrinsic min-content width and a long unbreakable
   token in either side could push the columns out of share (the original bug). */
.md-converter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
}

@media (max-width: 48rem) {
  .md-converter-grid {
    grid-template-columns: 1fr;
  }
}

/* Both editor surfaces (source + raw output) share textarea styling so the row
   looks visually balanced. The raw output is a <textarea readonly> so the copy
   handler can read `.value` cleanly. */
#source,
#output-raw {
  width: 100%;
  min-height: 16rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.9375rem;
  resize: vertical;
  /* allow horizontal overflow inside the textarea rather than blowing out the
     grid column — textareas natively scroll when content exceeds the box. */
  overflow: auto;
}

#output-raw {
  /* Subtle differentiation so the read-only output reads as "computed" vs. the
     editable source pane. Token-only — no literal color. */
  background: var(--color-bg-elevated);
}

/* Bottom row — full-width preview panel under the source/raw pair. */
.md-preview-panel {
  margin-top: var(--space-4);
}

/* Preview surface — bounded height so huge documents do not make the page
   infinitely tall; vertical scroll inside the box. */
.md-output {
  min-height: 12rem;
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--space-3);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.md-output:empty::before {
  content: attr(data-empty-placeholder);
  color: var(--color-ink-muted);
  font-style: italic;
}

/* Rendered preview prose — match site typography, scoped to #output-preview. */
#output-preview h1,
#output-preview h2,
#output-preview h3,
#output-preview h4,
#output-preview h5,
#output-preview h6 {
  font-family: var(--font-mono, monospace);
  margin-top: var(--space-3);
  margin-bottom: var(--space-2);
  line-height: 1.25;
}

#output-preview h1 { font-size: 1.5rem; }
#output-preview h2 { font-size: 1.25rem; }
#output-preview h3 { font-size: 1.125rem; }
#output-preview h4,
#output-preview h5,
#output-preview h6 { font-size: 1rem; }

#output-preview p {
  margin: 0 0 var(--space-2);
}

#output-preview ul,
#output-preview ol {
  margin: 0 0 var(--space-2);
  padding-inline-start: 1.5rem;
}

#output-preview ul ul,
#output-preview ol ol,
#output-preview ul ol,
#output-preview ol ul {
  margin: 0;
}

#output-preview li {
  margin-bottom: 0.125rem;
}

#output-preview code {
  font-family: var(--font-mono, monospace);
  font-size: 0.875em;
  padding: 0.125rem 0.375rem;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-1);
  color: var(--color-signal);
}

#output-preview pre {
  margin: 0 0 var(--space-2);
  padding: var(--space-3);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-2);
  overflow: auto;
}

#output-preview pre code {
  padding: 0;
  background: transparent;
  color: var(--color-ink);
  font-size: 0.875rem;
  white-space: pre;
}

#output-preview blockquote {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-inline-start: 3px solid var(--color-signal);
  background: var(--color-bg-elevated);
  color: var(--color-ink-muted);
}

#output-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 var(--space-2);
  font-size: 0.875rem;
}

#output-preview th,
#output-preview td {
  border: 1px solid var(--color-rule);
  padding: 0.375rem 0.625rem;
  text-align: start;
}

#output-preview th {
  background: var(--color-bg-elevated);
  font-weight: 600;
}

#output-preview a {
  color: var(--color-signal);
  text-decoration: underline;
}

#output-preview hr {
  margin: var(--space-3) 0;
  border: 0;
  border-top: 1px solid var(--color-rule);
}

#output-preview img {
  max-width: 100%;
  height: auto;
}

#output-preview input[type="checkbox"] {
  margin-inline-end: 0.375rem;
}

/* Status line under the output (sanitization fail / copy ack). */
.md-status {
  margin: var(--space-2) 0 0;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono, monospace);
  font-size: 0.875rem;
  border-radius: var(--radius-2);
  background: var(--color-bg-elevated);
  color: var(--color-ink-muted);
  border: 1px solid var(--color-rule);
}

.md-status[data-state="error"] {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.md-status[data-state="success"] {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: var(--color-success);
}

/* Sanitization notice — subtle one-liner under the output. */
#sanitization-notice {
  margin: var(--space-2) 0 0;
  font-size: 0.8125rem;
  color: var(--color-ink-muted);
  font-style: italic;
}
