/* Forgotten Fortunes 5.0 — Visual Unification + Header / Language / Sections Polish
 * Visual-only + micro-interaction layer.
 * Keeps article content, translation, SEO, audio and reader data flows untouched.
 */

:root {
  --ff-v50-cream: #efe3c3;
  --ff-v50-cream-soft: rgba(239,227,195,.14);
  --ff-v50-gold: #d6b66f;
  --ff-v50-gold-soft: rgba(214,182,111,.28);
  --ff-v50-panel: #0b241c;
  --ff-v50-panel-2: #102c22;
  --ff-v50-deep: #071a15;
  --ff-v50-deep-2: #0d2a20;
}

html, body { background-color: var(--ff-v50-deep); }
body.home,
body.blog,
body.archive,
body.category,
body.search,
body.page:not(.single-post) {
  background:
    radial-gradient(circle at 50% -12%, rgba(239,227,195,.08), transparent 34%),
    linear-gradient(180deg, #04120f 0%, #071c16 180px, #081f18 56%, #061712 100%);
}

/* --- Header refinement: softer ceramic / cream feel around the utility strip --- */
.ff-header .ff-header-inner {
  position: relative;
  isolation: isolate;
  background: linear-gradient(180deg, rgba(7,29,22,.96), rgba(7,25,20,.98));
}
.ff-header .ff-header-inner::before {
  content: '';
  position: absolute;
  inset: 5px 12px;
  border-radius: 18px;
  border: 1px solid rgba(214,182,111,.14);
  background:
    linear-gradient(90deg, rgba(239,227,195,.06), rgba(239,227,195,.02) 45%, rgba(239,227,195,.06)),
    linear-gradient(180deg, rgba(255,245,226,.02), transparent 60%);
  pointer-events: none;
  z-index: -1;
}
.ff-header .ff-header-inner > .ff-header-search,
.ff-header .ff-header-inner .wp-block-navigation__responsive-container-open,
.ff-header .ff-languages--inline .ff-language-current {
  box-shadow: inset 0 1px 0 rgba(255,245,226,.07), 0 10px 24px rgba(0,0,0,.18);
}
.ff-header .ff-header-inner > .ff-header-search {
  background:
    linear-gradient(180deg, rgba(239,227,195,.10), rgba(214,182,111,.03)),
    rgba(8,28,22,.96);
  border-color: rgba(214,182,111,.34);
}
.ff-header .ff-header-inner > .ff-header-search:hover,
.ff-header .ff-header-inner > .ff-header-search:focus-visible {
  background:
    linear-gradient(180deg, rgba(239,227,195,.14), rgba(214,182,111,.05)),
    rgba(16,44,34,.98);
}
.ff-header .ff-languages--inline .ff-language-current {
  background:
    linear-gradient(180deg, rgba(239,227,195,.10), rgba(214,182,111,.03)),
    rgba(8,28,22,.96) !important;
}
.ff-header .ff-languages--inline .ff-languages-list {
  background: linear-gradient(180deg, rgba(10,35,27,.99), rgba(8,28,22,.99));
  backdrop-filter: blur(6px);
}

@media (max-width: 782px) {
  .ff-header .ff-header-inner {
    background:
      radial-gradient(circle at 50% 0%, rgba(239,227,195,.09), transparent 58%),
      linear-gradient(180deg, rgba(7,29,22,.97), rgba(6,24,19,.99));
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
  }
  .ff-header .ff-header-inner::before {
    inset: 4px 10px;
    border-radius: 22px;
    background:
      linear-gradient(90deg, rgba(239,227,195,.07), rgba(239,227,195,.01) 50%, rgba(239,227,195,.07)),
      linear-gradient(180deg, rgba(255,248,232,.03), transparent 58%);
  }
  .ff-header .ff-header-inner > .ff-header-search,
  .ff-header .ff-header-inner .wp-block-navigation__responsive-container-open {
    background:
      linear-gradient(180deg, rgba(239,227,195,.12), rgba(214,182,111,.04)),
      rgba(10,29,23,.98);
    border: 1px solid rgba(214,182,111,.30);
    border-radius: 50%;
  }
  .ff-header .ff-header-inner > .ff-languages--inline {
    top: 8px;
    right: 60px;
  }
  .ff-header .ff-languages--inline .ff-language-current {
    min-height: 34px;
    padding-inline: 9px;
    border-radius: 999px;
  }
}

/* --- Front page / archive / category visual fill: remove flat black impression --- */
.ff-home .ff-opening-grid,
.ff-home .ff-paper-section,
.ff-home .ff-dual-features,
.ff-home .ff-topic-collections,
.ff-home .ff-after-article,
.ff-category .ff-category-grid,
.ff-category .ff-paper-section,
.ff-archive .ff-archive-query,
.ff-shell > .ff-archive-header,
.ff-shell > .alignwide > .ff-archive-header {
  position: relative;
  isolation: isolate;
}

.ff-home .ff-opening-grid::before,
.ff-home .ff-paper-section::before,
.ff-home .ff-dual-features::before,
.ff-home .ff-topic-collections::before,
.ff-category .ff-category-grid::before,
.ff-category .ff-paper-section::before,
.ff-archive .ff-archive-query::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(8,31,24,.94), rgba(10,42,32,.90) 52%, rgba(8,31,24,.95)),
    url('images/ff-marble-reading.webp') center/cover no-repeat;
  border: 1px solid rgba(214,182,111,.10);
}

