/*
Theme Name: ChemInfo Modern
Theme URI: https://cheminfo.uz/
Author: ChemInfo CMS Team
Description: Tezkor, yengil va zamonaviy kimyo va ilm-fan portali dizayni.
Version: 1.0.0
*/

:root {
  --blue: #22438c;
  --blue-dark: #193166;
  --blue-light: #2c56b3;
  --blue-hover: #1c3875;
  --text: #1e293b;
  --text-muted: #64748b;
  --bg: #f4f6f8;
  --white: #ffffff;
  --border: #e2e8f0;
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--blue-dark);
}

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

.container {
  width: min(calc(100% - 32px), 1160px);
  margin: 0 auto;
}

/* Topline Social & Info Bar */
.topline {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  color: var(--text-muted);
}
.topline-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
}
.topline-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topline-social {
  display: flex;
  align-items: center;
  gap: 8px;
}
.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  color: #64748b;
  transition: all 0.15s ease;
}
.social-icon:hover {
  background: #e2e8f0;
  color: var(--blue);
}

/* Brand Header */
.brand-header {
  background: var(--white);
  padding: 24px 0 20px;
  text-align: center;
  border-bottom: 1px solid #eef2f6;
}
.brand {
  font-size: 42px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: -0.5px;
  display: inline-block;
  line-height: 1;
}
.brand span {
  color: #2563eb;
}
.brand-header p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* Main Navigation Bar */
.main-nav {
  background: var(--blue);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(15, 25, 75, 0.18);
}
.nav-inner {
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.nav-inner::-webkit-scrollbar {
  display: none;
}
.nav-inner > a {
  color: #ffffff;
  padding: 0 14px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 3px solid transparent;
  transition: all 0.18s ease;
}
.nav-inner > a:hover {
  background: var(--blue-hover);
  color: #ffffff;
}
.nav-inner > a.active {
  background: var(--blue-dark);
  border-bottom-color: #60a5fa;
  color: #ffffff;
}

/* Nav Search Box & Sticky Right (Always visible on all screens!) */
.nav-search-wrap {
  margin-left: auto;
  position: sticky;
  right: 0;
  background: var(--blue);
  display: flex;
  align-items: center;
  padding: 0 6px 0 12px;
  height: 48px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: -10px 0 16px rgba(34, 67, 140, 0.95);
}
.nav-search-form {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 3px 6px 3px 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-search-form:focus-within {
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  border-color: #ffffff;
}
.nav-search-form input {
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 13px;
  width: 65px;
  outline: none;
  font-family: inherit;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}
.nav-search-form input::placeholder {
  color: rgba(255, 255, 255, 0.85);
  transition: color 0.2s ease;
}
.nav-search-form:focus-within input {
  color: #1e293b;
  width: 220px;
}
.nav-search-form:focus-within input::placeholder {
  color: #94a3b8;
}
.nav-search-form button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  font-size: 14px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.15s ease;
  outline: none;
}
.nav-search-form:focus-within button {
  color: #22438c;
}
.nav-search-form button:hover {
  transform: scale(1.18);
}

/* Nav Search Dropdown */
.nav-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 6px;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
  max-height: 420px;
  overflow-y: auto;
  z-index: 10000;
  display: none;
}
.nav-search-dropdown.active {
  display: block;
  animation: searchDropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes searchDropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-dropdown-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  display: block;
  text-decoration: none;
  transition: background 0.15s ease;
}
.search-dropdown-item:hover {
  background: #f8fafc;
}
.search-dropdown-item h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--blue);
  font-weight: 600;
}
.search-dropdown-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.search-dropdown-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 680px) {
  .nav-search-form:focus-within input {
    width: 140px;
  }
}
@media (max-width: 420px) {
  .nav-search-form input {
    width: 48px;
  }
  .nav-search-form:focus-within input {
    width: 110px;
  }
}

