/* Public JSON Reader tool (/json-reader).
 *
 * Built on theme-dark.css and auth.css (aurora backdrop, turning card edge,
 * gold button, ghost buttons, --auth-* tokens), like the other apps; this
 * file adds the hero, the tool card (toolbar, input and output panels, error
 * card, coloured code, tree) and the content sections.
 *
 * Layout, mobile first: heading and intro, then the tool card, then the
 * content. Inside the card the input and output panels are stacked, and sit
 * side by side from 1024px. Only the editors scroll sideways, never the page.
 *
 * Motion (transform and opacity only, nothing under prefers-reduced-motion):
 * floating braces and a pulsing node graph in the hero, a sliding bar while
 * working, and the scroll reveal of the content (start states only after
 * main.js marks <html> with `jr-reveal`). The heading and intro never animate.
 */

.jr-body {
  --jr-max: clamp(64rem, 50rem + 24vw, 92rem);
  --jr-surface: rgba(17, 18, 24, 0.82);
  --jr-raised: rgba(255, 255, 255, 0.035);
  --jr-code-bg: #0c0d12;
  --jr-accent: #a98bff;
  --jr-touch: 44px;
  /* The editors fill most of the screen height, so the JSON reads without
     scrolling inside a small box. */
  --jr-editor-height: clamp(24rem, 100vh - 15rem, 70rem);
  --jr-code-size: clamp(0.78rem, 0.74rem + 0.15vw, 0.875rem);
  --jr-code-line: 1.6em;

  /* Syntax colours: every one reads at 7:1 or better on --jr-code-bg. */
  --jr-tok-key: #8fc1ff;
  --jr-tok-string: #7fe0a6;
  --jr-tok-number: #ffbf73;
  --jr-tok-boolean: #d3a8ff;
  --jr-tok-null: #ff9fb3;
  --jr-tok-punct: #a6a8b6;
}

.jr-body .auth-card__glow {
  animation-duration: 14s;
}

.jr-main {
  display: block;
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
  overflow-x: clip;
}

.jr-container {
  width: 100%;
  max-width: calc(var(--jr-max) + 2 * var(--site-header-gutter));
  margin-inline: auto;
  padding-inline: var(--site-header-gutter);
}

/* ----------------------------------------------------------------- Hero */

.jr-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  gap: clamp(1.5rem, 1rem + 2vw, 2.75rem);
  padding-block: clamp(1.5rem, 1rem + 3vw, 4rem) clamp(2rem, 1.5rem + 3vw, 4.5rem);
  overflow: hidden;
  overflow: clip;
}

.jr-hero__copy {
  display: grid;
  justify-items: start;
  gap: clamp(0.8rem, 0.6rem + 0.6vw, 1.3rem);
  min-width: 0;
}

.jr-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

.jr-breadcrumb__list li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--auth-line-strong);
}

.jr-breadcrumb__list a {
  color: var(--auth-muted);
  text-decoration: none;
}

.jr-breadcrumb__list a:hover {
  color: var(--auth-gold);
}

.jr-hero__title {
  font-family: var(--font-brand);
  font-size: clamp(2.4rem, 1.4rem + 3.6vw, 4.6rem);
  font-weight: var(--font-weight-brand);
  line-height: 1.02;
  letter-spacing: -0.035em;
  background: linear-gradient(100deg, var(--auth-text) 25%, var(--auth-gold-strong) 70%, var(--jr-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.jr-hero__lead {
  max-width: 44em;
  color: var(--auth-muted);
  font-size: clamp(1rem, 0.92rem + 0.35vw, 1.2rem);
  line-height: 1.65;
}

.jr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.jr-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--jr-raised);
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-medium);
}

.jr-chip__icon {
  width: 1rem;
  height: 1rem;
  color: var(--auth-gold);
}

