/* ===== Design tokens ===== */
:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --border: #e7eaf0;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9aa1ad;
  --accent: #2563eb;
  --accent-tint: #e8effe;

  --cat-fin: #10b981;
  --cat-fin-tint: #e6f9ef;
  --cat-fit: #f34469;
  --cat-fit-tint: #fee9ec;
  --cat-math: #6366f1;
  --cat-math-tint: #e9eafe;
  --cat-other: #63707d;
  --cat-other-tint: #eceef1;
  --cat-crypto: #d97706;
  --cat-crypto-tint: #fef3c7;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 24px rgba(15, 20, 30, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 64px;
}

/* ===== Header ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
}
.logo-img {
  height: 60px;
  width: auto;
  display: block;
}
.nav {
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-links {
  display: contents;
}
.nav a.nav-link {
  position: relative;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-bottom: 4px;
}
.nav a.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s ease;
}
.nav a.nav-link:hover { color: var(--text-primary); }
.nav a.nav-link:hover::after { transform: scaleX(1); }

.nav-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7f9fc;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.nav-search svg {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 0.2s ease;
}
.nav-search input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  width: 170px;
}
.nav-search input::placeholder { color: var(--text-muted); }
.nav-search:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.nav-search:focus-within svg { color: var(--accent); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
  padding: 6px;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
}
a.search-result-item:hover, a.search-result-item:focus { background: var(--accent-tint); }
.search-result-item .result-category {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
}
.search-result-item.is-soon { color: var(--text-muted); cursor: default; }
.search-result-empty {
  padding: 14px 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Categories nav dropdown ===== */
.nav-categories {
  position: relative;
}
.nav-categories > .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}
.nav-categories-chevron {
  transition: transform 0.2s ease;
}
.nav-categories.is-open .nav-categories-chevron {
  transform: rotate(180deg);
}
.nav-categories-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  z-index: 50;
  padding: 6px;
}
.nav-categories-dropdown a {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.nav-categories-dropdown a:hover,
.nav-categories-dropdown a:focus {
  background: var(--accent-tint);
  color: var(--accent);
}

/* ===== Hero / breadcrumb ===== */
.hero {
  padding: 32px 0 24px;
}
.breadcrumb {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.breadcrumb .current { color: var(--accent); font-weight: 500; }
.hero h1 {
  font-size: 32px;
  margin: 0 0 10px;
}
.hero p {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 720px;
  margin: 0;
  line-height: 1.5;
}
.page-hero {
  padding: 56px 0 40px;
  text-align: left;
}
.page-hero h1 { font-size: 38px; margin-bottom: 12px; }
.page-hero p { font-size: 16px; max-width: 640px; }

/* ===== Teaser (popular calculators) ===== */
.teaser {
  background: var(--card);
  padding: 40px 0 56px;
}
.teaser h2, .category-browse h2 {
  font-size: 22px;
  margin: 0 0 6px;
}
.teaser .section-sub, .category-browse .section-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
}
.teaser-carousel {
  position: relative;
  margin-top: -20px;
}
.cards-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-top: 20px;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}
.cards-row::-webkit-scrollbar { display: none; }
.teaser-carousel.has-overflow .cards-row {
  padding-left: 38px;
  padding-right: 38px;
  scroll-padding-left: 38px;
  scroll-padding-right: 38px;
}
.carousel-arrow {
  display: none;
  position: absolute;
  top: 45%;
  left: 0;
  right: auto;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-primary);
  font-size: 15px;
  box-shadow: var(--shadow-card);
  z-index: 2;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.carousel-arrow:hover { color: var(--accent); border-color: var(--accent); }
.carousel-arrow:active { transform: translateY(-50%) scale(0.92); }
.carousel-arrow:disabled { opacity: 0.35; pointer-events: none; }
.carousel-arrow.prev { left: 0; }
.carousel-arrow.next { left: auto; right: 0; }
.teaser-carousel.has-overflow .carousel-arrow { display: flex; }
.mini-card {
  flex: 0 0 200px;
  background: #fafbfc;
  border: 1px dashed #eaecef;
  border-radius: var(--radius-md);
  padding: 20px;
  transition: background-color 0.35s ease, border-color 0.35s ease, transform 0.25s ease, box-shadow 0.35s ease;
}
.mini-card:hover {
  background: var(--accent-tint);
  border-color: #c7d7fb;
}
.mini-card.linked {
  border-style: solid;
  border-color: var(--border);
  background: var(--card);
}
.mini-card.linked:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}
.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-tint);
  color: var(--accent);
  margin-bottom: 8px;
}
.tag.live { background: #e6f9ef; color: #10b981; }
.mini-card h3 {
  font-size: 15px;
  margin: 0 0 4px;
}
.mini-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* ===== Calculator listing grid (many "coming soon" items) ===== */
.calc-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.calc-list-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.calc-list-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}
a.calc-list-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.calc-list-card h3 {
  font-size: 15px;
  margin: 0;
}
.calc-list-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ===== Category groups (accordion) ===== */
.calc-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 4px;
}
.calc-group-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 15px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.calc-group-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
}
.calc-group-card[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.calc-group-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--cat-fin-tint);
  color: var(--cat-fin);
  display: flex;
  align-items: center;
  justify-content: center;
}
.calc-group-icon svg { width: 19px; height: 19px; }
.calc-group-text { flex: 1; min-width: 0; }
.calc-group-text h3 {
  font-size: 15px;
  margin: 0 0 4px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.calc-group-text p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.calc-group-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.3s ease, color 0.2s ease;
}
.calc-group-card[aria-expanded="true"] .calc-group-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.calc-group-panel-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}
.calc-group-panel-wrap.open {
  grid-template-rows: 1fr;
}
.calc-group-panel-inner {
  overflow: hidden;
}
.calc-group-panel {
  padding-top: 24px;
}
.calc-group-panel h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 14px;
}

