/* === Self-hosted Fonts === */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/fonts/montserrat-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/fonts/lato-300.woff2) format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/lato-400.woff2) format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/lato-700.woff2) format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/lato-italic-400.woff2) format('woff2');
}

/* === CSS Custom Properties === */
:root {
  --bg: #ffffff;
  --bg-secondary: #f7f7f7;
  --text: #5a5a5a;
  --text-dark: #121212;
  --text-light: #767676;
  --accent: #3943b7;
  --accent-hover: #2d36a0;
  --border: #e8e8e8;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
  --header-bg: #ffffff;
  --footer-bg: #121212;
  --footer-text: #999;
  --font-heading: "Montserrat", Helvetica, Arial, sans-serif;
  --font-body: "Lato", Helvetica, Arial, sans-serif;
  --max-width: 1170px;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-secondary: #16213e;
  --text: #c0c0c0;
  --text-dark: #e0e0e0;
  --text-light: #999;
  --accent: #5a63d8;
  --accent-hover: #7b83ef;
  --border: #2a2a4a;
  --card-bg: #16213e;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --header-bg: #16213e;
  --footer-bg: #0f0f23;
  --footer-text: #666;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 15px;
}

/* === Header === */
.site-header {
  background: var(--header-bg);
  z-index: 100;
}

/* Top row: logo + dark mode toggle */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 0;
}

.logo { display: flex; align-items: center; gap: 0; }

.logo-icon {
  width: 36px;
  height: 36px;
  margin-right: 6px;
  object-fit: contain;
}

[data-theme="dark"] .logo-icon {
  filter: invert(1);
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 400;
  color: var(--text-dark);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--text-dark);
  border-color: var(--text);
}

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* Nav row */
.header-nav {
  border-top: 1px solid var(--border);
  border-bottom: 3px solid var(--text-dark);
}

[data-theme="dark"] .header-nav {
  border-bottom-color: var(--accent);
}

.main-nav ul {
  display: flex;
  list-style: none;
  gap: 0;
  align-items: center;
}

.main-nav a {
  display: block;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--accent);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text-dark);
  transition: transform 0.2s;
}

/* === Header Search (Pagefind) === */
.header-search {
  flex: 1;
  max-width: 480px;
  margin: 0 20px;
  position: relative;
}

.header-search .pagefind-ui {
  position: relative;
}

.header-search .pagefind-ui__search-input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.header-search .pagefind-ui__search-input::placeholder {
  color: var(--text-light);
}

.header-search .pagefind-ui__search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(57, 67, 183, 0.15);
}

[data-theme="dark"] .header-search .pagefind-ui__search-input:focus {
  box-shadow: 0 0 0 2px rgba(90, 99, 216, 0.25);
}

.header-search .pagefind-ui__search-clear {
  right: 10px;
  color: var(--text-light);
}

/* Hide the default Pagefind form label and icon overrides */
.header-search .pagefind-ui__form::before {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.4;
}

/* Results dropdown */
.header-search .pagefind-ui__drawer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
}

[data-theme="dark"] .header-search .pagefind-ui__drawer {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.header-search .pagefind-ui__result {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.header-search .pagefind-ui__result:last-child {
  border-bottom: none;
}

.header-search .pagefind-ui__result-link {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
}

.header-search .pagefind-ui__result-link:hover {
  color: var(--accent);
}

.header-search .pagefind-ui__result-excerpt {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-top: 4px;
}

.header-search mark {
  background: rgba(57, 67, 183, 0.15);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
}

[data-theme="dark"] .header-search mark {
  background: rgba(90, 99, 216, 0.25);
}

.header-search .pagefind-ui__message {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-light);
}

.header-search .pagefind-ui__button {
  margin: 8px 14px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.header-search .pagefind-ui__button:hover {
  background: var(--accent-hover);
}

/* Search toggle (mobile only) */
.search-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-light);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

.search-toggle:hover {
  color: var(--text-dark);
  border-color: var(--text);
}

/* === Hero === */
.hero {
  margin: 30px 0 20px;
  position: relative;
  overflow: hidden;
}

.hero-link {
  display: block;
  position: relative;
  color: #fff;
}

.hero-image {
  position: relative;
}

.hero-image img {
  width: 100%;
  height: 450px;
  object-fit: cover;
}

.hero-image::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}

.hero-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  z-index: 2;
}

.hero-content .category-badge {
  margin-bottom: 12px;
}

.hero-content h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  margin-bottom: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* === Content Grid === */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 30px;
  margin: 0 0 30px;
}

/* === Section Title === */
.section-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--text-dark);
  position: relative;
}

[data-theme="dark"] .section-title {
  border-bottom-color: var(--accent);
}

/* === Post List (horizontal layout like JNews) === */
.post-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-card {
  display: flex;
  gap: 0;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  transition: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

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

.post-card:hover {
  transform: none;
  box-shadow: none;
}

.post-card-link {
  display: flex;
  gap: 20px;
  color: inherit;
  width: 100%;
}

.post-card-image {
  flex-shrink: 0;
  width: 240px;
}

.post-card-image img {
  width: 240px;
  height: 160px;
  object-fit: cover;
}

.post-card-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.post-card-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 6px;
  color: var(--text-dark);
}

.post-card-title:hover {
  color: var(--accent);
}

.post-card .post-excerpt {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === Category Badge === */
.category-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 4px 7px;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
}

/* === Post Meta === */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  font-size: 12px;
  color: var(--text-light);
  align-items: center;
}

.post-meta .by-text {
  margin-right: 3px;
}

.post-meta .author {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--text-light);
}

