/* Omega Emporium -- front-end styles
   Palette extracted from DarkLibrary.png (candlelit reading room):
   near-black shadow, warm mahogany surfaces, brass/candlelight gold accent.
   A "light atmosphere" alternative palette lives under [data-theme="light"]
   below -- same warm/bookish character, just a daylit reading room instead
   of a candlelit one, toggled from the Profile menu's Settings section
   (see .theme-toggle) and persisted client-side (see site.js). */

:root {
  --bg: #0b0705;
  --surface: #1a120b;
  --surface-muted: #241a10;
  --text: #ece1cf;
  --text-muted: #a3907a;
  --border: #3c2c1a;
  --accent: #cf9a44;
  --accent-hover: #e3b466;
  --accent-soft: #3a2a15;
  --gold: #b8923f;
  --gold-soft: #2e2312;
  --success: #7c9a6a;
  --success-soft: #1c2417;
  /* Translucent overlays drawn on top of arbitrary book-cover art (see
     .doc-card__bookmark) -- kept as their own variables, rather than
     baked-in rgba() literals, so they can track the active theme too. */
  --overlay-bg: rgba(11, 7, 5, 0.65);
  --overlay-bg-active: rgba(58, 42, 21, 0.9);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.5), 0 14px 34px rgba(0, 0, 0, 0.55);
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light atmosphere -- a daylit reading room: warm parchment surfaces,
   ink-brown text, a deeper amber accent (the candlelight gold above is
   too pale to stay readable against a light background). Everything
   else in the stylesheet reads its colors from these custom properties,
   so this block is the entire light theme. */
[data-theme="light"] {
  --bg: #f6efdf;
  --surface: #fffcf5;
  --surface-muted: #ede1c7;
  --text: #2b2013;
  --text-muted: #6f6047;
  --border: #ddceac;
  --accent: #9c6b26;
  --accent-hover: #7e561d;
  --accent-soft: #f0e0bb;
  --gold: #8a6a28;
  --gold-soft: #f1e4c4;
  --success: #4c7239;
  --success-soft: #e2ecd7;
  --overlay-bg: rgba(255, 252, 245, 0.75);
  --overlay-bg-active: rgba(240, 224, 187, 0.92);
  --shadow: 0 1px 2px rgba(43, 32, 19, 0.1), 0 8px 28px rgba(43, 32, 19, 0.12);
  --shadow-hover: 0 2px 6px rgba(43, 32, 19, 0.12), 0 14px 34px rgba(43, 32, 19, 0.16);
}

/* A light touch of transition on the properties the theme toggle
   actually changes, so switching feels like a fade rather than a
   flash. Scoped to specific properties (not `all`) so it doesn't
   interfere with existing hover/animation transitions elsewhere. */
body,
.site-header,
.doc-card,
.profile-menu__panel,
.btn,
.btn-primary,
.btn-secondary,
.badge,
input,
textarea,
select {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  /* The document itself never scrolls -- #pageScroll (see base.html)
     does instead. See that file's comment for why: it works around an
     Android WebView bug where position:fixed elements (the chat bubble)
     drift with the page during scroll. */
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* The site's actual scroll container -- see the html/body rule above
   and the comment in base.html. */
.page-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.88;
}

.brand__logo {
  display: block;
  height: 46px;
  width: auto;
}

@media (max-width: 600px) {
  .brand__logo {
    height: 36px;
  }
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Small, unobtrusive Facebook link next to the logo -- deliberately
   kept compact so it doesn't compete with the brand mark for attention. */
.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  color: var(--text-muted);
  opacity: 0.75;
  flex: 0 0 auto;
}

.social-link:hover {
  color: var(--accent);
  opacity: 1;
  text-decoration: none;
}

@media (max-width: 600px) {
  .social-link {
    width: 22px;
    height: 22px;
  }

  .social-link svg {
    width: 15px;
    height: 15px;
  }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.site-nav > a { white-space: nowrap; }

/* On phones the logo and the nav links don't fit on one line, so let the
   header wrap the links onto their own row instead of overflowing sideways. */
@media (max-width: 600px) {
  .site-header__inner {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px 16px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 8px 14px;
  }
}

.tier-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
}

