/* json.css — /formatters/json/ */

.json-input {
  min-height: 180px;
  font-family: var(--mono);
  font-size: .8125rem;
}

.card.drop-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

/* The offending line with a caret under the character. It scrolls sideways
   rather than wraps: a wrapped line would leave the caret under the wrong spot. */
.json-error-excerpt {
  margin: .5rem 0 0;
  padding: .5rem .625rem;
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.4;
  white-space: pre;
  overflow-x: auto;
  background: rgba(0,0,0,.04);
  border-radius: var(--r-sm);
}

.json-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.125rem;
}
.json-actions label.btn { margin-bottom: 0; cursor: pointer; }
.json-filename { font-size: .8125rem; color: var(--text-muted); font-family: var(--mono); }

.json-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ===== OUTPUT ===== */
.json-out-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.json-out-tools { display: flex; gap: .5rem; flex-wrap: wrap; }

.json-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  padding: .625rem .875rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .8125rem;
}
.json-stat .k { color: var(--text-sec); }
.json-stat .v { font-family: var(--mono); font-weight: 600; color: var(--text); }
.json-stat.good .v { color: #15803d; }

.json-out {
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 1rem;
  background: #1e293b;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.65;
  color: #e2e8f0;
  white-space: pre;
  tab-size: 4;
}
.json-out-plain {
  min-height: 420px;
  max-height: 520px;
  font-size: .8125rem;
  background: var(--surface-2);
}

/* Token colors: keys and strings must not read alike, or a tree of
   "key": "value" pairs turns into one undifferentiated block. */
.j-key   { color: #7dd3fc; }
.j-str   { color: #86efac; }
.j-num   { color: #fdba74; }
.j-bool  { color: #d8b4fe; }
.j-null  { color: #94a3b8; font-style: italic; }
.j-punc  { color: #94a3b8; }

/* ===== TREE ===== */
.json-tree-tools { display: flex; gap: .5rem; margin-bottom: .75rem; }
.json-tree {
  max-height: 520px;
  overflow: auto;
  padding: .875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.7;
}
.json-tree .j-key   { color: #0369a1; }
.json-tree .j-index { color: var(--text-muted); }
.json-tree .j-str   { color: #15803d; }
.json-tree .j-num   { color: #c2410c; }
.json-tree .j-bool  { color: #7e22ce; }
.json-tree .j-null  { color: var(--text-muted); font-style: italic; }
.json-tree .j-punc  { color: var(--text-sec); }

.j-line { display: flex; align-items: baseline; gap: .35rem; white-space: nowrap; }
.j-children { padding-left: 1.125rem; border-left: 1px solid var(--border); margin-left: .3rem; }
.j-close { color: var(--text-sec); padding-left: .3rem; }

.j-node.collapsed > .j-children,
.j-node.collapsed > .j-close { display: none; }
.j-node.collapsed > .j-line > .j-count::after { content: ' …'; }

.j-toggle {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-sec);
  font-size: .75rem;
  line-height: 1;
  padding: 0 .1rem;
  width: 1rem;
  flex-shrink: 0;
  font-family: var(--font);
}
.j-toggle:hover { color: var(--primary); }
.j-spacer { display: inline-block; width: 1rem; flex-shrink: 0; }
.j-count { color: var(--text-muted); font-size: .75rem; }

.toggle-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 560px) {
  .json-options { gap: .875rem; }
  .json-out, .json-tree { font-size: .75rem; }
}
