/*
 * custom.css.j2 — Jinja2 template that renders to static/css/custom.css at build time.
 * The build pipeline injects values from the site.yml brand section.
 *
 * IMPORTANT: do NOT write Jinja2 variable syntax (double-brace) inside CSS
 * comments. Jinja2 parses those before they reach CSS, so any literal example
 * of variable interpolation belongs OUTSIDE comments or in escaped form.
 *
 * Layered approach:
 *   - CSS variables from the site.yml brand palette
 *   - Component styles (calculator card, result block, comparison table, ad slots)
 *   - Responsive breakpoints
 *
 * Loaded AFTER Pico CSS classless (which provides typography and basic layout).
 *
 * Reference: docs/03-repo-y-build.md §3.7.2, docs/05-adsense.md §5.3.3
 */

:root {
  --ch-primary:   #10007a;
  --ch-secondary: #12168c;
  --ch-accent:    #1e73be;
  --ch-text:      #222222;
  --ch-muted:     #595959;
  --ch-error:     #cf2e2e;
  --ch-bg-light:  #f7f8f9;
  --ch-radius:    12px;
  --ch-radius-sm: 6px;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ch-text);
  line-height: 1.6;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===================================================================== */
/* Breadcrumbs                                                           */
/* ===================================================================== */

nav.breadcrumbs {
  font-size: 0.875rem;
  color: var(--ch-muted);
  margin-bottom: 1rem;
}

nav.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

nav.breadcrumbs li:not(:last-child)::after {
  content: " / ";
  margin: 0 0.25rem;
  color: var(--ch-muted);
}

nav.breadcrumbs a {
  color: var(--ch-muted);
  text-decoration: none;
}

nav.breadcrumbs a:hover {
  color: var(--ch-primary);
  text-decoration: underline;
}

/* ===================================================================== */
/* Hero image (SVG)                                                       */
/* ===================================================================== */

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--ch-radius);
  margin: 1rem 0;
}

/* ===================================================================== */
/* H1 + Summary                                                           */
/* ===================================================================== */

h1.calc-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin: 1rem 0 0.5rem;
  color: var(--ch-text);
}

.calc-summary {
  font-size: 1.125rem;
  color: var(--ch-muted);
  margin-bottom: 1.5rem;
}

/* ===================================================================== */
/* Calculator card (form container)                                       */
/* ===================================================================== */

.calculator-card {
  background: var(--ch-bg-light);
  border-radius: var(--ch-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.calculator-card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.calc-input-group {
  margin-bottom: 1rem;
}

.calc-input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.calc-input-group .hint {
  display: block;
  color: var(--ch-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.calc-input-group input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--ch-radius-sm);
  font-size: 1rem;
  transition: border-color 0.15s;
}

.calc-input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--ch-primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.calc-input-with-unit {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.calc-input-with-unit select {
  padding: 0.625rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--ch-radius-sm);
  font-size: 1rem;
  background: white;
}

.btn-calculate {
  display: inline-block;
  background: var(--ch-primary);
  color: white;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: var(--ch-radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
  width: 100%;
}

.btn-calculate:hover {
  background: var(--ch-secondary);
}

.btn-calculate:active {
  transform: translateY(1px);
}

/* ===================================================================== */
/* Result block — hidden by default, revealed via .visible by JS         */
/* ===================================================================== */

.calc-result {
  display: none;
  background: var(--ch-primary);
  color: white;
  padding: 1.5rem;
  border-radius: var(--ch-radius);
  margin-top: 1rem;
}

.calc-result.visible {
  display: block;
}

.calc-result .result-label {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.calc-result .result-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0.25rem 0;
}

.calc-result .result-unit {
  font-size: 1.125rem;
  opacity: 0.9;
}

.calc-result .result-detail {
  font-size: 0.95rem;
  margin-top: 0.75rem;
  opacity: 0.92;
}

/* Breakdown items below the headline result */
.calc-result .result-breakdown {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.5rem;
}

.calc-result .result-item {
  display: flex;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.5rem 0.75rem;
  border-radius: var(--ch-radius-sm);
}

.calc-result .item-label {
  opacity: 0.9;
}

.calc-result .item-value {
  font-weight: 600;
}

/* ===================================================================== */
/* Comparison table (AEO-friendly)                                        */
/* ===================================================================== */

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  margin: 1rem 0;
}

.comparison-table thead {
  background: var(--ch-primary);
  color: white;
}

.comparison-table th,
.comparison-table td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.comparison-table tbody tr:nth-child(odd) {
  background: var(--ch-bg-light);
}

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

.faq-list {
  display: grid;
  gap: 1rem;
}

.faq-item h3 {
  font-size: 1.0625rem;
  margin: 0 0 0.25rem;
}

.faq-item p {
  margin: 0;
  color: var(--ch-muted);
}

/* ===================================================================== */
/* Sources, related tools, related posts                                  */
/* ===================================================================== */

.sources-list,
.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.sources-list li::before {
  content: "↗ ";
  color: var(--ch-primary);
}

.related-list .related-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--ch-bg-light);
  border-radius: var(--ch-radius-sm);
  text-decoration: none;
  color: var(--ch-text);
}