.btn-link:hover {
  color: var(--accent);
}

/* Profile menu -- combines what used to be separate "username" /
   "log in" / "log out" nav items into one dropdown, opened from a
   single "Profile" trigger button (see site.js for the open/close and
   theme-toggle behavior). */

.profile-menu {
  position: relative;
}

.profile-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  margin: -6px -10px;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-menu__trigger:hover {
  color: var(--accent-hover);
}

.profile-menu__trigger[aria-expanded="true"] {
  color: var(--accent-hover);
  border-color: var(--border);
  background: var(--surface-muted);
}

.profile-menu__chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.profile-menu__trigger[aria-expanded="true"] .profile-menu__chevron {
  transform: rotate(180deg);
}

.profile-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 14px 16px;
}

.profile-menu__panel[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .profile-menu__panel {
    right: -12px;
  }
}

.profile-menu__user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.profile-menu__identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.profile-menu__avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.profile-menu__avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-menu__avatar-placeholder {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.profile-menu__username {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu__divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.profile-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}

a.profile-menu__item {
  text-decoration: none;
}

.profile-menu__item:hover {
  color: var(--accent);
}

.profile-menu__settings-label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.theme-toggle__option {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-toggle__option:hover {
  color: var(--text);
}

.theme-toggle__option.is-active {
  background: var(--accent);
  color: #fff;
}

.theme-toggle__option.is-active:hover {
  color: #fff;
}

.profile-menu__settings-label--spaced {
  margin-top: 14px;
}

.avatar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.avatar-form__input {
  flex: 1 1 100%;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: var(--text-muted);
  max-width: 100%;
}

.avatar-form__clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.avatar-form__save {
  padding: 4px 14px;
  font-size: 0.78rem;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* Shelves -- tidy, wrapping grids of documents on the home page, one per
   category, each paginated independently once it passes 20 titles. */

.shelf {
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}

.shelf__headrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.shelf__heading {
  font-size: 1.25rem;
}

.shelf__count {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.shelf__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 16px;
  align-items: stretch;
}

/* Document cards (used inside a shelf grid, or standalone in search results) */

.doc-card {
  position: relative;
}

.doc-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.doc-card__link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}

.doc-card__cover {
  aspect-ratio: 2 / 3;
  background: linear-gradient(160deg, var(--surface-muted), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}

.doc-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-card__cover svg {
  width: 34%;
  height: 34%;
  opacity: 0.55;
}

.doc-card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.doc-card__title {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card__author {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.doc-card__badges {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Bookmark toggle button, overlaid on the card's cover */

.doc-card__bookmark-form {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  margin: 0;
}

.doc-card__bookmark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--overlay-bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.doc-card__bookmark:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.doc-card__bookmark--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--overlay-bg-active);
}

@media (max-width: 600px) {
  .shelf__grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 14px 12px;
  }
}

/* Badges */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-public-domain {
  background: var(--success-soft);
  color: var(--success);
}

.badge-browse-only {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-tier {
  background: var(--gold-soft);
  color: var(--gold);
}

/* Topic grid -- "Browse by Subject" tiles (homepage trimmed section and
   the full /topics/ index) */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.topic-tile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.topic-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  text-decoration: none;
}

.topic-tile__name {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--text);
}

.topic-tile__count {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Topic pills -- shown on a document's own detail page, linking back to
   each of its subject topics */

.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.topic-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.topic-pill:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.breadcrumb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.breadcrumb a {
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .topic-grid {
    grid-template-columns: 1fr;
  }
}

/* Empty state */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Pagination */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.shelf .pagination {
  margin-top: 20px;
}

/* Document detail */

.doc-detail {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
}

@media (max-width: 720px) {
  .doc-detail {
    grid-template-columns: 1fr;
  }
}

.doc-detail__cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-muted), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--text-muted);
}

