/* MC NovaTools — production theme hardening
   Calm corporate palette, deterministic light/dark contrast, and legacy-token compatibility. */

:root[data-theme="light"],
:root:not([data-theme]) {
  color-scheme: light;

  /* Legacy tool-page tokens */
  --bg-primary: #f6f8fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef2f7;
  --bg-elevated: #ffffff;
  --bg-hover: #e8eef6;
  --surface-default: rgba(255, 255, 255, 0.9);
  --surface-hover: #f4f7fb;
  --surface-active: #eaf0f7;
  --text-primary: #172033;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #64748b;
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-secondary: #0f766e;
  --accent-warm: #b45309;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --accent-subtle: rgba(37, 99, 235, 0.07);
  --success: #15803d;
  --warning: #b45309;
  --error: #b91c1c;
  --info: #1d4ed8;
  --border-default: rgba(30, 41, 59, 0.12);
  --border-hover: rgba(37, 99, 235, 0.28);
  --border-accent: rgba(37, 99, 235, 0.36);
  --card-bg: #ffffff;
  --card-border: rgba(30, 41, 59, 0.11);
  --card-hover-bg: #ffffff;
  --card-hover-border: rgba(37, 99, 235, 0.28);
  --header-bg: rgba(255, 255, 255, 0.94);
  --header-border: rgba(30, 41, 59, 0.1);
  --footer-bg: #f4f7fb;
  --footer-border: rgba(30, 41, 59, 0.1);
  --ad-bg: #f4f7fb;
  --ad-border: rgba(30, 41, 59, 0.1);
  --ad-label-color: #64748b;

  /* Semantic design-system tokens */
  --color-background: #f6f8fb;
  --color-bg-primary: #f6f8fb;
  --color-bg-secondary: #eef3f8;
  --color-bg-tertiary: #e5ebf3;
  --color-bg-elevated: #ffffff;
  --color-bg-hover: #e8eef6;
  --color-surface: rgba(255, 255, 255, 0.92);
  --color-surface-hover: #f5f8fc;
  --color-surface-active: #edf2f8;
  --color-surface-elevated: #ffffff;
  --color-text-primary: #172033;
  --color-text-secondary: #475569;
  --color-text-tertiary: #64748b;
  --color-text-muted: #64748b;
  --color-border: rgba(30, 41, 59, 0.13);
  --color-border-hover: rgba(37, 99, 235, 0.34);
  --color-border-strong: rgba(30, 41, 59, 0.24);
  --color-divider: rgba(30, 41, 59, 0.1);
  --color-primary-400: #3b82f6;
  --color-primary-500: #2563eb;
  --color-primary-600: #1d4ed8;
  --color-secondary-400: #14b8a6;
  --color-secondary-500: #0f766e;
  --color-secondary-600: #0d625d;
  --color-accent-400: #3b82f6;
  --color-accent-500: #2563eb;
  --color-accent-600: #1d4ed8;
  --color-accent-700: #1e40af;
  --color-accent-800: #1e3a8a;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-glow: rgba(37, 99, 235, 0.12);
  --color-accent-subtle: rgba(37, 99, 235, 0.07);
  --color-accent-secondary: #0f766e;
  --color-accent-secondary-glow: rgba(15, 118, 110, 0.1);
  --color-accent-warm: #b45309;
  --color-accent-warm-glow: rgba(180, 83, 9, 0.08);
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-error: #b91c1c;
  --color-info: #1d4ed8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 46px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 24px 68px rgba(15, 23, 42, 0.12);
  --shadow-2xl: 0 32px 90px rgba(15, 23, 42, 0.16);
  --shadow-glow: 0 0 36px rgba(37, 99, 235, 0.08);
  --shadow-glow-strong: 0 0 48px rgba(37, 99, 235, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Legacy tool-page tokens */
  --bg-primary: #0b1220;
  --bg-secondary: #101827;
  --bg-tertiary: #172033;
  --bg-elevated: #1c2940;
  --bg-hover: #22324a;
  --surface-default: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.075);
  --surface-active: rgba(255, 255, 255, 0.11);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #9aa8bb;
  --text-muted: #718096;
  --accent-primary: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-secondary: #2dd4bf;
  --accent-warm: #f59e0b;
  --accent-glow: rgba(96, 165, 250, 0.16);
  --accent-subtle: rgba(96, 165, 250, 0.08);
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  --border-default: rgba(203, 213, 225, 0.1);
  --border-hover: rgba(96, 165, 250, 0.3);
  --border-accent: rgba(96, 165, 250, 0.38);
  --card-bg: linear-gradient(180deg, rgba(23, 32, 51, 0.94), rgba(16, 24, 39, 0.98));
  --card-border: rgba(203, 213, 225, 0.1);
  --card-hover-bg: linear-gradient(180deg, rgba(28, 41, 64, 0.96), rgba(17, 27, 45, 0.99));
  --card-hover-border: rgba(96, 165, 250, 0.28);
  --header-bg: rgba(11, 18, 32, 0.92);
  --header-border: rgba(203, 213, 225, 0.1);
  --footer-bg: #0d1626;
  --footer-border: rgba(203, 213, 225, 0.1);
  --ad-bg: rgba(255, 255, 255, 0.025);
  --ad-border: rgba(203, 213, 225, 0.09);
  --ad-label-color: #718096;

  /* Semantic design-system tokens */
  --color-background: #0b1220;
  --color-bg-primary: #0b1220;
  --color-bg-secondary: #101827;
  --color-bg-tertiary: #172033;
  --color-bg-elevated: #1c2940;
  --color-bg-hover: #22324a;
  --color-surface: rgba(23, 32, 51, 0.82);
  --color-surface-hover: rgba(28, 41, 64, 0.9);
  --color-surface-active: rgba(34, 50, 74, 0.94);
  --color-surface-elevated: #172033;
  --color-text-primary: #f8fafc;
  --color-text-secondary: #cbd5e1;
  --color-text-tertiary: #9aa8bb;
  --color-text-muted: #718096;
  --color-border: rgba(203, 213, 225, 0.1);
  --color-border-hover: rgba(96, 165, 250, 0.3);
  --color-border-strong: rgba(203, 213, 225, 0.22);
  --color-divider: rgba(203, 213, 225, 0.1);
  --color-primary-400: #60a5fa;
  --color-primary-500: #3b82f6;
  --color-primary-600: #2563eb;
  --color-secondary-400: #2dd4bf;
  --color-secondary-500: #14b8a6;
  --color-secondary-600: #0d9488;
  --color-accent-400: #93c5fd;
  --color-accent-500: #60a5fa;
  --color-accent-600: #3b82f6;
  --color-accent-700: #2563eb;
  --color-accent-800: #1d4ed8;
  --color-accent: #60a5fa;
  --color-accent-hover: #93c5fd;
  --color-accent-glow: rgba(96, 165, 250, 0.16);
  --color-accent-subtle: rgba(96, 165, 250, 0.08);
  --color-accent-secondary: #2dd4bf;
  --color-accent-secondary-glow: rgba(45, 212, 191, 0.1);
  --color-accent-warm: #f59e0b;
  --color-accent-warm-glow: rgba(245, 158, 11, 0.09);
  --color-success: #4ade80;
  --color-warning: #fbbf24;
  --color-error: #f87171;
  --color-info: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 10px 26px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.32);
  --shadow-xl: 0 26px 72px rgba(0, 0, 0, 0.38);
  --shadow-2xl: 0 34px 96px rgba(0, 0, 0, 0.44);
  --shadow-glow: 0 0 34px rgba(96, 165, 250, 0.08);
  --shadow-glow-strong: 0 0 48px rgba(96, 165, 250, 0.1);
}

