/* ==========================================================================
   Clear AI Label — Production Design System, Dark Mode, AdSense & Typography
   ========================================================================== */
:root {
  --brand-indigo: #4f46e5;
  --brand-indigo-hover: #4338ca;
  --brand-purple: #6366f1;
  --brand-emerald: #059669;
  --bg-page: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --ring-indigo: rgba(79, 70, 229, 0.15);
}

html.dark {
  --bg-page: #0b1120;
  --bg-subtle: #111827;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --ring-indigo: rgba(99, 102, 241, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Comprehensive Dark Mode Overrides */
html.dark body {
  background-color: #0b1120;
  color: #f8fafc;
}

html.dark .bg-white,
html.dark .bg-white\/95,
html.dark .bg-white\/90 {
  background-color: #1e293b !important;
}

html.dark .bg-slate-50,
html.dark .bg-slate-50\/70,
html.dark .bg-slate-50\/80 {
  background-color: #0f172a !important;
}

html.dark .bg-slate-100 {
  background-color: #334155 !important;
}

html.dark .bg-indigo-50,
html.dark .bg-indigo-50\/60,
html.dark .bg-indigo-50\/70 {
  background-color: rgba(49, 46, 129, 0.45) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
}

html.dark .text-indigo-700,
html.dark .text-indigo-600,
html.dark .text-indigo-950,
html.dark .text-indigo-900 {
  color: #a5b4fc !important;
}

html.dark .text-slate-900,
html.dark .text-slate-800 {
  color: #f8fafc !important;
}

html.dark .text-slate-700,
html.dark .text-slate-600,
html.dark .text-slate-500 {
  color: #cbd5e1 !important;
}

html.dark .border-slate-200,
html.dark .border-slate-200\/80,
html.dark .border-slate-200\/90,
html.dark .border-slate-100,
html.dark .border-slate-300 {
  border-color: #334155 !important;
}

html.dark .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: #334155 !important;
}

html.dark .upload-box-dashed {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border-color: #475569;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

html.dark .upload-box-dashed:hover,
html.dark .upload-box-dashed.dropzone-active {
  background: linear-gradient(180deg, rgba(49, 46, 129, 0.35) 0%, rgba(30, 41, 59, 0.95) 100%);
  border-color: #818cf8;
}

html.dark .hero-indigo-title {
  background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 55%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

html.dark input,
html.dark select,
html.dark textarea {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-color: #475569 !important;
}

html.dark code {
  background-color: #0f172a !important;
  color: #a5b4fc !important;
  border-color: #334155 !important;
}

/* Hero Mesh Backdrop */
.hero-mesh-bg {
  background-image:
    radial-gradient(at 18% 12%, rgba(79, 70, 229, 0.07) 0px, transparent 48%),
    radial-gradient(at 82% 18%, rgba(16, 185, 129, 0.06) 0px, transparent 48%),
    radial-gradient(at 50% 85%, rgba(99, 102, 241, 0.05) 0px, transparent 50%);
}

html.dark .hero-mesh-bg {
  background-image:
    radial-gradient(at 18% 12%, rgba(79, 70, 229, 0.16) 0px, transparent 50%),
    radial-gradient(at 82% 18%, rgba(16, 185, 129, 0.10) 0px, transparent 50%);
}

/* Mega-Menu Dropdowns */
.mega-menu-panel {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s;
  pointer-events: none;
}

.mega-menu-group:hover .mega-menu-panel,
.mega-menu-group.open .mega-menu-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Dashed Upload Dropzone */
.upload-box-dashed {
  border: 2px dashed #cbd5e1;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(226, 232, 240, 0.6);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.upload-box-dashed:hover,
.upload-box-dashed.dropzone-active {
  border-color: #4f46e5;
  background: linear-gradient(180deg, #ffffff 0%, #f5f3ff 100%);
  box-shadow: 0 16px 36px -10px rgba(79, 70, 229, 0.14), 0 0 0 4px rgba(79, 70, 229, 0.08);
  transform: translateY(-1px);
}

/* Hero Purple/Indigo Title */
.hero-indigo-title {
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 60%, #4338ca 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.028em;
}

/* Primary Indigo Button */
.btn-indigo-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: all 0.16s ease;
}

.btn-indigo-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

/* Step Circle Pill */
.step-num-circle {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background-color: #e0e7ff;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

html.dark .step-num-circle {
  background-color: #312e81;
  color: #c7d2fe;
}

/* Article Typography & Polished Inline Code */
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.84em;
  padding: 0.08rem 0.28rem;
  border-radius: 0.25rem;
  background-color: #f1f5f9;
  color: #4338ca;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  line-height: 1.25;
  vertical-align: baseline;
  word-break: break-word;
  white-space: normal;
}

/* Prevent pseudo quotes from Tailwind typography */
.prose :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *))::before,
.prose :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *))::after,
.prose code::before,
.prose code::after {
  content: "" !important;
}

.prose table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.prose table th {
  background-color: #f8fafc;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.875rem 1rem;
}

.prose table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
  vertical-align: top;
  line-height: 1.6;
}

.prose table tr:hover td {
  background-color: #f8fafc;
}

html.dark .prose code {
  background-color: #1e293b !important;
  color: #a5b4fc !important;
  border-color: #334155 !important;
}

html.dark .prose table th {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border-bottom-color: #334155 !important;
}

html.dark .prose table td {
  border-bottom-color: #1e293b !important;
  color: #94a3b8 !important;
}

html.dark .prose table tr:hover td {
  background-color: #0f172a !important;
}

/* AdSense Compliant Placement Container (CLS-Safe & Non-Intrusive) */
.adsense-slot-container {
  margin: 2rem auto;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  text-align: center;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

html.dark .adsense-slot-container {
  background-color: #0f172a;
  border-color: #334155;
}

.adsense-slot-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
html.dark .custom-scrollbar::-webkit-scrollbar-track {
  background: #1e293b;
}
html.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Reading Progress Bar */
#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #4f46e5, #10b981);
  z-index: 60;
  width: 0%;
  transition: width 0.1s ease-out;
}
