/* ========================================
   UNIT CONVERT HUB — Design System
   ======================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

/* ── CSS Variables ── */
:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --primary-light: #EEEDFF;
  --secondary: #FF6B6B;
  --accent: #4ECDC4;
  --accent-2: #FFE66D;
  --gradient: linear-gradient(135deg, #6C63FF 0%, #FF6B6B 100%);
  --gradient-cool: linear-gradient(135deg, #4ECDC4 0%, #6C63FF 100%);
  --bg: #FFFFFF;
  --bg-light: #F8F9FC;
  --bg-card: #FFFFFF;
  --text: #1A1A2E;
  --text-light: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --shadow: 0 4px 24px rgba(108, 99, 255, 0.12);
  --shadow-hover: 0 8px 32px rgba(108, 99, 255, 0.20);
  --radius: 12px;
  --radius-lg: 20px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5, h6 {
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem); }

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.section { padding: 2rem 0; }
.section-alt { background: var(--bg-light); }

/* Page content wrapper for specific/calculator pages */
.page-content {
  max-width: 800px;
  margin: 0 auto;
}

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.navbar-logo svg { width: 32px; height: 32px; }

.navbar-logo span {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Desktop nav */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links li { position: relative; }

.nav-links a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.nav-links a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Dropdown */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.5rem;
  z-index: 100;
}

.nav-links li:hover .dropdown-menu { display: block; }

.dropdown-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.dropdown-menu a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Language toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-toggle a {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  transition: all 0.2s;
}

.lang-toggle a.active {
  background: var(--gradient);
  color: #fff;
}

.lang-toggle a:hover:not(.active) {
  background: var(--primary-light);
  color: var(--primary);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.hamburger.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 999;
}

.mobile-nav.open { display: block; }

.mobile-nav a {
  display: block;
  padding: 0.75rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.mobile-nav a:hover { color: var(--primary); }

.mobile-nav .mobile-sub {
  padding-left: 1rem;
}

.mobile-nav .mobile-sub a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-light);
}

/* ── Hero ── */
.hero {
  background: var(--gradient);
  color: #fff;
  padding: 3rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255,255,255,0.05) 0%, transparent 40%);
  pointer-events: none;
}

.hero h1 {
  color: #fff;
  margin-bottom: 0.75rem;
  position: relative;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 2rem;
  position: relative;
}

/* ── Converter Card ── */
.converter-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 600px;
  margin: -1.5rem auto 0;
  position: relative;
  z-index: 10;
}

.converter-card.in-hero {
  margin: 0 auto;
}

.converter-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.converter-input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.converter-input {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-light);
  color: var(--text);
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.converter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.unit-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  min-width: 40px;
}

.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gradient);
  border: none;
  cursor: pointer;
  margin: 0 auto;
  transition: transform 0.3s, box-shadow 0.3s;
  flex-shrink: 0;
}

.swap-btn:hover {
  transform: scale(1.08) rotate(180deg);
  box-shadow: var(--shadow-hover);
}

.swap-btn svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.result-display {
  text-align: center;
  padding: 1.25rem;
  background: var(--primary-light);
  border-radius: var(--radius);
}

.result-number {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.result-unit {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.formula-display {
  text-align: center;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-light);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-light);
}

.formula-display code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--primary);
}

/* ── Step-by-step ── */
.steps {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
}

.steps h3 { margin-bottom: 1rem; }

.steps ol {
  list-style: none;
  counter-reset: step;
}

.steps ol li {
  counter-increment: step;
  padding: 0.5rem 0 0.5rem 2.5rem;
  position: relative;
  font-size: 0.95rem;
}

.steps ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 28px;
  height: 28px;
  background: var(--gradient);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: var(--primary-light); }

tbody tr.highlight {
  background: var(--accent-2);
  font-weight: 700;
}

tbody td a { font-weight: 600; }

/* ── Cards Grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-hover);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.card ul {
  list-style: none;
  padding: 0;
}

.card ul li {
  padding: 0.3rem 0;
}

.card ul li a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  transition: color 0.2s;
}

.card ul li a:hover { color: var(--primary); }

/* ── Quick answer (editorial pages) ── */
.quick-answer {
  background: var(--gradient);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  margin: 1.5rem 0;
}

.quick-answer .big-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  display: block;
  margin-bottom: 0.5rem;
}

.quick-answer .sub-values {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.breadcrumb a { color: var(--primary); font-weight: 500; }
.breadcrumb span { color: var(--text-light); }

/* ── Content ── */
.content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.content h2 { margin: 2rem 0 1rem; }
.content h3 { margin: 1.5rem 0 0.75rem; }

.content p {
  margin-bottom: 1rem;
  color: var(--text);
  line-height: 1.7;
}

.content ul, .content ol {
  margin: 1rem 0 1rem 1.5rem;
}

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

.did-you-know {
  background: linear-gradient(135deg, #EEEDFF 0%, #E0F7FA 100%);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.did-you-know strong {
  color: var(--primary);
  display: block;
  margin-bottom: 0.35rem;
}

/* ── FAQ ── */
.faq { margin: 2rem 0; }

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: background 0.2s;
}

.faq-question:hover { background: var(--primary-light); }

.faq-question::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  transition: transform 0.3s;
  flex-shrink: 0;
  margin-left: 1rem;
}

.faq-item.open .faq-question::after {
  transform: rotate(45deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-answer p,
.faq-answer-inner {
  padding: 0 1.25rem 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
  margin: 0;
}

/* ── Related links ── */
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.related-links a {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--primary-light);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  transition: all 0.2s;
}

.related-links a:hover {
  background: var(--primary);
  color: #fff;
}

/* ── Popular conversions links ── */
.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.popular-grid a {
  padding: 0.6rem 0.75rem;
  background: var(--bg-light);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
}

.popular-grid a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Footer ── */
.footer {
  background: var(--text);
  color: rgba(255, 255, 255, 0.7);
  padding: 3rem 0 1.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer h4 {
  color: #fff;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.footer ul { list-style: none; }

.footer ul li { margin-bottom: 0.35rem; }

.footer ul a {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer ul a:hover { color: #fff; }

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }

  .converter-card { padding: 1.25rem; margin-top: -1rem; }
  .converter-input { font-size: 1.35rem; }
  .result-number { font-size: 1.75rem; }
  .section { padding: 2rem 0; }
  .hero { padding: 2rem 0; }
  .cards-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }

  .quick-answer .big-number { font-size: 2rem; }
}

@media (min-width: 769px) {
  .mobile-nav { display: none !important; }
}

/* ── Utility ── */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ── Animations ── */
@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
  }
  .fade-in.visible {
    opacity: 1;
    transform: none;
  }
}
