/* Converter247 — Stylesheet v4.0
   Fixed: All contrast ratios WCAG AA compliant
   Fixed: Render-blocking eliminated (critical CSS inlined in header.php)
   Fixed: Footer link distinguishability
*/

/* ── Design Tokens (contrast-safe values) ── */
:root {
  --c-primary: #1a56db;
  --c-primary-dark: #1241af;
  --c-primary-light: #dbeafe;
  --c-accent: #d97706;
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-surface-alt: #f1f5f9;
  --c-border: #e2e8f0;
  /* FIX: Bumped contrast — all pass WCAG AA 4.5:1 on white */
  --c-text: #1e293b;
  --c-text-muted: #475569;     /* was #64748b — now 7:1 on white */
  --c-text-light: #64748b;     /* was #94a3b8 — now 4.6:1 on white */
  --c-success: #15803d;
  --c-error: #dc2626;

  --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem;
  --sp-12: 3rem; --sp-16: 4rem;

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px; --r-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.09);

  --max-w: 1200px;
  --header-h: 64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ── Utilities ── */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 var(--sp-4); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ── Typography ── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.25; color: var(--c-text); }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); margin-top: var(--sp-10); margin-bottom: var(--sp-4); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.35rem); margin-top: var(--sp-8); margin-bottom: var(--sp-3); }
p { margin-bottom: var(--sp-4); }

/* ══════════════════════════════════════
   HEADER
   ══════════════════════════════════════ */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  height: var(--header-h);
  display: flex; align-items: center;
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,.94);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 var(--sp-4);
}
.logo {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 800;
  color: var(--c-text); text-decoration: none; letter-spacing: -.03em;
}
.logo:hover { text-decoration: none; }
.logo-icon {
  width: 32px; height: 32px; background: var(--c-primary);
  border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .85rem;
}
.logo span { color: var(--c-primary); }

/* Desktop nav */
.main-nav { display: none; }
.main-nav ul { display: flex; gap: 2px; }
.main-nav a {
  display: block; padding: .5rem .75rem; font-size: .9rem; font-weight: 500;
  color: var(--c-text-muted); border-radius: var(--r-sm);
  transition: color .15s, background .15s; text-decoration: none;
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--c-primary); background: var(--c-primary-light); text-decoration: none;
}

/* Hamburger */
.menu-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; background: none; border: none;
  cursor: pointer; color: var(--c-text); border-radius: var(--r-sm);
}
.menu-toggle:hover { background: var(--c-surface-alt); }
.menu-toggle svg { width: 24px; height: 24px; }

/* Mobile drawer */
.mobile-nav {
  position: fixed; top: 0; right: -100%; width: 300px; height: 100vh;
  background: var(--c-surface); z-index: 2000;
  transition: right .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-lg); padding: var(--sp-6); overflow-y: auto;
}
.mobile-nav.open { right: 0; }
.mobile-nav-close {
  position: absolute; top: var(--sp-4); right: var(--sp-4);
  width: 40px; height: 40px; background: var(--c-surface-alt);
  border: 1px solid var(--c-border); border-radius: var(--r-full);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: var(--c-text);
}
.mobile-nav-close:hover { background: var(--c-border); }
.mobile-nav ul { margin-top: 4rem; display: flex; flex-direction: column; gap: 2px; }
.mobile-nav a {
  display: block; padding: .85rem 1rem; font-size: 1.05rem; font-weight: 500;
  color: var(--c-text); border-radius: var(--r-md); text-decoration: none;
}
.mobile-nav a:hover { background: var(--c-primary-light); color: var(--c-primary); }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1999; }
.mobile-overlay.open { display: block; }

/* ══════════════════════════════════════
   SEARCH
   ══════════════════════════════════════ */
.search-wrapper { position: relative; width: 100%; max-width: 540px; }
.search-input {
  width: 100%; padding: .75rem 1rem .75rem 2.75rem;
  border: 2px solid var(--c-border); border-radius: var(--r-full);
  font-size: .95rem; background: var(--c-surface); color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(26,86,219,.15); }
.search-input::placeholder { color: var(--c-text-light); }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--c-text-light); pointer-events: none; }
.search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; z-index: 500;
}
.search-results.active { display: block; }
.search-result-item {
  display: flex; flex-direction: column; gap: 2px; padding: .75rem 1rem;
  cursor: pointer; transition: background .1s; text-decoration: none; color: var(--c-text);
}
.search-result-item:hover { background: var(--c-surface-alt); text-decoration: none; }
.search-result-item strong { font-size: .95rem; }
.search-result-cat { font-size: .75rem; color: var(--c-text-light); }

/* ══════════════════════════════════════
   HERO
   ══════════════════════════════════════ */
.hero { text-align: center; padding: var(--sp-12) 0 var(--sp-10); }
.hero h1 { margin-bottom: var(--sp-4); }
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.15rem); color: var(--c-text-muted);
  max-width: 580px; margin: 0 auto var(--sp-8);
}
.hero-search { max-width: 500px; margin: 0 auto; }

