/* ============================================================
   community.css — ZabiTech Community
   Refined responsive blue-and-white design
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --primary: #0878e8;
  --primary-dark: #0561bd;
  --primary-deep: #034b96;
  --primary-soft: rgba(8, 120, 232, .10);
  --primary-glow: rgba(8, 120, 232, .24);

  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --header-height: 64px;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .05), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow-md: 0 10px 28px -16px rgba(15, 23, 42, .22);
  --shadow-lg: 0 22px 48px -24px rgba(3, 75, 150, .38);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

body.community-page {
  min-height: 100vh;
  padding-top: var(--header-height);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video { max-width: 100%; }
img { height: auto; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(8, 120, 232, .45);
  outline-offset: 3px;
}

::selection {
  color: #fff;
  background: var(--primary);
}

/* ============================================================
   HEADER
   ============================================================ */
.blue-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: linear-gradient(110deg, #0878e8 0%, #066ed3 55%, #0565c4 100%);
  box-shadow: 0 2px 10px rgba(2, 45, 92, .12);
}

.blue-header .container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  flex: 0 0 auto;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -.035em;
  white-space: nowrap;
}

.blue-header nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}

.blue-header nav a {
  padding: 8px 12px;
  border-radius: 12px;
  color: rgba(255, 255, 255, .96);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.blue-header nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .16);
}

.blue-header nav a:active { transform: translateY(1px); }

.blue-header nav a.active,
.blue-header nav a[aria-current="page"] {
  color: var(--primary-dark);
  background: #fff;
  font-weight: 650;
  box-shadow: 0 2px 7px rgba(0, 0, 0, .08);
}

/* ============================================================
   MAIN LAYOUT / PAGE INTRO
   ============================================================ */
main.container {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 22px auto 34px;
  padding: 0 20px;
}

.page-head { margin-bottom: 1.45rem; }

h1 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: clamp(1.65rem, 2.7vw, 2.05rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.035em;
}

.sub {
  max-width: 900px;
  margin: 0;
  padding: 1px 0 1px 1rem;
  border-left: 4px solid var(--primary);
  color: var(--ink-2);
  font-size: .96rem;
  line-height: 1.65;
}

.sub strong { color: var(--ink); font-weight: 700; }

/* ============================================================
   FEATURED ARTICLE
   Uses a decorative CSS-generated monitor on the right.
   ============================================================ */
.featured {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 260px;
  margin-bottom: 1.35rem;
  padding: 2rem 2rem;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse at 88% 15%, rgba(66, 190, 255, .36), transparent 32%),
    linear-gradient(120deg, #0878e8 0%, #066bc9 54%, #0457ad 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

/* Soft decorative light */
.featured::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -145px;
  right: -85px;
  width: 390px;
  height: 390px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, .04) 36%, transparent 70%);
  pointer-events: none;
}

/* Decorative monitor illustration */
.featured::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  right: 3.5%;
  width: clamp(245px, 29%, 350px);
  aspect-ratio: 4 / 3;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3ClinearGradient id='screen' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23ffffff' stop-opacity='.17'/%3E%3Cstop offset='1' stop-color='%23ffffff' stop-opacity='.055'/%3E%3C/linearGradient%3E%3Cfilter id='shadow' x='-30%25' y='-30%25' width='160%25' height='170%25'%3E%3CfeGaussianBlur stdDeviation='9'/%3E%3C/filter%3E%3C/defs%3E%3Cellipse cx='205' cy='270' rx='125' ry='12' fill='%23002f67' opacity='.2' filter='url(%23shadow)'/%3E%3Cpath d='M175 232h50l13 29h-76z' fill='%23ffffff' fill-opacity='.19'/%3E%3Crect x='126' y='258' width='148' height='12' rx='6' fill='%23ffffff' fill-opacity='.22'/%3E%3Crect x='39' y='28' width='322' height='211' rx='17' fill='url(%23screen)' stroke='%23ffffff' stroke-opacity='.29' stroke-width='2'/%3E%3Cpath d='M56 28h288a17 17 0 0 1 17 17v27H39V45a17 17 0 0 1 17-17z' fill='%23ffffff' fill-opacity='.12'/%3E%3Cpath d='M39 72h322' stroke='%23ffffff' stroke-opacity='.19' stroke-width='2'/%3E%3Ccircle cx='65' cy='50' r='6' fill='%23ff6258'/%3E%3Ccircle cx='86' cy='50' r='6' fill='%23ffc044'/%3E%3Ccircle cx='107' cy='50' r='6' fill='%2334d399'/%3E%3Crect x='65' y='94' width='124' height='12' rx='5' fill='%23bde7ff' fill-opacity='.62'/%3E%3Crect x='65' y='119' width='207' height='12' rx='5' fill='%23ffffff' fill-opacity='.25'/%3E%3Crect x='65' y='144' width='171' height='12' rx='5' fill='%23ffffff' fill-opacity='.22'/%3E%3Crect x='65' y='169' width='92' height='12' rx='5' fill='%23bde7ff' fill-opacity='.48'/%3E%3Crect x='65' y='194' width='184' height='12' rx='5' fill='%23ffffff' fill-opacity='.22'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: .95;
  pointer-events: none;
  filter: drop-shadow(0 15px 18px rgba(0, 35, 80, .13));
  transition: transform .35s ease, opacity .35s ease;
}

