/* ================================================================
   TinyHumanMD | Shared Design System for Tool Pages
   Imports the same design tokens as the main site
   ================================================================ */

:root {
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  --s-20: 80px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --text-xs: 0.6875rem; --text-sm: 0.8125rem; --text-base: 0.9375rem;
  --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.75rem; --text-3xl: 2.25rem;
  --leading-tight: 1.15; --leading-normal: 1.55; --leading-relaxed: 1.7;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;

  --c-primary: #2563eb;
  --c-primary-soft: #eff4ff;
  --c-primary-mid: #dbe8fe;
  --c-green: #16a34a; --c-green-soft: #ecfdf3;
  --c-amber: #d97706; --c-amber-soft: #fffbeb;
  --c-purple: #7c3aed; --c-purple-soft: #f3f0ff;
  --c-red: #dc2626; --c-red-soft: #fef2f2;

  --c-text: #111827; --c-text-secondary: #4b5563; --c-text-muted: #9ca3af;
  --c-bg: #f8fafc; --c-surface: #ffffff;
  --c-border: #e5e7eb; --c-border-light: #f3f4f6;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);

  --ease: cubic-bezier(.4,0,.2,1);
  --dur: 200ms;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--font); font-size: var(--text-base); color: var(--c-text);
  background: var(--c-bg); line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--s-6); }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--c-primary); color: #fff; padding: var(--s-3) var(--s-4);
  font-weight: 600; border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.skip-link:focus { left: var(--s-4); }

/* ── Shared Header ────────────────────────────────────────────── */
.tool-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--c-border);
}
.tool-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: var(--s-4);
}
.tool-logo {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: var(--text-lg); color: var(--c-text);
  text-decoration: none; white-space: nowrap;
}
.tool-logo:hover { text-decoration: none; }

.tool-nav { flex: 1; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tool-nav-list { display: flex; gap: var(--s-1); }
.tool-nav-link {
  padding: 6px 12px; border-radius: var(--r-full); font-size: var(--text-sm);
  font-weight: 500; color: var(--c-text-secondary); white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  text-decoration: none;
}
.tool-nav-link:hover { color: var(--c-text); background: var(--c-border-light); text-decoration: none; }
.tool-nav-link:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.tool-nav-link.is-active { color: var(--c-primary); background: var(--c-primary-soft); }

.tool-suggest-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-1); padding: 6px 12px; border-radius: var(--r-full);
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text); font-size: var(--text-sm); font-weight: 600;
  white-space: nowrap; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tool-suggest-btn:hover { background: var(--c-border-light); text-decoration: none; }
.tool-suggest-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.tool-mobile-suggest {
  display: flex; width: 100%; padding: 10px 14px; border-radius: var(--r-md);
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text); font-size: var(--text-sm); font-weight: 600;
}
.tool-mobile-suggest:hover { background: var(--c-border-light); }

.tool-mobile-btn {
  display: none; background: none; border: none; color: var(--c-text);
  padding: var(--s-2); border-radius: var(--r-sm);
}

/* Mobile nav overlay */
.tool-mobile-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.3); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.tool-mobile-overlay.is-open { opacity: 1; pointer-events: auto; }
.tool-mobile-panel {
  position: absolute; top: 0; right: 0; width: 280px; height: 100%;
  background: var(--c-surface); box-shadow: var(--shadow-lg);
  padding: var(--s-6);
  transform: translateX(100%);
  transition: transform 300ms var(--ease);
}
.tool-mobile-overlay.is-open .tool-mobile-panel { transform: translateX(0); }
.tool-mobile-close {
  display: flex; background: none; border: none; color: var(--c-text-secondary);
  margin-bottom: var(--s-6);
}
.tool-mobile-list { display: flex; flex-direction: column; gap: var(--s-2); }
.tool-mobile-list a {
  display: block; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
  font-size: var(--text-base); font-weight: 500; color: var(--c-text);
  transition: background var(--dur) var(--ease); text-decoration: none;
}
.tool-mobile-list a:hover { background: var(--c-border-light); }
.tool-mobile-list a.is-active { color: var(--c-primary); background: var(--c-primary-soft); }

/* ── Tool Page Layout ──────────────────────────────────────── */
.tool-hero {
  padding: var(--s-12) 0 var(--s-8);
  text-align: center;
  background: linear-gradient(180deg, #fff 0%, var(--c-bg) 100%);
}
.tool-hero-inner { max-width: 640px; margin: 0 auto; }
.tool-hero .badge {
  display: inline-block; font-size: var(--text-xs); font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: var(--s-4);
}
.badge-blue { background: var(--c-primary-soft); color: var(--c-primary); }
.badge-green { background: var(--c-green-soft); color: var(--c-green); }
.badge-amber { background: var(--c-amber-soft); color: var(--c-amber); }
.badge-red { background: var(--c-red-soft); color: var(--c-red); }
.tool-title {
  font-size: clamp(1.75rem, 4.5vw, var(--text-3xl)); font-weight: 800;
  line-height: var(--leading-tight); letter-spacing: -.025em;
  color: var(--c-text); margin-bottom: var(--s-4);
}
.tool-subtitle {
  font-size: var(--text-lg); color: var(--c-text-secondary);
  max-width: 520px; margin: 0 auto; line-height: var(--leading-relaxed);
}

/* ── Form Controls ────────────────────────────────────────── */
.tool-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-6);
  box-shadow: var(--shadow-sm); margin-bottom: var(--s-6);
}
.tool-card h3 {
  font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--s-4);
}
.form-row {
  display: flex; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-4);
}
.form-row:last-child { margin-bottom: 0; }
.form-group { flex: 1; min-width: 140px; }
.form-group label {
  display: block; font-size: var(--text-sm); font-weight: 600;
  color: var(--c-text-secondary); margin-bottom: var(--s-1);
}
.form-group input,
.form-group select {
  width: 100%; height: 44px; padding: 0 var(--s-3);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-base);
  background: var(--c-surface); color: var(--c-text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: var(--s-8);
}
.form-group .helper {
  display: block; font-size: var(--text-xs); color: var(--c-text-muted);
  margin-top: var(--s-1);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px 24px; border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-sm); font-weight: 600;
  border: none; cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--c-border-light); color: var(--c-text); }
