/*
 * Forex Buying Guide — 3-col desktop (tabs | phone | copy), sticky scroll-spy track.
 */

.llc-fbg.section {
  position: relative;
  width: 100%;
  max-width: 100%;
  padding: clamp(40px, 6vw, 72px) 0 0;
  margin: 0;
  color: #f1f5f9;
  /* clip (not hidden): clips decorative layers WITHOUT creating a scroll
     container, so the sticky pinned column still works. */
  overflow: clip;
  box-sizing: border-box;
  --llc-fbg-head: 82px;
  /* Cap pin height so browser zoom-out does not create a giant empty blue frame. */
  --llc-fbg-pin: min(calc(100vh - var(--llc-fbg-head)), 880px);
  /* Per-step scroll in px (not vh) — stays stable at 50%/65%/75% zoom. */
  --llc-fbg-step-scroll: 220px;
  --llc-fbg-step-count: 5;
  --llc-fbg-phone-max: 560px;
}

.llc-fbg-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  background-image: linear-gradient(#044284 0%, #08082e 100%);
}

.llc-fbg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("../img/HomeForexBuybg.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  mix-blend-mode: soft-light;
  opacity: 0.6;
  z-index: 1;
}

.llc-fbg-container {
  position: relative;
  z-index: 1;
  max-width: 100%;
  box-sizing: border-box;
}

.llc-fbg-header {
  text-align: center;
  margin-bottom: clamp(8px, 1.5vw, 16px);
}

.llc-fbg-heading {
  margin: 0;
  font-size: clamp(28px, 5vw, 45px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  font-family: var(--lulu-font-primary);
}

/*
 * Pinned scroll-through: shell = pin height + extra scroll per remaining step.
 * Sticky left fills the capped pin so the UI stays on-screen while tabs cycle.
 */
.llc-fbg-shell {
  display: block;
  position: relative;
  max-width: 1140px;
  margin: 0 auto;
  min-height: calc(
    var(--llc-fbg-pin) + var(--llc-fbg-step-scroll) * (var(--llc-fbg-step-count) - 1)
  );
  box-sizing: border-box;
}

.llc-fbg-left {
  position: sticky;
  top: var(--llc-fbg-head);
  z-index: 2;
  width: 100%;
  min-width: 0;
  min-height: var(--llc-fbg-pin);
  height: var(--llc-fbg-pin);
  max-height: var(--llc-fbg-pin);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding-block: 12px;
}

.llc-fbg-left-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px clamp(24px, 3.5vw, 64px);
  align-items: end;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
}

.llc-fbg-nav {
  grid-column: 1;
  grid-row: 1;
  text-align: right;
  padding-top: 4px;
  padding-right: 40px;
  align-self: center;
}

/* Vertical rail beside tabs (LuLu-style stepper). */
.llc-fbg-tablist-wrap {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: clamp(16px, 2vw, 22px);
  min-height: 100%;
}

.llc-fbg-tablist-wrap::before {
  content: "";
  width: 3px;
  flex-shrink: 0;
  margin-top: 6px;
  margin-bottom: 6px;
  border-radius: 2px;
  background: none;
  opacity: 0.85;
}

.llc-fbg-phone-slot {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  min-width: 0;
}

.llc-fbg-copy-mount {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, auto);
  align-content: center;
  padding-left: clamp(8px, 2vw, 24px);
}

/* One cell: panels stack in place (no vertical sum if [hidden] ever fails). */
.llc-fbg-copy-panel {
  grid-area: 1 / 1;
  min-width: 0;
}

.llc-fbg-copy-panel[hidden],
.llc-fbg-copy-panel.llc-fbg-off {
  display: none !important;
}

.llc-fbg-tablist {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: clamp(10px, 1.2vw, 14px);
  flex: 0 1 auto;
}

.llc-fbg-tab {
  display: block;
  width: 100%;
  margin: 0;
  padding: 5px 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.94);
  font: inherit;
  font-size: clamp(22px, 3vw, 35px);
  font-weight: 800;
  text-align: right;
  cursor: pointer;
  transition:
    color 0.28s ease,
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    text-shadow 0.28s ease;
  white-space: nowrap;
}