.featured:hover::before {
  transform: translateY(-50%) scale(1.045);
  opacity: 1;
}

.featured .tag {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  margin-bottom: 13px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .065em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.featured h2 {
  position: relative;
  z-index: 1;
  max-width: min(65%, 720px);
  margin: 0 0 12px;
  color: #fff;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.24;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.featured p {
  position: relative;
  z-index: 1;
  max-width: min(61%, 640px);
  margin: 0 0 20px;
  color: rgba(255, 255, 255, .94);
  font-size: .96rem;
  line-height: 1.6;
}

.featured .read-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: .9rem;
  font-weight: 650;
  transition: background .2s ease, gap .2s ease, transform .2s ease;
  backdrop-filter: blur(8px);
}

.featured .read-link:hover {
  gap: 12px;
  background: rgba(255, 255, 255, .25);
  transform: translateY(-1px);
}

/* ============================================================
   FILTER TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.45rem;
  padding: .75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
}

.category-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
}

.filter-chip {
  flex: 0 0 auto;
  padding: .43rem .92rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font-size: .82rem;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.filter-chip:hover:not(.active) {
  border-color: rgba(8, 120, 232, .45);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.filter-chip:active { transform: scale(.98); }

.filter-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 8px rgba(8, 120, 232, .2);
}

.search-box {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: .25rem .65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-box input {
  width: 210px;
  min-width: 0;
  padding: .48rem .35rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: .85rem;
}

.search-box input::placeholder { color: var(--muted-2); }

.search-box button.clear-search {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

.search-box button.clear-search:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ============================================================
   ARTICLE FEED GRID
   ============================================================ */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  align-items: stretch;
  gap: 1.35rem;
  margin-top: .5rem;
}

/* ============================================================
   ARTICLE CARD
   ============================================================ */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #25b8e6);
  opacity: 0;
  transition: opacity .22s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(8, 120, 232, .35);
  box-shadow: 0 16px 30px -20px rgba(8, 70, 140, .4);
}

.card:hover::before { opacity: 1; }

.card h2 {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 .72rem;
  color: var(--ink);
  font-size: 1.04rem;
  font-weight: 750;
  line-height: 1.38;
  letter-spacing: -.015em;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card .meta,
.card .meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 .85rem;
  color: var(--muted);
  font-size: .76rem;
}

.card .category-tag {
  display: inline-flex;
  align-items: center;
  padding: .23rem .62rem;
  border: 1px solid rgba(30, 64, 175, .10);
  border-radius: 999px;
  background: #eef4ff;
  color: #1e40af;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-transform: capitalize;
}

.card .category-tag::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}

.card .post-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: .73rem;
}

.card .preview,
.card .excerpt {
  display: -webkit-box;
  overflow: hidden;
  flex-grow: 1;
  margin: 0 0 .9rem;
  color: var(--ink-2);
  font-size: .88rem;
  line-height: 1.58;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card .read,
.card .read-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-top: auto;
  padding-top: .65rem;
  color: var(--primary);
  font-size: .86rem;
  font-weight: 700;
  transition: gap .18s ease, color .18s ease;
}

.card .read:hover,
.card .read-link:hover {
  gap: .7rem;
  color: var(--primary-dark);
  text-decoration: underline;
}

.byline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: .8rem;
  padding-top: .8rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
}

.byline .avatar {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #18b7df);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton-card {
  min-height: 220px;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  animation: community-pulse 1.25s ease-in-out infinite;
}

.skeleton-card .line {
  margin-bottom: 1rem;
  border-radius: 10px;
  background: #e7edf4;
}

.skeleton-card .line.title { width: 80%; height: 25px; }
.skeleton-card .line.meta { width: 46%; height: 17px; border-radius: 20px; }
.skeleton-card .line.short { width: 100%; height: 58px; }