/* Decorative motif: braces and a small node graph, top right. */
.jr-motif {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.jr-motif__brace {
  position: absolute;
  color: rgba(235, 196, 42, 0.16);
  font-family: var(--font-mono);
  font-size: clamp(6rem, 4rem + 9vw, 13rem);
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

.jr-motif__brace--open {
  top: 2%;
  right: clamp(8rem, 4rem + 16vw, 24rem);
  transform: rotate(-8deg);
}

.jr-motif__brace--close {
  top: 10%;
  right: 2%;
  color: rgba(169, 139, 255, 0.16);
  transform: rotate(8deg);
}

.jr-motif__graph {
  position: absolute;
  top: clamp(2.5rem, 1rem + 4vw, 5rem);
  right: clamp(3rem, 1rem + 8vw, 13rem);
  width: clamp(9rem, 6rem + 10vw, 17rem);
  height: auto;
  overflow: visible;
  opacity: 0.75;
}

.jr-motif__edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.5;
}

.jr-motif__node {
  fill: var(--auth-card-solid);
  stroke: var(--auth-gold);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
}

.jr-motif__node--b,
.jr-motif__node--d {
  stroke: var(--jr-accent);
}

/* Phones and tablets: the motif steps back behind the heading. */
@media (max-width: 1023.98px) {
  .jr-motif__graph,
  .jr-motif__brace--open {
    display: none;
  }

  .jr-motif__brace--close {
    top: 0;
    right: -1rem;
    font-size: 7rem;
  }
}

/* ------------------------------------------------------------ Tool card */

.jr-card {
  position: relative;
  min-width: 0;
  padding: 1px;
  /* clip, not hidden: a hidden box is still a scroll container, and "Go to
     error" (scrollIntoView) would scroll the oversized edge light into view. */
  overflow: hidden;
  overflow: clip;
  border-radius: var(--auth-radius);
  background: var(--auth-line);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.jr-card__body {
  position: relative;
  display: grid;
  gap: clamp(0.9rem, 0.7rem + 0.6vw, 1.25rem);
  padding: clamp(0.9rem, 0.6rem + 1.4vw, 2rem);
  border-radius: calc(var(--auth-radius) - 1px);
  background-color: var(--auth-card-solid);
}

.jr-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.25rem;
}

.jr-card__title {
  font-family: var(--font-brand);
  font-size: clamp(1.25rem, 1.05rem + 0.7vw, 1.65rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
}

.jr-card__privacy {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.45rem;
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.jr-card__privacy-icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  color: var(--auth-success);
}

/* Toolbar: Format, Minify, indent, sort keys. */
.jr-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.jr-format {
  width: auto;
  min-height: 48px;
  padding-inline: 1.4rem;
}

.jr-kbd {
  padding: 0.1rem 0.45rem;
  border: 1px solid rgba(28, 28, 28, 0.35);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  opacity: 0.75;
}

@media (hover: none) and (pointer: coarse) {
  .jr-kbd {
    display: none;
  }
}

.jr-button {
  justify-content: center;
  white-space: nowrap;
}

.jr-button[hidden] {
  display: none;
}

.jr-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--jr-touch);
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
}

.jr-select__control {
  min-height: var(--jr-touch);
  padding: 0 2rem 0 0.85rem;
  border: 1px solid var(--auth-line-strong);
  border-radius: 999px;
  background-color: var(--auth-field);
  background-image: linear-gradient(45deg, transparent 50%, var(--auth-muted) 50%),
    linear-gradient(135deg, var(--auth-muted) 50%, transparent 50%);
  background-position: calc(100% - 1rem) 50%, calc(100% - 0.7rem) 50%;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
  color: var(--auth-text);
  font: inherit;
  appearance: none;
  cursor: pointer;
}

.jr-select__control option {
  background-color: var(--auth-card-solid);
  color: var(--auth-text);
}

.jr-select__control:disabled,
.jr-check__input:disabled + .jr-check__box {
  opacity: 0.5;
  cursor: not-allowed;
}

.jr-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--jr-touch);
  padding-inline: 0.25rem;
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.jr-check__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.jr-check__box {
  display: inline-grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid var(--auth-line-strong);
  border-radius: 6px;
  background-color: var(--auth-field);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.jr-check__icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--color-brand-contrast);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.jr-check__input:checked + .jr-check__box {
  border-color: var(--auth-gold);
  background-color: var(--auth-gold);
}

