/*
 * NSFC 62176129 — Unified Explainer Page Stylesheet
 * Overrides individual page styles to match the main website's modern gradient theme.
 * Injected via <link> in every papers-explainer/*/index.html
 */

/* ===== Google Fonts (loaded separately via <link> in HTML) ===== */

/* ===== CSS Variables — match main site "modern" theme ===== */
:root {
  --navy:       #0f2b46 !important;
  --navy-light: #1a3a5c !important;
  --ocean:      #1e6091 !important;
  --ocean-light:#2980b9 !important;
  --cyan:       #00b4d8 !important;
  --cyan-light: #48cae4 !important;
  --coral:      #f77f6b !important;
  --coral-light:#fca5a5 !important;

  --bg:         #f8fafc !important;
  --surface:    #ffffff !important;
  --card:       #ffffff !important;
  --card-bg:    #ffffff !important;
  --text:       #1e293b !important;
  --muted:      #64748b !important;
  --faint:      #94a3b8 !important;
  --border:     #e2e8f0 !important;
  --line:       #e2e8f0 !important;
  --accent:     #00b4d8 !important;
  --accent2:    #48cae4 !important;
  --warn:       #f59e0b !important;

  --maxw: 960px;
}

/* ===== Reset & Base ===== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  color: #1e293b !important;
  background-color: #f8fafc !important;
  background-image: none !important;
  line-height: 1.75 !important;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* ===== Injected Nav Override ===== */

#nsfc-nav {
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
  background: linear-gradient(135deg, #0f2b46 0%, #1a3a5c 50%, #1e6091 100%) !important;
  padding: 10px 24px !important;
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif !important;
  box-shadow: 0 2px 12px rgba(15, 43, 70, 0.15) !important;
  border-bottom: 1px solid rgba(0, 180, 216, 0.2) !important;
}

#nsfc-nav a {
  color: #48cae4 !important;
  text-decoration: none !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  transition: color 0.2s !important;
}

#nsfc-nav a:hover {
  color: #ffffff !important;
}

#nsfc-nav span {
  color: rgba(255, 255, 255, 0.5) !important;
  font-size: 12px !important;
  letter-spacing: 0.05em !important;
}

/* ===== Typography ===== */

h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif !important;
  color: #0f2b46 !important;
  line-height: 1.3 !important;
  letter-spacing: -0.025em;
  font-weight: 700 !important;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem) !important;
  letter-spacing: -0.035em;
  line-height: 1.2 !important;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 1.85rem) !important;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  padding-bottom: 0.5em;
  border-bottom: 2px solid #e2e8f0 !important;
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, #00b4d8, #48cae4);
  border-radius: 1px;
}

h3 {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem) !important;
  color: #1a3a5c !important;
  margin-top: 1.5em;
}

p, li, dd, td, th {
  color: #1e293b !important;
  line-height: 1.75 !important;
}

a {
  color: #00b4d8 !important;
  text-decoration: none !important;
  transition: color 0.2s ease !important;
}

a:hover {
  color: #1e6091 !important;
  text-decoration: underline !important;
}

.subtitle, .meta {
  color: #64748b !important;
  font-size: 1.05rem !important;
  line-height: 1.6 !important;
}

small, .small, .muted {
  color: #64748b !important;
}

strong, b {
  color: #0f2b46 !important;
  font-weight: 600;
}

/* ===== Container / Layout ===== */

.container, .wrap, .main {
  max-width: 960px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
}

/* ===== Hero / Header ===== */

.hero, .site-header {
  background: linear-gradient(135deg, #0f2b46 0%, #1a3a5c 40%, #1e6091 100%) !important;
  color: #ffffff !important;
  padding: 4rem 24px 3.5rem !important;
  text-align: center !important;
  border-radius: 0 !important;
  position: relative !important;
  overflow: hidden !important;
}

.hero::before, .site-header::before {
  content: '' !important;
  position: absolute !important;
  top: -50% !important;
  right: -20% !important;
  width: 400px !important;
  height: 400px !important;
  background: radial-gradient(circle, rgba(0, 180, 216, 0.15) 0%, transparent 70%) !important;
  pointer-events: none !important;
}

.hero::after, .site-header::after {
  content: '' !important;
  position: absolute !important;
  bottom: -30% !important;
  left: -10% !important;
  width: 300px !important;
  height: 300px !important;
  background: radial-gradient(circle, rgba(72, 202, 228, 0.1) 0%, transparent 70%) !important;
  pointer-events: none !important;
}

.hero h1, .site-header h1, .hero__inner h1 {
  color: #ffffff !important;
  font-weight: 800 !important;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.2) !important;
  position: relative !important;
  z-index: 1 !important;
}

