/* ---------- Design tokens ---------- */
:root {
  --ink: #16233F;
  --ink-soft: #3D4A63;
  --paper: #FAF6EC;
  --paper-raised: #FFFFFF;
  --line: #DCD4C0;
  --gold: #D9A441;
  --gold-deep: #A9781F;
  --teal: #2F6F5E;
  --radius: 10px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}

a { color: inherit; }

/* ---------- Accessibility Helper (CLS & SEO Friendly) ---------- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header & CLS Reserve Placeholder ---------- */
#site-header {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px; /* Reserve height before JS injects header */
  contain: layout intrinsic-size 64px;
}

.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--ink);
  color: var(--gold);
  border-radius: 8px;
  font-weight: 700;
}

.nav-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.nav-search input {
  width: 100%;
  padding: 9px 14px 9px 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.92rem;
  background: var(--paper);
}

.nav-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.55;
  pointer-events: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav-link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.78rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.nav-link .nav-icon { font-size: 1.05rem; }

.nav-link:hover {
  color: var(--gold-deep);
  background: #F3ECD8;
}

.nav-link.active {
  color: var(--teal);
  background: #E4F1EB;
  font-weight: 600;
}

.nav-link.active:active,
.nav-link:active {
  transform: scale(0.96);
}

.nav-dropdown { position: relative; }

.nav-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 220px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.16);
  z-index: 20;
}

.nav-dropdown.open .nav-dropdown-panel { display: block; }