.ff-home .ff-opening-grid,
.ff-home .ff-dual-features,
.ff-home .ff-topic-collections,
.ff-category .ff-category-grid {
  padding: clamp(16px, 1.8vw, 24px);
  border-radius: 2px;
}
.ff-home .ff-paper-section,
.ff-category .ff-paper-section {
  background:
    linear-gradient(180deg, rgba(8,31,24,.96), rgba(10,39,31,.96)),
    url('images/emerald-columns.webp') center/cover no-repeat;
  border-top: 1px solid rgba(214,182,111,.18);
  border-bottom: 1px solid rgba(214,182,111,.18);
}
.ff-home .ff-top-ad .ff-ad,
.ff-home .ff-editors-rail,
.ff-category .ff-category-rail,
.ff-reading-rail .ff-collection,
.ff-reading-rail .ff-ad-sidebar {
  background:
    linear-gradient(155deg, rgba(9,31,24,.96), rgba(14,47,36,.92)),
    url('images/ff-marble-menu.webp') center/cover no-repeat;
}
.ff-home .ff-editors-rail,
.ff-category .ff-category-rail {
  border: 1px solid rgba(214,182,111,.24);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02);
}
.ff-home .ff-topic-grid > a,
.ff-home .ff-topic-collections .ff-card,
.ff-category .ff-topic-grid > a,
.ff-category .ff-paper-section .wp-block-post-template > li,
.ff-archive .wp-block-post-template > li {
  backdrop-filter: saturate(1.02);
}

@media (min-width: 1380px) {
  .ff-shell.ff-home,
  .ff-shell.ff-single,
  body.archive .ff-shell,
  body.category .ff-shell {
    position: relative;
    isolation: isolate;
  }
  .ff-shell.ff-home::before,
  .ff-shell.ff-home::after,
  .ff-shell.ff-single::before,
  .ff-shell.ff-single::after,
  body.archive .ff-shell::before,
  body.archive .ff-shell::after,
  body.category .ff-shell::before,
  body.category .ff-shell::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(11vw, 148px);
    pointer-events: none;
    opacity: .38;
    background: url('images/emerald-columns.webp') center top / cover no-repeat;
    z-index: -1;
    filter: saturate(.72) contrast(.92);
  }
  .ff-shell.ff-home::before,
  .ff-shell.ff-single::before,
  body.archive .ff-shell::before,
  body.category .ff-shell::before { left: calc(-1 * min(9vw, 120px)); }
  .ff-shell.ff-home::after,
  .ff-shell.ff-single::after,
  body.archive .ff-shell::after,
  body.category .ff-shell::after { right: calc(-1 * min(9vw, 120px)); transform: scaleX(-1); }
}

