/* =========================================================
   JSONViewerTool.com – Production Theme Tokens (v1)
   - Dark mode default
   - Light mode via body.light-mode, html.light-mode (also sets [data-theme="light"] if used)
   ========================================================= */

/* ---- Base tokens (DARK) ---- */
:root {
  --bg-page: #0b1220;
  --bg-surface: #0f172a;
  --bg-surface-2: #111c33;
  --bg-elevated: rgba(255,255,255,0.04);
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #94a3b8;
  --border: #1f2937;
  --border-2: #243148;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --link: #60a5fa;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* ---- Light mode tokens ---- */
body.light-mode, html.light-mode,
[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-2: #ffffff;
  --bg-elevated: rgba(2,6,23,0.04);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-2: #e5e7eb;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --link: #2563eb;
  --shadow: 0 10px 30px rgba(2,6,23,0.08);
}

/* ---- Page background + global text ---- */
html, body {
  background: var(--bg-page);
  color: var(--text-primary);
}

a { color: var(--link); }
a:hover { color: var(--accent-2); }

/* ---- Header / Sidebar text and surfaces ---- */
.header, .site-header, #app-header-root, .top-header {
  color: var(--text-primary);
}

.header a, .site-header a, #app-header-root a, .top-header a,
.brand-title, .brand-sub, .logo-text {
  color: var(--text-primary) !important;
}

.sidebar, .sidebar-inner, .sidebar-container {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-right: 1px solid var(--border);
}

.sidebar a, .sidebar .sidebar-link, .sidebar .nav-item, .sidebar .section-title {
  color: var(--text-primary) !important;
}

.sidebar .sidebar-link-active,
.sidebar a.active,
.sidebar .active > a {
  background: rgba(37, 99, 235, 0.10) !important;
  color: var(--accent) !important;
  border-left: 3px solid var(--accent) !important;
}

/* ---- Cards / panels ---- */
.tool-card, .card, .panel, .content-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* ---- Blog index cards ---- */
.blog-card {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
}
.blog-card h2 a, .blog-card h2, .blog-hero h1, .blog-hero h2 {
  color: var(--text-primary) !important;
}
.blog-card p, .blog-hero p, .blog-breadcrumb {
  color: var(--text-secondary) !important;
}

/* ---- Blog post (article) page ---- */
body.light-mode, html.light-mode main.article,
body.light-mode, html.light-mode main.article > article,
body.light-mode, html.light-mode main.article article {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}
body.light-mode, html.light-mode main.article h1,
body.light-mode, html.light-mode main.article h2,
body.light-mode, html.light-mode main.article h3,
body.light-mode, html.light-mode main.article h4 {
  color: var(--text-primary) !important;
}
body.light-mode, html.light-mode main.article p,
body.light-mode, html.light-mode main.article li,
body.light-mode, html.light-mode main.article .hero-sub,
body.light-mode, html.light-mode main.article .article-meta {
  color: var(--text-secondary) !important;
  opacity: 1 !important;
}
body.light-mode, html.light-mode main.article pre,
body.light-mode, html.light-mode main.article code {
  background: #f8fafc !important;
  color: #0f172a !important;
  border: 1px solid var(--border) !important;
}

/* ---- Stats bar (Left/Right Chars/Size/Lines/Nodes) ---- */
/* The stats UI is generated in js/editor-stats.js using .editor-stats + .stats-pill + span[data-k] */
.editor-stats {
  background: #020617;
  border: 1px solid #1e293b;
}
body.light-mode, html.light-mode .editor-stats {
  background: #0b1220 !important; /* keep nice dark bar even in light mode */
  border-color: #1f2937 !important;
}
body.light-mode, html.light-mode .editor-stats,
body.light-mode, html.light-mode .editor-stats * {
  color: #e5e7eb !important;
  opacity: 1 !important;
}
body.light-mode, html.light-mode .editor-stats .stats-pill b {
  color: #cbd5e1 !important;
}
body.light-mode, html.light-mode .editor-stats .stats-pill span[data-k] {
  color: #e5e7eb !important;
  font-weight: 600 !important;
}
body.light-mode, html.light-mode .editor-stats .stats-copy {
  color: #e5e7eb !important;
}