.llc-fbg-tab:hover {
  color: #fff;
}

.llc-fbg-tab:active {
  transform: scale(0.98);
}

.llc-fbg-tab:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 4px;
  border-radius: 4px;
}

.llc-fbg-tab[aria-selected="true"] {
  color: #7ddcff;
  transform: translateX(-3px) scale(1.02);
}

.llc-fbg-tab[aria-selected="true"]:active {
  transform: translateX(-3px) scale(1);
}

@keyframes llc-fbg-step-in {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.llc-fbg-copy-panel.llc-fbg-step-animate > .llc-fbg-copy {
  animation: llc-fbg-step-in 0.44s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.llc-fbg-phone-variant.llc-fbg-step-animate .llc-fbg-phone-img {
  animation: llc-fbg-step-in 0.44s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Spy rail spans the shell; slabs drive scroll-spy step changes. */
.llc-fbg-spy-rail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  z-index: 0;
  visibility: hidden;
}

.llc-fbg-spy-slab {
  flex: 1 1 0;
  min-height: 0;
  scroll-margin-top: calc(72px + 20px);
  pointer-events: none;
  background: transparent;
  width: 100%;
}

/* Decorative phone is non-interactive: avoids focus / scroll-into-view fighting the stepper. */
.llc-fbg-phone-slot,
.llc-fbg-phone {
  pointer-events: none;
  justify-self: center;
}

.llc-fbg-phone-slot {
  padding-left: 0;
  box-sizing: border-box;
}

.llc-fbg-phone {
  user-select: none;
  position: relative;
  aspect-ratio: 995 / 1585;
  height: min(var(--llc-fbg-phone-max), calc(var(--llc-fbg-pin) - 48px));
  width: auto;
  margin: 0 auto;
}

/* Each step's mockup image stacks in the same spot; JS toggles [hidden]. */
.llc-fbg-phone-variant {
  position: absolute;
  inset: 0;
}

.llc-fbg-phone-variant[hidden],
.llc-fbg-phone-variant.llc-fbg-off {
  display: none !important;
}

.llc-fbg-phone-img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 24px 50px rgba(0, 0, 0, 0.45));
}

.llc-fbg-copy {
  position: relative;
  padding: 0.25rem 0 0 0.25rem;
  text-align: left;
  min-height: 0;
}

/* Large step num behind headline (reference UI). */
.llc-fbg-step {
  position: absolute;
  left: -0.05em;
  top: -0.18em;
  font-size: clamp(26px, 3vw, 30px);
  font-weight: 700;
  line-height: 0.88;
  color: #7ddcff;
  letter-spacing: 5px;
  font-family: var(--lulu-font-primary);
}

.llc-fbg-copy-front {
  position: relative;
  z-index: 1;
  padding-top: clamp(1.75rem, 4.5vw, 3rem);
}

.llc-fbg-title {
  margin: 0 0 16px;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  font-family: var(--lulu-font-primary);
}

.llc-fbg-text {
  margin: 0;
  font-size: clamp(16px, 1.6vw, 16px) !important;
  line-height: 20px !important;
  color: #fff !important;
  font-family: var(--lulu-font-secondary) !important;
  max-width: 28rem !important;
}