.doc-detail__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-detail__cover svg {
  width: 30%;
  height: 30%;
  opacity: 0.5;
}

.doc-detail__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.doc-detail__heading .page-title {
  margin-bottom: 0;
}

.doc-detail__heading-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  padding-top: 4px;
}

.bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

.bookmark-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.bookmark-btn--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.doc-detail__author {
  color: var(--text-muted);
  margin: 6px 0 14px;
  font-size: 1.05rem;
}

.doc-detail__badges {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.doc-detail__description {
  margin-bottom: 24px;
  max-width: 60ch;
}

.doc-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.notice {
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  max-width: 60ch;
}

.notice-locked {
  background: var(--gold-soft);
  border-color: transparent;
  color: var(--gold);
}

/* Auth forms */

.auth-card {
  max-width: 380px;
  margin: 40px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin-bottom: 20px;
}

.auth-card form p {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-card label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-card input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-sans);
}

.auth-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

.site-footer {
  text-align: center;
  padding: 30px 24px 50px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Library imagery */

.hero-photo {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
  border: 1px solid var(--border);
  height: 360px;
}

.hero-photo > picture {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-photo__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  display: block;
}

.hero-photo__scrim {
  position: absolute;
  inset: 0;
  /* Kept fairly light -- the glass panel below now carries most of the
     contrast work, so the photo itself stays visible through it rather
     than being darkened flat. */
  background: linear-gradient(180deg, rgba(6, 3, 2, 0.05) 0%, rgba(6, 3, 2, 0.25) 65%, rgba(6, 3, 2, 0.5) 100%);
}

.hero-photo__content {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  padding: 20px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  /* Frosted-glass panel: the library photo behind it stays visible,
     softened and slightly warmed, instead of being hidden behind a
     solid card. */
  background: linear-gradient(135deg, rgba(36, 26, 16, 0.5), rgba(20, 14, 8, 0.38));
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(207, 154, 68, 0.2);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.hero-photo__text {
  min-width: 0;
}

.hero-photo__title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  color: #f3e6cf;
  margin: 0 0 6px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
}

.hero-photo__subtitle {
  color: #d8c7ad;
  margin: 0;
  font-size: 1.05rem;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}

/* A small, quiet candle beside the hero text -- decorative only, not a
   focal point. The flame flickers with two offset, gently irregular
   animations (outer + inner flame) plus a soft breathing glow, so it
   reads as alive without drawing attention away from the page content. */
.hero-candle {
  flex-shrink: 0;
  width: 30px;
  height: 48px;
}

.hero-candle svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hero-candle__glow {
  fill: var(--accent);
  opacity: 0.32;
  filter: blur(7px);
  transform-origin: 20px 15px;
  animation: hero-candle-glow 3.4s ease-in-out infinite;
}

.hero-candle__flame-outer {
  fill: var(--accent-hover);
  filter: drop-shadow(0 0 4px var(--accent));
  transform-origin: 20px 21px;
  animation: hero-candle-flicker 2.6s ease-in-out infinite;
}

.hero-candle__flame-inner {
  fill: #fff6df;
  transform-origin: 20px 19px;
  animation: hero-candle-flicker-inner 2.1s ease-in-out infinite;
}

.hero-candle__wick {
  stroke: #4a3c2a;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.hero-candle__body {
  fill: #ece1cc;
}

.hero-candle__wax {
  fill: #f6efdf;
}

@keyframes hero-candle-flicker {
  0%, 100% { transform: scaleY(1) scaleX(1) rotate(0deg); opacity: 1; }
  22% { transform: scaleY(0.9) scaleX(1.06) rotate(-2deg); opacity: 0.88; }
  45% { transform: scaleY(1.07) scaleX(0.95) rotate(1.5deg); opacity: 1; }
  68% { transform: scaleY(0.95) scaleX(1.02) rotate(-1deg); opacity: 0.9; }
  85% { transform: scaleY(1.04) scaleX(0.97) rotate(2deg); opacity: 1; }
}

@keyframes hero-candle-flicker-inner {
  0%, 100% { transform: scaleY(1) translateX(0); opacity: 0.95; }
  30% { transform: scaleY(0.88) translateX(0.4px); opacity: 0.82; }
  55% { transform: scaleY(1.1) translateX(-0.4px); opacity: 1; }
  78% { transform: scaleY(0.94) translateX(0.3px); opacity: 0.88; }
}

@keyframes hero-candle-glow {
  0%, 100% { opacity: 0.28; transform: scale(1); }
  50% { opacity: 0.42; transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-candle__flame-outer,
  .hero-candle__flame-inner,
  .hero-candle__glow {
    animation: none;
  }
}

@media (max-width: 600px) {
  .hero-photo {
    height: 260px;
  }
  .hero-photo__content {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 14px 16px;
  }
  .hero-photo__title {
    font-size: 1.6rem;
  }
  .hero-candle {
    width: 22px;
    height: 36px;
  }
}

.shelf-strip {
  max-width: 1080px;
  margin: 20px auto 0;
  padding: 0 24px;
  opacity: 0.9;
}

.shelf-strip svg {
  display: block;
  width: 100%;
  height: 34px;
}

@media (max-width: 600px) {
  .shelf-strip {
    display: none;
  }
}

/* Pricing */

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  max-width: 760px;
}

.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pricing-card--current {
  border-color: var(--accent);
}

.pricing-card__price {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.pricing-card__price span {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.pricing-card__desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  flex: 1;
}

/* Tier descriptions are one feature per line (rendered via |linebreaks). */
.pricing-card__desc p {
  margin: 0 0 10px;
}

.pricing-card__desc p:last-child {
  margin-bottom: 0;
}

/* Live readings banner */

.live-readings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin: 20px 0 28px;
  box-shadow: var(--shadow);
}

.live-readings__heading {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 0 0 4px;
  color: var(--accent);
}

.live-readings__body {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 56ch;
}

.live-readings__btn {
  flex-shrink: 0;
}

.live-readings__icon {
  width: 18px;
  height: 18px;
}

@media (max-width: 600px) {
  .live-readings {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Search & filter bar */

.search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.search-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-sans);
}

.search-bar select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-sans);
}