/* ---- Buttons ---- */
button, .btn, .nav-btn {
  color: inherit;
}
body.light-mode, html.light-mode .nav-btn {
  background: rgba(2,6,23,0.06);
  border: 1px solid var(--border);
  color: var(--text-primary) !important;
}

/* ---- ACE editor light-mode readability ---- */
body.light-mode, html.light-mode .ace_gutter {
  background: #f1f5f9 !important;
  color: #475569 !important;
}
body.light-mode, html.light-mode .ace_active-line {
  background: #e0f2fe !important;
}
body.light-mode, html.light-mode .ace_gutter-active-line {
  background: #e0f2fe !important;
}


/* =========================================================
   Light mode: dark cards on homepage/blog – ensure readable text
   (Some sections keep dark background even in light mode)
   ========================================================= */
body.light-mode, html.light-mode .info-card,
body.light-mode, html.light-mode .home-blog-card {
  color: #e5e7eb !important;
}

body.light-mode, html.light-mode .info-card h2,
body.light-mode, html.light-mode .info-card h3,
body.light-mode, html.light-mode .home-blog-card h3,
body.light-mode, html.light-mode .home-blog-card h4 {
  color: #f8fafc !important;
}

body.light-mode, html.light-mode .info-card p,
body.light-mode, html.light-mode .info-card li,
body.light-mode, html.light-mode .home-blog-card p,
body.light-mode, html.light-mode .home-blog-card span {
  color: #cbd5e1 !important;
  opacity: 1 !important;
}

body.light-mode, html.light-mode .info-card a,
body.light-mode, html.light-mode .home-blog-card a {
  color: #93c5fd !important;
}
body.light-mode, html.light-mode .info-card a:hover,
body.light-mode, html.light-mode .home-blog-card a:hover {
  color: #bfdbfe !important;
}


/* Blog article sticky header (below site header) */
main.article > article > header {
  position: sticky;
  top: var(--app-header-height, 56px);
  z-index: 5;
  background: var(--page-bg, #0b1220);
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border-color, rgba(148,163,184,0.18));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
body.light-mode, html.light-mode main.article > article > header {
  background: var(--page-bg, #f8fafc);
  border-bottom-color: rgba(15,23,42,0.10);
}


/* =========================================================
   Global header fixes (light mode)
   ========================================================= */
body.light-mode, html.light-mode #app-header-root,
[data-theme="light"] #app-header-root {
  background: #ffffff !important;
  color: #0f172a !important;
  border-bottom: 1px solid rgba(15,23,42,0.12) !important;
}

body.light-mode, html.light-mode #app-header-root a,
[data-theme="light"] #app-header-root a,
body.light-mode, html.light-mode #app-header-root .brand-title,
body.light-mode, html.light-mode #app-header-root .brand-sub,
[data-theme="light"] #app-header-root .brand-title,
[data-theme="light"] #app-header-root .brand-sub {
  color: #0f172a !important;
}

/* Keep the {} logo/icon blue in both themes */
#app-header-root .brand-icon,
#app-header-root .brand-icon svg,
.sidebar .logo-icon,
.sidebar .logo-icon svg,
.logo-icon,
.logo-icon svg {
  color: #2563eb !important;
  fill: currentColor !important;
}

/* Dark cards/sections inside light pages: ensure text is readable */
body.light-mode, html.light-mode .card-dark,
body.light-mode, html.light-mode .info-card,
body.light-mode, html.light-mode .faq-card,
body.light-mode, html.light-mode .dark-panel,
[data-theme="light"] .card-dark,
[data-theme="light"] .info-card,
[data-theme="light"] .faq-card,
[data-theme="light"] .dark-panel {
  color: #e5e7eb !important;
}

body.light-mode, html.light-mode .card-dark *,
body.light-mode, html.light-mode .info-card *,
body.light-mode, html.light-mode .faq-card *,
body.light-mode, html.light-mode .dark-panel *,
[data-theme="light"] .card-dark *,
[data-theme="light"] .info-card *,
[data-theme="light"] .faq-card *,
[data-theme="light"] .dark-panel * {
  color: #e5e7eb !important;
}

