/* =========================================================
   THE PURPLE LIBRARY — LIBRARY V2
========================================================= */

:root {
  --library-bg: #160b31;
  --library-bg-soft: #241246;
  --library-panel: #32185b;
  --library-purple: #5e2a7e;
  --library-lavender: #cfa9ff;
  --library-paper: #fbfaff;
  --library-text: #171224;
  --library-muted: #8f82a6;
  --library-accent: #ff4fa0;
  --library-border: rgba(255, 255, 255, 0.12);
  --library-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  font-family: Inter, sans-serif;
  color: white;
  background: radial-gradient(
    circle at top,
    #6c3aa0 0%,
    #241246 46%,
    #12091f 100%
  );
}

/* =========================================================
   GLOBAL NAV
========================================================= */

.library-site-header {
  position: sticky;
  top: 0;
  z-index: 20;

  min-height: 76px;

  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;

  padding: 0 42px;

  background: #2d1658;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.library-brand {
  display: flex;
  align-items: center;
  gap: 14px;

  color: white;
  text-decoration: none;
}

.library-brand-dot {
  width: 18px;
  height: 18px;

  border-radius: 50%;

  background: #ff4fa0;
  box-shadow: 0 0 18px rgba(255, 79, 160, 0.45);
}

.library-brand-name {
  color: white;

  font-size: 29px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

.library-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.library-nav a {
  color: white;
  text-decoration: none;

  font-size: 15px;
  font-weight: 900;

  transition: 0.2s ease;
}

.library-nav a:hover {
  color: #ff4fa0;
}

.library-add-story-link {
  min-height: 44px;

  display: inline-flex;
  align-items: center;
  gap: 7px;

  padding: 0 24px;

  border: 1px solid rgba(207, 169, 255, 0.42);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.06);
  color: #ff4fa0 !important;
}

.library-add-story-link:hover {
  background: rgba(255, 79, 160, 0.12);
  border-color: rgba(255, 79, 160, 0.55);
}

