/* JSON to YAML Converter — direction switch, options, input and output panes, notes.
   Colours come from the shared tokens, so the panel follows the light and dark themes. */
.j2y {
  position: relative;
  display: grid;
  gap: 1.1rem;
  padding: clamp(16px, 2.4vw, 32px);
  text-align: left;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shade);
}
.j2y *, .j2y *::before, .j2y *::after { box-sizing: border-box; }
.j2y [hidden] { display: none !important; }
.j2y h2 { margin: 0 0 .35rem; font-size: 1.45rem; letter-spacing: -.02em; }
.j2y p { margin: 0; color: var(--ink-soft); }
.j2y-head p { max-width: 78ch; }
.j2y label { min-width: 0; font-size: .85rem; font-weight: 650; }
.j2y select {
  min-height: 42px;
  padding: .45rem .6rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 6px;
}
.j2y :is(input, textarea, select, button):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.j2y button, .j2y-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .45rem .9rem;
  font: inherit;
  font-size: .9rem;
  font-weight: 650;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.j2y button:disabled { opacity: .5; cursor: default; }
.j2y .j2y-primary { color: var(--on-action); background: var(--action); box-shadow: 3px 3px 0 var(--shade); }
.j2y .j2y-primary:hover:not(:disabled) { background: var(--primary-dark); }

/* Direction: pill labels around visually hidden radios. */
.j2y-modes { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; border: 0; }
.j2y-modes legend { width: 100%; margin-bottom: .45rem; padding: 0; font-weight: 700; }
.j2y-modes label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: .45rem 1rem; font-size: .95rem; background: var(--bg-2); border: 2px solid var(--line); border-radius: 999px; cursor: pointer; }
.j2y-modes input { position: absolute; opacity: 0; pointer-events: none; }
.j2y-modes label:has(input:checked) { color: var(--on-action); background: var(--action); box-shadow: 2px 2px 0 var(--shade); }
.j2y-modes label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

.j2y-options { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1.1rem; margin: 0; padding: .85rem 1rem 1rem; background: var(--blue-tint); border: 2px solid var(--line); border-radius: 10px; }
.j2y-options legend { padding: 0 .35rem; font-weight: 700; }
.j2y-options > label:not(.j2y-check) { display: grid; gap: .3rem; flex: 1 1 11rem; max-width: 22rem; }
.j2y-options > label[data-j2y="documents-wrap"] { flex-basis: 16rem; max-width: 28rem; }
.j2y-options select { width: 100%; min-width: 0; }
.j2y-check { display: flex; align-items: center; gap: .55rem; min-height: 42px; font-size: .95rem !important; font-weight: 500 !important; }
.j2y-check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--action); }

.j2y-panes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.j2y-pane { display: grid; grid-template-rows: auto 1fr auto; gap: .5rem; min-width: 0; }
.j2y-pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; min-height: 42px; }
.j2y-pane-head > label { font-size: 1rem; font-weight: 700; }
.j2y-tools { display: flex; flex-wrap: wrap; gap: .45rem; }
.j2y-file { position: relative; }
.j2y-file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.j2y-file:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.j2y-pane textarea {
  width: 100%;
  min-width: 0;
  min-height: 26rem;
  padding: .7rem .8rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  background: var(--field);
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
  resize: vertical;
}
.j2y-pane textarea[readonly] { background: var(--paper-3); }
.j2y-pane textarea[aria-invalid="true"] { border: 2px solid var(--error); }
.j2y-sub { min-height: 1.45em; font-size: .82rem; line-height: 1.45; }

.j2y-report { display: grid; gap: .6rem; }
.j2y-status { padding: .55rem .8rem; font-weight: 600; color: var(--ink) !important; background: var(--paper-3); border-left: 4px solid var(--border-soft); border-radius: 6px; overflow-wrap: anywhere; }
.j2y-status[data-state="ok"] { background: var(--success-soft); border-left-color: var(--success); }
.j2y-status[data-state="error"] { background: var(--error-soft); border-left-color: var(--error); }
.j2y-status:empty { display: none; }
.j2y-fixes { display: flex; flex-wrap: wrap; gap: .5rem; }
.j2y-fixes:not(:has(button:not([hidden]))) { display: none; }
.j2y-notes { display: grid; gap: .35rem; margin: 0; padding: .55rem .8rem .55rem 1.9rem; font-size: .88rem; color: var(--ink); background: var(--warning-soft); border-left: 4px solid var(--warning); border-radius: 6px; overflow-wrap: anywhere; }
.j2y-foot { font-size: .85rem; }

/* A file dragged over the panel. */
.j2y-dragging::after {
  content: 'Drop the file to convert it';
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg-2);
  border: 3px dashed var(--action);
  border-radius: 12px;
  opacity: .94;
  pointer-events: none;
}

@media (max-width: 760px) {
  .j2y-panes { grid-template-columns: minmax(0, 1fr); }
  .j2y-pane textarea { min-height: 15rem; }
  .j2y-options > label:not(.j2y-check) { max-width: none; }
}

/* Space the page holds for this view until it mounts (see .tool-view-placeholder in _workspace.css).
   Each height is a little under the space the view takes at that width, measured as how far the
   content below moves when the view replaces the placeholder, so nothing below it moves. Re-measure
   after changing the view's layout: node scripts/measure-tool-views.js --apply json-to-yaml. */
.tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1007px; }
@media (max-width: 1296px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1022px; } }
@media (max-width: 1000px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1051px; } }
@media (max-width: 856px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1119px; } }
@media (max-width: 760px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1234px; } }
@media (max-width: 660px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1303px; } }
@media (max-width: 556px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1322px; } }
@media (max-width: 520px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1371px; } }
@media (max-width: 480px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1475px; } }
@media (max-width: 448px) { .tool-view-placeholder[data-tool="json-to-yaml"] { min-height: 1587px; } }