/* Editor stats bar values visibility (light mode keeps dark bar) */
body.light-mode, html.light-mode .editor-stats,
body.light-mode, html.light-mode .editor-stats *,
[data-theme="light"] .editor-stats,
[data-theme="light"] .editor-stats * {
  color: #e5e7eb !important;
  opacity: 1 !important;
}


/* Blog index cards - ensure readable titles in light mode */
body.light-mode, html.light-mode .blog-list .post-card,
[data-theme="light"] .blog-list .post-card {
  background: #ffffff !important;
}

body.light-mode, html.light-mode .blog-list .post-card h2,
body.light-mode, html.light-mode .blog-list .post-card h3,
body.light-mode, html.light-mode .blog-list .post-card .title,
[data-theme="light"] .blog-list .post-card h2,
[data-theme="light"] .blog-list .post-card h3,
[data-theme="light"] .blog-list .post-card .title {
  color: #0f172a !important;
}

body.light-mode, html.light-mode .blog-list .post-card p,
body.light-mode, html.light-mode .blog-list .post-card .desc,
[data-theme="light"] .blog-list .post-card p,
[data-theme="light"] .blog-list .post-card .desc {
  color: #334155 !important;
}


/* SEO helpers */
.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.seo-content{max-width:1100px;margin:24px auto 0;padding:16px;border-radius:16px}
.seo-content h2{margin:0 0 10px}
.seo-content p{margin:0 0 12px}
.seo-content ol{margin:0 0 12px 18px}
.internal-links{display:flex;flex-wrap:wrap;gap:10px;max-width:1100px;margin:18px auto 0;padding:0 16px}
.internal-links a{text-decoration:underline}


/* FAQ styling */
.seo-content .faq{margin-top:12px}
.seo-content .faq-item{padding:10px 0;border-top:1px solid rgba(148,163,184,.35)}
.seo-content .faq-item h3{font-size:1rem;margin:0 0 6px 0}
.seo-content .related-tools{margin-top:10px}
.seo-content .related-tools a{margin-right:10px}


