/* =========================================================================
 * JSON Formatter & Validator — styles. Follows the HEIC tool template:
 * sticky top bar, compact hero, tool on the first screen, privacy proof,
 * guide, FAQ, small footer. Accent: amber #d97706.
 * All motion disabled under prefers-reduced-motion.
 * ========================================================================= */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --ink: #0f1420;
  --ink-soft: #4b5573;
  --ink-faint: #8a93ad;
  --line: #e2e7f2;
  --brand: #d97706;
  --brand-2: #b45309;
  --brand-soft: #fdf3e3;
  --ok: #0f9d58;
  --ok-soft: #e5f6ec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --err: #dc2626;
  --err-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 20, 32, 0.08);
  --shadow-lg: 0 18px 50px rgba(217, 119, 6, 0.16);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  text-decoration: none; font-weight: 700; transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.05rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 8px 12px; border-radius: 10px; transition: background 0.18s, color 0.18s;
}
.nav a:hover, .nav a:focus-visible { background: var(--surface-2); color: var(--ink); outline: none; }

/* ---------------- hero ----------------
   Compact by design: one line of headline + one line of promise, so the
   formatter itself is on the first screen. */
.hero {
  padding: 16px 0 8px;
  background:
    radial-gradient(600px 300px at 15% 0%, rgba(217, 119, 6, 0.10), transparent 60%),
    radial-gradient(700px 320px at 90% 10%, rgba(180, 83, 9, 0.10), transparent 60%);
}
.hero h1 {
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 4px; max-width: none;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { font-size: 1rem; color: var(--ink-soft); max-width: none; margin: 0 0 8px; }
.trust-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.trust-row li {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(15, 20, 32, 0.05);
}
.trust-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ---------------- tool card ----------------
   Input and output sit side by side on desktop (input left, output
   right, same row); options are a horizontal bar above them. Single
   column on mobile, input first, output after. */
.tool-section { padding: 8px 0 32px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: clamp(18px, 3vw, 28px);
}
.panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.pane { min-width: 0; }
.step-title { font-weight: 800; margin: 0 0 10px; font-size: 1rem; }

/* settings */
.settings { border: 0; margin: 0 0 4px; padding: 0; }
.settings legend { font-weight: 800; margin-bottom: 10px; padding: 0; }
.setting-row { margin: 14px 0; }
.setting-row label { font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.setting-note { font-size: 0.85rem; color: var(--ink-soft); margin: 4px 0 0; }
.setting-label { font-weight: 700; display: block; margin-bottom: 8px; }
.check-line { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; cursor: pointer; margin: 10px 0; }
.check-line input { accent-color: var(--brand); margin-top: 3px; }
.select-input, .file-input-label {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 0.92rem; background: var(--surface); color: var(--ink);
}
.select-input:focus-visible { outline: 3px solid rgba(217, 119, 6, 0.35); outline-offset: 2px; }
.side-actions { display: grid; gap: 8px; margin-top: 14px; }
.side-actions .btn { width: 100%; }

/* options bar — horizontal strip above the two panes */
.settings.options-bar {
  background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin: 0 0 14px;
}
.options-controls { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center; }
.options-controls .setting-inline { display: flex; align-items: center; gap: 10px; }
.options-controls .setting-inline label { font-weight: 700; white-space: nowrap; }
.options-controls .select-input { width: auto; min-width: 140px; }
.options-controls .check-line { margin: 0; }
.options-controls .side-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.options-controls .side-actions .btn { width: auto; }
.options-notes { margin-top: 10px; }
.options-notes summary { font-weight: 700; font-size: 0.88rem; color: var(--ink-soft); cursor: pointer; }
.options-notes summary:focus-visible { outline: 3px solid rgba(217, 119, 6, 0.35); outline-offset: 2px; border-radius: 6px; }
.options-notes .setting-note { margin-top: 6px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 0.92rem; text-decoration: none;
  padding: 10px 18px; transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 18px rgba(217, 119, 6, 0.35); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-small { padding: 7px 13px; font-size: 0.85rem; border-radius: 10px; }
.btn:focus-visible { outline: 3px solid rgba(217, 119, 6, 0.4); outline-offset: 2px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar .sep { flex-basis: 8px; }

/* editor */
.editor-wrap {
  display: flex; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: #fffdf8;
}
.editor-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }
.line-numbers {
  flex: none; width: 46px; min-width: 0; padding: 12px 8px 12px 0;
  background: var(--surface-2); color: var(--ink-faint);
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.55;
  text-align: right; white-space: pre; overflow: hidden;
  border-right: 1px solid var(--line);
  user-select: none;
}
#json-input {
  flex: 1; min-width: 0; min-height: 340px; max-height: 520px;
  padding: 12px 14px; border: 0; outline: none; resize: vertical;
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.55;
  color: var(--ink); background: transparent; tab-size: 2;
  white-space: pre; overflow: auto;
}

/* status + stats */
.status-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 6px 13px; font-weight: 800; font-size: 0.88rem;
  background: var(--surface-2); color: var(--ink-soft);
}
.status-pill.valid { background: var(--ok-soft); color: var(--ok); }
.status-pill.invalid { background: var(--err-soft); color: var(--err); }
.stats-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.stat-chip {
  display: inline-block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
}

/* error panel */
.error-panel {
  margin-top: 12px; border: 1px solid #f3c1c1; border-radius: var(--radius);
  background: linear-gradient(180deg, #fdf4f4, #fff); padding: 14px 16px;
}
.error-panel[hidden] { display: none; }
.error-panel h3 { margin: 0 0 4px; color: var(--err); font-size: 0.98rem; }
.error-location { font-weight: 800; font-size: 0.88rem; color: var(--err); margin: 0 0 8px; }
.error-code {
  margin: 0; padding: 10px 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.55; white-space: pre;
}
.error-code .caret-line { color: var(--err); font-weight: 800; }
.error-hint { font-size: 0.9rem; color: var(--ink-soft); margin: 8px 0 0; }
.error-hint[hidden] { display: none; }
.error-actions { margin-top: 10px; }

/* notices */
.notice {
  margin-top: 12px; border-radius: 12px; padding: 10px 14px; font-size: 0.9rem;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #f3d9b8;
  overflow-wrap: anywhere;
}
.notice[hidden] { display: none; }
.repair-report {
  margin-top: 12px; border-radius: 12px; padding: 10px 14px; font-size: 0.9rem;
  background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe6cd;
}
.repair-report[hidden] { display: none; }

/* output */
.output-label { font-weight: 800; margin: 0 0 10px; font-size: 1rem; }
.output-empty {
  border: 1px dashed #c9cfe0; border-radius: var(--radius); padding: 22px;
  min-height: 340px; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--ink-faint); font-size: 0.92rem;
}
.output-empty[hidden] { display: none; }
.output-pre {
  margin: 0; padding: 14px 16px; min-height: 340px; max-height: 520px; overflow: auto;
  background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.55; white-space: pre;
}
.output-pre[hidden] { display: none; }
.output-pre code { font: inherit; overflow-wrap: normal; }
.tok-key { color: #92400e; font-weight: 700; }
.tok-str { color: #047857; }
.tok-num { color: #b45309; }
.tok-lit { color: #6d28d9; }
.output-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.output-actions[hidden] { display: none; }

/* privacy */
.privacy { padding: 8px 0 44px; }
.privacy-card {
  background: linear-gradient(135deg, #1a1408, #5c3a06);
  color: #fdf3e3; border-radius: 22px; padding: clamp(22px, 3vw, 36px);
  box-shadow: var(--shadow-lg);
}
.privacy-card h2 { color: #fff; margin: 0 0 10px; font-size: 1.4rem; }
.privacy-card p { margin: 0 0 16px; }
.net-meter {
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px; padding: 9px 16px; font-weight: 700; color: #fff;
}
.net-meter b { font-size: 1.15rem; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #34d399; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
}
.verify-steps { margin: 16px 0 0; padding-left: 20px; }
.verify-steps li { margin: 6px 0; }
kbd {
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px; padding: 1px 7px; font: inherit; font-size: 0.85em;
}
.tool-card kbd, .content kbd {
  background: var(--surface-2); border-color: var(--line); color: var(--ink);
}

/* content */
.content { padding: 20px 0 44px; }
.content h2 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 0 0 12px; }
.content h3 { font-size: 1.08rem; margin: 26px 0 8px; }
.content p, .content li { color: var(--ink-soft); }
.content ol, .content ul { padding-left: 22px; }
.content li { margin: 6px 0; }
.content pre {
  background: #fffdf8; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.85rem; line-height: 1.55; color: var(--ink);
}
.content pre code { font: inherit; }
.content code:not(pre code) {
  font-family: var(--mono); font-size: 0.88em; background: var(--surface-2);
  border-radius: 6px; padding: 1px 6px;
}
.prose-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.prose-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.prose-card h3 { margin: 0 0 6px; }
.prose-card p { margin: 0; font-size: 0.93rem; }

.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 18px; margin: 10px 0;
}
.faq summary { font-weight: 700; cursor: pointer; }
.faq summary:focus-visible { outline: 3px solid rgba(217, 119, 6, 0.35); outline-offset: 2px; border-radius: 6px; }
.faq details p { margin: 10px 0 2px; }

/* footer — one small, quiet line */
.site-footer { border-top: 1px solid var(--line); padding: 18px 0 26px; color: var(--ink-faint); font-size: 0.85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
.site-footer p { margin: 0; }
.site-footer .footer-note { color: var(--ink-faint); }
.site-footer a { color: var(--brand-2); }

/* responsive */
@media (max-width: 860px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .settings.options-bar { padding: 12px 14px; }
  .options-controls { gap: 10px 18px; }
}
@media (max-width: 640px) {
  .nav { display: none; }
  .hero { padding: 20px 0 8px; }
  .toolbar .btn { flex: 1 1 auto; }
  #json-input { min-height: 220px; }
  .output-pre, .output-empty { min-height: 220px; }
  .line-numbers { width: 38px; }
  .site-footer .wrap { flex-direction: column; gap: 2px; }
}

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