/* ==========================================================================
   blog.css — page-local styles for the public blog module (frontend/views/blog/).

   Loaded ONLY by frontend/views/blog/index.php and view.php, on top of
   home.css + inner.css (frontend/views/layouts/inner.php loads those two on
   every inner page already). Everything here is scoped under .blog-* /
   .ui-prose.blog-body so it can never leak onto an unrelated inner page.
   Reuses inner.css's design tokens (--ink, --gold, --muted, --line-light,
   --radius-card, --radius-control, --fs-body, --fs-meta, --surface, --page)
   with a fallback on every var(), same convention as inner.css itself.
   ========================================================================== */

/* -------------------------------- Utility: visually-hidden ----------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------- List page: compact top bar -------------------------- */

.blog-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: clamp(20px, 3vw, 32px);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-light, #e6e9ed);
}

.blog-topbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
/* More specific than breadcrumbs.php's own inline .ak-breadcrumbs{margin-bottom:24px}
   so it wins on specificity regardless of <style>/<link> registration order. */
.blog-topbar-left .ak-breadcrumbs { margin-bottom: 0; }
.blog-topbar-count { color: var(--muted, #6b7280); font-size: var(--fs-meta, 14px); font-weight: 650; white-space: nowrap; }

.blog-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.blog-filter-form {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--page, #f4f6f8);
  border-radius: var(--radius-pill, 999px);
  padding: 4px;
}
.blog-search { display: flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 40px; color: var(--muted, #6b7280); }
.blog-search input {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink, #0b1928);
  min-width: 140px;
  outline: none;
}
.blog-search input::placeholder { color: var(--muted, #6b7280); }

.blog-cat-select {
  border: 0;
  background: var(--surface, #fff);
  border-radius: var(--radius-pill, 999px);
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink, #0b1928);
  cursor: pointer;
  max-width: 180px;
}

.blog-sort,
.blog-view-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-pill, 999px);
  background: var(--page, #f4f6f8);
}
.blog-sort a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill, 999px);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted, #6b7280);
  text-decoration: none;
  white-space: nowrap;
}
.blog-sort a.active { background: var(--surface, #fff); color: var(--ink, #0b1928); box-shadow: 0 4px 12px rgba(11, 25, 40, .08); }

.blog-view-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  color: var(--muted, #6b7280);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.blog-view-toggle button.active { background: var(--surface, #fff); color: var(--ink, #0b1928); box-shadow: 0 4px 12px rgba(11, 25, 40, .08); }

@media (max-width: 680px) {
  .blog-topbar { flex-direction: column; align-items: stretch; }
  .blog-toolbar { width: 100%; }
  .blog-filter-form { flex: 1 1 auto; width: 100%; }
  .blog-search { flex: 1; }
  .blog-search input { min-width: 0; width: 100%; }
}

/* ------------------------------ List page: news grid ------------------------------ */

.blog-news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 600px) { .blog-news-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
@media (min-width: 992px) { .blog-news-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .blog-news-grid { grid-template-columns: repeat(4, 1fr); gap: 24px; } }

/* List view toggle: same cards, re-flowed into compact rows via CSS only (no server
   round-trip / duplicate markup — see frontend/views/blog/_card.php's docblock). */
.blog-news-grid.is-list {
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid var(--line-light, #e6e9ed);
}

/* --------------------------------- News card --------------------------------- */

.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-light, #e6e9ed);
  border-radius: var(--radius-card, 16px);
  background: var(--surface, #fff);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.blog-card:hover,
.blog-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(239, 182, 49, .45);
  box-shadow: 0 22px 48px -18px rgba(11, 25, 40, .28);
}

.blog-card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--surface-blue, #e7f0f7), var(--surface-warm, #f5eddd));
}
.blog-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.blog-card:hover .blog-card-media img { transform: scale(1.06); }
.blog-card-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.blog-card-placeholder img { width: 38%; max-width: 110px; height: auto; object-fit: contain; opacity: .22; }

.blog-card-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e0392b;
  box-shadow: 0 0 0 2px var(--surface, #fff);
}
.blog-card-dot[hidden] { display: none; }

.blog-card-body { display: flex; flex-direction: column; gap: 8px; padding: 16px; flex: 1; }
.blog-card-cat { align-self: flex-start; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--gold-dark, #8a6212); }
.blog-card-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 16.5px;
  font-weight: 750;
  line-height: 1.34;
  color: var(--ink, #0b1928);
}
.blog-card:hover .blog-card-title { text-decoration: underline; }
.blog-card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: auto; padding-top: 4px; font-size: 12.5px; color: var(--muted, #6b7280); }
.blog-card-meta-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* List-view row layout for the exact same .blog-card markup. */
.blog-news-grid.is-list .blog-card {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  border: 0;
  border-bottom: 1px solid var(--line-light, #e6e9ed);
  border-radius: 0;
  padding: 14px 4px;
}
.blog-news-grid.is-list .blog-card:hover { transform: none; box-shadow: none; background: var(--page, #f7f8fa); }
.blog-news-grid.is-list .blog-card-media { flex: 0 0 120px; width: 120px; aspect-ratio: 4 / 3; border-radius: var(--radius-control, 12px); }
.blog-news-grid.is-list .blog-card-body { padding: 0; gap: 4px; }
.blog-news-grid.is-list .blog-card-title { -webkit-line-clamp: 2; font-size: 15.5px; }

@media (max-width: 560px) {
  .blog-news-grid.is-list .blog-card-media { flex-basis: 88px; width: 88px; }
  .blog-news-grid.is-list .blog-card-title { font-size: 14.5px; }
}

/* ------------------------------- List page: load more ------------------------------ */

.blog-loadmore { display: flex; flex-direction: column; align-items: center; gap: 20px; margin-top: clamp(32px, 5vw, 48px); }
.blog-loadmore-divider { position: relative; width: 100%; text-align: center; }
.blog-loadmore-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line-light, #e6e9ed); }
.blog-loadmore-divider span {
  position: relative;
  display: inline-block;
  padding: 0 16px;
  background: var(--page, #f4f6f8);
  color: var(--muted, #6b7280);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.js-blog-loadmore.is-loading { opacity: .65; cursor: default; pointer-events: none; }

/* --------------------------- Article: 2-column grid shell ------------------------ */

/* Wider shell than .inner-shell--narrow — the daryo.uz-style layout needs room for
   article column + sidebar side by side; collapses to a single column (no sidebar
   width reserved) at the same breakpoint the grid itself collapses. */
.inner-shell--article { max-width: var(--container, 1180px); }

.blog-article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
}
@media (min-width: 960px) {
  .blog-article-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

.blog-article-main { min-width: 0; }

/* ------------------------------- Article: topline / title ------------------------ */

.blog-article-topline { margin-bottom: 14px; }

.blog-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill, 999px);
  background: var(--surface-warm, #f5eddd);
  color: var(--gold-dark, #8a6212);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  text-decoration: none;
}
.blog-category-chip:hover { background: var(--gold-light, #f6dfa3); }
.blog-category-chip--outline { background: transparent; border: 1px solid var(--line-light, #e2e5ea); color: var(--muted, #6b7280); text-transform: none; letter-spacing: 0; font-weight: 700; }

.blog-article-title {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -.01em;
  color: var(--ink, #0b1928);
}

.blog-article-lead {
  margin: 16px 0 0;
  padding-left: 16px;
  border-left: 3px solid var(--gold, #efb631);
  font-size: clamp(16px, 2vw, 19px);
  font-weight: 650;
  line-height: 1.55;
  color: var(--muted-strong, #4b5563);
}

.blog-article-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 16px; }

/* ------------------------------- Article: cover ---------------------------------- */

.blog-cover {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-card, 16px);
  overflow: hidden;
  margin: clamp(20px, 3vw, 28px) 0;
  background: var(--page, #f4f6f8);
}
.blog-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --------------------------- Article: prose additions ---------------------------- */

/* .ui-prose already covers p/h2/h3/ul/ol/blockquote/table/img/iframe at 17px/1.7 —
   this file only adds what the rich-text body needs beyond that base. */

.blog-body h4 { margin-top: 1.3em; font-size: 18px; line-height: 1.3; color: var(--ink); }

/* Responsive 16:9 embed: TinyMCE's raw <iframe> output (YouTube) has fixed
   width/height attributes and is NOT responsive on its own — ui-prose only caps its
   max-width, which still leaves a fixed (and on mobile, cropped-looking) height. This
   is more specific than .ui-prose iframe, so it wins without touching inner.css. */
.blog-body iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-control, 12px);
}

/* Table horizontal scroll on narrow screens — .ui-prose tables otherwise have no
   min-width/wrap guard, so a wide admin-authored table could overflow at 360-390px. */
@media (max-width: 620px) {
  .blog-body table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .blog-body th,
  .blog-body td { white-space: nowrap; }
}

/* ------------------------------- Article: share row ------------------------------- */

.blog-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: clamp(20px, 3vw, 28px) 0;
  padding: 16px 0;
  border-top: 1px solid var(--line-light, #e6e9ed);
  border-bottom: 1px solid var(--line-light, #e6e9ed);
}
.blog-share-label { color: var(--muted, #6b7280); font-size: var(--fs-ui, 15px); font-weight: 700; margin-right: 2px; }

.blog-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--line-light, #e2e5ea);
  background: var(--surface, #fff);
  color: var(--ink, #0b1928);
  font-size: 13.5px;
  font-weight: 750;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.blog-share-btn:hover { border-color: var(--gold, #efb631); background: var(--surface-warm, #f5eddd); }
.blog-share-btn--tg { color: #229ed9; border-color: #bfe3f4; }
.blog-share-btn--fb { color: #1877f2; border-color: #c7dbfc; }
.blog-share-btn--x { color: #0b1928; }

/* Body text under the top share row's icons on narrow screens would overflow the
   36px-tall pills — hide the text and keep just the short label (TG/FB/X) there. */
@media (max-width: 400px) {
  .blog-share-btn--copy span { display: none; }
}

/* ------------------------------- Article: tags ------------------------------------ */

.blog-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: clamp(24px, 3vw, 32px); }

/* ------------------------------- Article: CTA card -------------------------------- */

.blog-cta { margin-top: clamp(28px, 4vw, 40px); background: var(--surface-warm, #f5eddd); }
.blog-cta .ui-card-body { align-items: center; text-align: center; gap: 10px; }
.blog-cta h3 { margin: 0; color: var(--ink); font-size: 21px; }

/* ------------------------------ Article: sidebar ----------------------------------- */

.blog-article-aside { min-width: 0; }
.blog-aside-sticky {
  background: var(--surface, #fff);
  border: 1px solid var(--line-light, #e6e9ed);
  border-radius: var(--radius-card, 16px);
  overflow: hidden;
}
@media (min-width: 960px) {
  .blog-aside-sticky { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow-y: auto; }
}
.blog-aside-title { margin: 0; padding: 16px 18px; font-size: 15px; font-weight: 800; color: var(--ink, #0b1928); border-bottom: 1px solid var(--line-light, #e6e9ed); }
.blog-aside-list { list-style: none; margin: 0; padding: 0; }
.blog-aside-list li { border-bottom: 1px solid var(--line-light, #eef0f3); }
.blog-aside-list li:last-child { border-bottom: 0; }
.blog-aside-list a { display: block; padding: 12px 18px; text-decoration: none; color: inherit; }
.blog-aside-list a:hover,
.blog-aside-list a:focus-visible { background: var(--page, #f7f8fa); }
.blog-aside-item-date { display: block; font-size: 11.5px; color: var(--muted, #6b7280); margin-bottom: 3px; }
.blog-aside-item-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--ink, #0b1928);
}

/* ----------------------------- Article: related posts ----------------------------- */

.blog-related { margin-top: clamp(40px, 6vw, 64px); }
.blog-related h2 { margin: 0 0 20px; color: var(--ink); font-size: 24px; }

/* -------------------------------- Preview banner ----------------------------------- */

.blog-preview-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 10px 16px;
  background: #a3271b;
  color: #fff;
  font-size: var(--fs-meta, 14px);
  font-weight: 800;
  text-align: center;
  letter-spacing: .02em;
}
