/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1a1a1a;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: #1d4ed8;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Focus styles (WCAG 2.1 AA) ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #166534;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== Skip-to-content link ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: #166534;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 0.375rem 0.375rem;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 200;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
  outline: none;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: #166534;
  text-decoration: none;
}
.site-logo:hover {
  text-decoration: none;
  color: #14532d;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.nav-links a {
  font-size: 0.875rem;
  color: #374151;
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: #166534;
}
.nav-links a[aria-current="page"] {
  font-weight: 700;
  border-bottom: 2px solid #166534;
  padding-bottom: 2px;
}

/* ===== Article ===== */
.article-container {
  max-width: 48rem;
  margin: 0 auto;
}

.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  color: #111;
  margin-bottom: 0.75rem;
}

.article-meta {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

.article-meta .separator {
  margin: 0 0.5rem;
}

.hero-image {
  width: 100%;
  border-radius: 0.5rem;
  margin-top: 1rem;
  aspect-ratio: 1200 / 630;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 50%, #f9fafb 100%);
  object-fit: cover;
}

/* ===== Prose (article body) ===== */
.prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  color: #111;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: #1f2937;
}

.prose h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul, .prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose blockquote {
  border-left: 4px solid #166534;
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  background: #f0fdf4;
  border-radius: 0 0.375rem 0.375rem 0;
  font-size: 0.95rem;
  color: #374151;
}

.prose strong {
  font-weight: 700;
}

.prose hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 2rem 0;
}

/* ===== Tables ===== */
.prose .table-wrapper {
  position: relative;
  overflow: hidden;
  margin: 1.5rem 0;
}
.prose .table-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2rem;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.prose .table-wrapper.has-scroll::after {
  opacity: 1;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.prose thead {
  background: #f9fafb;
}

.prose th {
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

.prose td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}

.prose tr:nth-child(even) {
  background: #f9fafb;
}

/* ===== Code ===== */
.prose code {
  background: #f3f4f6;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.prose pre {
  background: #1f2937;
  color: #e5e7eb;
  padding: 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ===== Calculator / Tool Styling ===== */
.masterblend-calculator,
.ppfd-cheat-sheet-tool {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.calculator-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.calculator-row label {
  font-weight: 600;
  min-width: 120px;
}

.calculator-row input,
.calculator-row select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
}

.calculator-row input[type="number"] {
  width: 100%;
  max-width: 120px;
}

#calculate-btn {
  background: #166534;
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1rem;
}
#calculate-btn:hover {
  background: #14532d;
}

.calculator-results {
  margin-top: 1rem;
}

.calculator-results .warning {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 0.75rem 1rem;
  border-radius: 0 0.375rem 0.375rem 0;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ===== Verdict / TL;DR box ===== */
/* Targets the H2 containing "TL;DR" or "Verdict" — auto-styled via sibling selector */
.prose h2[id^="tldr"],
.prose h2[id*="verdict"] {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 2px solid #166534;
  border-bottom: 2px solid #166534;
  border-radius: 0.75rem 0.75rem 0 0;
  padding: 1rem 1.25rem;
  margin-bottom: 0;
  color: #166534;
}

/* ===== Affiliate disclosure styling ===== */
.prose > blockquote:first-child,
.prose > hr:first-of-type + blockquote,
blockquote:has(strong:first-child) {
  background: #fffbeb;
  border-left-color: #f59e0b;
  font-size: 0.85rem;
}

/* ===== Affiliate CTA buttons ===== */
.prose a[href^="/go/"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #166534;
  color: #fff;
  padding: 0.625rem 1.25rem;
  min-height: 44px;
  min-width: 44px;
  border-radius: 0.375rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  margin: 0.25rem 0.25rem 0.25rem 0;
}
.prose a[href^="/go/"]:hover {
  background: #14532d;
  text-decoration: none;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  margin-top: 3rem;
}

.footer-container {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 0.875rem;
  color: #4b5563;
}

.footer-disclosure {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 36rem;
  margin: 0.75rem auto;
  line-height: 1.5;
}

.footer-copyright {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 0.75rem;
}

/* ===== Hamburger Nav Toggle ===== */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 4px;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: #374151;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ===== 404 helper ===== */
.error-page {
  text-align: center;
  padding: 4rem 1.5rem;
}
.error-page h1 {
  font-size: 3rem;
  color: #166534;
  margin-bottom: 1rem;
}
.error-page p {
  font-size: 1.125rem;
  color: #6b7280;
  margin-bottom: 2rem;
}
.error-page a {
  display: inline-block;
  background: #166534;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  font-weight: 600;
  text-decoration: none;
}
.error-page a:hover {
  background: #14532d;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding: 0.5rem 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.5rem;
  }
  .nav-links.nav-open {
    display: flex;
  }
  .nav-links li {
    width: 100%;
  }
  .nav-links a {
    display: block;
    padding: 0.625rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid #f3f4f6;
  }
  .nav-container {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .article-header h1 {
    font-size: 1.5rem;
  }
  .prose h2 {
    font-size: 1.25rem;
  }
  .prose h3 {
    font-size: 1.1rem;
  }
  .prose table {
    font-size: 0.8rem;
  }
  .prose th, .prose td {
    padding: 0.5rem;
  }
}

/* ===== Print ===== */
@media print {
  .site-header,
  .site-footer,
  .nav-toggle,
  .toc,
  .skip-link,
  .prose a[href^="/go/"] {
    display: none !important;
  }
  main {
    max-width: 100%;
    padding: 0;
  }
  .prose a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  .prose a[href^="/"]::after {
    content: " (indoorfoodgrower.com" attr(href) ")";
  }
  .hero-image {
    max-height: 300px;
  }
}
