/* ===== Design tokens ===== */
:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-accent: #3b82f6;
  --color-accent-dark: #2563eb;
  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-win: #dcfce7;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.10);

  --container-width: 1120px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--color-accent-dark); }

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; color: var(--color-text-muted); }

@media (min-width: 768px) {
  h1 { font-size: 2.5rem; }
  h2 { font-size: 1.85rem; }
}

@media (min-width: 1024px) {
  h1 { font-size: 3rem; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.85em 1.6em;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--color-accent-dark); }
.btn-secondary {
  background: transparent;
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
}
.btn-secondary:hover { background: var(--color-bg-alt); }
.btn-sm { padding: 0.5em 1em; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn:focus-visible,
.icon-btn:focus-visible,
.nav-toggle:focus-visible,
.subtool-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===== Top navigation ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: saturate(180%) blur(6px);
  z-index: 100;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}
.nav-logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}
.nav-logo span { color: var(--color-accent); }
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-links {
  list-style: none;
  display: flex;
  gap: 24px;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.nav-links a:hover { color: var(--color-accent-dark); }

@media (max-width: 767px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 8px 20px 16px;
    gap: 4px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { display: block; padding: 10px 0; }
}
@media (min-width: 768px) {
  .nav-toggle { display: none; }
}

/* Anchor targets should clear the sticky header */
#explore-tools, .subtool-panels { scroll-margin-top: 90px; }

/* Sub-tool selector cards (used on merged pages like Feature Comparison Table) */
.subtool-card {
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}
.subtool-card.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}
.subtool-card .card-link { pointer-events: none; }
.subtool-panels { margin-top: 32px; }
.subtool-panel[hidden] { display: none; }

/* ===== Hero ===== */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}
.hero p.lead {
  max-width: 640px;
  margin: 0 auto 1.5em;
  font-size: 1.1rem;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Sections & cards ===== */
section { padding: 40px 0; }
.section-alt { background: var(--color-bg-alt); }
.section-title { text-align: center; margin-bottom: 8px; }
.section-subtitle { text-align: center; max-width: 620px; margin: 0 auto 2em; }

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 0.4em; }
.card p { margin-bottom: 0.6em; font-size: 0.95rem; }
.card a.card-link { font-size: 0.9rem; font-weight: 600; text-decoration: none; }

/* ===== Tool layout ===== */
.tool-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}
.tool-step-badge {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--color-text-muted);
}

.tool-panel {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.tool-panel h2 { font-size: 1.2rem; margin-bottom: 4px; }
.tool-panel .panel-hint { font-size: 0.9rem; margin-bottom: 1em; }

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
@media (min-width: 768px) {
  .field-row.criteria-row { grid-template-columns: 2fr 1fr auto; }
  .field-row.option-row { grid-template-columns: 1fr auto; }
}

input[type="text"], input[type="number"], input[type="range"], select, textarea {
  width: 100%;
  padding: 0.6em 0.75em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
label { font-size: 0.85rem; font-weight: 600; color: var(--color-text); display: block; margin-bottom: 4px; }

.icon-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: #b91c1c;
  font-size: 1rem;
  line-height: 1;
}
.icon-btn:hover { background: #fef2f2; }

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
  margin-left: 6px;
}
.tooltip .tooltip-bubble {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: 6px;
  width: 220px;
  transition: opacity .15s ease;
  z-index: 10;
}
.tooltip:hover .tooltip-bubble,
.tooltip:focus .tooltip-bubble { visibility: visible; opacity: 1; }

/* Results */
.results {
  margin-top: 24px;
}
.result-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: #fff;
}
.result-row.winner { background: var(--color-win); border-color: var(--color-success); }
.result-rank { font-weight: 800; color: var(--color-text-muted); }
.result-row.winner .result-rank { color: var(--color-success); }
.result-name { font-weight: 600; }
.result-score { font-weight: 800; }
.result-bar-track {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--color-bg-alt);
  border-radius: 999px;
  overflow: hidden;
}
.result-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 999px;
}
.result-row.winner .result-bar-fill { background: var(--color-success); }

/* Comparison table */
.comparison-table-wrap { overflow-x: auto; }
table.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.comparison-table th, table.comparison-table td {
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  text-align: left;
}
table.comparison-table th { background: var(--color-bg-alt); }
table.comparison-table td.best-cell { background: var(--color-win); font-weight: 700; }

/* Helper / callout blocks */
.callout {
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 24px;
  font-size: 0.95rem;
}
.callout strong { color: var(--color-text); }

/* Topic-specific scoring-tips blocks */
.tips-block {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.tips-block .tips-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-accent-dark);
  margin-bottom: 8px;
}
.tips-block ul { margin: 0; padding-left: 1.2em; }
.tips-block li { font-size: 0.92rem; color: var(--color-text); margin-bottom: 4px; }
.tips-block li:last-child { margin-bottom: 0; }

/* FAQ */
.faq-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 1024px) {
  .faq-layout { grid-template-columns: 2.2fr 1fr; }
}
.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 18px 0;
}
.faq-item h3 { margin-bottom: 0.4em; }
.faq-sidebar-cta {
  position: sticky;
  top: 90px;
  align-self: start;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 14px 0 0;
}
.breadcrumb a { color: var(--color-text-muted); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* Blog */
.blog-card p.blog-meta { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 0.5em; }
article.post { max-width: 720px; margin: 0 auto; }
article.post h2 { margin-top: 1.4em; }
article.post p { color: var(--color-text); }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  padding: 40px 0 24px;
  margin-top: 40px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
}
.footer-col h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); margin-bottom: 0.8em; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--color-text); text-decoration: none; font-size: 0.9rem; }
.footer-col a:hover { color: var(--color-accent-dark); }
.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.footer-bottom a { color: var(--color-text-muted); margin-left: 16px; text-decoration: none; }
.footer-bottom a:hover { text-decoration: underline; }

/* Utility */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #eff6ff;
  color: var(--color-accent-dark);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