html,
body {
  background: var(--bg-primary) !important;
  color: var(--text-primary);
}

body {
  background-image:
    radial-gradient(circle at 8% 0%, var(--accent-subtle), transparent 28%),
    radial-gradient(circle at 92% 4%, color-mix(in srgb, var(--accent-secondary) 7%, transparent), transparent 24%),
    linear-gradient(180deg, var(--bg-primary), var(--bg-secondary)) !important;
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.055), transparent 28%),
    linear-gradient(180deg, #f8fafd 0%, #f3f6fa 100%) !important;
}

.main-header,
.app-header,
.nt-navbar,
.home-header {
  background: var(--header-bg) !important;
  border-color: var(--header-border) !important;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07) !important;
}

:root[data-theme="dark"] .main-header,
:root[data-theme="dark"] .app-header,
:root[data-theme="dark"] .nt-navbar,
:root[data-theme="dark"] .home-header {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22) !important;
}

.logo-text,
.footer-logo,
.nt-mega-header__brand {
  background: none !important;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: currentColor !important;
  text-shadow: none !important;
}

.logo-mc,
.section-eyebrow,
.home-eyebrow,
.featured-tool-card__category,
.home-blog-card__meta {
  background: none !important;
  color: var(--accent-primary) !important;
  -webkit-text-fill-color: currentColor !important;
}

.nt-card,
.tool-card,
.blog-card,
.category-card,
.task-chip,
.featured-tool-card,
.category-nav-card,
.home-blog-card,
.workflow-card,
.workflow-panel {
  background: var(--card-bg) !important;
  border-color: var(--card-border) !important;
}

.nt-card:hover,
.tool-card:hover,
.blog-card:hover,
.category-card:hover,
.task-chip:hover,
.featured-tool-card:hover,
.category-nav-card:hover,
.home-blog-card:hover,
.workflow-card:hover {
  border-color: var(--card-hover-border) !important;
  box-shadow: var(--shadow-lg) !important;
}

.home-hero,
.nt-hero {
  background:
    radial-gradient(circle at 12% 0%, var(--accent-subtle), transparent 32%),
    linear-gradient(180deg, var(--bg-primary), var(--bg-secondary)) !important;
}

.home-trust,
.home-search__box,
.home-search__results:not(:empty),
.workflow-panel__stack a,
.workflow-card__steps a,
.home-trust__item {
  background: var(--bg-elevated) !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
textarea,
select,
.input,
.nt-input,
.nt-textarea,
.nt-select {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-default) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary) !important;
  opacity: 1;
}