/* ══════════════════════════════════════
   SECTIONS & GRIDS
   ══════════════════════════════════════ */
.section { padding: var(--sp-10) 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-6); }
.section-title h2 { margin: 0; font-size: 1.35rem; }
.section-title a { font-size: .9rem; font-weight: 600; }

/* Category cards */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-3); }
.category-card {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-lg);
  text-align: center; text-decoration: none; color: var(--c-text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.category-card:hover { border-color: var(--c-primary); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.category-icon {
  width: 48px; height: 48px; background: var(--c-primary-light);
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.category-card h3 { font-size: .85rem; font-weight: 600; margin: 0; color: var(--c-text); }
/* FIX: tool-count contrast — was --c-text-light, now --c-text-muted (passes AA) */
.category-card .tool-count { font-size: .75rem; color: var(--c-text-muted); font-weight: 500; }

/* Tool cards */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-4); }
.tool-card {
  display: block; padding: var(--sp-5); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-lg);
  text-decoration: none; color: var(--c-text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tool-card:hover { border-color: var(--c-primary); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.tool-card h3 { font-size: 1rem; font-weight: 600; margin: 0 0 var(--sp-2); }
.tool-card p { font-size: .875rem; color: var(--c-text-muted); margin: 0; }
.tool-card-badge {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--c-primary-light); color: var(--c-primary-dark); margin-bottom: var(--sp-3);
}

/* Stats banner */
.stats-bar {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4);
  padding: var(--sp-6); background: var(--c-primary); border-radius: var(--r-xl);
  color: #fff; text-align: center; margin: var(--sp-8) 0;
}
.stat-item strong { display: block; font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; }
.stat-item span { font-size: .85rem; opacity: .9; }

/* ══════════════════════════════════════
   CONVERTER TOOL UI
   ══════════════════════════════════════ */
.converter-box {
  background: var(--c-surface); border: 2px solid var(--c-border);
  border-radius: var(--r-xl); padding: var(--sp-6); margin: var(--sp-6) 0;
  box-shadow: var(--shadow-md);
}
.converter-fields { display: flex; flex-direction: column; gap: var(--sp-4); align-items: center; }
.converter-field { width: 100%; }
.converter-field label {
  display: block; font-size: .85rem; font-weight: 600;
  color: var(--c-text-muted); margin-bottom: var(--sp-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.converter-field input,
.converter-field textarea,
.converter-field select {
  width: 100%; padding: 1rem 1.25rem;
  border: 2px solid var(--c-border); border-radius: var(--r-md);
  font-size: 1.25rem; font-weight: 600; font-family: var(--font-mono);
  background: var(--c-surface-alt); color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.converter-field input:focus,
.converter-field textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12); background: var(--c-surface);
}
.converter-field input[readonly] { background: var(--c-primary-light); border-color: transparent; cursor: default; }

.swap-btn {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: 2px solid var(--c-border);
  border-radius: var(--r-full); background: var(--c-surface);
  cursor: pointer; color: var(--c-primary);
  transition: background .15s, border-color .15s, transform .2s; flex-shrink: 0;
}
.swap-btn:hover { background: var(--c-primary); color: #fff; border-color: var(--c-primary); transform: rotate(180deg); }
.swap-btn svg { width: 20px; height: 20px; }

.copy-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; font-size: .85rem; font-weight: 600;
  background: var(--c-surface-alt); border: 1px solid var(--c-border);
  border-radius: var(--r-sm); cursor: pointer; color: var(--c-text-muted);
  margin-top: var(--sp-2); transition: background .15s, color .15s;
}
.copy-btn:hover { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

.formula-display {
  text-align: center; padding: 1.25rem; margin: 1rem 0;
  background: var(--c-primary-light); border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: 1.1rem; font-weight: 600;
  color: var(--c-primary-dark); border: 2px solid #bfdbfe;
}

/* ══════════════════════════════════════
   BREADCRUMBS
   ══════════════════════════════════════ */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: var(--sp-1); padding: var(--sp-4) 0; font-size: .85rem; }
.breadcrumbs a { color: var(--c-text-muted); text-decoration: underline; text-underline-offset: 2px; }
.breadcrumbs a:hover { color: var(--c-primary); }
.breadcrumbs .sep { color: var(--c-text-light); }
.breadcrumbs .current { color: var(--c-text); font-weight: 500; }

/* ══════════════════════════════════════
   CONTENT SECTIONS (tool pages)
   ══════════════════════════════════════ */
.tool-content { padding: var(--sp-8) 0 var(--sp-16); }
.content-section { margin-top: var(--sp-10); }
.content-section h2 { padding-bottom: var(--sp-3); border-bottom: 2px solid var(--c-border); margin-top: 0; }
.content-section ul, .content-section ol { padding-left: var(--sp-6); margin-bottom: var(--sp-4); }
.content-section li { margin-bottom: var(--sp-2); list-style: disc; }
.content-section ol li { list-style: decimal; }
.content-section code {
  font-family: var(--font-mono); font-size: .9em;
  background: var(--c-surface-alt); padding: 2px 6px; border-radius: 4px;
}

/* Tables */
.conversion-table, .example-table {
  width: 100%; margin: var(--sp-4) 0 var(--sp-6);
  border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden;
}
.conversion-table th, .conversion-table td,
.example-table th, .example-table td {
  padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--c-border);
}
.conversion-table th, .example-table th {
  background: var(--c-surface-alt); font-weight: 600; font-size: .85rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted);
}
.conversion-table td, .example-table td { font-family: var(--font-mono); font-size: .9rem; }
.conversion-table tr:last-child td, .example-table tr:last-child td { border-bottom: none; }

