/* ============================================================
   ATLAS LIBRARY — "Wisdom and Spirit" consolidated reading canon
   Loaded after style.css. Scoped entirely to .library-page.
   ============================================================ */

.library-page {
  --atlas-red: #990403;
  --atlas-red-bright: #c41e1c;
  --atlas-red-deep: #4a0000;
  --gold: #d4af37;
  --gold-soft: #e6cf92;
  --ink: #0f0303;
  --line: rgba(212, 175, 55, 0.18);
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #f5eeec;
  --text-dim: #b8a5a1;
  --text-faint: #8a7873;

  margin: 0;
  padding: 0;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--ink);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-align: left;
}

/* Ambient light — a slow oxblood glow behind everything */
.library-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(153, 4, 3, 0.34) 0%, transparent 62%),
    radial-gradient(ellipse 60% 40% at 88% 12%, rgba(212, 175, 55, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 8% 78%, rgba(74, 0, 0, 0.42) 0%, transparent 62%);
}

/* Fine grain so the dark field never reads as flat */
.library-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
}

/* ---------- Top bar ---------- */

.library-page .topbar {
  background-color: rgba(15, 3, 3, 0.82);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  padding: 12px 26px;
}

.library-page .topbar h1 {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--text);
}

.library-page .topbar .language-switcher .lang-link {
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  padding: 3px 2px;
  transition: color 0.25s ease;
}

.library-page .topbar .language-switcher .lang-link.active,
.library-page .topbar .language-switcher .lang-link:hover {
  color: var(--gold);
}

.library-page .topbar .language-switcher span {
  color: rgba(255, 255, 255, 0.2);
}

/* ---------- Shell ---------- */

.library-shell {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px 110px;
}

/* ---------- Masthead ---------- */

.library-hero {
  padding: 104px 0 62px;
  text-align: center;
  animation: libRise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 26px;
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: "";
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.hero-eyebrow::after {
  background: linear-gradient(90deg, var(--gold), transparent);
}

.library-hero h2 {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 7.4vw, 92px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.012em;
  margin: 0 0 8px;
  color: #fffaf8;
  text-transform: none;
}

.library-hero h2 em {
  font-style: italic;
  font-weight: 300;
  background: linear-gradient(100deg, var(--gold-soft) 8%, var(--gold) 42%, #b08d27 92%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--gold);
}

.hero-rule {
  width: 100%;
  max-width: 340px;
  height: 1px;
  margin: 34px auto 30px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  position: relative;
}

.hero-rule::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--gold);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.65);
}

.library-hero p {
  max-width: 660px;
  margin: 0 auto;
  font-size: 17px;
  line-height: 1.78;
  color: var(--text-dim);
  font-weight: 300;
}

/* ---------- Control rail: filters + search ---------- */

.library-controls {
  position: sticky;
  top: 65px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 16px 22px;
  margin-bottom: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: rgba(18, 5, 5, 0.9);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.filter-set {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 18px;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.filter-chip .chip-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 9px;
  vertical-align: 1px;
  background: currentColor;
  opacity: 0.7;
}

.filter-chip[data-filter="intellectual"] .chip-dot { background: var(--atlas-red-bright); opacity: 1; }
.filter-chip[data-filter="bridge"] .chip-dot { background: #9aa0a6; opacity: 1; }
.filter-chip[data-filter="spiritual"] .chip-dot { background: var(--gold); opacity: 1; }

.filter-chip:hover {
  color: var(--text);
  border-color: rgba(212, 175, 55, 0.4);
}

.filter-chip.is-active {
  color: #fff8f4;
  border-color: rgba(212, 175, 55, 0.6);
  background: linear-gradient(180deg, rgba(153, 4, 3, 0.42), rgba(74, 0, 0, 0.3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 20px rgba(153, 4, 3, 0.25);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 250px;
  flex: 0 1 290px;
}

.search-field svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  stroke: var(--text-faint);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px 11px 36px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.search-field input::placeholder {
  color: var(--text-faint);
}

.search-field input:focus {
  outline: none;
  border-color: rgba(212, 175, 55, 0.5);
  background: rgba(0, 0, 0, 0.5);
}

/* ---------- Frame sections ---------- */

.frame-section {
  padding-top: 74px;
  scroll-margin-top: 150px;
}

.frame-header {
  display: flex;
  align-items: baseline;
  gap: 22px;
  padding-bottom: 20px;
  margin-bottom: 38px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}

.frame-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 96px;
  height: 2px;
  background: var(--frame-accent, var(--atlas-red));
  box-shadow: 0 0 16px var(--frame-glow, rgba(153, 4, 3, 0.6));
}

.frame-numeral {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--frame-accent, var(--atlas-red));
  padding-top: 6px;
  flex-shrink: 0;
}

.frame-heading {
  flex: 1;
  min-width: 0;
}

.frame-heading h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 400;
  letter-spacing: 0.008em;
  margin: 0 0 7px;
  color: #fffaf8;
}

.frame-heading p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-dim);
  font-weight: 300;
  max-width: 640px;
}

