/* ── JSON Diff Checker — tool-specific styles ────────────────────────────────
   Global styles are inherited from /css/style.css.
   Colours reference CSS custom properties only — no hardcoded values, except
   the added/removed/changed swatches which reuse the same semantic RGBA
   values as diff-checker for visual consistency across the site.
   ─────────────────────────────────────────────────────────────────────────── */

.jd-shell {
  display: grid;
  gap: 1.5rem;
}

.jd-toolbar,
.jd-options,
.jd-results,
.jd-helper,
.jd-editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--tool-surface-radius, 12px);
}

.jd-editors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.jd-editor-card {
  padding: var(--tool-panel-padding-desktop, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.jd-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.jd-textarea {
  min-height: 320px;
  resize: vertical;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.jd-error {
  margin: 0;
  color: var(--color-danger, #c0392b);
  font-size: 0.85rem;
}

.jd-toolbar,
.jd-options,
.jd-results {
  padding: var(--tool-panel-padding-desktop, 1.5rem);
}

.jd-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.jd-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 1rem;
  border-radius: var(--tool-button-radius, 8px);
  border: 1px solid var(--border-color);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition), color var(--transition);
}

.jd-button:hover,
.jd-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.jd-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.jd-button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.jd-live {
  min-height: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 0.5rem;
}

.jd-options h2,
.jd-results-head h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.jd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
}

.jd-results-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.jd-summary {
  margin: 0.25rem 0 1.25rem;
}

.jd-stat-added strong { color: #166534; }
.jd-stat-removed strong { color: #b91c1c; }
.jd-stat-changed strong { color: #92400e; }

.jd-output {
  border: 1px solid var(--border-color);
  border-radius: var(--tool-input-radius, 8px);
  background: color-mix(in srgb, var(--bg-input) 88%, var(--color-surface));
  padding: 1rem;
  min-height: 160px;
  overflow: auto;
  max-height: 60vh;
}

.jd-output.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
}

.jd-row-list {
  display: grid;
  gap: 0.6rem;
}

.jd-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 8px;
}

.jd-row-icon {
  min-width: 1.3rem;
  font-weight: 700;
  font-family: Consolas, 'Courier New', monospace;
}

.jd-row.is-added {
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.1);
}

.jd-row.is-removed {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.1);
}

.jd-row.is-changed {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
}

.jd-row-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.jd-row-path {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.jd-row-values {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.jd-row-value {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.jd-row-value-tag {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-right: 0.4rem;
}

.jd-row.is-removed .jd-row-value,
.jd-row-value.is-old {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  color: #b91c1c;
}

.jd-row-value.is-new {
  color: #166534;
}

.jd-more-rows {
  margin: 0.75rem 0 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  text-align: center;
}

.jd-path-help {
  margin: 1rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.jd-helper {
  padding: var(--tool-panel-padding-desktop, 1.5rem);
  color: var(--text-secondary);
}

.jd-helper p {
  margin: 0;
}

@media (max-width: 860px) {
  .jd-editors {
    grid-template-columns: 1fr;
  }
  .jd-textarea {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .jd-toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .jd-button {
    width: 100%;
  }
  .jd-results-head {
    align-items: flex-start;
  }
}