@media (max-width: 991px) {
  /* No pinning on mobile: the section flows normally, image flush to bottom. */
  .llc-fbg.section {
    padding-bottom: 0;
  }

  .llc-fbg-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .llc-fbg-left {
    position: relative;
    top: auto;
    max-width: none;
    width: 100%;
    order: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    display: block;
    padding-block: 0;
  }

  .llc-fbg-left-inner {
    grid-template-columns: 1fr;
    text-align: left;
    max-width: none;
    margin: 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    align-items: start;
  }

  .llc-fbg-phone-slot {
    align-self: auto;
  }

  /* Out of flow so it adds NO height to the stack (scroll-spy only / unused on mobile). */
  .llc-fbg-spy-rail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;
  }

  .llc-fbg-nav {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
    position: sticky;
    top: 72px;
    z-index: 4;
    background: linear-gradient(180deg, rgba(7, 20, 40, 0.98) 85%, transparent);
    padding: 6px 0 10px;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    min-width: 0;
    align-self: auto;
  }

  .llc-fbg-tablist-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    /* Visible thin scrollbar so users know more tabs are off-screen (Firefox). */
    scrollbar-width: thin;
    scrollbar-color: rgba(125, 220, 255, 0.75) rgba(255, 255, 255, 0.08);
    padding-bottom: 6px;
    gap: 0;
  }

  .llc-fbg-tablist-wrap::-webkit-scrollbar {
    height: 6px;
  }

  .llc-fbg-tablist-wrap::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
  }

  .llc-fbg-tablist-wrap::-webkit-scrollbar-thumb {
    background: rgba(125, 220, 255, 0.65);
    border-radius: 999px;
  }

  .llc-fbg-tablist-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(125, 220, 255, 0.9);
  }

  .llc-fbg-tablist-wrap::before {
    display: none;
  }

  .llc-fbg-tablist {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    min-width: min-content;
    padding: 4px 2px 0;
  }

  .llc-fbg-tab {
    text-align: center;
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 12px 14px 10px;
    margin: 0;
    border-radius: 0;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255, 255, 255, 0.88);
    font-size: clamp(0.95rem, 3.6vw, 1.08rem);
  }

  .llc-fbg-tab[aria-selected="true"] {
    transform: translateY(-2px) scale(1.03);
    color: #7ddcff;
    border-bottom-color: #7ddcff;
    text-shadow: none;
  }

  .llc-fbg-tab[aria-selected="true"]:active {
    transform: translateY(-1px) scale(1.01);
  }

  /* Order on mobile: tabs → copy text → phone mockup */
  .llc-fbg-copy-mount {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    text-align: left;
    align-self: stretch;
    margin-top: 8px;
    padding: clamp(16px, 4vw, 22px);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(125, 220, 255, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  }

  .llc-fbg-phone-slot {
    grid-column: 1;
    grid-row: 3;
    min-width: 0;
    margin-top: clamp(18px, 5vw, 28px);
    margin-bottom: 0;
    justify-self: center;
    padding-left: 0;
  }

  .llc-fbg-phone {
    width: min(330px, 86vw);
    height: auto;
  }

  .llc-fbg-copy {
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: clamp(10px, 3vw, 16px);
    padding: 0;
  }

  .llc-fbg-step {
    position: static;
    left: auto;
    transform: none;
    width: auto;
    flex-shrink: 0;
    font-size: clamp(2.75rem, 14vw, 4rem);
    font-weight: 800;
    line-height: 0.95;
    color: #fff;
    opacity: 1;
    letter-spacing: -0.03em;
  }

  .llc-fbg-copy-front {
    padding-top: 0.2rem;
    flex: 1;
    min-width: 0;
    text-align: left;
  }

  .llc-fbg-title {
    font-size: clamp(1.08rem, 4vw, 1.28rem);
    margin-bottom: 10px;
  }

  .llc-fbg-text {
    font-size: clamp(0.92rem, 3.5vw, 1.02rem);
    max-width: none;
    color: rgba(241, 245, 249, 0.9);
  }

  .llc-fbg-spy-slab {
    flex: 1 1 0;
    min-height: 0;
    scroll-margin-top: calc(72px + 140px);
  }
}

/* Zoomed-in / short desktop: shrink phone so the trio still fits. */
@media (min-width: 992px) and (max-height: 760px) {
  .llc-fbg.section {
    --llc-fbg-phone-max: 440px;
  }
}

@media (min-width: 992px) and (max-height: 640px) {
  .llc-fbg.section {
    --llc-fbg-phone-max: 360px;
  }
}

@media (max-width: 480px) {
  .llc-fbg-phone {
    width: min(300px, 86vw);
  }

  .llc-fbg-text {
    font-size: clamp(0.95rem, 3.8vw, 1.05rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .llc-fbg-tab {
    transition: none;
  }

  .llc-fbg-tab[aria-selected="true"] {
    transform: none;
  }

  .llc-fbg-copy-panel.llc-fbg-step-animate > .llc-fbg-copy,
  .llc-fbg-phone-variant.llc-fbg-step-animate .llc-fbg-phone-img {
    animation: none;
  }
}
