/* JSONOID — arcade-dark client-side JSON power station */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --space-gutter: clamp(16px, 4vw, 48px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(69, 240, 255, 0.05), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }
a { color: var(--cyan); }
code { color: var(--gold); font-family: var(--mono); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }
.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}
.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 3px 3px 0 var(--magenta);
}
.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

main {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px var(--space-gutter) 72px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-panel,
.query-panel,
.workspace,
.transform-panel,
.error-panel,
.transform-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.panel-head,
.toolbar,
.view-subbar,
.card-head,
.status-row,
.input-actions,
.mini-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(69, 240, 255, 0.4);
}
.danger { color: var(--red); text-shadow: 0 0 8px rgba(255, 85, 96, 0.4); }
.note,
.privacy-note,
.privacy-footer {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(65, 255, 139, 0.45);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: rgba(65, 255, 139, 0.08);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
}
.badge-gold {
  border-color: rgba(255, 200, 87, 0.5);
  background: rgba(255, 200, 87, 0.08);
  color: var(--gold);
}

.drop-zone {
  margin-top: 14px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, var(--surface-2), rgba(18, 18, 29, 0.35));
  transition: border-color 0.18s, box-shadow 0.18s;
}
.drop-zone.is-over {
  border-color: var(--cyan);
  box-shadow: 0 0 28px rgba(69, 240, 255, 0.12), inset 0 0 48px rgba(69, 240, 255, 0.04);
}

.field-label,
.indent-control {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
}

textarea,
input[type="text"],
select {
  width: 100%;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
}
textarea:hover,
input[type="text"]:hover,
select:hover { border-color: #5e5e80; }

#jsonInput {
  min-height: 280px;
  resize: vertical;
  tab-size: 2;
}
.input-actions { margin-top: 10px; justify-content: flex-start; }
.parse-status {
  margin: 0;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12.5px;
}

.btn,
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn:hover,
.tab:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:active,
.tab:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.btn-primary:hover { box-shadow: 0 0 18px rgba(69, 240, 255, 0.5); }
.btn-ghost { background: transparent; }

.error-panel { margin-top: 14px; border-left: 3px solid var(--red); }
.error-message { margin: 6px 0 0; color: var(--text); font-family: var(--mono); font-size: 13px; }
.error-line,
.error-caret,
.code-output {
  margin: 12px 0 0;
  overflow: auto;
  white-space: pre;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}
.error-caret { margin-top: 4px; color: var(--red); border-color: rgba(255, 85, 96, 0.35); }
.repair-list {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--dim);
  font-size: 12.5px;
}

.query-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.workspace { padding: 0; overflow: hidden; }
.toolbar {
  align-items: stretch;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  min-height: 38px;
  color: var(--dim);
  padding: 9px 11px;
  border-radius: 999px;
}
.tab.is-active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(69, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(69, 240, 255, 0.35);
}
.view-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.indent-control { flex-direction: row; align-items: center; margin: 0; }
.indent-control select { width: auto; min-height: 40px; }

.view-panel { padding: 16px; min-height: 260px; }
.view-subbar { margin-bottom: 12px; }
.tree-output {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 12.5px;
}
.tree-output ul {
  margin: 5px 0 5px 16px;
  padding: 0 0 0 12px;
  list-style: none;
  border-left: 1px solid var(--line);
}
.tree-output li { margin: 4px 0; }
.tree-output summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  cursor: pointer;
}
.node-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}
.node-key { color: var(--cyan); }
.node-meta { color: var(--gold); }
.node-string { color: var(--green); }
.node-number { color: var(--gold); }
.node-bool { color: var(--magenta); }
.node-null { color: var(--dim); }
.node-copy {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 10.5px;
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-family: var(--mono);
  font-size: 12px;
}
th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--cyan);
}
th button {
  width: 100%;
  min-height: 34px;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
td { color: var(--text); max-width: 260px; overflow-wrap: anywhere; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}
.stats-grid div {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.stats-grid dt {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
}
.stats-grid dd {
  margin: 4px 0 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.stringified-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 200, 87, 0.35);
  border-radius: 8px;
  background: rgba(255, 200, 87, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.transform-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}
.transform-card { padding: 14px; }
.transform-card .code-output { max-height: 360px; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer p { margin: 0; }
.site-footer p + p { margin-top: 6px; }
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-info { border-left-color: var(--cyan); }
.toast-success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

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

@media (min-width: 1024px) {
  .transform-grid { grid-template-columns: 1fr 1fr; }
  #jsonInput { min-height: 360px; }
}

@media (max-width: 480px) {
  .wordmark { letter-spacing: 1px; }
  .toolbar,
  .panel-head,
  .status-row { align-items: stretch; }
  .btn,
  .tab,
  .view-actions,
  .input-actions { width: 100%; }
  .btn,
  .tab { justify-content: center; }
  .indent-control { width: 100%; justify-content: space-between; }
}

@media (pointer: coarse) {
  .btn,
  .tab,
  input[type="text"],
  select { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor { animation: none; }
}
