/* -- Sort / Filter bar -- */
.sort-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
}

.sort-bar label {
  font-size: 0.85rem;
  color: #9e9e9e;
}

.sort-bar select {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #2a3a5e;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.sort-bar select:focus {
  outline: 2px solid #64b5f6;
  outline-offset: 1px;
}

.sort-bar .count {
  font-size: 0.8rem;
  color: #666;
  margin-left: 0.5rem;
}

.sort-bar #search-input {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #2a3a5e;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  width: 180px;
  max-width: 220px;
}

@media (max-width: 560px) {
  .sort-bar #search-input {
    width: 100%;
    max-width: none;
  }
}

.sort-bar #search-input:focus {
  outline: 2px solid #64b5f6;
  outline-offset: 1px;
}

/* -- Grid (3D cards) -- */
.title-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.4rem;
  padding: 0 1rem 2rem;
  max-width: 1280px;
  margin: 0 auto;
  perspective: 900px; /* enables 3D depth for children */
}

@media (max-width: 1100px) {
  .title-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 820px) {
  .title-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .title-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
}
@media (max-width: 360px) {
  .title-grid { grid-template-columns: 1fr; }
}

/* -- Card -- */
.title-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  perspective: 900px;
  cursor: pointer;
}

/* Inner element that actually rotates in 3D */
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
  will-change: transform;
}


/* Shadow when hovered/tilted */
.title-card:hover .card-inner {
  box-shadow:
    6px 8px rgba(0,0,0,0.7);
}

/* -- Front Face -- */
.card-front {
  position: absolute;
  inset: 0;
  background: #16213e;
  overflow: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}



/* -- Right Side -- */
.card-right {
  position: absolute;
  top: 0;
  right: -10px;
  bottom: 0;
  width: 10px;
  /*background: linear-gradient(to right, #1a2744, #0b1221);*/
  box-shadow: 4px 4px 5px rgba(0,0,0,0.6);
  transform-origin: left center;
  transform: rotateY(90deg);
  z-index: -1;
  pointer-events: none;
}

/* -- Bottom Face -- */
.card-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 10px;
  /*background: linear-gradient(to bottom, #16213e, #0b1221);*/
  transform-origin: top center;
  transform: rotateX(-90deg);
  box-shadow: 0 4px 6px rgba(0,0,0,0.5);
  z-index: -2;
  pointer-events: none;
}

/* -- Overlay --*/
.card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.65rem 0.7rem;
  pointer-events: none;
  z-index: 1;
  /* optional very subtle gradient so text pops */
  /*background: linear-gradient(
    to top,
    rgba(0,0,0,0.85) 0%,
    rgba(0,0,0,0.45) 35%,
    transparent 70%
  );*/
}

/* Tiny core badge */
.badge {
  align-self: flex-start;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #e0e0e0;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  backdrop-filter: blur(2px);
}

/* Title: wrap but limit to 2 lines max */
.card-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  max-width: 100%;
}

/*
.card-meta {
  font-size: 0.64rem;
  color: #cfd8dc;
  margin-top: 0.15rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}*/

/* -- Infinite-scroll sentinel -- */
.scroll-sentinel {
  width: 100%;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 0.8rem;
}

.scroll-sentinel .spinner {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid #333;
  border-top-color: #64b5f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -- End-of-list message -- */
#end-message {
  text-align: center;
  padding: 2rem 1rem;
  color: #53535d;
  font-size: 0.85rem;
}
