/* Forgotten Fortunes V4.8 — Mobile Reading Experience / Cinematic Navigation
 * Progressive enhancements that preserve article content, Polylang routing, SEO and audio.
 */

/* Desktop/tablet language control: only active flag and code, no second label. */
.ff-header .ff-languages--inline {
  padding: 0;
  margin-left: 4px;
  flex: none;
  border: 0;
  background: none;
}
.ff-header .ff-languages--inline .ff-lang-globe,
.ff-header .ff-languages--inline .ff-lang-name { display: none; }
.ff-header .ff-languages--inline .ff-language-current {
  min-height: 36px;
  padding: 7px 10px;
  gap: 5px;
  border-radius: 20px;
  font: 700 11px/1 system-ui, sans-serif;
  white-space: nowrap;
}
.ff-header .ff-languages--inline .ff-languages-list {
  padding: 7px;
  min-width: 106px;
  max-width: 150px;
  top: calc(100% + 8px);
  width: max-content;
  gap: 2px;
  border-radius: 12px;
  z-index: 12;
}
.ff-header .ff-languages--inline .ff-language-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  padding: 8px 9px;
  gap: 7px;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.ff-header .ff-languages--inline .ff-lang-code {letter-spacing: .04em; font-weight: 600;}
.ff-header .ff-languages--inline .ff-lang-flag {font-size: 15px; line-height: 1;}

/* Language choices are enhanced into WordPress' existing hamburger overlay.
   Do not render a second permanent header bar on small screens. */
.ff-v48-mobile-languages { display: none; }

@media (max-width: 1180px) {
  .ff-header-inner {gap: 10px;}
  .ff-header-inner > .wp-block-navigation {flex: 0 0 auto; min-width: 40px;}
}

@media (max-width: 782px) {
  .ff-header .ff-header-inner {
    display: grid !important;
    grid-template-columns: 44px minmax(0,1fr) 44px;
    grid-template-rows: minmax(48px,auto);
    align-items: center;
    justify-content: stretch;
    gap: 8px !important;
    min-height: 56px;
    padding: 6px 14px !important;
    width: 100%;
    box-sizing: border-box;
  }
  .ff-header .ff-header-inner > .wp-block-site-title,
  .ff-header .ff-header-inner > .ff-brand {
    grid-area: 1 / 2;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0 !important;
    text-align: center;
    justify-self: stretch;
    overflow: hidden;
  }
  .ff-header .ff-header-inner .ff-brand a,
  .ff-header .ff-header-inner > .wp-block-site-title a {
    display: block;
    font-size: clamp(13px, 4vw, 18px) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.02em;
  }
  .ff-header .ff-header-inner > .ff-header-search {
    grid-area: 1 / 1;
    justify-self: start;
    width: 42px;
    height: 42px;
    padding: 0;
    margin: 0;
  }
  .ff-header .ff-header-inner > .wp-block-navigation {
    grid-area: 1 / 3;
    justify-self: end;
    display: flex;
    flex: 0 0 auto;
    min-width: 0;
    width: 44px;
    margin: 0;
    align-items: center;
    justify-content: flex-end;
  }
  .ff-header .ff-header-inner .wp-block-navigation__responsive-container-open {
    display: flex !important;
    width: 44px;
    height: 44px;
    padding: 0;
    align-items: center;
    justify-content: center;
  }
  .ff-header .ff-header-inner .wp-block-navigation__responsive-container:not(.is-menu-open) {display:none !important;}
  .ff-header .ff-header-inner > .ff-languages--inline {
    position: absolute;
    right: 62px;
    top: 9px;
    grid-area: auto;
    z-index: 3;
    transform: none;
  }
  .ff-v48-language-ready .ff-header .ff-header-inner > .ff-languages--inline {display: none !important;}
  .ff-header .wp-block-navigation__responsive-container.is-menu-open .ff-v48-mobile-languages {
    display: block;
    width: 100%;
    align-self: stretch;
    padding: 18px 0 5px;
    margin: 14px 0 0;
    border-top: 1px solid rgba(214,182,111,.35);
    box-sizing: border-box;
  }
  .ff-v48-language-title {
    margin: 0 0 12px;
    color: #d6b66f;
    font: 700 11px/1.3 system-ui, sans-serif;
    letter-spacing: .15em;
    text-transform: uppercase;
  }
  .ff-v48-language-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    width: 100%;
  }
  .ff-v48-language-choice {
    min-width: 88px;
    min-height: 44px;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    color: #f5e8c9;
    text-decoration: none;
    border: 1px solid rgba(214,182,111,.38);
    border-radius: 10px;
    font: 650 13px/1 system-ui,sans-serif;
    background: #17372b;
  }
  .ff-v48-language-choice[aria-current="page"] {
    color: #081712;
    background: #dfc482;
    border-color: #dfc482;
  }
  .ff-v48-language-choice:focus-visible {outline: 2px solid #efcc81;outline-offset:3px;}
}