.frame-count {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Frame accent tokens */
.frame-intellectual { --frame-accent: var(--atlas-red-bright); --frame-glow: rgba(196, 30, 28, 0.55); }
.frame-bridge       { --frame-accent: #9aa0a6; --frame-glow: rgba(154, 160, 166, 0.4); }
.frame-spiritual    { --frame-accent: var(--gold); --frame-glow: rgba(212, 175, 55, 0.5); }

/* ---------- Volume grid ---------- */

.volume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 40px 30px;
}

.volume-card {
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: inherit;
  animation: libRise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.volume-plate {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  background: #1c0808;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.6),
    0 18px 38px rgba(0, 0, 0, 0.55);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Gilt hairline that ignites on hover */
.volume-plate::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: 2px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: box-shadow 0.45s ease;
}

/* Covers arrive at wildly different aspect ratios. Rather than crop the art —
   which decapitates titles — each cover is contained inside a 2:3 plate and
   the gap is filled by a blurred, darkened copy of the cover itself. */
.volume-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.3);
  filter: blur(26px) saturate(1.3) brightness(0.42);
  pointer-events: none;
}

.volume-plate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(150deg, rgba(15, 3, 3, 0.35), rgba(15, 3, 3, 0.6));
}

.volume-cover {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  transition: transform 0.75s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s ease;
  filter: saturate(0.9) brightness(0.93) drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
}

/* A volume whose jacket image is missing falls back to a typographic plate
   rather than a broken-image icon. */
.volume-plate.is-coverless .volume-cover,
.volume-plate.is-coverless .volume-backdrop {
  display: none;
}

.volume-fallback {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  aspect-ratio: 2 / 3;
  box-sizing: border-box;
  padding: 26px 20px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(153, 4, 3, 0.4), transparent 68%),
    linear-gradient(170deg, #240a0a 0%, #120404 100%);
}

.volume-fallback::before,
.volume-fallback::after {
  content: "";
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  flex-shrink: 0;
}

.volume-fallback-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.24;
  color: #fdf6f4;
}

.volume-fallback-author {
  display: block;
  margin-top: 9px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Reading veil that lifts on hover */
.volume-veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  opacity: 0;
  background: linear-gradient(to top, rgba(10, 2, 2, 0.94) 0%, rgba(10, 2, 2, 0.55) 42%, transparent 78%);
  transition: opacity 0.4s ease;
}

.volume-open {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-soft);
  transform: translateY(8px);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.volume-card:hover .volume-plate,
.volume-card:focus-visible .volume-plate {
  transform: translateY(-9px);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.6),
    0 30px 60px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(212, 175, 55, 0.28);
}

.volume-card:hover .volume-plate::after,
.volume-card:focus-visible .volume-plate::after {
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.45);
}

.volume-card:hover .volume-cover,
.volume-card:focus-visible .volume-cover {
  transform: scale(1.06);
  filter: saturate(1.05) brightness(1);
}

.volume-card:hover .volume-veil,
.volume-card:focus-visible .volume-veil {
  opacity: 1;
}

.volume-card:hover .volume-open,
.volume-card:focus-visible .volume-open {
  transform: translateY(0);
}

.volume-card:focus-visible {
  outline: none;
}