.nav-dropdown-panel a {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-dropdown-panel a:hover { background: #F3ECD8; color: var(--gold-deep); }

.nav-dropdown-panel .cat-count {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

@media (max-width: 820px) {
  .nav-search { order: 3; max-width: none; flex-basis: 100%; }
  .nav-link span:not(.nav-icon) { display: none; }
}

/* ---------- Page shell (sidebar layout) ---------- */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 60px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
}

.sidebar {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  position: sticky;
  top: 78px;
  min-width: 220px;
  min-height: 380px; /* Layout shift Prevention */
}

.sidebar-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  padding: 10px 12px 6px;
  color: var(--ink-soft);
}

.sidebar a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.92rem;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar a:hover {
  background: #F3ECD8;
  color: var(--gold-deep);
}

.sidebar a.active {
  background: #E4F1EB;
  color: var(--teal);
  border-left-color: var(--teal);
  font-weight: 600;
}

.sidebar .cat-count {
  color: var(--ink-soft);
  font-size: 0.78rem;
  background: var(--paper);
  padding: 1px 8px;
  border-radius: 10px;
}

.sidebar a.active .cat-count { color: var(--teal); background: #FFFFFF; }

/* ---------- Category icon colors ---------- */
.icon-percentage { background: #E4F1EB; color: #2F6F5E; }
.icon-finance-money { background: #FBF0DC; color: #A9781F; }
.icon-converters { background: #E7EDF9; color: #33518F; }
.icon-utility { background: #FBE9E7; color: #B24A2E; }
.icon-date-time { background: #F0E7FA; color: #6B3FA0; }
.icon-health { background: #FCE7EF; color: #B23A6E; }

/* ---------- Numbered all-tools list ---------- */
.tools-list-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 36px 0 12px;
}

.tools-numbered {
  list-style: none;
  counter-reset: toolnum;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 20px;
}

.tools-numbered li {
  counter-increment: toolnum;
  border-bottom: 1px solid var(--line);
}

.tools-numbered li a {
  display: block;
  padding: 9px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.tools-numbered li a::before {
  content: counter(toolnum) ". ";
  color: var(--gold-deep);
  font-weight: 600;
}

.tools-numbered li a:hover { color: var(--gold-deep); }

/* ---------- Hero / page heading ---------- */
.page-head {
  padding: 48px 0 8px;
}

.page-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0 0 8px;
}

.page-head p {
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0;
}

/* ---------- Calculator card ---------- */
.calc-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin: 28px 0 12px;
}

.calc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.calc-row label {
  color: var(--ink-soft);
}

.calc-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 1rem;
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  width: 130px;
}

.calc-result {
  margin-top: 18px;
  padding: 16px 18px;
  background: #F3ECD8;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  font-size: 1.15rem;
}

.calc-result strong {
  font-variant-numeric: tabular-nums;
  color: var(--gold-deep);
}

/* ---------- Formula box ---------- */
.formula-box {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 20px 0 32px;
}

.formula-box .formula-label {
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: none;
  margin: 0 0 8px;
}

.formula-box .formula-line {
  font-family: "Courier New", monospace;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  margin: 0 0 14px;
  color: var(--paper);
  white-space: pre-line;
  line-height: 1.6;
}

.formula-box .formula-example {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 12px;
  font-size: 0.95rem;
  color: #CBD2E1;
}

.formula-box .formula-example strong {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ---------- How to use steps ---------- */
.howto-list {
  counter-reset: howto;
  list-style: none;
  padding: 0;
  margin: 20px 0 32px;
}

.howto-list li {
  counter-increment: howto;
  position: relative;
  padding: 14px 0 14px 46px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.howto-list li:last-child { border-bottom: none; }

.howto-list li::before {
  content: counter(howto);
  position: absolute;
  left: 0;
  top: 12px;
  width: 28px;
  height: 28px;
  background: var(--gold);
  color: var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ---------- FAQ accordion ---------- */
.faq-list {
  margin: 20px 0 40px;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--paper-raised);
  overflow: hidden;
}

.faq-item summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--serif);
  font-size: 1.02rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: "+";
  color: var(--gold-deep);
  font-size: 1.3rem;
  font-weight: 400;
  flex-shrink: 0;
}

.faq-item[open] summary::after { content: "−"; }

.faq-item .faq-answer {
  padding: 0 18px 16px;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- Article ---------- */
.article {
  max-width: 70ch;
  margin: 36px 0 56px;
}

.article h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  margin-top: 2em;
}

.article p { color: var(--ink-soft); }

/* ---------- All tools grid ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 32px 0 56px;
  min-height: 300px; /* Reserve height for dynamically loaded tools */
}

.tool-card {
  display: block;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.06);
}

.tool-card.active {
  border-color: var(--teal);
  border-width: 2px;
  background: #F3FAF7;
}

.tool-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--ink);
  color: var(--gold);
  border-radius: 8px;
  font-family: var(--serif);
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.tool-card-icon.icon-percentage { background: #E4F1EB; color: #2F6F5E; }
.tool-card-icon.icon-finance-money { background: #FBF0DC; color: #A9781F; }
.tool-card-icon.icon-converters { background: #E7EDF9; color: #33518F; }
.tool-card-icon.icon-utility { background: #FBE9E7; color: #B24A2E; }
.tool-card-icon.icon-date-time { background: #F0E7FA; color: #6B3FA0; }
.tool-card-icon.icon-health { background: #FCE7EF; color: #B23A6E; }

.tool-card-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.tool-card-desc {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0;
}

/* ---------- Footer ---------- */
#site-footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  min-height: 80px;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-inner a { text-decoration: underline; }

/* =========================================================
   Mobile Floating Icon & Off-Canvas Category Sidebar
   ========================================================= */

/* Floating Button Default: Hidden on Desktop */
.mobile-cat-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 20px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--ink);
  color: var(--gold);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.mobile-cat-btn:active {
  transform: scale(0.92);
}

/* Dark Background Dimmer Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(22, 35, 63, 0.4);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile Responsive Breakpoint (820px and lower) */
@media (max-width: 820px) {
  .mobile-cat-btn {
    display: flex;
  }

  .sidebar#site-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--line);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar#site-sidebar.active {
    left: 0;
  }
}
/* Print Button Styling */
.global-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 20px;
  background: #16233f;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}
.global-print-btn:hover {
  background: #0f172a;
}

/* Print Rules - Dikhane aur Chhupane ke liye */
@media print {
  #site-header, #site-sidebar, #site-footer, .article, .calc-row, .global-print-btn {
    display: none !important;
  }
  body, main {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .calc-card-container, .calc-card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
  }
}
/* Language Switcher Styling */
.lang-switcher {
  display: inline-block;
  margin-left: 15px;
}

.lang-select {
  padding: 6px 12px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: #16233f;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.lang-select:hover {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

.lang-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
/* Sidebar Panel Up/Down Scroll Fix */
#site-sidebar, 
.categories-sidebar, 
.sidebar-nav {
  max-height: calc(100vh - 120px); /* Screen height ke hisab se limit */
  overflow-y: auto;               /* Jab item zyada hon toh andar scrollbar aa jaye */
  position: sticky;
  top: 90px;                       /* Header ke neeche fixed rahega */
  padding-right: 8px;
}

/* Scrollbar ko clean aur modern dikhane ke liye (Optional) */
#site-sidebar::-webkit-scrollbar {
  width: 5px;
}

#site-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color, #ccc);
  border-radius: 4px;
}

/* Breadcrumb navigation */
.breadcrumb-nav {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.breadcrumb-nav a {
  color: #1a73e8;
  text-decoration: none;
  font-weight: 500;
}
.breadcrumb-nav a:hover {
  text-decoration: underline;
}
.breadcrumb-nav .separator {
  color: #94a3b8;
}
