@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Cairo', sans-serif;
  background: #ffffff;
  color: #1a1a1a;
}

.page-shell {
  padding: 24px 40px;
}

h1.page-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 20px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e5e5;
}

.container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 1400px;
  direction: ltr;
}

.main-col {
  flex: 2.2;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.card {
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  direction: rtl;
}

.card-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  padding: 18px 20px;
  margin: 0;
  border-bottom: 1px solid #eee;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a:hover {
  color: #2563eb;
}

.card-body {
  padding: 18px 20px;
}

.card-thumb {
  width: 34px;
  height: 34px;
  background: #f2f2f2;
  border-radius: 4px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 12px;
}

.card-text {
  font-size: 15px;
  line-height: 1.9;
  color: #222;
  margin: 0 0 14px 0;
}

.card-link {
  color: #2563eb;
  font-size: 15px;
  text-decoration: none;
  font-weight: 500;
}

.card-link:hover {
  text-decoration: underline;
}

.card-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.sidebar {
  flex: 1.3;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  padding: 18px;
  direction: rtl;
  min-width: 0;
}

@media (min-width: 901px) {
  .sidebar {
    position: sticky;
    top: 88px;
    align-self: flex-start;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
  }
}

@media (max-width: 900px) {
  .page-shell {
    padding: 20px 16px;
  }

  h1.page-title {
    font-size: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .container {
    flex-direction: column;
    gap: 16px;
  }

  /* Filter on top, posts below */
  .sidebar {
    order: -1;
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .main-col {
    order: 1;
    width: 100%;
  }

  .tags {
    gap: 8px;
  }

  .tag {
    font-size: 13px;
    padding: 7px 14px;
  }

  .card-title {
    font-size: 17px;
    padding: 14px 16px;
  }

  .card-body {
    padding: 14px 16px;
  }

  .card-image {
    height: 180px;
  }

  .card-text {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding: 16px 12px;
  }

  .card-image {
    height: 160px;
  }

  .tags {
    gap: 6px;
  }

  .tag {
    font-size: 12px;
    padding: 6px 12px;
  }
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: #f2f2f2;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  white-space: nowrap;
  text-decoration: none;
}

.tag.active {
  background: #1a1a1a;
  color: #fff;
}

.empty-state {
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  color: #6b7280;
}

.pagination {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  color: #111;
  font-weight: 600;
}

.pagination .current {
  background: #111;
  color: #fff;
  border-color: #111;
}

body.dark-mode {
  background: #000;
  color: #fff;
}

body.dark-mode .page-title,
body.dark-mode .card-title,
body.dark-mode .card-text {
  color: #fff;
}

body.dark-mode .card,
body.dark-mode .sidebar {
  background: #111;
  border-color: #333;
}

body.dark-mode .tag {
  background: #222;
  color: #fff;
}

body.dark-mode .tag.active {
  background: #fff;
  color: #111;
}

body.dark-mode .empty-state {
  border-color: #444;
  color: #d1d5db;
}