.library-auth {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.library-login-link,
.library-signup-link,
.library-profile-link {
  color: white;
  text-decoration: none;

  font-size: 15px;
  font-weight: 900;
}

.library-login-link:hover {
  color: #ff4fa0;
}

.library-signup-link {
  min-height: 48px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 26px;

  border-radius: 999px;

  background: #ff4fa0;
  color: white;

  box-shadow: 0 12px 28px rgba(255, 79, 160, 0.24);
}

.library-profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-profile-avatar {
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: linear-gradient(135deg, #ff4fa0, #8b5cf6);
  color: white;

  font-size: 15px;
  font-weight: 900;
}

body[data-library-auth="guest"] .library-auth-member {
  display: none;
}

body[data-library-auth="member"] .library-auth-guest {
  display: none;
}

/* =========================================================
   PAGE SHELL
========================================================= */

.library-shell {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 76px 32px 110px;
}

.library-hero {
  max-width: 860px;
  margin-bottom: 38px;
}

.library-kicker {
  display: inline-flex;

  margin-bottom: 16px;
  padding: 8px 14px;

  border-radius: 999px;

  background: rgba(255, 255, 255, 0.1);
  color: #cfa9ff;

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-hero h1 {
  max-width: 780px;

  color: white;

  font-family: Georgia, "Times New Roman", serif;
  font-size: 70px;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.library-hero p {
  max-width: 760px;

  margin-top: 22px;

  color: #d8c8ef;

  font-size: 19px;
  line-height: 1.65;
}

.library-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;

  margin-top: 28px;
}

.library-primary-action,
.library-secondary-action {
  min-height: 48px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 22px;

  border-radius: 999px;

  text-decoration: none;
  font-weight: 900;
}

.library-primary-action {
  background: #ff4fa0;
  color: white;

  box-shadow: 0 12px 30px rgba(255, 79, 160, 0.28);
}

.library-secondary-action {
  background: rgba(255, 255, 255, 0.09);
  color: white;

  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* =========================================================
   SEARCH + SOURCE TABS
========================================================= */

.library-search-panel {
  display: grid;
  gap: 16px;

  margin-bottom: 24px;
}

.library-search-box {
  min-height: 62px;

  display: flex;
  align-items: center;
  gap: 12px;

  padding: 0 20px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;

  background: rgba(37, 19, 66, 0.72);
  backdrop-filter: blur(16px);
}

.library-search-box svg {
  width: 20px;
  height: 20px;

  color: #cfa9ff;
}

.library-search-box input {
  width: 100%;

  border: none;
  outline: none;

  background: transparent;
  color: white;

  font-size: 16px;
  font-weight: 700;
}

.library-search-box input::placeholder {
  color: #c9b7e8;
}

.library-source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.library-source-tabs button,
.library-source-tabs a {
  min-height: 42px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 16px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.08);
  color: white;
  text-decoration: none;

  font-size: 13px;
  font-weight: 900;

  cursor: pointer;
  transition: 0.2s ease;
}

.library-source-tabs button.active,
.library-source-tabs button:hover,
.library-source-tabs a:hover {
  background: #ff4fa0;
  border-color: #ff4fa0;
}

/* =========================================================
   RESULTS TOOLBAR
========================================================= */

.library-results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  margin-bottom: 26px;
  padding: 18px 22px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;

  background: rgba(37, 19, 66, 0.72);
  backdrop-filter: blur(16px);
}

.library-results-toolbar strong {
  display: block;

  color: white;

  font-size: 18px;
  font-weight: 900;
}

.library-results-toolbar span {
  color: #cfa9ff;

  font-size: 13px;
  font-weight: 800;
}

.library-sort-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-sort-control select {
  min-height: 40px;

  padding: 0 14px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;

  background: #2d1658;
  color: white;

  font-weight: 800;
}

/* =========================================================
   STORY GRID — COMPACT CARDS
========================================================= */

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.story-card {
  min-height: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;

  border-radius: 20px;

  color: var(--library-text);

  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.97),
    rgba(244, 234, 255, 0.96)
  );

  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.story-card-native {
  padding: 16px;
}

.story-card-external {
  padding: 0;
}

.story-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;

  margin-bottom: 12px;
}

.story-source-badge,
.story-status-badge {
  min-height: 22px;

  display: inline-flex;
  align-items: center;

  padding: 0 8px;

  border-radius: 999px;

  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.story-source-badge {
  background: #f0e3ff;
  color: #6b3c93;
}

.story-source-badge.external {
  background: #fff1d8;
  color: #8a5a12;
}

.story-status-badge {
  background: #ffe4f1;
  color: #9f2f68;
}

.story-card h2 {
  margin: 0;

  color: #171224;

  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1.02;
}

.story-author {
  margin-top: 5px;

  color: #7a4ca5;

  font-size: 11px;
  font-weight: 900;
}

.story-summary {
  margin-top: 10px;

  color: #6f617f;

  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1.45;
}

.story-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;

  margin-top: 11px;
}

.story-chip {
  min-height: 20px;

  display: inline-flex;
  align-items: center;

  padding: 0 7px;

  border-radius: 999px;

  background: #f0e3ff;
  color: #6b3c93;

  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
}

.story-stats {
  display: flex;
  align-items: center;
  justify-content: flex-start;

  gap: 6px;

  flex-wrap: nowrap;

  width: 100%;
  white-space: nowrap;
}

.story-stat {
  display: inline-flex;
  align-items: center;

  gap: 2px;

  flex: 0 0 auto;

  font-size: 10px;
  line-height: 1;
}

.story-stat svg {
  width: 11px;
  height: 11px;
}

.story-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  margin-top: 12px;
  padding-top: 12px;

  border-top: 1px solid rgba(94, 42, 126, 0.12);
}

.story-date {
  color: #8f82a6;

  font-size: 9px;
  font-weight: 800;
}