/* Layout Grid */
.content-wrap {
  padding: 32px 0 60px;
}
.blog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 32px;
}
.primary-column {
  min-width: 0;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Section Title */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 10px;
  margin-bottom: 24px;
}
.section-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.section-title span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Post Cards & Grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}
.post-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.card-visual {
  height: 160px;
  background-color: #e2e8f0;
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.visual-01 {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
  flex-direction: column;
}
.visual-01 strong {
  font-size: 32px;
  line-height: 1;
}
.visual-01 span {
  font-size: 10px;
  letter-spacing: 1px;
  opacity: 0.8;
}
.post-content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.category {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--blue);
  letter-spacing: 0.5px;
  margin: 0 0 6px;
}
.post-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 700;
}
.post-card h3 a {
  color: var(--text);
}
.post-card h3 a:hover {
  color: var(--blue);
}
.lead {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-meta {
  margin-top: auto;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

/* Featured Post (Hero) */
.featured-post {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.featured-visual {
  min-height: 280px;
  background-size: cover;
  background-position: center;
  position: relative;
  background-color: #1e3a8a;
  display: flex;
  align-items: flex-end;
  padding: 24px;
}
.featured-badge {
  background: var(--blue);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.featured-post .post-content {
  padding: 24px;
}
.featured-post h1 {
  font-size: clamp(22px, 3.5vw, 28px);
  margin: 0 0 12px;
  line-height: 1.25;
  font-weight: 800;
}

/* Single Article View */
.single-article-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 32px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.single-article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.article-featured-image-wrap {
  margin-bottom: 24px;
}
.article-featured-image-wrap img {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: var(--radius);
}
.tag-badge {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.tag-badge:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Scaled Article Body Typography (18px base) */
.rich-editor-surface {
  font-size: 18px;
  line-height: 1.75;
  color: #1e293b;
}
.rich-editor-surface p {
  font-size: 18px;
  line-height: 1.75;
  margin: 0 0 20px;
}
.rich-editor-surface ul, .rich-editor-surface ol {
  font-size: 17.5px;
  line-height: 1.7;
  margin: 0 0 20px 22px;
  padding: 0;
}
.rich-editor-surface li {
  margin-bottom: 6px;
}
.rich-editor-surface blockquote {
  font-size: 19px;
  line-height: 1.7;
  font-style: italic;
  color: #334155;
  border-left: 4px solid var(--blue);
  background: #f8fafc;
  padding: 12px 20px;
  margin: 22px 0;
  border-radius: 0 6px 6px 0;
}
.rich-editor-surface h2 {
  font-size: 25px;
  line-height: 1.35;
  margin: 30px 0 14px;
  color: #0f172a;
  font-weight: 800;
}
.rich-editor-surface h3 {
  font-size: 21px;
  line-height: 1.4;
  margin: 26px 0 12px;
  color: #0f172a;
  font-weight: 700;
}
.rich-editor-surface h4 {
  font-size: 18px;
  line-height: 1.45;
  margin: 22px 0 10px;
  color: #1e293b;
  font-weight: 700;
}
.rich-editor-surface table {
  display: block;
  width: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 17px;
}
.rich-editor-surface th, .rich-editor-surface td {
  border: 1px solid #dcdcde;
  padding: 10px 14px;
}
.rich-editor-surface th {
  background: #f8fafc;
  font-weight: 700;
}
.rich-editor-surface img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
  margin: 20px auto;
}
.rich-editor-surface pre, .rich-editor-surface code {
  max-width: 100%;
  overflow-x: auto;
}

/* Sidebar Widgets */
.widget {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.widget h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 8px;
}
.categories-widget a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
  color: var(--text);
}
.categories-widget a:last-child {
  border-bottom: none;
}
.categories-widget a:hover {
  color: var(--blue);
}
.categories-widget a b {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Pagination */
.pagination-wrap, .navigation.pagination {
  margin: 32px 0 0;
  text-align: center;
}
.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s ease;
}
.page-numbers:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--blue);
}
.page-numbers.current {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}
.page-numbers.dots {
  border: none;
  background: transparent;
}

/* Ad Inserter Frontend Styling */
.ai-ad-wrapper {
  margin: 20px 0;
  text-align: center;
}
.ai-align-center {
  margin: 20px auto;
  text-align: center;
}
.ai-align-left {
  float: left;
  margin: 10px 20px 14px 0;
  max-width: 50%;
}
.ai-align-right {
  float: right;
  margin: 10px 0 14px 20px;
  max-width: 50%;
}
.ai-between-posts {
  grid-column: 1 / -1;
  width: 100%;
  margin: 14px 0;
}
@media (max-width: 680px) {
  .ai-device-desktop { display: none !important; }
  .ai-align-left, .ai-align-right { float: none; max-width: 100%; margin: 14px auto; text-align: center; }
}
@media (min-width: 681px) {
  .ai-device-mobile { display: none !important; }
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 32px 0;
  font-size: 13px;
  border-top: 1px solid #1e293b;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.site-footer strong {
  color: #ffffff;
}
.site-footer p {
  margin: 0;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .blog-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
  }
}