.hero .subtitle, .site-header .subtitle,
.hero p, .site-header p,
.hero .meta, .site-header .meta {
  color: rgba(255, 255, 255, 0.8) !important;
  position: relative !important;
  z-index: 1 !important;
}

.hero__inner {
  max-width: 960px !important;
  margin: 0 auto !important;
  position: relative !important;
  z-index: 1 !important;
}

.hero__figure {
  margin-top: 2rem !important;
  position: relative !important;
  z-index: 1 !important;
}

.hero__figure img {
  border-radius: 12px !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
}

/* ===== Sections ===== */

.section, section {
  padding-top: 3rem !important;
  padding-bottom: 3rem !important;
}

section:nth-child(even) {
  background-color: #ffffff;
}

section:nth-child(odd) {
  background-color: #f8fafc;
}

/* ===== Cards ===== */

.card, .module {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 1.5rem !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05) !important;
  transition: all 0.3s ease !important;
  position: relative !important;
  overflow: hidden !important;
}

.card::before, .module::before {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 3px !important;
  background: linear-gradient(90deg, #00b4d8, #48cae4, transparent) !important;
  opacity: 0 !important;
  transition: opacity 0.3s ease !important;
}

.card:hover, .module:hover {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05) !important;
  transform: translateY(-2px) !important;
  border-color: #00b4d8 !important;
}

.card:hover::before, .module:hover::before {
  opacity: 1 !important;
}

.card h3, .module h3 {
  color: #0f2b46 !important;
  margin-top: 0 !important;
}

.card p, .module p {
  color: #475569 !important;
}

/* ===== Grid Layouts ===== */

.grid, .grid-2, .cards-3, .asset-grid {
  display: grid !important;
  gap: 1.5rem !important;
}

.grid, .grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) !important;
}

.cards-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
}

/* ===== Badges & Pills ===== */

.badge, .pill {
  display: inline-block !important;
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.1), rgba(72, 202, 228, 0.1)) !important;
  color: #1e6091 !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  border: 1px solid rgba(0, 180, 216, 0.2) !important;
  letter-spacing: 0.02em;
}

/* ===== Buttons ===== */

button, .btn {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif !important;
  background: linear-gradient(135deg, #00b4d8, #0ea5e9) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 10px 20px !important;
  border-radius: 8px !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 8px rgba(0, 180, 216, 0.25) !important;
}

button:hover, .btn:hover {
  background: linear-gradient(135deg, #0ea5e9, #1e6091) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(0, 180, 216, 0.35) !important;
}

button:active, .btn:active {
  transform: translateY(0) !important;
}

button.active, button[aria-pressed="true"], button.pressed {
  background: linear-gradient(135deg, #0f2b46, #1a3a5c) !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* ===== Select / Input ===== */

select, input[type="range"] {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  background: #ffffff !important;
  color: #1e293b !important;
  font-size: 0.9rem !important;
}

select:focus, input:focus {
  outline: none !important;
  border-color: #00b4d8 !important;
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15) !important;
}

/* ===== TOC (Table of Contents) ===== */

.toc {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.04), rgba(30, 96, 145, 0.04)) !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 1.25rem 1.5rem !important;
  margin: 2rem 0 !important;
}

.toc a {
  color: #1e6091 !important;
  font-weight: 500 !important;
}

.toc a:hover {
  color: #00b4d8 !important;
}

/* ===== Figures & Images ===== */

figure, .fig {
  margin: 2rem 0 !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 1rem !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

figure img, .fig img, .gallery img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px !important;
  display: block !important;
  margin: 0 auto !important;
}

figcaption, .fig figcaption {
  color: #64748b !important;
  font-size: 0.85rem !important;
  text-align: center !important;
  margin-top: 0.75rem !important;
  font-style: italic !important;
  line-height: 1.5 !important;
}

/* ===== Gallery ===== */

.gallery {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
  gap: 1rem !important;
}

/* ===== Code Blocks ===== */

pre, code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, monospace !important;
}