.post-meta .meta-sep {
  margin: 0 8px;
  color: var(--text-light);
}

.post-meta time {
  text-transform: uppercase;
  font-size: 11px;
}

.reading-time {
  font-size: 12px;
}

.reading-time::before {
  content: "";
  margin: 0;
}

/* === Subtitle === */
.subtitle {
  font-size: 22px;
  color: var(--text-light);
  font-style: normal;
  font-weight: 300;
  margin: 0 0 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

/* === Single Post === */
.single-post .post-header {
  margin-bottom: 20px;
}

.single-post .post-header h1 {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 10px;
  color: var(--text-dark);
}

.featured-image {
  margin-bottom: 25px;
  border-radius: 0;
  overflow: hidden;
}

.featured-image img {
  width: 100%;
  object-fit: cover;
}

/* === Article Body === */
.article-body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
}

.article-body h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  margin: 25px 0 15px;
  color: var(--text-dark);
}

.article-body h3 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--text-dark);
}

.article-body p { margin-bottom: 20px; }

.article-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 15px 20px;
  margin: 20px 0;
  background: var(--bg-secondary);
  border-radius: 0;
  font-style: italic;
}

.article-body ul, .article-body ol {
  margin: 15px 0 20px 25px;
}

.article-body li { margin-bottom: 8px; }

.article-body img {
  border-radius: 0;
  margin: 20px auto;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
}

/* === Static Page (no sidebar) === */
.page-content {
  max-width: 780px;
  margin: 0 auto;
  padding-bottom: 30px;
}

/* === Breadcrumb === */
.breadcrumb {
  font-size: 12px;
  margin-bottom: 15px;
  color: var(--text-light);
}

.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 6px; }

/* === Tags === */
.post-tags {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 5px 12px;
  background: var(--bg-secondary);
  border-radius: 0;
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s;
}

.tag:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Reading Progress Bar === */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* === Share Buttons === */
.share-buttons {
  display: flex;
  gap: 0;
  margin-top: 20px;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
  font-family: var(--font-body);
}

.share-btn:hover {
  opacity: 0.85;
  color: #fff;
}

.share-facebook { background: #1877f2; }
.share-x { background: #000; }

.share-link {
  background: var(--text-light);
  flex: 0 0 auto;
  padding: 12px 20px;
}

/* === Author Box === */
.author-box {
  display: flex;
  gap: 20px;
  margin-top: 25px;
  padding: 25px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.author-box-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-box-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

.author-box-name:hover {
  color: var(--accent-hover);
}

.author-box-bio {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* === Author Hero (taxonomy page) === */
.author-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 32px;
  background: var(--bg-alt);
  border-radius: 8px;
  margin-bottom: 32px;
}
.author-hero-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.author-hero-name {
  font-size: 28px;
  margin: 0 0 8px 0;
}
.author-hero-bio {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 768px) {
  .author-hero {
    flex-direction: column;
    text-align: center;
    padding: 24px;
  }
  .author-hero-avatar {
    width: 100px;
    height: 100px;
  }
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
}

.widget {
  background: var(--card-bg);
  border-radius: 0;
  padding: 0;
  margin-bottom: 30px;
  box-shadow: none;
}

.widget-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--text-dark);
}

[data-theme="dark"] .widget-title {
  border-bottom-color: var(--accent);
}

.recent-posts { list-style: none; }

.recent-posts li {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.recent-posts li:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.recent-posts a {
  display: flex;
  gap: 12px;
  color: var(--text-dark);
  align-items: flex-start;
}

.recent-posts .thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 0;
  flex-shrink: 0;
}

.recent-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recent-posts time {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  display: block;
  margin-top: 4px;
}

.category-list { list-style: none; }

.category-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.category-list a {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 14px;
}

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

.category-list .count {
  color: var(--text-light);
  font-size: 13px;
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin: 25px 0;
  padding-top: 20px;
}

.page-link {
  padding: 8px 18px;
  border-radius: 0;
  background: var(--accent);
  color: #fff !important;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.page-link:hover { background: var(--accent-hover); }

.page-info {
  font-size: 13px;
  color: var(--text-light);
}

/* === Footer === */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 40px 0 20px;
  margin-top: 40px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  margin-bottom: 25px;
}

.site-footer h3 {
  font-family: var(--font-heading);
  color: #fff;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 700;
}

.footer-links {
  list-style: none;
  margin-top: 10px;
}

.footer-links li { line-height: 2; }

.footer-links a {
  color: var(--footer-text);
  font-size: 14px;
}

.footer-links a:hover { color: #fff; }

.footer-categories ul {
  list-style: none;
  columns: 2;
}

.footer-categories a {
  color: var(--footer-text);
  font-size: 14px;
  line-height: 2;
}

.footer-categories a:hover { color: #fff; }

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

/* === Responsive === */
@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .header-search {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    max-width: none;
    padding: 10px 15px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 150;
  }

  .header-search.open {
    display: block;
  }

  .header-search .pagefind-ui__drawer {
    position: relative;
    margin-top: 8px;
    max-height: 50vh;
  }

  .search-toggle { display: flex; }

  .nav-toggle { display: flex; }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
  }

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

  .main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  .main-nav a {
    display: block;
    padding: 10px 20px;
  }

  .hero-image img { height: 280px; }

  .hero-content {
    padding: 20px;
  }

  .hero-content h1 { font-size: 1.3rem; }

  .post-card-link {
    flex-direction: column;
    gap: 12px;
  }

  .post-card-image {
    width: 100%;
  }

  .post-card-image img {
    width: 100%;
    height: 200px;
  }

  .single-post .post-header h1 { font-size: 26px; }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}