/* ---- Global Footer ---- */
.app-footer{
  margin-top: 40px;
  padding: 16px 20px;
  border-top: 1px solid rgba(148,163,184,0.25);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
}
body.light-mode, html.light-mode .app-footer{
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  color: #475569;
}
.footer-content{
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
}
.footer-links{
  display:flex;
  align-items:center;
  gap:8px;
}
.footer-links a{
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
body.light-mode, html.light-mode .footer-links a{
  color: #2563eb;
}
.footer-links a:hover{
  text-decoration: underline;
}
.footer-dot{
  opacity: 0.8;
}



.footer-pipe{margin:0 8px;color:inherit;opacity:.8;}

/* =========================================================
   Readability upgrades (content only)
   - Improves contrast + typography for long text blocks
   - Does NOT affect editors/ace/monaco panels
   ========================================================= */

:root{
  --content-heading: var(--text-primary);
  --content-body: #cbd5e1;          /* softer than pure white */
  --content-muted: var(--text-muted);
  --content-max: 920px;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --code-bg: #020617;
  --code-border: #1e293b;
}

body.light-mode, html.light-mode{
  --content-heading: #0f172a;
  --content-body: #334155;
  --content-muted: #64748b;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --code-bg: #f1f5f9;
  --code-border: #e2e8f0;
}

html, body{
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Match dark-mode text weight in light mode */
body.light-mode, html.light-mode {
  font-weight: 400;
}
body.light-mode .tool-card,
body.light-mode .tool-card p,
body.light-mode .tool-card li,
body.light-mode .tool-card span,
body.light-mode .tool-card a,
body.light-mode .tool-seo-content,
body.light-mode .tool-seo-content p,
body.light-mode .tool-seo-content li,
body.light-mode .tool-seo-content a,
body.light-mode main,
body.light-mode main p,
body.light-mode main li,
html.light-mode .tool-card,
html.light-mode .tool-card p,
html.light-mode .tool-card li,
html.light-mode .tool-card span,
html.light-mode .tool-card a,
html.light-mode .tool-seo-content,
html.light-mode .tool-seo-content p,
html.light-mode .tool-seo-content li,
html.light-mode .tool-seo-content a,
html.light-mode main,
html.light-mode main p,
html.light-mode main li {
  font-weight: 400;
}

/* Light mode: normalize sidebar + code text weight */
body.light-mode .sidebar,
body.light-mode .sidebar a,
body.light-mode .sidebar .sidebar-link,
body.light-mode .sidebar .sidebar-section-title,
body.light-mode .sidebar .sidebar-title,
body.light-mode .sidebar .sidebar-brand,
body.light-mode .sidebar .sidebar-brand *,
body.light-mode .sidebar .logo-title,
body.light-mode .sidebar .logo-sub,
html.light-mode .sidebar,
html.light-mode .sidebar a,
html.light-mode .sidebar .sidebar-link,
html.light-mode .sidebar .sidebar-section-title,
html.light-mode .sidebar .sidebar-title,
html.light-mode .sidebar .sidebar-brand,
html.light-mode .sidebar .sidebar-brand *,
html.light-mode .sidebar .logo-title,
html.light-mode .sidebar .logo-sub {
  font-weight: 400;
}

body.light-mode code,
body.light-mode pre,
body.light-mode pre code,
body.light-mode .ace_editor,
body.light-mode .ace_editor *,
html.light-mode code,
html.light-mode pre,
html.light-mode pre code,
html.light-mode .ace_editor,
html.light-mode .ace_editor * {
  font-weight: 400 !important;
}

/* Safer reading width + breathing room */
.tool-content,
.home-content,
.seo-block-home,
.info-card,
main.article{
  max-width: var(--content-max);
  margin: 28px auto;
  padding: 0 16px;
}

/* Better default typography for informational content */
.tool-content,
.home-content,
.seo-block-home,
.info-card,
main.article{
  color: var(--content-body);
  line-height: 1.75;
  font-size: clamp(15.5px, 1.05vw, 16.75px);
  letter-spacing: 0.1px;
}

/* Headings */
.tool-content h2, .home-content h2, .seo-block-home h2, .info-card h2, main.article h2{
  color: var(--content-heading);
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.22;
  margin: 24px 0 10px;
  letter-spacing: -0.2px;
}

.tool-content h3, .home-content h3, .seo-block-home h3, .info-card h3, main.article h3{
  color: var(--content-heading);
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.35;
  margin: 18px 0 8px;
}

/* Paragraph rhythm */
.tool-content p, .home-content p, .seo-block-home p, .info-card p, main.article p{
  margin: 10px 0;
}

/* Links */
.tool-content a, .home-content a, .seo-block-home a, .info-card a, main.article a{
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.tool-content a:hover, .home-content a:hover, .seo-block-home a:hover, .info-card a:hover, main.article a:hover{
  color: var(--link-hover);
}

/* Lists */
.tool-content ul, .tool-content ol,
.home-content ul, .home-content ol,
.seo-block-home ul, .seo-block-home ol,
.info-card ul, .info-card ol,
main.article ul, main.article ol{
  margin: 10px 0 14px 20px;
  padding: 0;
}

.tool-content li, .home-content li, .seo-block-home li, .info-card li, main.article li{
  margin: 6px 0;
}

/* Code blocks & examples */
.tool-content pre, .home-content pre, .seo-block-home pre, .info-card pre, main.article pre{
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 12px;
  padding: 14px 14px;
  overflow-x: auto;
}

.tool-content code, .home-content code, .seo-block-home code, .info-card code, main.article code{
  color: inherit;
  font-size: 0.92em;
}

/* FAQ cards (if used) */
.faq, .faq-section{
  margin-top: 14px;
}

.faq-item{
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  margin: 10px 0;
}

body.light-mode, html.light-mode .faq-item{
  background: #ffffff;
}

.faq-item h3{
  margin: 0 0 6px;
}

.faq-item p{
  margin: 0;
  color: var(--content-body);
}