.story-open-link {
  min-height: 30px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 11px;

  border-radius: 999px;

  background: #ff4fa0;
  color: white;
  text-decoration: none;

  font-size: 10px;
  font-weight: 900;

  box-shadow: 0 8px 18px rgba(255, 79, 160, 0.2);
}

/* =========================================================
   COVER CARD VARIANT
========================================================= */

.story-cover {
  position: relative;

  min-height: 0;

  background: #2d1658;
}

.story-cover img {
  width: 100%;

  display: block;

  aspect-ratio: 2 / 2.65;
  object-fit: cover;
}

.story-cover .story-source-badge {
  position: absolute;
  top: 10px;
  left: 10px;

  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.story-cover .story-status-badge {
  position: absolute;
  top: 10px;
  right: 10px;

  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.story-external-body,
.story-cover-body {
  flex: 1;

  display: flex;
  flex-direction: column;

  padding: 14px;
}

.story-external-note {
  margin-top: 10px;

  color: #8f82a6;

  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* =========================================================
   EMPTY STATE
========================================================= */

.library-empty-state {
  display: none;

  max-width: 620px;
  margin: 70px auto 0;
  padding: 46px;

  text-align: center;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 30px;

  background: rgba(37, 19, 66, 0.72);
  backdrop-filter: blur(16px);
}

.library-empty-state.show {
  display: block;
}

.library-empty-icon {
  width: 74px;
  height: 74px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0 auto 20px;

  border-radius: 24px;

  background: rgba(255, 255, 255, 0.1);
  color: #cfa9ff;
}

.library-empty-icon svg {
  width: 34px;
  height: 34px;
}

.library-empty-state h2 {
  margin: 0;

  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
}

.library-empty-state p {
  max-width: 420px;
  margin: 14px auto 0;

  color: #d8c8ef;

  font-size: 16px;
  line-height: 1.6;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1080px) {
  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  .library-site-header {
    grid-template-columns: 1fr;
    gap: 18px;

    padding: 18px 22px;
  }

  .library-brand-name {
    font-size: 26px;
  }

  .library-nav {
    width: 100%;

    justify-content: flex-start;
    gap: 18px;

    overflow-x: auto;
    padding-bottom: 4px;
  }

  .library-auth {
    width: 100%;
    justify-content: flex-start;
  }

  .library-shell {
    padding: 48px 18px 90px;
  }

  .library-hero h1 {
    font-size: 48px;
  }

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

  .library-results-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .story-card {
    min-height: auto;
  }
}

/* =========================================================
   STORY EVENT BADGES
========================================================= */

.abfl-event-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;

  margin-top: 12px;
}

.abfl-event-badge {
  min-height: 34px;

  display: inline-flex;
  align-items: center;
  gap: 7px;

  width: max-content;
  max-width: 100%;

  padding: 0 11px;

  border-radius: 999px;

  background: #fff1d8;
  color: #8a5a12;
  text-decoration: none;

  font-size: 11px;
  font-weight: 900;
}

.abfl-event-badge span {
  color: #9f2f68;

  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.abfl-event-badge strong {
  color: #8a5a12;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   STORY COVER FALLBACK
========================================================= */

.story-cover-fallback {
  width: 100%;

  aspect-ratio: 2 / 2.65;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  gap: 12px;

  background: radial-gradient(circle at top, #6f398f, #32185b 55%, #241246);

  color: #f7efff;

  text-align: center;
}

.story-cover-fallback svg {
  width: 42px;
  height: 42px;

  color: #ff4fa0;
}

.story-cover-fallback span {
  max-width: 120px;

  color: #d8c8ef;

  font-size: 11px;
  font-weight: 900;

  letter-spacing: 0.08em;

  text-transform: uppercase;
}

.story-stats-native {
  display: flex;
  align-items: center;
  gap: 5px;

  width: 100%;

  margin-top: auto;

  white-space: nowrap;

  font-size: 10.5px;
  line-height: 1;

  font-weight: 700;
  letter-spacing: -0.01em;

  color: #7f7195;
}

.story-stats-native span {
  display: inline-block;
}

.story-stat-separator {
  opacity: 0.45;
}
