/* TỨ PHỦ — Legends directory (Ancient Manuscript + Digital Library) */

.legends-hero {
  position: relative;
  overflow: hidden;
}

.legends-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(196, 154, 89, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 80%, rgba(116, 43, 50, 0.18), transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(196, 154, 89, 0.035) 27px,
      rgba(196, 154, 89, 0.035) 28px
    );
  pointer-events: none;
}

.legends-search-wrap {
  position: relative;
}

.legends-search-wrap input[type="search"] {
  padding-left: 2.75rem;
}

.legends-search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #c49a59;
  pointer-events: none;
}

.legends-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.legends-suggest-btn {
  border: 1px solid rgba(98, 68, 60, 0.75);
  background: rgba(42, 26, 28, 0.65);
  color: #d5ba99;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.75rem;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.legends-suggest-btn:hover,
.legends-suggest-btn:focus-visible {
  border-color: #c49a59;
  color: #e4c58c;
  background: rgba(53, 35, 38, 0.9);
  outline: none;
}

/* Featured editorial */
.legend-featured-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .legend-featured-grid {
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: auto auto auto;
  }

  .legend-featured-main {
    grid-row: 1 / span 3;
  }
}

.legend-feat-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.85);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.legend-feat-card:hover {
  border-color: rgba(196, 154, 89, 0.55);
}

.legend-feat-card--main .legend-feat-media {
  aspect-ratio: 16 / 10;
}

.legend-feat-card--side {
  flex-direction: row;
  min-height: 0;
}

.legend-feat-card--side .legend-feat-media {
  width: 38%;
  min-width: 7.5rem;
  aspect-ratio: auto;
  align-self: stretch;
}

.legend-feat-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.legend-feat-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.legend-feat-card--side .legend-feat-body {
  padding: 0.85rem 1rem;
}

/* Group category cards */
.legend-group-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

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

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

.legend-group-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.45);
  background: rgba(255, 255, 255, 0.42);
  padding: 1rem;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  color: inherit;
}

.legend-group-card:hover,
.legend-group-card:focus-visible {
  border-color: #c49a59;
  box-shadow: 0 6px 20px rgba(51, 36, 31, 0.08);
  outline: none;
}

.legend-group-card.is-active {
  border-color: #742b32;
  box-shadow: inset 0 0 0 1px rgba(116, 43, 50, 0.35);
}

.legend-group-icon {
  display: inline-flex;
  height: 2.25rem;
  width: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid rgba(196, 154, 89, 0.45);
  color: #742b32;
  background: rgba(244, 230, 209, 0.65);
}

/* Directory layout */
.legends-directory {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .legends-directory {
    grid-template-columns: 260px minmax(0, 1fr);
    align-items: start;
  }
}

.legends-sidebar {
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.92);
  padding: 1rem;
}

.legends-sidebar h3 {
  font-family: "Noto Serif", Georgia, serif;
  font-size: 0.95rem;
  color: #e4c58c;
}

.legends-filter-field + .legends-filter-field {
  margin-top: 0.85rem;
}

.legends-filter-field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d5ba99;
}

.legends-filter-field input,
.legends-filter-field select {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #62443c;
  background: #352326;
  color: #f4e6d1;
  padding: 0.55rem 0.7rem;
  font-size: 0.875rem;
}

.legends-filter-field input:focus,
.legends-filter-field select:focus {
  outline: none;
  border-color: #c49a59;
}

.legends-figure-search {
  margin-bottom: 0.4rem;
}

/* Results */
.leg-results--grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

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

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

.leg-results--list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.leg-grid-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.88);
  overflow: hidden;
  height: 100%;
  transition: border-color 0.15s ease;
}

.leg-grid-card:hover {
  border-color: rgba(196, 154, 89, 0.5);
}

.leg-list-item {
  display: grid;
  gap: 0.85rem;
  align-items: start;
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.55);
  background: rgba(42, 26, 28, 0.88);
  padding: 0.75rem;
}

@media (min-width: 640px) {
  .leg-list-item {
    grid-template-columns: 96px minmax(0, 1fr) auto;
  }
}

.leg-list-thumb {
  width: 96px;
  height: 72px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(98, 68, 60, 0.5);
}

.leg-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leg-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.25rem;
  background: rgba(25, 15, 18, 0.55);
  padding: 0.15rem 0.45rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #d5ba99;
}

.leg-badge--draft {
  color: #e4c58c;
  border: 1px solid rgba(196, 154, 89, 0.35);
}

.leg-badge--pending {
  color: #d5ba99;
}

.view-toggle-btn.is-active {
  border-color: #c49a59;
  color: #e4c58c;
  background: rgba(53, 35, 38, 0.9);
}

.page-btn {
  display: inline-flex;
  min-width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid #62443c;
  color: #d5ba99;
  font-size: 0.875rem;
  background: transparent;
}

.page-btn:hover:not(:disabled),
.page-btn:focus-visible:not(:disabled) {
  border-color: #c49a59;
  color: #e4c58c;
  outline: none;
}

.page-btn.is-active {
  border-color: #c49a59;
  color: #190f12;
  background: #c49a59;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mobile filter drawer */
.legends-filter-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  visibility: hidden;
}

.legends-filter-drawer.is-open {
  pointer-events: auto;
  visibility: visible;
}

.legends-filter-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(25, 15, 18, 0.72);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.legends-filter-drawer.is-open .legends-filter-drawer-overlay {
  opacity: 1;
}

.legends-filter-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 360px);
  background: #2a1a1c;
  border-left: 1px solid #62443c;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legends-filter-drawer.is-open .legends-filter-drawer-panel {
  transform: translateX(0);
}

.legends-filter-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.legends-filter-drawer-foot {
  border-top: 1px solid #62443c;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.5rem;
}

@media (min-width: 1024px) {
  .legends-mobile-filter-btn {
    display: none !important;
  }

  .legends-filter-drawer {
    display: none !important;
  }
}

/* Variant example cards */
.variant-card {
  border-radius: 0.75rem;
  border: 1px dashed rgba(196, 154, 89, 0.45);
  background: rgba(42, 26, 28, 0.7);
  padding: 1rem;
}

.variant-card-label {
  display: inline-flex;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c49a59;
  border: 1px solid rgba(196, 154, 89, 0.4);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

/* Source library */
.source-type-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

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

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

.source-type-card {
  border-radius: 0.75rem;
  border: 1px solid rgba(98, 68, 60, 0.45);
  background: rgba(255, 255, 255, 0.4);
  padding: 1rem 1.1rem;
}

@media (prefers-reduced-motion: reduce) {
  .legends-filter-drawer-overlay,
  .legends-filter-drawer-panel,
  .legend-feat-card,
  .legend-group-card,
  .leg-grid-card {
    transition: none !important;
  }
}