.jr-check__input:checked + .jr-check__box .jr-check__icon {
  opacity: 1;
  transform: scale(1);
}

.jr-check__input:focus-visible + .jr-check__box,
.jr-select__control:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 3px;
}

/* ------------------------------------------------------------- Panels */

.jr-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 0.8rem + 0.8vw, 1.5rem);
}

@media (min-width: 1024px) {
  .jr-workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

.jr-panel {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
}

.jr-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  min-height: var(--jr-touch);
}

.jr-panel__label {
  color: var(--auth-text);
  font-size: var(--auth-fs-body);
  font-weight: var(--font-weight-semibold);
}

.jr-counter {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
}

.jr-counter.is-over {
  color: var(--auth-error);
  font-weight: var(--font-weight-semibold);
}

.jr-panel__tools,
.jr-panel__actions,
.jr-tree-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The file input is visually hidden inside its button-like label, still focusable. */
.jr-file {
  position: relative;
}

.jr-file__input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.jr-file:focus-within {
  outline: 2px solid var(--auth-gold);
  outline-offset: 3px;
}

.jr-file:has(.jr-file__input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.jr-editor {
  position: relative;
}

.jr-input,
.jr-view {
  width: 100%;
  height: var(--jr-editor-height);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--jr-code-bg);
  color: var(--auth-text);
  font-family: var(--font-mono);
  font-size: var(--jr-code-size);
  line-height: var(--jr-code-line);
  tab-size: 4;
}

.jr-input {
  display: block;
  padding: 0.75rem 0.9rem;
  overflow: auto;
  white-space: pre;
  overflow-wrap: normal;
  resize: vertical;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.jr-input::placeholder {
  color: var(--auth-subtle);
}

.is-wrapped .jr-input {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jr-input:focus {
  outline: none;
  border-color: var(--auth-gold);
  box-shadow: 0 0 0 4px var(--auth-gold-soft);
}

.jr-input[aria-invalid="true"] {
  border-color: rgba(255, 138, 138, 0.6);
}

.jr-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 4px var(--auth-error-soft);
}

/* Drag and drop: a dashed frame and a label over the box. */
.jr-drop-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6rem;
  border: 2px dashed var(--auth-gold);
  border-radius: var(--auth-radius-sm);
  background-color: rgba(12, 13, 18, 0.88);
  color: var(--auth-gold);
  font-weight: var(--font-weight-semibold);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.jr-drop-overlay__icon {
  width: 2.25rem;
  height: 2.25rem;
}

.is-dragging .jr-drop-overlay {
  opacity: 1;
}

.jr-hint {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.jr-file-message {
  color: var(--auth-error);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-medium);
}

.jr-file-message[hidden] {
  display: none;
}

/* Output tabs. */
.jr-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--jr-raised);
}

.jr-tab {
  min-width: 6.5rem;
  min-height: var(--jr-touch);
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--auth-muted);
  font: inherit;
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.jr-tab:hover {
  color: var(--auth-text);
}

.jr-tab[aria-selected="true"] {
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
  box-shadow: inset 0 0 0 1px rgba(235, 196, 42, 0.45);
}

.jr-tab:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.jr-copy.is-done {
  border-color: var(--auth-success);
  color: var(--auth-success);
}

/* Status line. */
.jr-status {
  position: relative;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  min-height: 1.6rem;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.5;
}

.jr-status__dot {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background-color: var(--auth-subtle);
  transform: translateY(-0.05rem);
}

.jr-status__text {
  color: var(--auth-text);
  font-weight: var(--font-weight-semibold);
}

.jr-status__stats {
  min-width: 0;
  color: var(--auth-subtle);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.jr-status.is-valid .jr-status__dot {
  background-color: var(--auth-success);
  box-shadow: 0 0 0 4px rgba(94, 224, 160, 0.16);
}

.jr-status.is-valid .jr-status__text {
  color: var(--auth-success);
}

.jr-status.is-invalid .jr-status__dot {
  background-color: var(--auth-error);
  box-shadow: 0 0 0 4px var(--auth-error-soft);
}

.jr-status.is-invalid .jr-status__text {
  color: var(--auth-error);
}

.jr-status.is-busy .jr-status__dot {
  background-color: var(--auth-gold);
}

/* A light slides along the top of the output while the worker is busy. */
.jr-panel--output {
  position: relative;
}

.jr-panel--output::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, transparent, var(--auth-gold), var(--jr-accent), transparent);
  opacity: 0;
  transform: scaleX(0.2);
  transition: opacity var(--transition-normal);
}

