/* ============================================================
   PARTIAL DERIVATIVE CALCULATOR — Design System
   Aesthetic: Scientific Precision × Editorial Warmth
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@400;500&family=Outfit:wght@300;400;500;600&display=swap');

:root {
  --ink:       #1a1a2e;
  --ink-soft:  #3d3d5c;
  --ink-muted: #7a7a9d;
  --paper:     #faf9f6;
  --paper-alt: #f2f0ea;
  --accent:    #c84b31;
  --accent-2:  #e8a838;
  --accent-3:  #2d6a4f;
  --grid:      #e8e6df;
  --white:     #ffffff;

  --ff-display: 'DM Serif Display', Georgia, serif;
  --ff-body:    'Outfit', sans-serif;
  --ff-mono:    'DM Mono', 'Courier New', monospace;

  --radius:  8px;
  --radius-lg: 16px;
  --shadow:  0 2px 16px rgba(26,26,46,0.08);
  --shadow-lg: 0 8px 48px rgba(26,26,46,0.14);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--ff-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── Grid background texture ─────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--ff-display); line-height: 1.2; }
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.6rem); }
p  { color: var(--ink-soft); }

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--ink); }

code, .mono {
  font-family: var(--ff-mono);
  font-size: 0.88em;
  background: var(--paper-alt);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--grid);
}

/* ── Layout ──────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }
.container--narrow { max-width: 720px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* ── NAV ─────────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--grid);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--ff-display);
  font-size: 1.25rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo span {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--ff-mono);
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.nav-links { display: flex; align-items: center; gap: 32px; list-style: none; }
.nav-links a { font-size: 0.9rem; font-weight: 500; color: var(--ink-soft); }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-links a.active { border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

.nav-cta {
  background: var(--ink);
  color: var(--paper) !important;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-weight: 500 !important;
}
.nav-cta:hover { background: var(--accent) !important; color: var(--white) !important; }

/* ── HERO ────────────────────────────────────────────────── */
.hero {
  padding: 80px 0 64px;
  position: relative;
  overflow: hidden;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
}

