/* ===========================
   Theme toggle + helpers
   =========================== */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #ffffff; /* dark mode (default): white background */
  margin-left: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  color: #facc15; /* sun icon color (yellow) */
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* override old mobile styles that were hiding icons */
  opacity: 1;
  transform: none;
}

.theme-toggle-svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* Icon base: hidden, then we show per mode */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Dark mode (default): show yellow sun on white background */
body.site-body .theme-toggle .icon-sun {
  display: inline-flex;
  color: #facc15; /* yellow sun */
}

body.site-body .theme-toggle .icon-moon {
  display: none;
}

/* Light mode: dark background with white moon */
body.site-body.light-mode .theme-toggle {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), #020617);
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: #e5e7eb; /* base icon color for moon */
}

body.site-body.light-mode .theme-toggle .icon-sun {
  display: none;
}

body.site-body.light-mode .theme-toggle .icon-moon {
  display: inline-flex;
  color: #e5e7eb; /* white/very light moon */
}

/* ===========================
   Clickable article cards
   =========================== */

.article-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.article-card-link:focus-visible .article-card {
  outline: 2px solid #22c55e;
  outline-offset: 3px;
}

/* ===========================
   Article body secondary image
   =========================== */

.article-body-image {
  margin: 1.6rem 0;
  border-radius: 1.4rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.9);
}

.article-body-image img {
  display: block;
  width: 100%;
}

/* Middle (secondary) image: a bit smaller & centered */
.article-body-image--secondary {
  max-width: 52rem;   /* tweak if you want it smaller/larger */
  width: 100%;
  margin: 2.5rem auto;
}

/* ===========================
   Sticky affiliate sidebar
   =========================== */

@media (min-width: 1024px) {
  .article-body-aside {
    position: sticky;
    top: 5.25rem; /* below header */
  }

  /* Bottom half: content wide, affiliates narrow, affiliates on the LEFT */
  .article-body-shell--bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); /* left = narrow, right = wide */
    gap: 2.5rem;
    align-items: flex-start;
  }

  .article-body-shell--bottom .article-body-aside {
    grid-column: 1;
  }

  .article-body-shell--bottom .article-body-main {
    grid-column: 2;
  }
}

/* Inline affiliate block (if you ever render it in-flow) */
.article-inline-affiliate {
  margin: 1.6rem 0;
}

/* ===========================
   Article cards (both modes)
   =========================== */

/* Darken the small strip behind the headline on images so text is readable */
.article-card-media-bottom {
  background: linear-gradient(
    to top,
    rgba(15, 23, 42, 0.92),
    rgba(15, 23, 42, 0.0)
  );
}

/* ===========================
   Light mode overrides
   =========================== */

