/* Light theme (default): pure white background, pure black text */
:root {
  --bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e5e5e5;
  --text: #000000;
  --sub-text: #444444;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --radius: 12px;
}

/* Dark theme: pure black background, pure white text — follows the OS/browser
   preference automatically, or an explicit user choice via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card-bg: #0a0a0a;
    --border: #2a2a2a;
    --text: #ffffff;
    --sub-text: #cccccc;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --card-bg: #0a0a0a;
  --border: #2a2a2a;
  --text: #ffffff;
  --sub-text: #cccccc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Site header: logo, primary nav, mobile hamburger toggle, search, theme toggle */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

/* --- Mobile-first base: phone layout by default --- */
.site-header-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.site-logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-logo i { color: var(--accent); }

.nav-toggle {
  display: flex;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle:hover { background: var(--border); }

/* Phone: nav-panel is a floating dropdown card, closed by default */
.nav-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 12px;
  right: 12px;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  padding: 12px;
  z-index: 30;
}

.nav-panel.is-open { display: flex; }

.site-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.site-nav a {
  color: var(--sub-text);
  padding: 13px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
  background: var(--border);
  text-decoration: none;
}

.site-nav a i { font-size: 0.9em; width: 1.1em; text-align: center; }

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.search-form {
  display: flex;
  gap: 6px;
  width: 100%;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.search-form button {
  flex-shrink: 0;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.search-form button:hover {
  background: var(--accent-hover);
}

.theme-toggle {
  flex-shrink: 0;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 14px;
  cursor: pointer;
}

.theme-toggle::after {
  content: "Toggle theme";
  font-size: 0.85rem;
  font-weight: 500;
}

.theme-toggle:hover {
  background: var(--border);
}

/* Tablet and up: nav collapses back into one inline row, hamburger hides */
@media (min-width: 900px) {
  .site-header-inner {
    padding: 14px 32px;
    gap: 24px;
  }

  .site-logo { font-size: 1.2rem; }

  .nav-toggle { display: none; }

  .nav-panel {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .site-nav {
    flex-direction: row;
    align-items: center;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
  }

  .site-nav a {
    padding: 9px 14px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .site-nav a i { font-size: 0.85em; }

  .header-actions {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 0;
    margin-top: 0;
    border-top: none;
  }

  .search-form {
    width: 220px;
  }

  .search-form input[type="search"] {
    padding: 9px 12px;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
  }

  .theme-toggle::after {
    content: none;
  }
}

.pagination {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.pagination a.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.breadcrumbs {
  margin-bottom: 16px;
}

.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: var(--sub-text);
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 6px;
  color: var(--sub-text);
}

.breadcrumbs a {
  color: var(--sub-text);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs [aria-current="page"] {
  color: var(--text);
}

.related-posts {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.related-posts h2 {
  font-size: 1.2rem;
  margin: 0 0 16px;
}

.related-posts h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}

.listing {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.post-single {
  /* Deliberately narrower than the site's 1500px containers — long lines of
     body text at full width are hard to read; ~75 characters per line is
     the readability sweet spot. */
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.listing h1, .post-single h1 {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

@media (min-width: 640px) {
  .listing, .post-single {
    padding: 32px 24px 64px;
  }

  .listing { padding-left: 32px; padding-right: 32px; }

  .listing h1, .post-single h1 {
    font-size: 1.75rem;
    margin: 0 0 24px;
  }
}

.empty-state {
  color: var(--sub-text);
}

.category-tabs {
  max-width: 1500px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--sub-text);
  font-size: 0.9rem;
  font-weight: 600;
}

.category-tabs a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.category-tabs a.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tools-highlight {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.tools-highlight h2 {
  font-size: 1.2rem;
  margin: 0 0 16px;
}

.category-description {
  color: var(--sub-text);
  max-width: 640px;
  margin: -12px 0 24px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 16px;
}

/* Standard image treatment for every post/article image on the site — one
   consistent aspect ratio (16:9) and object-fit everywhere, so images never
   look stretched or inconsistently cropped between card types. */
.post-card img,
.post-list-item img,
.trending-card img,
.post-featured-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.post-card img {
  border-radius: 8px;
  margin-bottom: 12px;
}

.post-card h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.post-card p {
  color: var(--sub-text);
  font-size: 0.9rem;
  margin: 0;
}

.post-meta {
  color: var(--sub-text);
  font-size: 0.9rem;
  margin: 0 0 24px;
}

.post-featured-image {
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.post-content {
  font-size: 1rem;
}

.post-content img { max-width: 100%; height: auto; border-radius: 8px; }

@media (min-width: 640px) {
  .post-content {
    font-size: 1.05rem;
  }
}

/* Interactive calculator tools */
.calc-tool {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  max-width: 480px;
}

.calc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.calc-tab {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.calc-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.calc-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 14px 0 6px;
}

.calc-form label:first-child {
  margin-top: 0;
}

.calc-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.btn-calc {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.btn-calc:hover {
  background: var(--accent-hover);
}

.calc-result {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.calc-result-value {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.calc-result-label {
  color: var(--sub-text);
  margin: 0;
}

.calc-result-table {
  width: 100%;
  margin-top: 10px;
  font-size: 0.9rem;
}

.calc-result-table td {
  padding: 4px 0;
}

.calc-result-table td:last-child {
  text-align: right;
  font-weight: 600;
}

/* Ad slots */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px 0;
  overflow: hidden;
  text-align: center;
}

.ad-slot ins.adsbygoogle {
  width: 100%;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 40px 24px 24px;
  font-size: 0.85rem;
  color: var(--sub-text);
}

.site-footer-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.footer-col h3 {
  color: var(--text);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 14px;
}

.footer-col a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sub-text);
  margin: 0 0 10px;
}

.footer-col a:hover { color: var(--accent); }

.footer-brand .site-logo {
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.footer-brand p {
  color: var(--sub-text);
  max-width: 260px;
  margin: 0;
}

.footer-copyright {
  max-width: 1500px;
  margin: 32px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

@media (min-width: 480px) {
  .site-footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 800px) {
  .site-footer-inner {
    grid-template-columns: 1.5fr repeat(3, 1fr);
  }
}

/* Tables (e.g. loan calculator results) scroll horizontally on narrow
   screens instead of squeezing or overflowing the page. */
table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

/* Magazine homepage */
.hero {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 16px 4px;
}

.hero h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.hero p {
  color: var(--sub-text);
  font-size: 0.95rem;
  max-width: 640px;
}

.section {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 16px;
}

@media (min-width: 640px) {
  .hero { padding: 40px 24px 8px; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1.05rem; }
  .section { padding: 32px 24px; }
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 1.3rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h2 i { color: var(--accent); }

.section-header a {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.category-card i {
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 10px;
  display: block;
}

.category-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.category-card p {
  color: var(--sub-text);
  font-size: 0.85rem;
  margin: 0 0 14px;
}

.post-card .post-card-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 8px;
}

/* Two-column magazine layout: main content + right sidebar.
   Mobile-first: single stacked column by default, sidebar below main
   content; becomes a real two-column layout with a sticky sidebar at
   tablet width and up. */
.homepage-layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 4px 16px 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.homepage-main .section {
  max-width: none;
  margin: 0;
  padding: 24px 0;
}

.homepage-main .section:first-child { padding-top: 4px; }

.homepage-sidebar {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 900px) {
  .homepage-layout {
    padding: 8px 24px 40px;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    align-items: start;
  }

  .homepage-main .section {
    padding: 32px 0;
  }

  .homepage-main .section:first-child { padding-top: 8px; }

  .homepage-sidebar {
    position: sticky;
    top: 84px;
    gap: 24px;
  }
}

.sidebar-widget {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sidebar-widget h3 {
  font-size: 0.95rem;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-widget h3 i { color: var(--accent); }

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  color: var(--text);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-list a:hover { color: var(--accent); }

.sidebar-rank {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--sub-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-category-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  color: var(--text);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.sidebar-category-links li:last-child a { border-bottom: none; }
.sidebar-category-links a:hover { color: var(--accent); }
.sidebar-category-links i { color: var(--accent); width: 18px; }

/* Trending section: a distinct grid of ranked cards — visually different
   from the plain Latest Posts grid via the accent top-border and the
   numbered rank badge overlaid on the image. */
.trending-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.trending-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
}

.trending-card-media {
  position: relative;
}

.trending-card-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trending-card-body {
  padding: 16px;
}

.trending-card-body h3 {
  font-size: 1rem;
  margin: 6px 0 8px;
  line-height: 1.35;
}

.trending-views {
  color: var(--sub-text);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Latest Posts: a short editorial "list" of the newest items first (bigger,
   horizontal, more like a headline feed), followed by the rest as a
   standard grid — a real list+grid combination, not just one repeated
   pattern. */
.post-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-list-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.post-list-item:first-child { padding-top: 0; }

.post-list-item img {
  border-radius: 10px;
}

.post-list-item h3 {
  font-size: 1.05rem;
  margin: 6px 0 8px;
}

.post-list-item p {
  color: var(--sub-text);
  margin: 0;
  font-size: 0.9rem;
}

@media (min-width: 560px) {
  .post-list-item {
    grid-template-columns: 220px 1fr;
    gap: 20px;
    align-items: center;
  }

  .post-list-item h3 {
    font-size: 1.15rem;
  }

  .post-list-item p {
    font-size: 1rem;
  }
}

/* 404 page */
.error-page {
  text-align: center;
  padding-top: 48px;
  padding-bottom: 48px;
}

.error-page i {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 16px;
  display: block;
}

.error-page h1 {
  margin: 0 0 8px;
}

.error-page p {
  color: var(--sub-text);
  max-width: 480px;
  margin: 0 auto 28px;
}

.error-page-home {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.error-page-home:hover {
  background: var(--accent-hover);
  text-decoration: none;
}


/* Homepage-funnel page (ads.php) */
.funnel {
  max-width: 640px;
  margin: 32px auto;
  padding: 0 16px;
}

.funnel-header {
  text-align: center;
  margin-bottom: 24px;
}

.funnel-header h1 {
  font-size: 1.4rem;
  margin: 0 0 8px;
}

.funnel-sub {
  color: var(--sub-text);
  margin: 0;
  font-size: 0.9rem;
}

.funnel-step.is-hidden {
  display: none;
}

.funnel-step h2 {
  text-align: center;
  font-size: 1.15rem;
  margin: 0 0 20px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.option-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.option-card i {
  font-size: 1.5rem;
  color: var(--accent);
}

.option-card span {
  font-size: 0.95rem;
  font-weight: 600;
}

.option-card:hover,
.option-card:focus-visible {
  background: var(--card-hover, var(--border));
  border-color: var(--accent);
  transform: translateY(-2px);
}

.option-card--sm {
  padding: 18px 16px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.95rem;
  margin-bottom: 16px;
  padding: 0;
}

.back-btn:hover {
  text-decoration: underline;
}

.noscript-links {
  margin-top: 24px;
  text-align: center;
  color: var(--sub-text);
}

.noscript-links ul {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .funnel { margin: 48px auto; padding: 0 20px; }
  .funnel-header { margin-bottom: 32px; }
  .funnel-header h1 { font-size: 1.75rem; }
  .funnel-sub { font-size: 1rem; }
  .funnel-step h2 { font-size: 1.3rem; margin-bottom: 24px; }
  .option-grid { gap: 16px; }
  .option-card { padding: 28px 16px; }
  .option-card i { font-size: 1.8rem; }
  .option-card span { font-size: 1rem; }
  .option-card--sm { padding: 20px 16px; }
}

/* Legal / static info pages (about, contact, privacy, terms, disclaimer) */
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.legal-page h1 {
  font-size: 1.4rem;
  margin: 0 0 20px;
}

.legal-page h2 {
  font-size: 1.05rem;
  margin: 28px 0 10px;
}

@media (min-width: 640px) {
  .legal-page { padding: 32px 24px 64px; }
  .legal-page h1 { font-size: 1.75rem; margin: 0 0 24px; }
  .legal-page h2 { font-size: 1.2rem; margin: 32px 0 12px; }
}