.btn-secondary:hover { background: var(--c-border); }

/* ── Results ───────────────────────────────────────────────── */
.result-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-3); margin-top: var(--s-4);
}
.result-item {
  background: var(--c-bg); border-radius: var(--r-md); padding: var(--s-4);
  text-align: center;
}
.result-value {
  font-size: var(--text-2xl); font-weight: 800; color: var(--c-primary);
  line-height: 1;
}
.result-label {
  font-size: var(--text-xs); color: var(--c-text-secondary);
  margin-top: var(--s-1); font-weight: 500;
}
.result-value.is-warning { color: var(--c-amber); }
.result-value.is-danger { color: var(--c-red); }
.result-value.is-ok { color: var(--c-green); }

/* ── Chart Container ──────────────────────────────────────── */
.chart-wrap {
  position: relative; width: 100%; min-height: 300px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-4);
  box-shadow: var(--shadow-sm);
}
.chart-wrap canvas { width: 100% !important; }

/* ── Privacy Banner ───────────────────────────────────────── */
.privacy-banner {
  text-align: center; padding: var(--s-3) var(--s-4);
  font-size: var(--text-xs); color: var(--c-text-muted);
  background: var(--c-border-light); border-radius: var(--r-md);
  margin: var(--s-6) 0;
}
.privacy-banner svg { vertical-align: -2px; margin-right: 4px; }

/* ── Footer ───────────────────────────────────────────────── */
.tool-footer {
  padding: var(--s-10) 0; border-top: 1px solid var(--c-border); text-align: center;
}
.tool-footer-inner { max-width: 560px; margin: 0 auto; }
.tool-footer p {
  font-size: var(--text-sm); color: var(--c-text-secondary);
  line-height: var(--leading-relaxed);
}
.tool-footer .disclaimer {
  margin-top: var(--s-3); font-size: var(--text-xs); color: var(--c-text-muted);
}

.footer-disclaimer-short {
  margin-top: var(--s-3); font-size: 11px; color: var(--c-text-muted); font-style: italic;
}

/* ── FAQ Section (SEO rich content) ────────────────────────── */
.faq-section {
  padding: var(--s-12) 0; border-top: 1px solid var(--c-border);
}
.faq-section h2 {
  font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em;
  margin-bottom: var(--s-6);
}
.faq-item {
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  margin-bottom: var(--s-3); overflow: hidden;
  background: var(--c-surface);
}
.faq-question {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-5); cursor: pointer;
  font-size: var(--text-base); font-weight: 600; color: var(--c-text);
  background: none; border: none; width: 100%; text-align: left;
  font-family: var(--font);
  transition: background var(--dur) var(--ease);
}
.faq-question:hover { background: var(--c-border-light); }
.faq-question svg {
  flex-shrink: 0; transition: transform var(--dur) var(--ease);
  color: var(--c-text-muted);
}
.faq-item.is-open .faq-question svg { transform: rotate(180deg); }
.faq-answer {
  display: none; padding: 0 var(--s-5) var(--s-5);
  font-size: var(--text-sm); color: var(--c-text-secondary);
  line-height: var(--leading-relaxed);
}
.faq-answer p { margin-bottom: var(--s-3); }
.faq-answer p:last-child { margin-bottom: 0; }
.faq-answer ul { margin: var(--s-2) 0 var(--s-3) var(--s-5); }
.faq-answer li { margin-bottom: var(--s-1); }
.faq-answer strong { color: var(--c-text); }
.faq-item.is-open .faq-answer { display: block; }

/* ── Cross-linking / Related Tools ────────────────────────── */
.related-tools {
  padding: var(--s-10) 0;
}
.related-tools h2 {
  font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--s-5);
  text-align: center;
}
.tools-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s-3);
}
.tool-link-card {
  display: block; padding: var(--s-4) var(--s-5);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); text-decoration: none;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tool-link-card:hover {
  box-shadow: var(--shadow-md); transform: translateY(-1px);
  text-decoration: none;
}
.tool-link-card h3 {
  font-size: var(--text-base); font-weight: 700; color: var(--c-text);
  margin-bottom: var(--s-1);
}
.tool-link-card p {
  font-size: var(--text-xs); color: var(--c-text-secondary);
  line-height: var(--leading-normal); margin: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .tool-nav { display: none; }
  .tool-suggest-btn { display: none; }
  .tool-mobile-btn { display: flex; }
  .tool-hero { padding: var(--s-8) 0 var(--s-6); }
  .tool-title { font-size: 1.5rem; }
  .tool-subtitle { font-size: var(--text-sm); }
  .tool-card { padding: var(--s-4); }
  .form-row { flex-direction: column; gap: var(--s-3); }
  .form-group { min-width: 100%; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { padding: var(--s-2); min-height: 250px; }
}
@media (max-width: 480px) {
  .container { padding: 0 var(--s-3); }
  .tool-title { font-size: 1.375rem; }
  .result-grid { grid-template-columns: 1fr 1fr; }
}