.hero h1 {
  margin-bottom: 20px;
  max-width: 680px;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-subtitle {
  font-size: 1.1rem;
  max-width: 540px;
  margin-bottom: 40px;
  color: var(--ink-soft);
}

.hero-decoration {
  position: absolute;
  right: -40px;
  top: 20px;
  font-family: var(--ff-mono);
  font-size: 8rem;
  color: var(--ink);
  opacity: 0.04;
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

/* ── CALCULATOR CARD ─────────────────────────────────────── */
.calc-section { padding: 0 0 80px; }

.calc-card {
  background: var(--white);
  border: 1px solid var(--grid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.calc-header {
  background: var(--ink);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.calc-header-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}
.calc-header-dot:nth-child(2) { background: #febc2e; }
.calc-header-dot:nth-child(3) { background: #28c840; }

.calc-header-title {
  font-family: var(--ff-mono);
  font-size: 0.8rem;
  color: rgba(250,249,246,0.5);
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.calc-body { padding: 36px 32px 40px; }

.form-group { margin-bottom: 28px; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.input-wrap { position: relative; }

.input-wrap input,
.input-wrap select {
  width: 100%;
  padding: 14px 18px;
  font-family: var(--ff-mono);
  font-size: 1rem;
  border: 2px solid var(--grid);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(200,75,49,0.1);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 6px;
  font-family: var(--ff-mono);
}

.vars-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.var-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 2px solid var(--grid);
  border-radius: 100px;
  cursor: pointer;
  background: var(--paper);
  font-family: var(--ff-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition: all var(--transition);
  user-select: none;
}

.var-chip:hover { border-color: var(--accent); color: var(--accent); }

.var-chip input[type="checkbox"] { display: none; }

.var-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.order-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.btn-calc {
  width: 100%;
  padding: 16px 32px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius);
  font-family: var(--ff-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-calc::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.btn-calc:hover::after { transform: translateX(0); }
.btn-calc span { position: relative; z-index: 1; }

/* ── RESULT ──────────────────────────────────────────────── */
.result-box {
  margin-top: 32px;
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  display: none;
  animation: fadeUp 0.35s ease forwards;
}

.result-box.show { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.result-expr {
  font-family: var(--ff-mono);
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 500;
  word-break: break-word;
  line-height: 1.5;
}

.result-steps {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--grid);
}

.step {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.step-num {
  width: 24px;
  height: 24px;
  min-width: 24px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.step-text { font-size: 0.9rem; color: var(--ink-soft); }
.step-text code { font-size: 0.85rem; }

.error-box {
  margin-top: 20px;
  padding: 16px 20px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #c53030;
  font-size: 0.9rem;
  display: none;
}
.error-box.show { display: block; }

/* ── EXAMPLES SECTION ────────────────────────────────────── */
.examples-section { padding: 64px 0; background: var(--paper-alt); }

.section-label {
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.example-card {
  background: var(--white);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.example-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.example-func {
  font-family: var(--ff-mono);
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: 500;
}

.example-desc { font-size: 0.82rem; color: var(--ink-muted); }

/* ── THEORY SECTION ──────────────────────────────────────── */
.theory-section { padding: 80px 0; }

.theory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 48px;
}

.theory-card {
  padding: 32px;
  border: 1px solid var(--grid);
  border-radius: var(--radius-lg);
  background: var(--white);
}

.theory-card h3 { margin-bottom: 12px; }
.theory-card p { font-size: 0.92rem; }
.theory-card .formula {
  margin-top: 16px;
  padding: 16px;
  background: var(--paper);
  border-radius: var(--radius);
  font-family: var(--ff-mono);
  font-size: 0.9rem;
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

/* ── BLOG PREVIEW ────────────────────────────────────────── */
.blog-preview { padding: 80px 0; background: var(--paper-alt); }

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.blog-card {
  background: var(--white);
  border: 1px solid var(--grid);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}

.blog-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

.blog-card-thumb {
  height: 160px;
  background: linear-gradient(135deg, var(--ink) 0%, #2d3561 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: 3.5rem;
  color: rgba(255,255,255,0.08);
  position: relative;
  overflow: hidden;
}

.blog-card-thumb::after {
  content: attr(data-symbol);
  position: absolute;
  font-size: 5rem;
  color: rgba(255,255,255,0.06);
  right: 20px;
  bottom: -10px;
}

.blog-card-thumb-label {
  font-family: var(--ff-mono);
  font-size: 2rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.05em;
}

.blog-card-body { padding: 24px; }

.blog-card-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.blog-card h3 { font-size: 1.1rem; margin-bottom: 8px; line-height: 1.4; }
.blog-card h3 a { color: var(--ink); }
.blog-card h3 a:hover { color: var(--accent); }
.blog-card p { font-size: 0.88rem; margin-bottom: 16px; }

.blog-card-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-family: var(--ff-mono);
}

/* ── FAQ SECTION ─────────────────────────────────────────── */
.faq-section { padding: 80px 0; }

.faq-list { margin-top: 40px; }

.faq-item {
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--white);
  overflow: hidden;
}

.faq-q {
  padding: 20px 24px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  user-select: none;
}

.faq-q:hover { color: var(--accent); }

.faq-icon {
  width: 24px;
  height: 24px;
  border: 1px solid var(--grid);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  transition: transform var(--transition);
}

.faq-item.open .faq-icon { transform: rotate(45deg); }

.faq-a {
  padding: 0 24px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
}

.faq-item.open .faq-a {
  max-height: 300px;
  padding: 0 24px 20px;
}

.faq-a p { font-size: 0.92rem; }

/* ── BLOG PAGE ───────────────────────────────────────────── */
.blog-hero {
  padding: 72px 0 48px;
  border-bottom: 1px solid var(--grid);
}

.blog-list { padding: 64px 0; }

.blog-list-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 48px;
}

.blog-featured {
  background: var(--white);
  border: 1px solid var(--grid);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 32px;
}

.blog-featured-thumb {
  height: 240px;
  background: linear-gradient(135deg, var(--ink) 0%, #2d3561 50%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: 4rem;
  color: rgba(255,255,255,0.15);
}

.blog-featured-body { padding: 32px; }
.blog-featured-body .blog-card-tag { font-size: 0.75rem; }
.blog-featured-body h2 { font-size: 1.6rem; margin: 8px 0 12px; }
.blog-featured-body h2 a { color: var(--ink); }
.blog-featured-body h2 a:hover { color: var(--accent); }

.btn-read {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 22px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-read:hover { background: var(--accent); color: var(--white); }

.sidebar-widget {
  background: var(--white);
  border: 1px solid var(--grid);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.sidebar-widget h4 {
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--grid);
}

.sidebar-links { list-style: none; }
.sidebar-links li { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 0.88rem; }
.sidebar-links li:last-child { border-bottom: none; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  padding: 4px 12px;
  border: 1px solid var(--grid);
  border-radius: 100px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  transition: all var(--transition);
}
.tag-pill:hover { border-color: var(--accent); color: var(--accent); }

/* ── BLOG POST ───────────────────────────────────────────── */
.post-hero {
  padding: 72px 0 48px;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.post-tag {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 3px 12px;
  border-radius: 100px;
}

.post-date {
  font-family: var(--ff-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.post-read-time {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.post-content { padding: 56px 0 80px; }

.post-body { max-width: 720px; }

.post-body h2 {
  margin: 40px 0 16px;
  font-size: 1.7rem;
}

.post-body h3 {
  margin: 28px 0 12px;
  font-size: 1.2rem;
}

.post-body p { margin-bottom: 20px; line-height: 1.8; }

.post-body ul, .post-body ol {
  margin: 16px 0 24px 24px;
  color: var(--ink-soft);
}

.post-body li { margin-bottom: 8px; line-height: 1.7; }

.post-body .callout {
  background: var(--paper-alt);
  border-left: 4px solid var(--accent);
  padding: 20px 24px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 28px 0;
}

.post-body .callout p { margin: 0; }

.post-body .formula-block {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--ff-mono);
  font-size: 1rem;
  padding: 24px;
  border-radius: var(--radius);
  margin: 24px 0;
  overflow-x: auto;
  line-height: 1.8;
}

.post-sidebar {
  position: sticky;
  top: 80px;
}

.post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 64px;
  align-items: start;
}

.toc-list { list-style: none; }
.toc-list li { 
  padding: 6px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 0.85rem;
}
.toc-list li:last-child { border-bottom: none; }
.toc-list a { color: var(--ink-soft); }
.toc-list a:hover { color: var(--accent); }

/* ── FOOTER ──────────────────────────────────────────────── */
footer {
  background: var(--ink);
  color: rgba(250,249,246,0.6);
  padding: 64px 0 32px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 48px;
}

.footer-brand h3 {
  color: var(--paper);
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.footer-brand p { font-size: 0.88rem; max-width: 280px; }

.footer-col h4 {
  color: var(--paper);
  font-size: 0.8rem;
  font-family: var(--ff-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 8px; font-size: 0.88rem; }
.footer-col a { color: rgba(250,249,246,0.6); }
.footer-col a:hover { color: var(--paper); }

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid rgba(250,249,246,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── UTILITIES ───────────────────────────────────────────── */
.text-accent { color: var(--accent); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 32px;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .theory-grid { grid-template-columns: 1fr; }
  .blog-list-grid { grid-template-columns: 1fr; }
  .post-layout { grid-template-columns: 1fr; }
  .post-sidebar { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .order-row { grid-template-columns: 1fr; }
  .nav-links .nav-cta { display: none; }
  .hero { padding: 48px 0 40px; }
}

@media (max-width: 480px) {
  .calc-body { padding: 24px 20px 28px; }
  .calc-header { padding: 14px 20px; }
}