/* Reading navigation: small fixed control, only visible while article text is being read. */
.ff-v48-reader-dock { display: none; }
.ff-v48-section-sheet:not([open]) {display:none;}
.ff-v48-section-sheet {
  box-sizing: border-box;
  color: #f6eddb;
  border: 1px solid rgba(218,185,111,.52);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 0;
  width: 100%;
  max-width: 620px;
  max-height: min(79dvh, 660px);
  margin: auto auto 0;
  overflow: hidden;
  background: linear-gradient(180deg, #153a2e, #061912);
  box-shadow: 0 -20px 52px rgba(0,0,0,.42);
}
.ff-v48-section-sheet::backdrop {background: rgba(1,12,9,.70);}
.ff-v48-sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: min(79dvh, 660px);
  padding: 16px 16px max(18px,env(safe-area-inset-bottom));
  box-sizing: border-box;
}
.ff-v48-sheet-heading {display:flex;align-items:center;justify-content:space-between;gap:16px;flex:none;}
.ff-v48-sheet-heading h2 {font: 400 26px/1.18 Georgia,serif;letter-spacing:-.02em;margin:3px 0 14px;color:#f6e5bd;}
.ff-v48-sheet-close {
  display:grid;place-items:center;
  width:44px;height:44px;flex:none;
  border:1px solid rgba(214,182,111,.32);border-radius:50%;
  background:#102e24;color:#f4e2b8;
  font: 28px/1 Georgia,serif;cursor:pointer;
}
.ff-v48-sheet-subhead {color:#c5aa6b;font:650 11px/1.2 system-ui,sans-serif;text-transform:uppercase;letter-spacing:.16em;margin:5px 0 10px;}
.ff-v48-section-pills {
  display:flex;
  align-items:center;
  gap:9px;
  min-height:44px;
  width:100%;
  overflow-x:auto;
  flex:none;
  scroll-snap-type:x proximity;
  overscroll-behavior-x:contain;
  scrollbar-width:thin;
  scrollbar-color:#927a47 transparent;
  padding-bottom:8px;
  border-bottom:1px solid rgba(214,182,111,.24);
}
.ff-v48-section-pill {
  padding:9px 14px;
  border:1px solid rgba(214,182,111,.32);
  border-radius:999px;
  flex:none;
  max-width:min(250px,74vw);
  white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
  scroll-snap-align:start;
  color:#eaddc1;
  background:#102b21;
  min-height:40px;
  font:500 13px/1.2 system-ui,sans-serif;
  cursor:pointer;
}
.ff-v48-section-pill.is-active {background:#dfc482;color:#0a1a12;border-color:#dfc482;}
.ff-v48-section-list {display:flex;flex-direction:column;gap:4px;overflow-y:auto;overscroll-behavior:contain;padding:12px 0 0;}
.ff-v48-section-item {
  display:block;
  width:100%;
  text-align:left;
  min-height:44px;
  padding:11px 14px;
  background:transparent;
  border:1px solid transparent;
  border-radius:10px;
  color:#ece6d9;
  font:500 15px/1.45 system-ui,sans-serif;
  cursor:pointer;
}
.ff-v48-section-item.is-subsection {padding-left:31px;font-size:14px;color:#cfcbbd;}
.ff-v48-section-item.is-active {background:#244b3a;border-color:rgba(214,182,111,.35);color:#f3e1b2;}
.ff-v48-section-item:hover,.ff-v48-section-item:focus-visible,.ff-v48-section-pill:focus-visible,.ff-v48-sheet-close:focus-visible {outline:2px solid #d6b66f;outline-offset:2px;}
.ff-v48-target-flash {animation: ff-v48-glow 650ms ease-out;}
@keyframes ff-v48-glow {0%{background-color:rgba(214,182,111,.24);}100%{background-color:transparent;}}

@media (max-width: 782px) {
  .ff-v48-reader-dock {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto auto;
    gap: 5px;
    position:fixed;
    left:max(8px, env(safe-area-inset-left));
    right:max(8px, env(safe-area-inset-right));
    bottom:max(8px, env(safe-area-inset-bottom));
    z-index: 120;
    max-width: 580px;
    margin: auto;
    padding: 5px;
    border-radius: 16px;
    background: linear-gradient(150deg,rgba(19,58,44,.97),rgba(6,23,17,.98));
    border:1px solid rgba(214,182,111,.5);
    box-shadow: 0 14px 30px rgba(0,0,0,.35);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translateY(18px);
    transition:transform .24s ease, opacity .24s ease, visibility .24s ease;
    box-sizing:border-box;
  }
  .ff-v48-reader-dock.is-visible {
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translateY(0);
  }
  .ff-v48-reader-dock button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 48px;
    border:1px solid transparent;
    border-radius:11px;
    padding:8px 10px;
    background:transparent;
    color:#f8eedb;
    font:600 13px/1.2 system-ui,sans-serif;
    cursor:pointer;
  }
  .ff-v48-reader-dock button:focus-visible {outline:2px solid #d6b66f;outline-offset:2px;}
  .ff-v48-reader-dock .ff-v48-sections-trigger {justify-content:flex-start;gap:8px;padding-left:12px;background:rgba(214,182,111,.1);border-color:rgba(214,182,111,.23);}
  .ff-v48-sections-icon {color:#e3c77e;font:26px/1 Georgia,serif;flex:none;}
  .ff-v48-trigger-text {display:block;text-align:left;min-width:0;}
  .ff-v48-trigger-text strong {display:block;color:#f5e3b8;font:650 12px/1.15 system-ui,sans-serif;letter-spacing:.015em;}
  .ff-v48-trigger-text small {display:block;max-width:clamp(95px,32vw,240px);color:#d4c6ac;font:400 11px/1.2 system-ui,sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px;}
  .ff-v48-reader-dock .ff-v48-top,
  .ff-v48-reader-dock .ff-v48-sources {font-size:12px;padding:8px;white-space:nowrap;}
  .ff-v48-reader-dock [hidden] {display:none!important;}
  /* Do not cover the final lines during reading. */
  .single-post .ff-after-article {padding-bottom:78px;}
  .single-post .ff-story-section h2[id],
  .single-post .ff-story-section h3[id],
  .single-post .ff-reading-body h2[id],
  .single-post .ff-reading-body h3[id] {scroll-margin-top:90px;}
}

@media (max-width:359px) {
  .ff-v48-reader-dock .ff-v48-top,.ff-v48-reader-dock .ff-v48-sources{font-size:11px;padding:6px;}
  .ff-v48-trigger-text small{max-width:88px;}
  .ff-header .ff-header-inner {grid-template-columns:40px minmax(0,1fr) 40px; gap:6px!important;padding-inline:10px!important;}
  .ff-header .ff-header-inner .ff-brand a{font-size:13px!important;}
}

/* Cinematic editorial transitions, guarded by reduced-motion and loaded JS. */
@media (prefers-reduced-motion: no-preference) {
  .ff-v48-pending {opacity:0.001;transform:translateY(18px);will-change:opacity,transform;}
  .ff-v48-pending.ff-v48-revealed {opacity:1;transform:none;}
  .ff-v48-revealed {animation: ff-v48-enter .34s ease-out both;}
  @keyframes ff-v48-enter {from{opacity:.78;transform:translateY(10px);}to{opacity:1;transform:none;}}
  .ff-topic-grid > a:hover,.ff-card:hover {transform:translateY(-2px);transition:transform .22s ease;}
}
@media (prefers-reduced-motion: reduce) {
  .ff-v48-reader-dock {transition:none!important;}
  .ff-v48-target-flash,.ff-v48-revealed {animation:none!important;}
  .ff-v48-pending {opacity:1!important;transform:none!important;}
  *, *::before, *::after {scroll-behavior:auto!important;}
}
@media print {
  .ff-v48-reader-dock,.ff-v48-section-sheet,.ff-v48-mobile-languages {display:none!important;}
}