/* Difficulty seal, top-right of the plate */
.volume-seal {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  min-width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(10, 2, 2, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.volume-seal[data-tier="light"]  { border-color: rgba(74, 222, 128, 0.55); color: #86efac; }
.volume-seal[data-tier="medium"] { border-color: rgba(251, 191, 36, 0.55); color: #fcd34d; }
.volume-seal[data-tier="hard"]   { border-color: rgba(249, 115, 22, 0.55); color: #fdba74; }
.volume-seal[data-tier="severe"] { border-color: rgba(239, 68, 68, 0.6);   color: #fca5a5; }

.volume-meta {
  padding-top: 15px;
}

.volume-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: 0.004em;
  margin: 0 0 5px;
  color: #fdf6f4;
  transition: color 0.3s ease;
}

.volume-card:hover .volume-title {
  color: var(--gold-soft);
}

.volume-author {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Filtered-out state */
.volume-card.is-hidden,
.frame-section.is-hidden {
  display: none;
}

/* Empty search state */
.library-empty {
  display: none;
  padding: 90px 20px;
  text-align: center;
}

.library-empty.is-visible {
  display: block;
}

.library-empty h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 30px;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 10px;
}

.library-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--text-faint);
}

/* ---------- Closing mark ---------- */

.library-coda {
  margin-top: 100px;
  padding-top: 46px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}

.library-coda blockquote {
  margin: 0 auto;
  max-width: 620px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(20px, 2.5vw, 27px);
  font-style: italic;
  font-weight: 300;
  line-height: 1.55;
  color: var(--text-dim);
}

.library-coda cite {
  display: block;
  margin-top: 18px;
  font-family: "Inter", Arial, sans-serif;
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------- Modal, re-tailored for the library ---------- */

.library-page .movie-modal-overlay {
  background: rgba(6, 1, 1, 0.9);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
  padding: 24px;
  box-sizing: border-box;
}

.library-page .movie-modal-content {
  background: linear-gradient(160deg, #1b0707 0%, #100303 62%);
  border: 1px solid var(--line);
  border-radius: 3px;
  max-width: 880px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.85);
  transform: translateY(26px) scale(0.985);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.library-page .movie-modal-overlay.active .movie-modal-content {
  transform: translateY(0) scale(1);
}

.library-page .modal-left {
  flex: 0 0 300px;
  position: relative;
  background: #0a0202;
}

.library-page .modal-left::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line), transparent);
}

/* Same no-crop treatment inside the modal */
.library-page .modal-poster {
  border-radius: 0;
  object-fit: contain;
  padding: 26px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(153, 4, 3, 0.22), transparent 70%),
    #0a0202;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.6));
}

.library-page .modal-right {
  padding: 46px 46px 44px;
}

.library-page .modal-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 400;
  line-height: 1.14;
  color: #fffaf8;
  margin: 0 0 12px;
}

.library-page .modal-author {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.26em;
  color: var(--gold);
  margin: 0 0 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.library-page .modal-difficulty {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  padding: 15px 20px;
  margin-bottom: 26px;
}

.library-page .difficulty-label {
  letter-spacing: 0.24em;
  color: var(--text-faint);
  font-size: 10px;
}

.library-page .difficulty-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-soft);
  min-width: 52px;
}

.library-page .modal-desc {
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text-dim);
  font-weight: 300;
}

.library-page .modal-desc p {
  margin: 0 0 16px;
}

.library-page .modal-desc p:last-child {
  margin-bottom: 0;
}

.library-page .modal-desc em {
  color: var(--gold-soft);
  font-style: italic;
}

.library-page .modal-close {
  top: 18px;
  right: 22px;
  width: 34px;
  height: 34px;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.4);
  font-size: 22px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.library-page .modal-close:hover {
  color: var(--gold);
  border-color: rgba(212, 175, 55, 0.5);
  transform: rotate(90deg);
}

/* ---------- Motion ---------- */

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

@media (prefers-reduced-motion: reduce) {
  .library-page *,
  .library-page *::before,
  .library-page *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .library-shell { padding: 0 22px 80px; }
  .library-hero { padding: 84px 0 48px; }

  .frame-header {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .frame-count { width: 100%; }

  .library-controls {
    top: 60px;
    padding: 14px 16px;
    gap: 14px;
  }

  .search-field { flex: 1 1 100%; min-width: 0; }

  .volume-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 30px 20px;
  }

  .library-page .modal-right { padding: 32px 26px 30px; }
  .library-page .modal-left { flex: none; width: 100%; max-height: 320px; }
}

@media (max-width: 560px) {
  .library-shell { padding: 0 16px 64px; }
  .library-hero { padding: 70px 0 40px; }

  .hero-eyebrow {
    letter-spacing: 0.28em;
    font-size: 9.5px;
  }

  .hero-eyebrow::before,
  .hero-eyebrow::after { width: 24px; }

  .library-hero p { font-size: 15px; }


  .filter-chip { padding: 9px 13px; font-size: 10px; letter-spacing: 0.1em; }
  .filter-chip .chip-dot { margin-right: 7px; }

  .frame-section { padding-top: 56px; }
  .frame-numeral { display: none; }

  .volume-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 26px 16px;
  }

  .volume-title { font-size: 15px; }
  .volume-author { font-size: 10px; }

  .library-coda { margin-top: 70px; }
}