.related-list .related-item:hover {
  background: #dcfce7;
}

.related-list .related-icon {
  font-size: 1.5rem;
}

/* ===================================================================== */
/* Ad containers — CRITICAL: min-height to prevent CLS                   */
/* See docs/05-adsense.md §5.3.3                                         */
/* ===================================================================== */

.ad-container {
  margin: 1.5rem 0;
  text-align: center;
  min-height: 100px;
}

.ad-pre-form {
  margin: 1.5rem 0;
  min-height: 100px;
}

.ad-post-result {
  margin: 2rem 0;
  min-height: 250px;
}

.ad-post-h2-1,
.ad-post-h2-2 {
  margin: 2.5rem 0;
  min-height: 250px;
}

/* Optional sticky mobile anchor — DISABLED by default. Enable via JS or
   by uncommenting the class addition in the template. */
.ad-sticky-mobile {
  display: none;  /* default */
}

/* ===================================================================== */
/* Disclaimer                                                             */
/* ===================================================================== */

.disclaimer {
  font-size: 0.875rem;
  color: var(--ch-muted);
  background: #fef9c3;
  padding: 0.75rem 1rem;
  border-radius: var(--ch-radius-sm);
  margin: 1.5rem 0;
}

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

.calc-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: var(--ch-muted);
  text-align: center;
}

.calc-footer .last-updated {
  display: block;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.back-to-site {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--ch-primary);
  text-decoration: none;
  font-weight: 500;
}

.back-to-site:hover {
  text-decoration: underline;
}

/* ===================================================================== */
/* Hub + category landings                                                */
/* ===================================================================== */

.category-section {
  margin: 2rem 0;
}

.category-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.calc-card {
  display: block;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--ch-radius);
  padding: 1rem;
  text-decoration: none;
  color: var(--ch-text);
  transition: border-color 0.15s, transform 0.15s;
}

.calc-card:hover {
  border-color: var(--ch-primary);
  transform: translateY(-2px);
}

.calc-card h3 {
  font-size: 1.0625rem;
  margin: 0 0 0.25rem;
  color: var(--ch-text);
}

.calc-card p {
  font-size: 0.9375rem;
  color: var(--ch-muted);
  margin: 0;
}

/* ===================================================================== */
/* Responsive — mobile first, adjust upward                              */
/* ===================================================================== */

@media (max-width: 768px) {
  main {
    padding: 0.75rem;
  }

  h1.calc-title {
    font-size: 1.5rem;
  }

  .calculator-card {
    padding: 1rem;
  }

  .calc-result .result-value {
    font-size: 2rem;
  }

  .ad-container {
    margin: 1rem 0;
  }

  .ad-post-result,
  .ad-post-h2-1,
  .ad-post-h2-2 {
    min-height: 100px;
  }
}