/* ==========================================================================
   SR Editer — Bibliothèque de textures (library.html)
   Hero sobre, accès réservé (aperçu + carte de connexion), filtres
   (catégories, recherche, selects custom), grille. Logique : js/pages/library.js.
   ========================================================================== */

/* ── Hero ── */
.lib-hero {
  max-width: 1400px;
  margin: 0 auto;
  padding: 11rem var(--gutter) 4.5rem;
}
.lib-title {
  font-family: var(--font-heading);
  font-size: clamp(3.5rem, 10vw, 9rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-transform: none;
}
.lib-lead {
  max-width: 42ch;
  margin-top: 2rem;
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.aww-library {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter) 8rem;
}

/* ── Accès réservé : mosaïque de textures + carte ── */
.lib-gate {
  position: relative;
  max-width: 1400px;
  margin: 0 auto 8rem;
  padding: 0 var(--gutter);
}
.lib-gate[hidden] {
  display: none;
}
.lib-gate-mosaic {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 35%, transparent 95%);
  mask-image: linear-gradient(180deg, #000 0%, #000 35%, transparent 95%);
}
.lib-gate-mosaic img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  filter: saturate(0.9) brightness(0.75);
}
.lib-gate-card {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: -14rem auto 0;
  padding: 2.75rem;
  border-radius: 28px;
  background: rgba(16, 13, 11, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.85);
}
.lib-gate-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-transform: none;
}
.lib-gate-card p {
  margin-top: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.lib-gate-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 1.75rem 0 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}
.lib-gate-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lib-gate-list li::before {
  content: "";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff6b35' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat,
    rgba(255, 107, 53, 0.14);
}
.lib-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.lib-gate-actions .aww-btn {
  flex: 1 1 auto;
}

/* ── État vide / erreur ── */
.library-empty-card {
  max-width: 480px;
  margin: 3rem auto;
  padding: 2.75rem 2.25rem;
  border-radius: 24px;
  background: rgba(16, 13, 11, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.library-empty-card[hidden] {
  display: none;
}
.library-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  color: var(--accent);
  background: rgba(255, 107, 53, 0.1);
}
.library-empty-icon svg {
  width: 26px;
  height: 26px;
}
.library-empty-card h2 {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-transform: none;
  margin-bottom: 0.65rem;
}
.library-empty-card p {
  max-width: 36ch;
  margin: 0 auto 1.75rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.library-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.4rem;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.library-reset-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.3);
}
.library-reset-btn svg {
  width: 15px;
  height: 15px;
}

/* ── Catégories ── */
.library-category-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.pill-btn {
  padding: 0.55rem 1.05rem;
  border-radius: 100px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease;
}
.pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.pill-btn.active {
  background: var(--text-primary);
  color: var(--bg-color);
}

/* ── Barre d'outils : recherche + filtres ── */
.library-toolbar {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 3rem;
}
.search-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 200px;
}
.search-input-wrap .search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-secondary); pointer-events: none; }
.library-toolbar input {
  width: 100%;
  padding: 0.75rem 1.25rem 0.75rem 2.75rem;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  font-size: 0.92rem;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  box-shadow: none;
}
.library-toolbar input:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.22);
}
.library-toolbar input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.25);
}
.select-filters {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  position: relative;
}

/* ── Select personnalisé (généré par js/pages/library.js) ── */
.sr-custom-select {
  position: relative;
  user-select: none;
  flex: 0 0 auto;
}
.sr-select-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  clip: rect(0, 0, 0, 0) !important;
  overflow: hidden !important;
}
.sr-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.72rem 1.15rem;
  min-width: 195px;
  max-width: 235px;
  box-sizing: border-box;
  background: transparent;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  color: #f4f4f5;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: none;
  white-space: nowrap;
}
.sr-select-trigger:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}
.sr-custom-select.is-open .sr-select-trigger {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.25);
}
.sr-select-trigger-content {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}
.sr-select-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sr-select-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}
.sr-select-label {
  color: #ffffff;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}
.sr-select-arrow {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
  flex-shrink: 0;
}
.sr-custom-select.is-open .sr-select-arrow {
  transform: rotate(180deg);
  color: var(--accent);
}
.sr-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  min-width: 240px;
  box-sizing: border-box;
  background: rgba(14, 15, 22, 0.48);
  backdrop-filter: blur(36px) saturate(180%);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 6px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 120;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top left;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  pointer-events: none;
  overscroll-behavior: contain;
}
.sr-custom-select.is-open .sr-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.sr-select-options {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}
.sr-select-options::-webkit-scrollbar {
  width: 4px;
}
.sr-select-options::-webkit-scrollbar-track {
  background: transparent;
}
.sr-select-options::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}
.sr-select-options::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
.sr-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  box-sizing: border-box;
}
.sr-select-option:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(2px);
}
.sr-select-option.is-selected {
  background: rgba(255, 107, 53, 0.14);
  color: var(--accent);
  font-weight: 600;
}
.sr-select-option-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-select-color-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.sr-select-check {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.sr-select-option.is-selected .sr-select-check {
  opacity: 1;
}

/* ── Grille de textures ── */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.5rem 1.25rem;
}
.library-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.library-card-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: #0f0c0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.3s ease;
}
.library-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s var(--ease-out-quint);
}
.library-card:hover .library-card-preview {
  border-color: rgba(255, 107, 53, 0.45);
}
.library-card:hover .library-card-preview img {
  transform: scale(1.06);
}
.library-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.library-card-body h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-card-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.library-chip {
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}
.library-download {
  margin-top: 0.35rem;
  padding: 0.6rem 1rem;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.library-download:hover {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-color);
}
#library-status {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .lib-gate-mosaic {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .lib-gate-mosaic img:nth-child(n+9) {
    display: none;
  }
}

@media (max-width: 860px) {
  .lib-hero {
    padding: 8rem 1.25rem 3rem;
  }
  .aww-library {
    padding: 0 1.25rem 5rem;
  }
  .lib-gate {
    padding: 0 1.25rem;
    margin-bottom: 5rem;
  }
  .lib-gate-mosaic {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
  }
  .lib-gate-mosaic img {
    border-radius: 12px;
  }
  .lib-gate-mosaic img:nth-child(n+7) {
    display: none;
  }
  .lib-gate-card {
    margin-top: -6rem;
    padding: 2rem 1.5rem;
    border-radius: 22px;
  }
  .library-category-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
  }
  .library-category-pills::-webkit-scrollbar {
    display: none;
  }
  .pill-btn {
    flex-shrink: 0;
  }
  .library-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 2rem;
  }
  .search-input-wrap {
    width: 100%;
    min-width: 0;
  }
  .select-filters {
    width: 100%;
    gap: 0.6rem;
  }
  .select-filters .sr-custom-select {
    flex: 1 1 0;
    min-width: 0;
    width: 50%;
  }
  .select-filters .sr-select-trigger {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.7rem 0.85rem;
    font-size: 0.82rem;
  }
  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.25rem 0.85rem;
  }
}