.home-footer,
.app-footer,
.nt-footer,
.tool-footer {
  background: var(--footer-bg) !important;
  border-color: var(--footer-border) !important;
  color: var(--text-secondary) !important;
}

.tool-footer a,
.home-footer a,
.app-footer a,
.nt-footer a {
  color: var(--accent-primary) !important;
}

.bg-ambient::before {
  background: radial-gradient(ellipse at center, var(--accent-glow) 0%, transparent 68%) !important;
}

.bg-ambient::after {
  background: radial-gradient(ellipse at bottom right, color-mix(in srgb, var(--accent-secondary) 10%, transparent) 0%, transparent 64%) !important;
}

:root[data-theme="light"] .bg-ambient,
:root[data-theme="light"] .noise-overlay {
  display: none !important;
}

/* Light-mode safety: prevent white-on-white gradient text and dark-only surfaces. */
:root[data-theme="light"] .text-gradient-primary,
:root[data-theme="light"] [class*="gradient-text"] {
  background: none !important;
  color: #1d4ed8 !important;
  -webkit-text-fill-color: currentColor !important;
}

:root[data-theme="light"] img,
:root[data-theme="light"] picture,
:root[data-theme="light"] canvas,
:root[data-theme="light"] svg {
  visibility: visible;
}

:root[data-theme="light"] .header-logo-img,
:root[data-theme="light"] .home-hero__spin-logo img {
  opacity: 1 !important;
  filter: drop-shadow(0 8px 18px rgba(15, 23, 42, 0.12)) !important;
}

/* Legacy inline tool pages used hardcoded dark/neon values. The production override
   deliberately normalizes their common shells without rewriting every tool. */
:root[data-theme="light"] .tool-hero h1,
:root[data-theme="light"] .tool-header h1,
:root[data-theme="light"] .seo-section h2,
:root[data-theme="light"] .seo-section h3,
:root[data-theme="light"] .faq-item summary,
:root[data-theme="light"] .output-label,
:root[data-theme="light"] .input-label,
:root[data-theme="light"] .stat-value,
:root[data-theme="light"] .file-name-large {
  color: var(--text-primary) !important;
  -webkit-text-fill-color: currentColor !important;
}

:root[data-theme="light"] .tool-hero p,
:root[data-theme="light"] .tool-header p,
:root[data-theme="light"] .seo-section p,
:root[data-theme="light"] .seo-section li,
:root[data-theme="light"] .faq-item p,
:root[data-theme="light"] .output-placeholder,
:root[data-theme="light"] .hero-note,
:root[data-theme="light"] .file-size-large,
:root[data-theme="light"] .stat-label,
:root[data-theme="light"] .quality-option .desc {
  color: var(--text-secondary) !important;
}

:root[data-theme="light"] .card,
:root[data-theme="light"] .tool-workspace,
:root[data-theme="light"] .trust-help,
:root[data-theme="light"] .related-tools,
:root[data-theme="light"] .tool-description,
:root[data-theme="light"] .faq-item,
:root[data-theme="light"] .output-wrap,
:root[data-theme="light"] .file-info-card,
:root[data-theme="light"] .quality-selector,
:root[data-theme="light"] .quality-option,
:root[data-theme="light"] .state-section,
:root[data-theme="light"] .progress-section,
:root[data-theme="light"] .dropzone {
  background: var(--bg-elevated) !important;
  border-color: var(--border-default) !important;
  box-shadow: var(--shadow-sm) !important;
}

:root[data-theme="light"] #jsonInput,
:root[data-theme="light"] #jsonOutput,
:root[data-theme="light"] pre,
:root[data-theme="light"] code:not([class]) {
  background: #f8fafc !important;
  color: #1e293b !important;
  border-color: var(--border-default) !important;
}

:root[data-theme="light"] .json-key { color: #1d4ed8 !important; }
:root[data-theme="light"] .json-string { color: #047857 !important; }
:root[data-theme="light"] .json-number { color: #a16207 !important; }
:root[data-theme="light"] .json-boolean { color: #6d28d9 !important; }
:root[data-theme="light"] .json-null { color: #b91c1c !important; }

:root[data-theme="light"] .btn-primary,
:root[data-theme="light"] .download-btn {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

:root[data-theme="light"] .btn-primary:hover,
:root[data-theme="light"] .download-btn:hover {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
}

:root[data-theme="light"] .btn-secondary,
:root[data-theme="light"] .btn-ghost {
  background: #ffffff !important;
  border-color: var(--border-default) !important;
  color: #1d4ed8 !important;
}

:root[data-theme="light"] .btn-danger,
:root[data-theme="light"] .error-text,
:root[data-theme="light"] .error-message {
  color: #b91c1c !important;
}

:root[data-theme="light"] .stats-badge,
:root[data-theme="light"] .copy-feedback,
:root[data-theme="light"] .state-section[data-state="success"] {
  color: #166534 !important;
}

:root[data-theme="light"] .progress-fill {
  background: #2563eb !important;
}

::selection {
  background: rgba(37, 99, 235, 0.22);
  color: inherit;
}