.search-bar input:focus,
.search-bar select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Free preview + paywall */

.preview-frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  height: 480px;
  margin-bottom: 16px;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ece1cf;
}

.preview-frame__fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 130px;
  background: linear-gradient(180deg, rgba(11, 7, 5, 0) 0%, var(--bg) 90%);
  pointer-events: none;
}

.paywall {
  text-align: center;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 60ch;
}

.paywall h3 {
  margin-bottom: 8px;
}

.paywall p {
  color: var(--text-muted);
  margin: 0 0 16px;
}

.paywall .btn {
  margin-right: 8px;
}

@media (max-width: 720px) {
  .preview-frame {
    height: 360px;
  }
}

/* Upload form */

.upload-form {
  max-width: 640px;
}

.upload-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 18px;
}

.upload-form label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.upload-form input[type="text"],
.upload-form input[type="file"],
.upload-form select,
.upload-form textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-sans);
}

.upload-form textarea {
  resize: vertical;
}

.upload-form input:focus,
.upload-form select:focus,
.upload-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.upload-form__help {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.upload-form__current {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.upload-form__error {
  color: var(--accent);
  font-size: 0.85rem;
}

/* Site messages (e.g. "Document uploaded") */

.messages {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

.message {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message-success {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.message-error {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Forum */

.badge-pinned {
  background: var(--gold-soft);
  color: var(--gold);
  margin-right: 6px;
}

.badge-locked {
  background: var(--surface-muted);
  color: var(--text-muted);
  margin-right: 6px;
}

.forum-toolbar {
  margin-bottom: 24px;
}

.forum-topic-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.forum-topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s ease;
}

.forum-topic-row:last-child {
  border-bottom: none;
}

.forum-topic-row:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

.forum-topic-row--pinned {
  background: var(--gold-soft);
}

.forum-topic-row__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.forum-topic-row__title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--text);
}

.forum-topic-row__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.forum-topic-row__stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
}

.forum-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
}

.forum-post {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 20px;
}

.forum-post__author {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.forum-post__username {
  font-weight: 600;
  color: var(--accent);
}

.forum-post__date {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.forum-post__body {
  color: var(--text);
  word-wrap: break-word;
}

.forum-post__body p {
  margin: 0 0 1em;
}

.forum-post__body p:last-child {
  margin-bottom: 0;
}

.forum-reply-form {
  margin-top: 24px;
}

.forum-reply-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: vertical;
}

.forum-reply-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.forum-reply-form .btn-primary {
  margin-top: 10px;
}

.forum-post__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.forum-post__actions form {
  display: inline;
}

.forum-danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.forum-danger-zone .btn-link {
  color: var(--text-muted);
}

.forum-danger-zone .btn-link:hover {
  color: var(--accent);
}

.seed-list {
  columns: 2;
  gap: 32px;
  margin: 20px 0 28px;
  padding-left: 20px;
  color: var(--text-muted);
}

.seed-list li {
  margin-bottom: 8px;
  break-inside: avoid;
}

.library-import-results {
  margin-top: 28px;
}

/* Online presence dot -- a small circular indicator shown next to a
   friend's (or a message thread partner's) username/avatar when their
   Profile.last_seen is recent enough to count as "online now". */

.online-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--success);
  flex-shrink: 0;
}