.is-busy .jr-panel--output::before {
  opacity: 1;
}

/* Error card. */
.jr-error,
.jr-fixed {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 138, 138, 0.38);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-error-soft);
}

.jr-error[hidden],
.jr-fixed[hidden],
.jr-warnings[hidden],
.jr-note[hidden],
.jr-snippet[hidden],
.jr-error__where[hidden],
.jr-tabpanel[hidden],
.jr-empty[hidden],
.jr-code[hidden],
.jr-context[hidden] {
  display: none;
}

.jr-error__icon,
.jr-fixed__icon {
  width: 1.3rem;
  height: 1.3rem;
  margin-top: 0.1rem;
  color: var(--auth-error);
}

.jr-error__body {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.jr-error__message {
  color: var(--auth-text);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.jr-error__where {
  color: var(--auth-error);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
}

.jr-snippet {
  margin: 0;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  border-radius: var(--radius-md);
  background-color: var(--jr-code-bg);
  color: var(--auth-text);
  font-family: var(--font-mono);
  font-size: var(--jr-code-size);
  line-height: 1.55;
  white-space: pre;
}

.jr-snippet__gutter {
  color: var(--auth-subtle);
}

.jr-snippet__caret {
  color: var(--auth-error);
  font-weight: var(--font-weight-bold);
}

.jr-error__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.jr-fix {
  border-color: var(--auth-gold);
  color: var(--auth-gold);
}

/* "Fixed: ..." with Undo. */
.jr-fixed {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  border-color: rgba(94, 224, 160, 0.38);
  background-color: rgba(94, 224, 160, 0.1);
}

.jr-fixed__icon {
  margin-top: 0;
  color: var(--auth-success);
}

.jr-fixed__text {
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
}

@media (max-width: 479.98px) {
  .jr-fixed {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .jr-fixed .jr-button {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------- Output view */

.jr-tabpanel {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.jr-view {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
}

.jr-view:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.jr-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  min-height: 100%;
  padding: 1.5rem;
  color: var(--auth-muted);
  font-family: var(--font-sans);
  text-align: center;
}

.jr-empty__braces {
  color: rgba(235, 196, 42, 0.5);
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.2em;
}

.jr-empty__text {
  max-width: 28em;
  font-size: var(--auth-fs-small);
  line-height: 1.6;
}

/* Formatted result: one row per line. The number is a CSS counter in
   ::before (never selected or copied), pinned on the left while the code
   scrolls sideways; with "Wrap long lines" a long line continues on the next
   rows, beside its own number. */
.jr-code {
  min-height: 100%;
}

.jr-lines {
  --jr-digits: 2;
  min-width: max-content;
  padding-block: 0.75rem;
  color: var(--jr-tok-punct);
  counter-reset: jr-line;
}

.jr-ln {
  display: flex;
  min-height: var(--jr-code-line);
  counter-increment: jr-line;
}

.jr-ln::before {
  content: counter(jr-line);
  position: sticky;
  left: 0;
  z-index: 1;
  flex: 0 0 auto;
  width: calc(var(--jr-digits) * 1ch + 1.35rem);
  padding-inline: 0.75rem 0.6rem;
  border-right: 1px solid var(--auth-line);
  background-color: var(--jr-code-bg);
  color: #6e7180;
  text-align: right;
  user-select: none;
}

.jr-ln__text {
  flex: 1 1 auto;
  min-width: 0;
  padding-inline: 0.9rem 1.5rem;
  white-space: pre;
}

.is-wrapped .jr-lines {
  min-width: 0;
}

.is-wrapped .jr-ln__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jr-code__gutter,
.jr-code__text {
  margin: 0;
  padding-block: 0.75rem;
  font: inherit;
  line-height: inherit;
  white-space: pre;
}

.jr-code__gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-inline: 0.75rem 0.6rem;
  border-right: 1px solid var(--auth-line);
  background-color: var(--jr-code-bg);
  color: #6e7180;
  text-align: right;
  user-select: none;
}

.jr-code__text {
  padding-inline: 0.9rem 1.5rem;
  color: var(--jr-tok-punct);
}

/* Large results: a spacer for the scroll height and a window of lines. */
.jr-virtual {
  position: relative;
  min-width: max-content;
}

.jr-virtual[hidden] {
  display: none;
}

.jr-virtual__window {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 100%;
  will-change: transform;
}

.jr-virtual__window .jr-code__gutter,
.jr-virtual__window .jr-code__text {
  padding-block: 0;
}

.jr-virtual__text {
  color: var(--auth-text);
}

.jr-tok--key { color: var(--jr-tok-key); }
.jr-tok--string { color: var(--jr-tok-string); }
.jr-tok--number { color: var(--jr-tok-number); }
.jr-tok--boolean { color: var(--jr-tok-boolean); font-weight: var(--font-weight-semibold); }
.jr-tok--null { color: var(--jr-tok-null); font-style: italic; }

/* Error context: the visitor's input around the error. */
.jr-context {
  min-width: max-content;
  padding-block: 0.6rem;
}

.jr-context__line {
  display: grid;
  grid-template-columns: 4.5rem auto;
  white-space: pre;
}

.is-wrapped .jr-context {
  min-width: 0;
}

.is-wrapped .jr-context__line {
  grid-template-columns: 4.5rem minmax(0, 1fr);
}

.is-wrapped .jr-context__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jr-context__number {
  position: sticky;
  left: 0;
  padding-right: 0.75rem;
  border-right: 1px solid var(--auth-line);
  background-color: var(--jr-code-bg);
  color: #6e7180;
  text-align: right;
  user-select: none;
}

.jr-context__text {
  padding-inline: 0.9rem 1.5rem;
  color: var(--auth-muted);
}

.jr-context__line.is-error {
  background-color: rgba(255, 128, 128, 0.14);
  box-shadow: inset 3px 0 0 var(--auth-error);
}

.jr-context__line.is-error .jr-context__number {
  background-color: #2a1517;
  color: var(--auth-error);
  font-weight: var(--font-weight-bold);
}

.jr-context__line.is-error .jr-context__text {
  color: var(--auth-text);
}

.jr-context__more {
  position: sticky;
  left: 0;
  padding: 0.35rem 0.9rem;
  color: var(--auth-subtle);
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
}

.jr-note {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

/* ---------------------------------------------------------------- Tree */

.jr-tree {
  padding: 0.5rem 0.4rem;
  font-family: var(--font-mono);
}

.jr-tree__list,
.jr-node__children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.jr-node__children {
  margin-left: 0.95rem;
  padding-left: 0.65rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.12);
}

.jr-node__children[hidden] {
  display: none;
}

.jr-tree__empty {
  padding: 1rem;
  color: var(--auth-muted);
  font-family: var(--font-sans);
  font-size: var(--auth-fs-small);
}

.jr-node__row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
  min-width: 100%;
  min-height: 2.25rem;
  padding: 0.2rem 0.6rem 0.2rem 0.35rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--jr-tok-punct);
  font: inherit;
  text-align: left;
  white-space: pre;
  cursor: default;
}

.jr-node__toggle {
  cursor: pointer;
}

/* Wrapped: a long value continues under its key instead of running off to the right. */
.is-wrapped .jr-node__row {
  flex-wrap: wrap;
  width: auto;
}

.is-wrapped .jr-node__value {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.jr-node__toggle[aria-disabled="true"] {
  cursor: default;
}

.jr-node__row:hover {
  background-color: rgba(255, 255, 255, 0.045);
}

.jr-node__row:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: -2px;
  background-color: rgba(235, 196, 42, 0.08);
}

/* Coarse pointers get full-size touch targets. */
@media (pointer: coarse) {
  .jr-node__row {
    min-height: var(--jr-touch);
  }
}

.jr-node__chevron {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin-inline: 0.2rem 0.25rem;
  border-right: 2px solid var(--auth-muted);
  border-bottom: 2px solid var(--auth-muted);
  transform: rotate(-45deg);
  transition: transform var(--transition-normal);
}

.jr-node__toggle[aria-expanded="true"] .jr-node__chevron {
  transform: rotate(45deg);
}

.jr-node__toggle[aria-disabled="true"] .jr-node__chevron {
  opacity: 0.3;
}

.jr-node--leaf .jr-node__row {
  padding-left: 1.45rem;
}

.jr-node__key {
  color: var(--jr-tok-key);
}

.jr-node__index {
  color: var(--auth-subtle);
}

.jr-node__type {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  color: var(--auth-subtle);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.02em;
}

.jr-node__count {
  color: var(--auth-muted);
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
}

.jr-node__more {
  color: var(--auth-gold);
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.jr-collapse-icon {
  transform: rotate(180deg);
}

/* Warnings (valid JSON). */
.jr-warnings {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(240, 168, 60, 0.4);
  border-radius: var(--auth-radius-sm);
  background-color: rgba(240, 168, 60, 0.1);
  font-size: var(--auth-fs-small);
}

.jr-warnings__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  color: #f5bd68;
  font-weight: var(--font-weight-semibold);
}

.jr-warnings__icon {
  width: 1.1rem;
  height: 1.1rem;
}

.jr-warnings__fine {
  color: var(--auth-muted);
  font-weight: var(--font-weight-normal);
}

.jr-warnings__list {
  display: grid;
  gap: 0.25rem;
  max-height: 10rem;
  margin: 0;
  padding: 0 0 0 1.1rem;
  overflow: auto;
  color: var(--auth-text);
  overflow-wrap: anywhere;
}

.jr-warnings__where {
  color: #f5bd68;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- Content */

.jr-content {
  display: grid;
  gap: clamp(2rem, 1.5rem + 2vw, 3.5rem);
}

.jr-section {
  max-width: 60rem;
  color: var(--auth-muted);
  line-height: 1.7;
}

.jr-section > p + * {
  margin-top: 1rem;
}

.jr-section__title {
  margin-bottom: 0.75rem;
  color: var(--auth-text);
  font-family: var(--font-brand);
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 2.1rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.jr-how {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .jr-how {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .jr-section:has(.jr-how) {
    max-width: none;
  }

  .jr-how {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.jr-how__step,
.jr-errors__item,
.jr-faq__item {
  position: relative;
  padding: clamp(1rem, 0.85rem + 0.6vw, 1.5rem);
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--jr-surface);
  font-size: var(--auth-fs-small);
}

.jr-how__step {
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.jr-how__number {
  position: absolute;
  top: 0.4rem;
  right: 0.9rem;
  color: rgba(255, 255, 255, 0.07);
  font-family: var(--font-brand);
  font-size: 3rem;
  line-height: 1;
}

.jr-how__title,
.jr-errors__title {
  color: var(--auth-text);
  font-size: 1.05rem;
  font-weight: var(--font-weight-semibold);
}

.jr-section:has(.jr-errors) {
  max-width: none;
}

.jr-errors {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
}

@media (min-width: 760px) {
  .jr-errors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .jr-errors {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.jr-errors__item {
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.jr-compare {
  display: grid;
  gap: 0.4rem;
  margin: 0.25rem 0 0;
}

.jr-compare__row {
  display: grid;
  gap: 0.2rem;
}

.jr-compare dt {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.jr-compare__row--wrong dt {
  color: var(--auth-error);
}

.jr-compare__row--right dt {
  color: var(--auth-success);
}

.jr-compare dd {
  margin: 0;
}

.jr-compare code {
  display: block;
  padding: 0.45rem 0.65rem;
  overflow-x: auto;
  border-radius: var(--radius-md);
  background-color: var(--jr-code-bg);
  color: var(--auth-text);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  white-space: pre;
}

.jr-section--privacy {
  padding: clamp(1.1rem, 0.9rem + 1vw, 1.75rem);
  border: 1px solid rgba(94, 224, 160, 0.25);
  border-radius: var(--auth-radius-sm);
  background: linear-gradient(135deg, rgba(94, 224, 160, 0.08), rgba(255, 255, 255, 0.02));
}

.jr-faq {
  max-width: none;
}

.jr-faq__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
}

@media (min-width: 900px) {
  .jr-faq__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.jr-faq__question {
  margin-bottom: 0.4rem;
  color: var(--auth-text);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  font-weight: var(--font-weight-semibold);
}

.jr-contact {
  margin-top: 1rem;
  font-size: var(--auth-fs-small);
}

.jr-contact a {
  color: var(--auth-gold);
}

/* --------------------------------------------------------------- Phones */

@media (max-width: 479.98px) {
  .jr-toolbar .jr-format {
    flex: 1 1 100%;
  }

  .jr-toolbar .jr-button {
    flex: 1 1 auto;
  }

  .jr-panel__tools .jr-button,
  .jr-panel__actions .jr-button,
  .jr-tree-tools .jr-button {
    flex: 1 1 auto;
  }

  .jr-tabs {
    width: 100%;
  }

  .jr-tab {
    flex: 1 1 0;
    min-width: 0;
  }

  .jr-panel__actions {
    width: 100%;
  }
}

/* --------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: no-preference) {
  .jr-motif__brace--open {
    animation: jr-float-open 10s ease-in-out infinite alternate;
  }

  .jr-motif__brace--close {
    animation: jr-float-close 12s ease-in-out infinite alternate;
  }

  .jr-motif__graph {
    animation: jr-drift 14s ease-in-out infinite alternate;
  }

  .jr-motif__node {
    animation: jr-pulse 3.2s ease-in-out infinite;
  }

  .jr-motif__node--a { animation-delay: 0.4s; }
  .jr-motif__node--b { animation-delay: 0.8s; }
  .jr-motif__node--c { animation-delay: 1.2s; }
  .jr-motif__node--d { animation-delay: 1.6s; }

  .jr-hero.is-offscreen .jr-motif__brace,
  .jr-hero.is-offscreen .jr-motif__graph,
  .jr-hero.is-offscreen .jr-motif__node {
    animation-play-state: paused;
  }

  .is-busy .jr-panel--output::before {
    animation: jr-slide 1.2s ease-in-out infinite;
  }

  .jr-error:not([hidden]),
  .jr-fixed:not([hidden]),
  .jr-warnings:not([hidden]) {
    animation: jr-appear 260ms var(--auth-ease) both;
  }

  .jr-how__step,
  .jr-errors__item,
  .jr-faq__item {
    transition: transform var(--transition-normal), border-color var(--transition-normal);
  }

  .jr-how__step:hover,
  .jr-errors__item:hover,
  .jr-faq__item:hover {
    transform: translateY(-2px);
    border-color: var(--auth-line-strong);
  }

  .jr-reveal [data-reveal] {
    transition: opacity 650ms var(--auth-ease), transform 650ms var(--auth-ease);
  }

  .jr-reveal [data-reveal]:not(.is-revealed) {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-aurora,
  .auth-card__glow {
    animation: none;
  }

  .jr-node__chevron,
  .jr-check__icon,
  .jr-drop-overlay {
    transition: none;
  }
}

@keyframes jr-float-open {
  from { transform: rotate(-8deg) translate3d(0, 0, 0); }
  to { transform: rotate(-4deg) translate3d(0, -16px, 0); }
}

@keyframes jr-float-close {
  from { transform: rotate(8deg) translate3d(0, 0, 0); }
  to { transform: rotate(4deg) translate3d(0, 14px, 0); }
}

@keyframes jr-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-10px, 12px, 0); }
}

@keyframes jr-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}

@keyframes jr-slide {
  from { transform: translateX(-60%) scaleX(0.3); }
  to { transform: translateX(60%) scaleX(0.3); }
}

@keyframes jr-appear {
  from { opacity: 0; transform: translate3d(0, -4px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
