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

/* ========== ROOT VARIABLES ========== */
:root {
  --brand-light: #60A5FA;
  --brand-dark: #1D4ED8;
  --background: #0F172A;
  --stroke: #1E293B;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --card-bg: #1E293B;
  --hover-glow: rgba(96, 165, 250, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow-effect: 0 0 20px rgba(96, 165, 250, 0.4);
}

/* ========== RESET & BASE ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Archivo', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ========== CONTAINER ========== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== HEADER ========== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--stroke);
    padding: 24px 20px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-md);
    border-radius: 16px;  
}

.header h1 {
  font-size: 24px;
  line-height: 135%;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  animation: fadeSlideIn 0.6s ease-out;
}

#q {
  flex: 1;
  min-width: 280px;
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Archivo', sans-serif;
  transition: all 0.3s ease;
  outline: none;
}

#q:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px var(--hover-glow);
  background: rgba(30, 41, 59, 0.8);
}

#q::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

#sort {
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Archivo', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

#sort:hover {
  border-color: var(--brand-light);
  box-shadow: var(--glow-effect);
}

#sort:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px var(--hover-glow);
}

/* ========== TAGS ========== */
.tags {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  animation: fadeSlideIn 0.7s ease-out;
}

.tag {
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag:hover {
  background: var(--brand-light);
  color: var(--background);
  border-color: var(--brand-light);
  box-shadow: var(--glow-effect);
  transform: translateY(-2px);
}

.tag.active {
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  color: var(--text-primary);
  border-color: transparent;
  box-shadow: var(--glow-effect);
}

/* ========== GRID ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1600px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========== CARD ========== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
  animation: fadeSlideUp 0.5s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

.card:hover {
  border-color: var(--brand-light);
  box-shadow: var(--glow-effect), var(--shadow-lg);
  transform: translateY(-8px) scale(1.02);
}

.card:hover .card-image {
  transform: scale(1.1);
}

.card:hover .read {
  opacity: 1;
  transform: translateY(0);
}

.card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
}

.title {
  font-size: 16px;
  line-height: 140%;
  font-weight: 800;
  color: var(--text-primary);
  flex: 1;
  transition: color 0.3s ease;
}

.card:hover .title {
  color: var(--brand-light);
}

.bookmark {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 4px;
  line-height: 1;
}

.bookmark:hover {
  color: var(--brand-light);
  transform: scale(1.2);
  filter: drop-shadow(0 0 8px var(--brand-light));
}

.bookmark.active {
  color: #FBBF24;
  filter: drop-shadow(0 0 8px #FBBF24);
}

.desc {
  font-size: 14px;
  line-height: 160%;
  font-weight: 400;
  color: var(--text-secondary);
  padding: 0 16px 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  font-size: 14px;
  line-height: 145%;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 16px 12px;
  opacity: 0.7;
}

.taglist {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px 16px;
}

.taglist span {
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid var(--brand-light);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.taglist span:hover {
  background: var(--brand-light);
  color: var(--background);
  box-shadow: 0 0 12px var(--brand-light);
}

.read {
  background: linear-gradient(135deg, var(--brand-light), var(--brand-dark));
  color: var(--text-primary);
  text-decoration: none;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border-radius: 0 0 16px 16px;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
  margin-top: auto;
  box-shadow: 0 -4px 12px rgba(96, 165, 250, 0.2);
}

.read:hover {
  background: linear-gradient(135deg, var(--brand-dark), #1E40AF);
  box-shadow: var(--glow-effect);
  letter-spacing: 0.5px;
}

/* ========== FOOTER & LOADER ========== */
.pager {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

.loader {
  display: flex;
  gap: 12px;
  align-items: center;
}

.loader.hidden {
  display: none;
}

.loader span {
  width: 12px;
  height: 12px;
  background: var(--brand-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
  box-shadow: 0 0 12px var(--brand-light);
}

.loader span:nth-child(1) {
  animation-delay: -0.32s;
}

.loader span:nth-child(2) {
  animation-delay: -0.16s;
}

.sentinel {
  height: 1px;
  opacity: 0;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header h1 {
    font-size: 20px;
  }

  #q, #sort {
    width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card-image {
    height: 180px;
  }
}

/* ========== UTILITY ========== */
.hidden {
  display: none !important;
}