.friend-row__avatar .online-dot,
.profile-page__avatar .online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
}

.online-dot--large {
  width: 13px;
  height: 13px;
}

.message-thread__title {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Profile-menu badges (unread message / pending friend-request counts) */

.profile-menu__badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

/* Section headings (friends list groups: requests / sent / friends) */

.section-heading {
  font-size: 1.1rem;
  margin: 32px 0 12px;
}

.section-heading:first-of-type {
  margin-top: 0;
}

/* Friend rows -- shared by the friends list and the messages inbox */

.friend-row-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 8px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.friend-row:last-child {
  border-bottom: none;
}

.friend-row__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
}

.friend-row__identity:hover {
  text-decoration: none;
}

.friend-row__identity:hover .friend-row__username {
  color: var(--accent);
}

.friend-row__avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 7px;
  overflow: visible;
  display: inline-flex;
}

.friend-row__avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
  display: block;
}

.friend-row__avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.friend-row__username {
  font-weight: 600;
  color: var(--text);
}

.friend-row__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Messages inbox -- a friend-row made fully clickable, with a message
   preview and an unread-count badge. */

.conversation-row {
  color: inherit;
}

.conversation-row:hover {
  background: var(--surface-muted);
}

.conversation-row__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.conversation-row__preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46ch;
}

.conversation-row__preview--empty {
  font-style: italic;
}

.conversation-row__unread {
  flex-shrink: 0;
}

/* Public profile page */

.profile-page__header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.profile-page__avatar {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
}

.profile-page__avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  display: block;
}

.profile-page__avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.profile-page__identity .page-title {
  margin-bottom: 2px;
}

.profile-page__identity .page-subtitle {
  margin-bottom: 0;
}

.profile-page__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Message thread -- simple left/right chat bubbles */

.message-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0;
}

.message-bubble-row {
  display: flex;
  justify-content: flex-start;
}

.message-bubble-row--own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 65%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
}

.message-bubble-row--own .message-bubble {
  background: var(--accent-soft);
  border-color: transparent;
}

.message-bubble__body {
  color: var(--text);
  word-wrap: break-word;
}

.message-bubble__body p {
  margin: 0 0 0.6em;
}

.message-bubble__body p:last-child {
  margin-bottom: 0;
}

.message-bubble__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