pre {
  background: #0f172a !important;
  color: #e2e8f0 !important;
  padding: 1.25rem !important;
  border-radius: 12px !important;
  overflow-x: auto !important;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
  border: 1px solid rgba(0, 180, 216, 0.15) !important;
}

code {
  background: rgba(0, 180, 216, 0.08) !important;
  color: #1e6091 !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-size: 0.88em !important;
}

pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
}

/* ===== KPI / Stats Boxes ===== */

.kpi {
  background: linear-gradient(135deg, #0f2b46, #1a3a5c) !important;
  color: #ffffff !important;
  border-radius: 12px !important;
  padding: 1.25rem !important;
  text-align: center !important;
  box-shadow: 0 4px 12px rgba(15, 43, 70, 0.2) !important;
}

.kpi strong, .kpi b {
  color: #48cae4 !important;
  font-size: 1.8rem !important;
  display: block !important;
}

.kpi span, .kpi small, .kpi .label {
  color: rgba(255, 255, 255, 0.75) !important;
  font-size: 0.8rem !important;
}

/* ===== Progress / Bar Charts ===== */

.progress, .bar-row {
  background: #f1f5f9 !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  margin: 0.5rem 0 !important;
}

.bar, .hbar, .progress > div {
  background: linear-gradient(90deg, #00b4d8, #48cae4) !important;
  border-radius: 8px !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  padding: 6px 12px !important;
  transition: width 0.6s ease !important;
}

/* ===== Tables ===== */

table, .table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  border: 1px solid #e2e8f0 !important;
  margin: 1.5rem 0 !important;
}

thead, .table thead {
  background: linear-gradient(135deg, #0f2b46, #1a3a5c) !important;
}

th {
  color: #ffffff !important;
  font-weight: 600 !important;
  padding: 12px 16px !important;
  text-align: left !important;
  font-size: 0.85rem !important;
  letter-spacing: 0.02em !important;
}

td {
  padding: 10px 16px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  font-size: 0.9rem !important;
}

tbody tr:hover {
  background: rgba(0, 180, 216, 0.04) !important;
}

tbody tr:last-child td {
  border-bottom: none !important;
}

/* ===== Callout / Note / Takehome ===== */

.note, .callout, .takehome {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.06), rgba(72, 202, 228, 0.04)) !important;
  border-left: 4px solid #00b4d8 !important;
  border-radius: 0 12px 12px 0 !important;
  padding: 1.25rem 1.5rem !important;
  margin: 1.5rem 0 !important;
  color: #1e293b !important;
}

.note strong, .callout strong, .takehome strong {
  color: #0f2b46 !important;
}

/* ===== FAQ / Details ===== */

.faq-item, details {
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  margin: 0.75rem 0 !important;
  overflow: hidden !important;
  background: #ffffff !important;
}

summary, .faq-item summary {
  padding: 1rem 1.25rem !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  color: #0f2b46 !important;
  background: #ffffff !important;
  transition: background 0.2s !important;
  list-style: none !important;
}

summary:hover {
  background: rgba(0, 180, 216, 0.04) !important;
}

summary::marker, summary::-webkit-details-marker {
  display: none !important;
}

summary::before {
  content: '▸' !important;
  display: inline-block !important;
  margin-right: 0.5em !important;
  transition: transform 0.2s !important;
  color: #00b4d8 !important;
}

details[open] summary::before {
  transform: rotate(90deg) !important;
}

details > :not(summary) {
  padding: 0 1.25rem 1rem !important;
}

/* ===== Citations ===== */

.citations, .references, .cite {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 1.5rem !important;
  margin: 2rem 0 !important;
}

.citations li, .references li {
  color: #475569 !important;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
  margin-bottom: 0.5rem !important;
}

/* ===== Feature Lists ===== */

.feature-list li, ul.features li {
  position: relative !important;
  padding-left: 1.5em !important;
  margin-bottom: 0.75rem !important;
}

.feature-list li::before, ul.features li::before {
  content: '→' !important;
  position: absolute !important;
  left: 0 !important;
  color: #00b4d8 !important;
  font-weight: 700 !important;
}

/* ===== Controls Section ===== */

.controls {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
  align-items: center !important;
  margin: 1rem 0 !important;
  padding: 1rem !important;
  background: #f8fafc !important;
  border-radius: 12px !important;
  border: 1px solid #e2e8f0 !important;
}

/* ===== Interactive / Puzzle ===== */

