/* v2.6 2025-10-30T17:10:00Z */
:root {
  --bordeaux: #33030C;
  --grey: #b8b8b8;
  --white: #f5f5f5;
  --black: #0a0a0a;
}

/* ===== HEADER ===== */
.library-header {
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  background: #33030C;
  color: var(--white);
}
.library-header h1 {
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
  color: var(--grey);
}
.search-bar {
  margin: 0;
  max-width: 300px;
  flex: 1;
}
.search-bar input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--bordeaux);
  border-radius: 4px;
  background: #111;
  color: var(--white);
  font-size: 1rem;
  font-family: "Inter", sans-serif;
}
.search-bar input:focus { outline: 1px solid var(--grey); }

/* ===== SORT BAR ===== */
.sort-bar {
  margin: 0 0 0 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sort-bar select {
  background: #111;
  color: var(--always-white);
  border: 1px solid var(--bordeaux);
  border-radius: 4px;
  padding: 0.6rem;
}
.filter-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

/* ===== CATEGORY FILTER ICONS ===== */
.category-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0 1.5rem;
}
.filter-icon {
  width: 70px;
  height: 70px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.filter-icon:hover   { transform: scale(1.1); opacity: 0.6; }
.filter-icon.active  { opacity: 1; transform: scale(1.1); }

/* ===== GRID ===== */
.library-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1200px;
  margin: auto;
}

/* ===== PAGINATION ===== */
.pagination {
  text-align: center;
  margin: 1.5rem 0;
}
.page-btn {
  background: #111;
  color: var(--always-white);
  border: 1px solid var(--bordeaux);
  border-radius: 4px;
  padding: 0.4rem 0.7rem;
  margin: 0 0.2rem;
  cursor: pointer;
}
.page-btn.active {
  background: var(--bordeaux);
  color: #fff;
}

.items-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.items-bar select {
  background: #111;
  color: var(--always-white);
  border: 1px solid var(--bordeaux);
  border-radius: 6px;
  padding: 0.6rem;
}


/* ===== CARD ===== */
.card {
  perspective: 1000px;
  flex: 0 0 calc(25% - 1.5rem);
  max-width: calc(25% - 1.5rem);
  box-sizing: border-box;
  filter: drop-shadow(2px 4px 10px rgba(0,0,0,0.75));
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

.card .ribbon {
  position: absolute;
  top: 12px;
  right: -40px;
  width: 120px;
  text-align: center;
  transform: rotate(45deg);
  background: var(--bordeaux);
  color: #fff;
  font-size: 0.8rem;
  font-family: "Inter", sans-serif;
  padding: 4px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 2;
  opacity: 1;
  transition: opacity 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card .ribbon span {
  display: block;
  transform: none;
}

.card.flipped .ribbon {
  opacity: 0;
}

/* ===== CARD INNER ===== */
.card-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
  cursor: pointer;
  border-radius: inherit;
  overflow: visible;
}
.card.flipped .card-inner {
  transform: rotateY(180deg);
}

/* ===== BORDO LUMINOSO ANIMATO (IN 3D) ===== */
.card-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  border: 2px solid transparent;
  background: linear-gradient(
    130deg,
    #33030c,
    #31040d,
    #4e0303,
    #36040e,
    #33030c
  ) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
          mask-composite: exclude;
  background-size: 300% 300%;
  animation: borderGlow 8s linear infinite;
  z-index: 3;
  pointer-events: none;
}
@keyframes borderGlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== FRONT & BACK ===== */
.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 19px;
  background-size: cover;
  background-position: center;
  backface-visibility: hidden;
  overflow: hidden;
  z-index: 1;
}

/* FRONT */
.card-front {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
}
.card-front::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1;
}
.card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.2));
  z-index: 1;
}
.card-front-content {
  position: relative;
  z-index: 2;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

/* ===== HEADER (usato su entrambe le facce) ===== */
.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
  position: relative;
  z-index: 3;
}

.card-header img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  aspect-ratio: 1 / 1;
  display: block;
  background: transparent;
  padding: 4px;                /* evita taglio bordi */
  box-sizing: border-box;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
}


.card-header .category-name {
  font-size: 0.7rem;
  color: var(--grey);
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* ===== FRONT CONTENT ===== */
.card-front-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0.8rem;
}

/* ===== BACK CONTENT ===== */
.card-back-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex-grow: 1;
  padding: 1rem;
  text-align: center;
  gap: 1rem;
}

.card-back-content p {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 1rem;
}

/* TITLE */
.card-title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--white);
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  border-bottom: 1px solid var(--grey);
  width: 100%;
}

/* TAGS */
.card-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
}
.card-tags .tag {
  background: rgba(51,3,12,0.7);
  border: 1px solid var(--bordeaux);
  border-radius: 3px;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  cursor: help;
}

/* BACK */
.card-back {
  transform: rotateY(180deg) scaleX(-1);
  background-color: #111;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  padding: 0.8rem;
}
.card-back::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1;
}
.card-back::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0.2));
  z-index: 1;
}
.card-back > * {
  position: relative;
  z-index: 2;
  transform: scaleX(-1);
}
.card-back p {
  font-size: 0.95rem;
  opacity: 0.95;
}
.content-btn {
  background: var(--bordeaux);
  color: var(--white);
  padding: 0.55rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.3s ease, transform 0.1s ease;
  margin-bottom: 1rem;
}
.content-btn:hover { background: #55061a; }
.content-btn:active { transform: translateY(1px); }

/* ===== TOOLTIP ===== */
#tooltip {
  position: absolute;
  display: none;
  opacity: 0;
  pointer-events: none;
  background: #111;
  border: 1px solid var(--grey);
  color: var(--white);
  font-size: 0.8rem;
  font-family: "Inter", sans-serif;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(255,255,255,0.15);
  max-width: 240px;
  z-index: 9999;
  transition: opacity 0.15s ease;
}
#tooltip strong { color: var(--grey); font-weight: 600; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .card { flex: 0 0 calc(33.33% - 1rem); max-width: calc(33.33% - 1rem); }
}
@media (max-width: 900px) {
  .card { flex: 0 0 calc(50% - 1rem); max-width: calc(50% - 1rem); }
}
@media (max-width: 700px) {
  .card { flex: 0 0 100%; max-width: 100%; }
}