@media (max-width: 600px) {
  .message-bubble {
    max-width: 85%;
  }
}

/* ---- Simple long-form content pages (privacy policy, etc.) ---- */
.prose {
  max-width: 720px;
  line-height: 1.65;
  color: var(--text);
}
.prose h2 {
  margin-top: 2em;
  margin-bottom: 0.5em;
  font-size: 1.15rem;
  color: var(--accent);
}
.prose p {
  margin-bottom: 1em;
}
.prose ul {
  margin: 0 0 1em 1.2em;
  padding: 0;
}
.prose li {
  margin-bottom: 0.4em;
}
.prose a {
  color: var(--accent);
}

/* Videos -- Netflix-style poster rows/grid (home page "Videos" shelf, the
   /videos/ index) and the per-film player page. Posters are YouTube's own
   portrait movie-poster images; playback is YouTube's embedded player. */

.video-row {
  position: relative;
}

.video-row__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 180px);
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 6px 2px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.video-row__track > .video-card {
  scroll-snap-align: start;
}

.video-row__arrow {
  position: absolute;
  top: 6px;
  bottom: 14px;
  z-index: 3;
  width: 40px;
  border: none;
  background: linear-gradient(90deg, var(--bg), transparent);
  color: var(--text);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}

.video-row__arrow:hover {
  color: var(--accent);
  opacity: 1;
}

.video-row__arrow--prev {
  left: -2px;
}

.video-row__arrow--next {
  right: -2px;
  background: linear-gradient(270deg, var(--bg), transparent);
}

.video-row__arrow[hidden] {
  display: none;
}

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

.video-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.video-card:hover {
  text-decoration: none;
}

.video-card__poster {
  position: relative;
  aspect-ratio: 279 / 402;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, var(--surface-muted), var(--border));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.video-card__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-card__img--fallback {
  object-position: center;
}

.video-card:hover .video-card__poster,
.video-card:focus-visible .video-card__poster {
  transform: scale(1.04);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.video-card__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(11, 7, 5, 0.7);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.video-card__play svg {
  margin-left: 3px;
}

.video-card:hover .video-card__play,
.video-card:focus-visible .video-card__play {
  opacity: 1;
}

.video-card__play--large {
  position: static;
  margin: 0;
  width: 72px;
  height: 72px;
  opacity: 1;
}

.video-card__info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 34px 10px 10px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0));
  color: #fff;
  transform: translateY(100%);
  transition: transform 0.18s ease;
}

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

.video-card__title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.25;
}

.video-card__meta {
  font-size: 0.74rem;
  opacity: 0.85;
  margin-top: 3px;
}

@media (hover: none) {
  /* Touch screens can't hover -- keep the title strip visible. */
  .video-card__info {
    transform: none;
  }
}

.video-detail__back {
  margin-bottom: 12px;
}

.video-player {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 72vh;
  width: 100%;
  margin-bottom: 26px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.video-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-player__linkout {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  color: #fff;
  text-decoration: none;
}

.video-player__linkout:hover {
  text-decoration: none;
}

.video-player__linkout-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 460px;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.72);
  border-radius: var(--radius);
}

.video-detail {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 28px;
  margin-bottom: 40px;
  align-items: start;
}

.video-detail__poster {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.video-detail__meta {
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.video-detail__why,
.video-detail__topics {
  margin-top: 10px;
}

.video-detail__note {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 14px;
}

@media (max-width: 600px) {
  .video-detail {
    grid-template-columns: 1fr;
  }
  .video-detail__poster {
    width: 140px;
  }
  .video-row__track {
    grid-auto-columns: 128px;
  }
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .video-row__arrow {
    display: none;
  }
}

/* /videos/ -- one Netflix-style row per topic, with a strip of jump chips. */

.video-category {
  margin-bottom: 30px;
  scroll-margin-top: 90px;
}

.video-category .shelf__headrow {
  margin-bottom: 6px;
}

.video-jump {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin: -12px 0 28px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.video-jump__chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}

.video-jump__chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

