/* ==========================================================================
   Easy JSON Formatter – shared base styles
   Design tokens, theme (light/dark), reset, top bar and footer.
   Used by every page.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:           #f5f6f8;
  --panel:        #ffffff;
  --surface:      #f0f2f5;
  --surface-2:    #e7eaee;
  --border:       #e1e4e9;
  --border-strong:#cfd4db;
  --text:         #15181d;
  --muted:        #5b6370;
  --faint:        #8a919c;

  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft:  #eef0ff;
  --on-accent:    #ffffff;

  --ok:           #15803d;
  --ok-soft:      #e7f6ec;
  --err:          #c62828;
  --err-soft:     #fdeced;
  --warn:         #b45309;
  --warn-soft:    #fff5e3;

  --key:          #1d5fbf;
  --str:          #0f7a3e;
  --num:          #b4530a;
  --bool:         #9333ea;
  --null:         #6b7280;
  --punct:        #7b8390;
  --guide:        #e6e9ee;
  --hit:          #fde68a;
  --hit-cur:      #f59e0b;
  --selected:     #eef0ff;

  --shadow-sm:    0 1px 2px rgba(16, 24, 40, .06);
  --shadow:       0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg:    0 12px 40px rgba(16, 24, 40, .18);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --topbar-h:  60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:           #0b0e13;
    --panel:        #11151c;
    --surface:      #171c24;
    --surface-2:    #1f2530;
    --border:       #242b36;
    --border-strong:#323b48;
    --text:         #e6e9ef;
    --muted:        #9aa3b0;
    --faint:        #6c7582;
    --accent:       #8b93ff;
    --accent-hover: #a5abff;
    --accent-soft:  rgba(139, 147, 255, .14);
    --on-accent:    #0b0e13;
    --ok:           #4ade80;
    --ok-soft:      rgba(74, 222, 128, .12);
    --err:          #f87171;
    --err-soft:     rgba(248, 113, 113, .12);
    --warn:         #fbbf24;
    --warn-soft:    rgba(251, 191, 36, .12);
    --key:          #7cc4fa;
    --str:          #a6e07a;
    --num:          #f7b267;
    --bool:         #d6a6ff;
    --null:         #9aa3b0;
    --punct:        #7d8796;
    --guide:        #222934;
    --hit:          rgba(250, 204, 21, .3);
    --hit-cur:      #ca8a04;
    --selected:     rgba(139, 147, 255, .12);
    --shadow-sm:    0 1px 2px rgba(0, 0, 0, .4);
    --shadow:       0 1px 3px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    --shadow-lg:    0 12px 40px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #0b0e13;
  --panel:        #11151c;
  --surface:      #171c24;
  --surface-2:    #1f2530;
  --border:       #242b36;
  --border-strong:#323b48;
  --text:         #e6e9ef;
  --muted:        #9aa3b0;
  --faint:        #6c7582;
  --accent:       #8b93ff;
  --accent-hover: #a5abff;
  --accent-soft:  rgba(139, 147, 255, .14);
  --on-accent:    #0b0e13;
  --ok:           #4ade80;
  --ok-soft:      rgba(74, 222, 128, .12);
  --err:          #f87171;
  --err-soft:     rgba(248, 113, 113, .12);
  --warn:         #fbbf24;
  --warn-soft:    rgba(251, 191, 36, .12);
  --key:          #7cc4fa;
  --str:          #a6e07a;
  --num:          #f7b267;
  --bool:         #d6a6ff;
  --null:         #9aa3b0;
  --punct:        #7d8796;
  --guide:        #222934;
  --hit:          rgba(250, 204, 21, .3);
  --hit-cur:      #ca8a04;
  --selected:     rgba(139, 147, 255, .12);
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .4);
  --shadow:       0 1px 3px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg:    0 12px 40px rgba(0, 0, 0, .6);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ── Icons (inline SVG sprite) ─────────────────────────────────────────── */
.i {
  width: 16px; height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── Accessibility helpers ─────────────────────────────────────────────── */
.visually-hidden {
  position: absolute !important;
  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: 12px; top: -60px;
  z-index: 300;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -.5px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), var(--shadow-sm);
}
.brand-text { min-width: 0; }
.brand-name {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-name .sub { font-weight: 500; color: var(--muted); }
.brand-tag {
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions { display: flex; align-items: center; gap: 4px; }

/* Shared ghost icon button */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn .i { width: 18px; height: 18px; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .i { width: 16px; height: 16px; }

/* Theme toggle shows the icon for the theme you'd switch to */
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: .88rem;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand .brand-mark { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; }
.footer-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover { color: var(--text); text-decoration: underline; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 400;
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: #15181d;
  color: #fff;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
:root[data-theme="dark"] .toast { background: #e6e9ef; color: #0b0e13; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: #e6e9ef; color: #0b0e13; }
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 12px; }
  .brand-tag { display: none; }
  .brand-name .sub { display: none; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Keep anchor targets clear of the sticky top bar */
[id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }

/* ── Footer with tool columns ─────────────────────────────────────────── */
.footer-cols {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 8px;
  display: grid;
  grid-template-columns: 1.3fr repeat(3, 1fr);
  gap: 28px;
}
.footer-cols h2 {
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}
.footer-cols ul { list-style: none; display: grid; gap: 6px; }
.footer-cols a { color: var(--muted); text-decoration: none; font-size: .86rem; }
.footer-cols a:hover { color: var(--text); text-decoration: underline; }
.footer-about p { margin-top: 10px; font-size: .86rem; line-height: 1.6; max-width: 300px; }
.footer-about .footer-brand { font-weight: 650; color: var(--text); }
.footer-bottom { border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-about { grid-column: 1 / -1; }
}
.footer-about .footer-brand { text-decoration: none; }
.footer-about .footer-brand .brand-mark { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; }