/* FAQ Accordion */
.faq-item { border: 1px solid var(--c-border); border-radius: var(--r-md); margin-bottom: var(--sp-3); overflow: hidden; }
.faq-q {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; background: var(--c-surface); border: none;
  cursor: pointer; font-size: 1rem; font-weight: 600; color: var(--c-text); text-align: left;
}
.faq-q:hover { background: var(--c-surface-alt); }
.faq-icon { transition: transform .2s; flex-shrink: 0; color: var(--c-text-muted); font-size: .75rem; }
.faq-item.open .faq-icon { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 1.25rem 1.25rem; color: var(--c-text-muted); font-size: .95rem; line-height: 1.7; }
.faq-item.open .faq-a { display: block; }

/* Related tools */
.related-tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.related-tool-link {
  display: block; padding: 1rem; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  text-decoration: none; color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-link:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); text-decoration: none; }
.related-tool-link h4 { font-size: .9rem; margin: 0 0 4px; }
.related-tool-link p { font-size: .8rem; color: var(--c-text-muted); margin: 0; }

/* ══════════════════════════════════════
   AD UNIT — FIX: Contrast-safe colors
   ══════════════════════════════════════ */
.ad-unit {
  text-align: center; padding: 1rem 0; min-height: 90px;
  background: var(--c-surface-alt); border: 1px dashed var(--c-border);
  border-radius: var(--r-md); margin: 1.5rem 0;
  display: flex; align-items: center; justify-content: center;
  /* FIX: "Advertisement" text must pass WCAG contrast */
  color: var(--c-text-muted);
  font-size: .8rem;
}

/* ══════════════════════════════════════
   FOOTER — FIX: All contrast issues
   ══════════════════════════════════════ */
.site-footer {
  background: #0f172a;  /* darker for better contrast */
  color: #cbd5e1;       /* FIX: was rgba(255,255,255,.65) = fails. Now #cbd5e1 = 9.5:1 */
  padding: var(--sp-12) 0 var(--sp-8);
  margin-top: var(--sp-16);
}
.footer-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-8); }
.footer-brand .logo { color: #fff; }
.footer-brand .logo:hover { text-decoration: none; }
.footer-brand .logo span { color: #93c5fd; }  /* FIX: blue on dark = better contrast */
.footer-brand p { font-size: .875rem; margin-top: var(--sp-3); color: #94a3b8; } /* 4.6:1 on #0f172a = passes */
.footer-parent { font-size: .8rem !important; margin-top: .5rem !important; }
.footer-parent a { color: #93c5fd; text-decoration: underline; text-underline-offset: 2px; }
.footer-parent a:hover { color: #bfdbfe; }

.footer-col h4 {
  color: #f1f5f9;  /* FIX: near-white for headings */
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: var(--sp-4);
}
/* FIX: Footer links — was rgba(255,255,255,.6) = FAIL. Now solid colors + underline */
.footer-col a {
  display: block; color: #cbd5e1; font-size: .875rem; padding: 3px 0;
  text-decoration: underline; text-decoration-color: #475569;
  text-underline-offset: 2px;
}
.footer-col a:hover { color: #ffffff; text-decoration-color: #ffffff; }

.footer-bottom {
  border-top: 1px solid #1e293b; margin-top: var(--sp-8);
  padding-top: var(--sp-6); font-size: .8rem; text-align: center; color: #94a3b8;
}
/* FIX: dracau.com link in footer bottom — was inline rgba = fail */
.footer-bottom a {
  color: #93c5fd; text-decoration: underline; text-underline-offset: 2px;
}
.footer-bottom a:hover { color: #bfdbfe; }

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (min-width: 640px) {
  .converter-fields { flex-direction: row; }
  .converter-field { flex: 1; }
  .swap-btn { margin-top: 1.5rem; }
  .stats-bar { grid-template-columns: repeat(4, 1fr); }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
@media (min-width: 768px) {
  .hero { padding: var(--sp-16) 0 var(--sp-12); }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 1024px) {
  .main-nav { display: block; }
  .menu-toggle { display: none; }
  .header-inner { gap: var(--sp-6); }
}

/* ── Animations ── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeInUp .4s ease forwards; opacity: 0; }
.fade-in:nth-child(2) { animation-delay: .05s; }
.fade-in:nth-child(3) { animation-delay: .1s; }
.fade-in:nth-child(4) { animation-delay: .15s; }