.interactive {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  padding: 1.5rem !important;
  margin: 1.5rem 0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

.tile {
  background: #ffffff !important;
  border: 2px dashed #e2e8f0 !important;
  border-radius: 10px !important;
  padding: 12px !important;
  cursor: grab !important;
  transition: all 0.2s !important;
  color: #1e293b !important;
}

.tile:hover {
  border-color: #00b4d8 !important;
  background: rgba(0, 180, 216, 0.04) !important;
}

.dropzone {
  border: 2px dashed #cbd5e1 !important;
  border-radius: 12px !important;
  padding: 1rem !important;
  min-height: 60px !important;
  transition: all 0.2s !important;
}

.dropzone.active, .dropzone:hover {
  border-color: #00b4d8 !important;
  background: rgba(0, 180, 216, 0.06) !important;
}

/* ===== Risk Indicators ===== */

.risk {
  border-radius: 8px !important;
  padding: 0.75rem 1rem !important;
  font-weight: 600 !important;
}

.risk.high, .risk.danger {
  background: rgba(239, 68, 68, 0.08) !important;
  color: #dc2626 !important;
  border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

.risk.medium, .risk.warning {
  background: rgba(245, 158, 11, 0.08) !important;
  color: #d97706 !important;
  border: 1px solid rgba(245, 158, 11, 0.2) !important;
}

.risk.low, .risk.success {
  background: rgba(16, 185, 129, 0.08) !important;
  color: #059669 !important;
  border: 1px solid rgba(16, 185, 129, 0.2) !important;
}

/* ===== Footer ===== */

.footer, .site-footer {
  background: linear-gradient(135deg, #0f2b46 0%, #1a3a5c 100%) !important;
  color: rgba(255, 255, 255, 0.7) !important;
  padding: 2.5rem 24px !important;
  text-align: center !important;
  margin-top: 3rem !important;
  font-size: 0.85rem !important;
}

.footer a, .site-footer a {
  color: #48cae4 !important;
}

.footer p, .site-footer p {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* ===== Skip Link (Accessibility) ===== */

.skip-link {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.skip-link:focus {
  position: fixed !important;
  top: 8px !important;
  left: 8px !important;
  width: auto !important;
  height: auto !important;
  background: #00b4d8 !important;
  color: #ffffff !important;
  padding: 8px 16px !important;
  border-radius: 8px !important;
  z-index: 10000 !important;
}

/* ===== Lists ===== */

ul, ol {
  padding-left: 1.5em !important;
}

li {
  margin-bottom: 0.4rem !important;
}

/* ===== Blockquotes ===== */

blockquote {
  border-left: 4px solid #00b4d8 !important;
  margin: 1.5rem 0 !important;
  padding: 1rem 1.5rem !important;
  background: rgba(0, 180, 216, 0.04) !important;
  border-radius: 0 12px 12px 0 !important;
  color: #475569 !important;
  font-style: italic !important;
}

/* ===== Horizontal Rules ===== */

hr {
  border: none !important;
  height: 1px !important;
  background: linear-gradient(90deg, transparent, #e2e8f0, transparent) !important;
  margin: 2.5rem 0 !important;
}

/* ===== Scrollbar ===== */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== Selection ===== */

::selection {
  background: rgba(0, 180, 216, 0.2);
  color: #0f2b46;
}

/* ===== Print ===== */

@media print {
  #nsfc-nav { display: none !important; }
  body { background: #fff !important; }
  .card, .module { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .container, .wrap, .main {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .hero, .site-header {
    padding: 3rem 16px 2.5rem !important;
  }

  h1 {
    font-size: 1.6rem !important;
  }

  .grid, .grid-2, .cards-3, .asset-grid {
    grid-template-columns: 1fr !important;
  }

  .kpi {
    padding: 1rem !important;
  }
}

@media (max-width: 480px) {
  .hero, .site-header {
    padding: 2.5rem 12px 2rem !important;
  }

  h1 {
    font-size: 1.4rem !important;
  }

  .card, .module {
    padding: 1rem !important;
  }
}

/* ===== Smooth transitions for interactive elements ===== */

a, button, .btn, .card, .module, .tile, summary, select {
  transition: all 0.2s ease !important;
}

/* ===== Canvas / SVG containers ===== */

canvas {
  border-radius: 8px !important;
  max-width: 100% !important;
}

svg {
  max-width: 100%;
  height: auto;
}