@keyframes community-pulse {
  0%, 100% { opacity: .62; }
  50% { opacity: 1; }
}

.loader {
  grid-column: 1 / -1;
  width: 36px;
  height: 36px;
  margin: 40px auto;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: community-spin .8s linear infinite;
}

@keyframes community-spin { to { transform: rotate(360deg); } }

/* ============================================================
   EMPTY / ERROR STATES
   ============================================================ */
.empty,
.load-error,
.empty-state,
.error-state {
  grid-column: 1 / -1;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xl);
  background: #fff;
  color: var(--muted);
  font-size: .94rem;
  text-align: center;
}

.empty::before {
  content: "📭";
  display: block;
  margin-bottom: 12px;
  font-size: 2.7rem;
  opacity: .6;
}

.load-error::before,
.error-state::before {
  content: "⚠️";
  display: block;
  margin-bottom: 12px;
  font-size: 2.7rem;
}

.load-error button,
.retry-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: .62rem 1.35rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}

.load-error button:hover,
.retry-btn:hover { background: var(--primary-dark); }
.load-error button:active,
.retry-btn:active { transform: translateY(1px); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  margin-top: auto;
  padding: 24px 0;
  background: linear-gradient(110deg, #0878e8, #0565c4);
  color: #fff;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-footer p {
  margin: 0;
  font-size: .84rem;
  line-height: 1.55;
  opacity: .94;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links a {
  color: #fff;
  font-size: .84rem;
  font-weight: 550;
  opacity: .92;
  transition: opacity .18s ease;
}

.footer-links a:hover { opacity: 1; text-decoration: underline; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 1500px) {
  main.container { max-width: 1320px; }
}

@media (max-width: 1000px) {
  .blue-header .container { gap: 12px; }
  .blue-header nav a { padding: 7px 9px; font-size: .84rem; }
  .featured h2 { max-width: 62%; }
  .featured p { max-width: 58%; }
  .feed-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
}

@media (max-width: 760px) {
  :root { --header-height: 60px; }

  .blue-header .container { padding: 0 14px; }
  .logo { font-size: 1.05rem; }
  .blue-header nav { gap: 2px; }
  .blue-header nav a { padding: 6px 8px; font-size: .78rem; }

  main.container { margin: 18px auto 26px; padding: 0 16px; }

  .featured {
    min-height: 235px;
    padding: 1.65rem 1.4rem;
    border-radius: 20px;
  }

  .featured::before {
    right: 1%;
    width: 34%;
    opacity: .55;
  }

  .featured h2 { max-width: 70%; font-size: 1.4rem; }
  .featured p { max-width: 67%; font-size: .9rem; }
  .toolbar { border-radius: 22px; }
  .search-box input { width: 175px; }
  .feed-grid { gap: 1rem; }
}

@media (max-width: 560px) {
  :root { --header-height: 0px; }

  body.community-page { padding-top: 0; }

  .blue-header {
    position: relative;
    height: auto;
    min-height: 60px;
    padding: 10px 0;
  }

  .blue-header .container {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .logo { font-size: 1.12rem; }

  .blue-header nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 0 3px;
    scrollbar-width: thin;
  }

  .blue-header nav a {
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: .82rem;
  }

  main.container { margin: 18px auto 24px; padding: 0 13px; }

  h1 { font-size: 1.55rem; }
  .sub { padding-left: .75rem; font-size: .9rem; }

  .featured {
    min-height: 0;
    padding: 1.45rem 1.2rem;
    border-radius: 18px;
  }

  /* Keep the banner clean on narrow screens */
  .featured::before { display: none; }
  .featured::after { right: -190px; opacity: .65; }
  .featured .tag { margin-bottom: 11px; font-size: .66rem; }
  .featured h2 { max-width: 100%; font-size: 1.28rem; }
  .featured p { max-width: 100%; margin-bottom: 17px; font-size: .88rem; }
  .featured .read-link { padding: 9px 14px; font-size: .86rem; }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: .8rem;
    padding: .9rem;
    border-radius: 18px;
  }

  .category-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: thin;
  }

  .filter-chip { padding: .42rem .82rem; font-size: .8rem; }

  .search-box { width: 100%; }
  .search-box input { width: 100%; }

  .feed-grid { grid-template-columns: 1fr; gap: .9rem; }
  .card { padding: 1.15rem; border-radius: 16px; }
  .card h2 { font-size: 1.02rem; }
  .footer-inner { padding: 0 14px; }
  .footer-links { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