.calc-simple-list {
  columns: 3 220px;
  column-gap: 32px;
}
.calc-simple-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  break-inside: avoid;
}
.calc-simple-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.calc-simple-item.is-live .calc-simple-dot {
  background: var(--cat-fin);
}
a.calc-simple-item {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
a.calc-simple-item:hover {
  color: var(--accent);
}
a.calc-simple-item:hover .calc-simple-dot {
  background: var(--accent);
}
.calc-simple-item.is-soon span {
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== All Calculators (flat directory) page ===== */
.all-calc-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
}
.all-calc-jump a {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.all-calc-jump a:hover { color: var(--accent); border-color: var(--accent); }
.all-calc-category {
  font-size: 24px;
  margin: 48px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 90px;
}
.all-calc-category:first-of-type { margin-top: 0; border-top: none; padding-top: 0; }
.all-calc-group {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin: 24px 0 12px;
}

/* ===== Category browse ===== */
.category-browse {
  background: #f9fafc;
  padding: 48px 0 56px;
}
.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.category-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 320px;
  justify-self: center;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.category-card > * {
  position: relative;
  z-index: 1;
}
.category-card:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 20px 40px rgba(15, 20, 30, 0.16);
}
.category-illustration {
  height: 140px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-illustration svg { width: 100px; height: 90px; }
.category-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 24px;
}
.category-card h3 { font-size: 17px; margin: 0; }
.category-card p { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.explore-btn {
  align-self: flex-start;
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid currentColor;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  z-index: 0;
  transition: color 0.3s ease;
}
.explore-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.35s ease;
  z-index: -1;
}
.explore-btn:hover {
  color: #fff;
}
.explore-btn:hover::before {
  transform: scaleX(1);
}

.cat-financial { color: var(--cat-fin); }
.cat-financial .category-illustration { background: var(--cat-fin-tint); }
.cat-financial .category-badge { background: var(--cat-fin); }
.cat-financial .explore-btn::before { background: var(--cat-fin); }

.cat-fitness { color: var(--cat-fit); }
.cat-fitness .category-illustration { background: var(--cat-fit-tint); }
.cat-fitness .category-badge { background: var(--cat-fit); }
.cat-fitness .explore-btn::before { background: var(--cat-fit); }

.cat-math { color: var(--cat-math); }
.cat-math .category-illustration { background: var(--cat-math-tint); }
.cat-math .category-badge { background: var(--cat-math); }
.cat-math .explore-btn::before { background: var(--cat-math); }

.cat-other { color: var(--cat-other); }
.cat-other .category-illustration { background: var(--cat-other-tint); }
.cat-other .category-badge { background: var(--cat-other); }
.cat-other .explore-btn::before { background: var(--cat-other); }

.cat-crypto { color: var(--cat-crypto); }
.cat-crypto .category-illustration { background: var(--cat-crypto-tint); }
.cat-crypto .category-badge { background: var(--cat-crypto); }
.cat-crypto .explore-btn::before { background: var(--cat-crypto); }

/* ===== Footer ===== */
.site-footer {
  background: #f9fafc;
  border-top: 1px solid var(--border);
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 20px;
  padding-bottom: 20px;
}
.site-footer p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.footer-links {
  display: flex;
  gap: 24px;
}
.footer-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.footer-links a:hover { color: var(--text-primary); }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .container { padding: 0 20px; }
  .site-header .container { flex-wrap: wrap; justify-content: flex-start; height: auto; padding-top: 14px; padding-bottom: 14px; gap: 10px 16px; }
  /* Flatten .nav so .nav-links and .nav-search lay out directly against the
     logo in the outer flex row, each sized by its own content — otherwise
     the search box's width:100% would inflate .nav's own preferred width to
     always equal the full row, forcing an unnecessary wrap even when the
     links alone would've fit fine beside the logo. .nav-links stays a real
     box (not flattened) so the three links wrap to a new row as one group
     instead of splitting mid-row when they no longer fit beside the logo. */
  .nav { display: contents; }
  .nav-links { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: flex-end; margin-left: auto; }
  .nav-search { width: 100%; }
  .nav-search input { width: auto; flex: 1; }
  .hero h1 { font-size: 26px; }
  .page-hero h1 { font-size: 28px; }
  .category-cards { grid-template-columns: 1fr; }
  .site-footer .container { justify-content: center; text-align: center; }
}