@media (max-width: 900px) {
  .blog-layout {
    grid-template-columns: 1fr;
    padding: 16px 0 36px;
  }
  .sidebar {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

@media (max-width: 680px) {
  .container {
    width: min(calc(100% - 24px), 1160px);
  }
  .topline-date {
    display: none;
  }
  .topline-inner {
    justify-content: center;
  }
  .brand {
    font-size: 32px;
  }
  .brand-header {
    padding: 16px 0 14px;
  }
  .nav-inner > a {
    padding: 0 10px;
    font-size: 11.5px;
    height: 42px;
  }
  .single-article-card {
    padding: 18px 14px !important;
    border-radius: 6px !important;
  }
  .rich-editor-surface, .rich-editor-surface p {
    font-size: 16px !important;
    line-height: 1.7 !important;
    margin-bottom: 16px !important;
  }
  .rich-editor-surface ul, .rich-editor-surface ol {
    font-size: 15.5px !important;
    margin-left: 18px !important;
  }
  .rich-editor-surface h2 {
    font-size: 21px !important;
    margin: 24px 0 10px !important;
  }
  .rich-editor-surface h3 {
    font-size: 18px !important;
    margin: 20px 0 8px !important;
  }
  .rich-editor-surface blockquote {
    font-size: 16.5px !important;
    padding: 10px 14px !important;
  }
}

/* Mobile-first navigation and overflow hardening */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.mobile-nav-bar {
  display: none;
}

.mobile-nav-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  min-height: 48px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.mobile-nav-toggle-icon {
  font-size: 22px;
  line-height: 1;
}

.rich-editor-surface {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.rich-editor-surface iframe,
.rich-editor-surface video,
.rich-editor-surface embed,
.rich-editor-surface object {
  display: block;
  width: 100%;
  max-width: 100%;
}

.rich-editor-surface .katex-display,
.rich-editor-surface pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ai-ad-wrapper,
.ai-ad-wrapper iframe,
.ai-ad-wrapper img,
.ai-between-posts {
  max-width: 100%;
}

@media (max-width: 782px) {
  .mobile-nav-bar {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  .mobile-nav-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .nav-inner {
    display: none;
    width: min(calc(100% - 24px), 1160px);
    padding: 8px 0 12px;
    overflow: visible;
    flex-direction: column;
    align-items: stretch;
  }

  .main-nav.is-open .nav-inner {
    display: flex;
  }

  .nav-inner > a {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    justify-content: flex-start;
    font-size: 14px;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }

  .nav-search-wrap {
    width: 100%;
    height: auto;
    margin: 8px 0 0;
    padding: 0;
    position: relative;
    right: auto;
    box-shadow: none;
  }

  .nav-search-form {
    width: 100%;
    min-height: 44px;
    border-radius: 7px;
    padding: 4px 6px 4px 12px;
  }

  .nav-search-form input,
  .nav-search-form:focus-within input {
    width: auto;
    min-width: 0;
    flex: 1;
    font-size: 16px;
  }

  .nav-search-form button {
    min-width: 40px;
    min-height: 40px;
  }

  .nav-search-dropdown {
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
  }

  .content-wrap {
    padding: 20px 0 40px;
  }

  .blog-layout {
    padding: 0;
    gap: 22px;
  }

  .featured-visual {
    min-height: 200px;
    padding: 16px;
  }

  .featured-post,
  .post-card,
  .single-article-card,
  .widget {
    box-shadow: none;
  }

  .featured-post .post-content {
    padding: 18px;
  }

  .featured-post h1 {
    font-size: 23px;
  }

  .post-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 18px;
  }

  .single-article-card > h1 {
    overflow-wrap: anywhere;
  }

  .single-article-meta {
    gap: 8px 12px;
    margin-bottom: 18px;
    padding-bottom: 12px;
  }

  .article-featured-image-wrap {
    margin-bottom: 18px;
  }

  .rich-editor-surface table {
    display: block;
    width: 100% !important;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .rich-editor-surface th,
  .rich-editor-surface td {
    min-width: 112px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .rich-editor-surface a {
    overflow-wrap: anywhere;
  }

  .sidebar {
    gap: 18px;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 380px) {
  .container {
    width: min(calc(100% - 16px), 1160px);
  }

  .brand {
    font-size: 28px;
  }

  .brand-header p {
    font-size: 13px;
  }

  .single-article-card {
    padding: 16px 12px !important;
  }

  .page-numbers {
    min-width: 34px;
    height: 34px;
  }
}