/* --- Single article: darker margins get the same imperial treatment --- */
.single-post {
  background:
    radial-gradient(circle at 50% -10%, rgba(239,227,195,.08), transparent 32%),
    linear-gradient(180deg, #03100d 0%, #071c16 200px, #081f18 58%, #061712 100%);
}
.single-post .ff-single {
  position: relative;
  isolation: isolate;
}
.single-post .ff-single::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background: radial-gradient(circle at 50% 0%, rgba(239,227,195,.04), transparent 46%);
}
.single-post .ff-after-article {
  padding: clamp(18px, 2vw, 28px);
  background:
    linear-gradient(150deg, rgba(8,31,24,.96), rgba(12,42,32,.92)),
    url('images/ff-marble-menu.webp') center/cover no-repeat;
  border: 1px solid rgba(214,182,111,.16);
}

/* --- Mobile sections sheet: keep list + top pill rail, fix overflow / clipping --- */
.ff-v48-section-sheet {
  overflow: visible;
}
.ff-v48-sheet-inner {
  max-height: min(82dvh, 780px);
}
.ff-v48-sheet-subhead {
  margin-bottom: 8px;
}
.ff-v48-section-pills {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.ff-v48-section-pills::-webkit-scrollbar { display: none; }
.ff-v48-section-pill,
.ff-v48-section-item {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ff-v48-section-pill {
  min-width: min(78vw, 260px);
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  line-height: 1.22;
}
.ff-v48-section-list {
  min-width: 0;
}
.ff-v48-section-item {
  text-align: left;
  padding-right: 16px;
  line-height: 1.34;
}
.ff-v48-section-item.is-subsection {
  padding-left: 27px;
}

/* Remove the textual “Languages” label. Flags + global codes are enough. */
.ff-v48-language-title { display: none !important; }
.ff-v48-mobile-languages {
  padding-top: 4px !important;
  margin-top: 0 !important;
  border-top: 0 !important;
}
.ff-v48-language-choices {
  gap: 8px;
}
.ff-v48-language-choice {
  min-width: 72px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(239,227,195,.11), rgba(214,182,111,.04)),
    rgba(15,43,33,.98);
}

/* When the mobile drawer opens, keep languages near the top rather than buried below the full menu. */
.ff-header .wp-block-navigation__responsive-container.is-menu-open .ff-v48-mobile-languages {
  order: -1;
}

/* Desktop polish for the same chapter sheet if opened on larger screens. */
@media (min-width: 783px) {
  .ff-v48-section-sheet {
    width: min(720px, calc(100vw - 72px));
  }
  .ff-v48-sheet-inner {
    padding: 28px 28px 26px;
  }
  .ff-v48-section-list {
    max-height: min(54dvh, 520px);
  }
}

@media (max-width: 782px) {
  .ff-home .ff-opening-grid,
  .ff-home .ff-dual-features,
  .ff-home .ff-topic-collections,
  .ff-category .ff-category-grid { padding: 12px; }

  .ff-v48-section-sheet {
    width: min(100vw - 20px, 680px);
    max-width: calc(100vw - 20px);
  }
  .ff-v48-sheet-inner {
    padding: 18px 16px 16px;
    border-radius: 22px;
    background:
      linear-gradient(180deg, rgba(10,37,29,.99), rgba(7,28,22,.99)),
      url('images/ff-marble-menu.webp') center/cover no-repeat;
  }
  .ff-v48-section-pill {
    min-width: min(72vw, 230px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ff-v48-section-pills { scroll-behavior: auto; }
}