body.site-body.light-mode {
  background: radial-gradient(circle at top left, #f9fafb 0, #f9fafb 40%, #e5e7eb 80%);
  color: #020617;
}

/* Header + navigation + brand */

body.site-body.light-mode .site-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(148, 163, 184, 0.4);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

/* Make nav links clearly visible in light mode */
body.site-body.light-mode .main-nav .nav-link {
  color: #111827;              /* dark text */
  font-weight: 500;
}

body.site-body.light-mode .main-nav .nav-link:hover {
  color: #0f766e;              /* teal-ish hover */
}

/* If you have an "active" class, give it more contrast */
body.site-body.light-mode .main-nav .nav-link.is-active,
body.site-body.light-mode .main-nav .nav-link.active {
  color: #0f172a;
  border-bottom: 2px solid #22c55e;
}

body.site-body.light-mode .brand-logo {
  color: #eef2ff;
}

/* Hero + sections */

body.site-body.light-mode .hero-text p,
body.site-body.light-mode .section-subtitle,
body.site-body.light-mode .page-body {
  color: #4b5563;
}

body.site-body.light-mode .hero {
  background: radial-gradient(circle at top left, #ffffff, #f3f4f6);
  border-color: rgba(148, 163, 184, 0.4);
}

/* Search fields + forms */

body.site-body.light-mode .hero-search-input,
body.site-body.light-mode .form-row input,
body.site-body.light-mode .form-row textarea {
  background: #f9fafb;
  color: #111827;
  border-color: rgba(148, 163, 184, 0.6);
}

body.site-body.light-mode .hero-search-input::placeholder {
  color: #9ca3af;
}

/* Article cards */

body.site-body.light-mode .article-card {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

body.site-body.light-mode .article-card-media-gradient {
  background: linear-gradient(to top, rgba(15, 23, 42, 0.55), transparent);
}

/* Keep article headlines on images white in light mode */
body.site-body.light-mode .article-card-media-bottom h3,
body.site-body.light-mode .article-card-media-bottom h2 {
  color: #f9fafb;
}

/* And keep pills readable too */
body.site-body.light-mode .article-card-media-top .article-pill {
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.75);
}

body.site-body.light-mode .article-card-content {
  color: #111827;
}

body.site-body.light-mode .article-card-excerpt {
  color: #4b5563;
}

body.site-body.light-mode .article-card-meta span:last-child {
  color: #4b5563;
}

/* Article hero + body */

body.site-body.light-mode .article-hero {
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

body.site-body.light-mode .article-hero-overlay {
  background: linear-gradient(to top, rgba(249, 250, 251, 0.92), transparent 40%);
}

body.site-body.light-mode .article-hero-title {
  color: #111827;
}

body.site-body.light-mode .article-hero-excerpt {
  color: #4b5563;
}

body.site-body.light-mode .article-body-content {
  color: #111827;
}

body.site-body.light-mode .article-body-content h2,
body.site-body.light-mode .article-body-content h3 {
  color: #111827;
}

/* Affiliates + side cards */

/* Make affiliate cards feel clickable in both modes */
.article-aside-card {
  cursor: pointer;
}

body.site-body.light-mode .article-aside-card {
  background:
    radial-gradient(circle at 0 0, #22c55e11, transparent 60%),
    #ffffff;
  border-color: rgba(148, 163, 184, 0.5);
  color: #374151;
}

body.site-body.light-mode .article-affiliate-desc {
  color: #4b5563;
}

/* Light-mode hamburger / mobile nav background */
@media (max-width: 768px) {
  body.site-body.light-mode .main-nav {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  }
}

/* Footer */

body.site-body.light-mode .site-footer {
  border-top-color: rgba(209, 213, 219, 0.9);
}

body.site-body.light-mode .site-footer-inner {
  color: #6b7280;
}

/* ===========================
   Articles pagination
   =========================== */

.articles-pagination-wrapper {
  margin-top: 3rem;           /* space below the last row of articles */
  display: flex;
  justify-content: center;    /* center horizontally */
}

.articles-pagination {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.articles-pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.75);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background 0.18s ease-out, color 0.18s ease-out,
              border-color 0.18s ease-out, box-shadow 0.18s ease-out,
              transform 0.18s ease-out;
}

/* Dark mode (default) */
body.site-body .articles-pagination-link {
  background: #020617;
  color: #e5e7eb;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.6);
}

body.site-body .articles-pagination-link:hover {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.95);
  transform: translateY(-1px);
}

body.site-body .articles-pagination-link--current {
  background: #22c55e;
  border-color: #22c55e;
  color: #020617;
}

body.site-body .articles-pagination-link--disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

/* Light mode tweaks */
body.site-body.light-mode .articles-pagination-link {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
}

body.site-body.light-mode .articles-pagination-link:hover {
  background: #f3f4f6;
}

body.site-body.light-mode .articles-pagination-link--current {
  background: #22c55e;
  border-color: #22c55e;
  color: #020617;
}

/* ===========================
   Admin analytics styling
   =========================== */

.admin-section {
  max-width: 80rem;
  margin: 2.5rem auto;
  padding: 0 1.5rem 3rem;
}

.admin-section-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.admin-section-header p {
  font-size: 0.9rem;
  color: #9ca3af;
}

/* Tabs */
.admin-tabs {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.85);
}

.admin-tab:hover {
  background: rgba(30, 64, 175, 0.95);
  border-color: rgba(191, 219, 254, 0.9);
}

.admin-tab--active {
  background: #22c55e;
  color: #020617;
  border-color: #22c55e;
}

/* Filter bar */
.admin-filter-bar {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.admin-filter-form label {
  font-size: 0.85rem;
  color: #9ca3af;
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-filter-form input[type="date"] {
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #020617;
  color: #e5e7eb;
  font-size: 0.85rem;
}

.admin-filter-form button {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #22c55e;
  background: #22c55e;
  color: #020617;
  font-size: 0.85rem;
  cursor: pointer;
}

.admin-filter-form button:hover {
  filter: brightness(1.1);
}

.admin-filter-note {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Metrics */
.admin-metrics-grid {
  margin: 1rem 0 1.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem;
}

.admin-metric-card {
  padding: 0.8rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.95), #020617);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.8);
}

.admin-metric-card h2 {
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.admin-metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #e5e7eb;
}

.admin-metric-sub {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Tables */
.admin-table-wrapper {
  margin-top: 1.5rem;
}

.admin-table-wrapper h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  border-radius: 0.9rem;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 55, 1);
  box-shadow: 0 16px 50px rgba(15, 23, 42, 0.9);
}

.admin-table thead {
  background: radial-gradient(circle at top left, #0f172a, #020617);
}

.admin-table th,
.admin-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.admin-table th {
  font-weight: 600;
  color: #e5e7eb;
  white-space: nowrap;
}

.admin-table td {
  color: #d1d5db;
}

.admin-table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.8);
}

.admin-table tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.95);
}

.admin-table tbody tr:hover {
  background: rgba(30, 64, 175, 0.6);
}

.admin-table-cell-long {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Light mode tweaks */
body.site-body.light-mode .admin-metric-card {
  background: linear-gradient(to bottom right, #ffffff, #e5e7eb);
  border-color: rgba(209, 213, 219, 0.9);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

body.site-body.light-mode .admin-metric-card h2 {
  color: #4b5563;
}

body.site-body.light-mode .admin-metric-value {
  color: #111827;
}

body.site-body.light-mode .admin-metric-sub {
  color: #6b7280;
}

body.site-body.light-mode .admin-table {
  border-color: rgba(209, 213, 219, 0.9);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.15);
}

body.site-body.light-mode .admin-table thead {
  background: linear-gradient(to right, #0f172a, #111827);
}

body.site-body.light-mode .admin-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

body.site-body.light-mode .admin-table tbody tr:nth-child(odd) {
  background: #f3f4f6;
}

body.site-body.light-mode .admin-table td {
  color: #111827;
}

body.site-body.light-mode .admin-tabs .admin-tab {
  background: #f3f4f6;
  color: #111827;
  border-color: rgba(209, 213, 219, 0.9);
}

body.site-body.light-mode .admin-tabs .admin-tab--active {
  background: #22c55e;
  border-color: #22c55e;
  color: #020617;
}
