/**
 * Legal pages — Terms & Conditions + Privacy Policy.
 *
 * Layout: sticky TOC on the left, sectioned content on the right.
 * Every section reads as a numbered card with a large gold index, and
 * the TOC highlights the section currently in view.
 *
 * IMPORTANT: content is never hidden behind a JS-gated opacity. The
 * entrance animation plays on page load via @keyframes, so the page
 * renders correctly even when JS fails or is disabled.
 */

/* =========================================================================
 * Page shell
 * ====================================================================== */

.bes-legal {
  background: var(--bes-white);
  position: relative;
}

.bes-legal__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: start;
}

@media (min-width: 1024px) {
  .bes-legal__layout {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 72px;
  }
}

/* =========================================================================
 * Table of contents
 * ====================================================================== */

.bes-legal__toc {
  position: relative;
  background: var(--bes-white);
  border: 1px solid var(--bes-border);
  padding: 24px 22px 22px;
  overflow: hidden;
  isolation: isolate;
}

@media (min-width: 1024px) {
  .bes-legal__toc {
    position: sticky;
    top: 110px;
  }
}

/* Gold top accent bar */
.bes-legal__toc::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--bes-gold), var(--bes-gold-600));
  z-index: 1;
}

/* Subtle gold glow in the corner */
.bes-legal__toc::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(234, 193, 23, 0.06),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.bes-legal__toc > * {
  position: relative;
  z-index: 2;
}

.bes-legal__toc-title {
  font-family: var(--bes-font-head);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bes-border);
  color: var(--bes-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.bes-legal__toc-title::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 2px;
  background: var(--bes-gold);
}

.bes-legal__toc-list {
  display: grid;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: none;
}

@media (min-width: 1024px) {
  .bes-legal__toc-list {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    padding-right: 6px;
  }
}

/* Custom scrollbar */
@media (min-width: 1024px) {
  .bes-legal__toc-list::-webkit-scrollbar {
    width: 6px;
  }

  .bes-legal__toc-list::-webkit-scrollbar-thumb {
    background: rgba(234, 193, 23, 0.35);
    border-radius: 0;
  }

  .bes-legal__toc-list::-webkit-scrollbar-thumb:hover {
    background: var(--bes-gold);
  }

  .bes-legal__toc-list::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* TOC links */
.bes-legal__toc-list li {
  list-style: none;
}

.bes-legal__toc-list a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 9px 18px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--bes-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color var(--bes-dur-fast) var(--bes-ease),
    background var(--bes-dur-fast) var(--bes-ease),
    border-color var(--bes-dur-fast) var(--bes-ease),
    padding-left var(--bes-dur-fast) var(--bes-ease);
}

/* Section number prefix on each link */
.bes-legal__toc-list a::before {
  content: attr(data-num);
  display: inline-block;
  min-width: 18px;
  font-family: var(--bes-font-head);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(109, 105, 104, 0.55);
  transition: color var(--bes-dur-fast) var(--bes-ease);
  flex-shrink: 0;
}

.bes-legal__toc-list a:hover {
  color: var(--bes-text);
  background: var(--bes-silver-50);
  border-left-color: var(--bes-gold);
  padding-left: 22px;
}

.bes-legal__toc-list a:hover::before {
  color: var(--bes-gold-600);
}

/* Active state — JS toggles .is-active as you scroll */
.bes-legal__toc-list a.is-active {
  color: var(--bes-black);
  background: linear-gradient(90deg, rgba(234, 193, 23, 0.1), transparent 85%);
  border-left-color: var(--bes-gold);
  font-weight: 600;
  padding-left: 22px;
}

.bes-legal__toc-list a.is-active::before {
  color: var(--bes-gold-600);
}

/* =========================================================================
 * Legal content — base typography
 * ====================================================================== */

.bes-legal__content {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--bes-text);
  max-width: 78ch;
  min-width: 0;
}

/* =========================================================================
 * Section — numbered card
 * ====================================================================== */

.bes-legal__section {
  position: relative;
  padding: 34px 32px 32px 92px;
  margin-bottom: 24px;
  background: var(--bes-white);
  border: 1px solid var(--bes-border);
  border-left: 3px solid transparent;
  overflow: hidden;
  isolation: isolate;
  scroll-margin-top: 110px;
  transition:
    border-left-color var(--bes-dur) var(--bes-ease),
    box-shadow var(--bes-dur) var(--bes-ease),
    background var(--bes-dur) var(--bes-ease);
}

.bes-legal__section:hover {
  border-left-color: var(--bes-gold);
  background: #fefefe;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

/* Faint gold wash in the top-right corner */
.bes-legal__section::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: linear-gradient(
    135deg,
    transparent 40%,
    rgba(234, 193, 23, 0.06) 100%
  );
  pointer-events: none;
  z-index: 0;
}

.bes-legal__section > * {
  position: relative;
  z-index: 1;
}

/* Big gold section number, absolutely positioned on the left */
.bes-legal__section-num {
  position: absolute;
  left: 28px;
  top: 30px;
  font-family: var(--bes-font-head);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--bes-gold);
  opacity: 0.9;
  transition:
    transform var(--bes-dur) var(--bes-ease),
    color var(--bes-dur) var(--bes-ease);
}

.bes-legal__section:hover .bes-legal__section-num {
  transform: translateY(-2px) scale(1.05);
  color: var(--bes-gold-600);
}

/* Thin gold rule under the number */
.bes-legal__section-num::after {
  content: "";
  display: block;
  width: 26px;
  height: 2px;
  background: var(--bes-gold);
  margin-top: 12px;
  opacity: 0.55;
  transition: width var(--bes-dur) var(--bes-ease);
}

.bes-legal__section:hover .bes-legal__section-num::after {
  width: 40px;
  opacity: 1;
}

/* Section heading */
.bes-legal__section h2 {
  display: block;
  font-family: var(--bes-font-head);
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--bes-text);
}

/* Body copy */
.bes-legal__section p {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--bes-text);
  margin: 0 0 14px;
}

.bes-legal__section p:last-child {
  margin-bottom: 0;
}

/* Gold highlighter under bold text */
.bes-legal__section p strong {
  font-weight: 600;
  color: var(--bes-black);
  background: linear-gradient(
    180deg,
    transparent 62%,
    rgba(234, 193, 23, 0.3) 62% 92%,
    transparent 92%
  );
  padding: 0 2px;
}

/* Subheading (h3) */
.bes-legal__section h3 {
  font-family: var(--bes-font-head);
  font-size: 1.125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 22px 0 10px;
  color: var(--bes-text);
}

/* Bullet lists */
.bes-legal__section ul {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.bes-legal__section ul li {
  position: relative;
  padding-left: 24px;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--bes-text);
}

.bes-legal__section ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 12px;
  height: 2px;
  background: var(--bes-gold);
}

/* Ordered lists */
.bes-legal__section ol {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
  counter-reset: bes-legal-ol;
}

.bes-legal__section ol li {
  position: relative;
  padding-left: 28px;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--bes-text);
  counter-increment: bes-legal-ol;
}

.bes-legal__section ol li::before {
  content: counter(bes-legal-ol, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--bes-font-head);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--bes-gold-600);
  letter-spacing: 0.04em;
}

/* Inline links */
.bes-legal__section a {
  color: var(--bes-text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--bes-gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color var(--bes-dur-fast) var(--bes-ease);
}

.bes-legal__section a:hover {
  color: var(--bes-gold-600);
  text-decoration-color: var(--bes-gold-600);
}

/* =========================================================================
 * Meta row (used by Privacy Policy at the top of the content column)
 * ====================================================================== */

.bes-legal__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--bes-border);
  font-size: 0.875rem;
  color: var(--bes-text-muted);
}

.bes-legal__updated {
  font-weight: 500;
}

.bes-legal__updated strong {
  color: var(--bes-text);
}

/* =========================================================================
 * Download button
 * ====================================================================== */

.bes-legal__download {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 12px 16px;
  min-height: 44px;
  font-family: var(--bes-font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bes-black);
  background: var(--bes-gold);
  overflow: hidden;
  isolation: isolate;
  transition:
    background var(--bes-dur-fast) var(--bes-ease),
    transform var(--bes-dur-fast) var(--bes-ease),
    box-shadow var(--bes-dur-fast) var(--bes-ease);
}

.bes-legal__download::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.42) 50%,
    transparent 100%
  );
  transform: skewX(-18deg);
  transition: left 700ms var(--bes-ease-out);
  pointer-events: none;
  z-index: 1;
}

.bes-legal__download:hover::before {
  left: 130%;
}

.bes-legal__download svg {
  position: relative;
  z-index: 2;
  width: 14px;
  height: 14px;
  transition: transform var(--bes-dur) var(--bes-ease);
}

.bes-legal__download:hover {
  background: var(--bes-gold-600);
  color: var(--bes-black);
  transform: translateY(-2px);
  box-shadow: var(--bes-glow-md);
}

.bes-legal__download:hover svg {
  transform: translateY(2px);
}

/* =========================================================================
 * Foot download block
 * ====================================================================== */

.bes-legal__foot-download {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--bes-border);
  font-size: 0.9375rem;
  color: var(--bes-text-muted);
}

@media (min-width: 640px) {
  .bes-legal__foot-download {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* =========================================================================
 * Entrance animation — pure CSS, plays on page paint.
 * Never gates visibility on JS. Reduced-motion users see sections instantly.
 * ====================================================================== */

@keyframes bes-legal-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bes-legal__content > .bes-legal__section {
  animation: bes-legal-in 520ms var(--bes-ease-out) both;
}

/* Small stagger for the first ten sections */
.bes-legal__content > .bes-legal__section:nth-child(1) {
  animation-delay: 30ms;
}
.bes-legal__content > .bes-legal__section:nth-child(2) {
  animation-delay: 70ms;
}
.bes-legal__content > .bes-legal__section:nth-child(3) {
  animation-delay: 110ms;
}
.bes-legal__content > .bes-legal__section:nth-child(4) {
  animation-delay: 150ms;
}
.bes-legal__content > .bes-legal__section:nth-child(5) {
  animation-delay: 190ms;
}
.bes-legal__content > .bes-legal__section:nth-child(6) {
  animation-delay: 230ms;
}
.bes-legal__content > .bes-legal__section:nth-child(7) {
  animation-delay: 270ms;
}
.bes-legal__content > .bes-legal__section:nth-child(8) {
  animation-delay: 310ms;
}
.bes-legal__content > .bes-legal__section:nth-child(9) {
  animation-delay: 350ms;
}
.bes-legal__content > .bes-legal__section:nth-child(10) {
  animation-delay: 390ms;
}
.bes-legal__content > .bes-legal__section:nth-child(n + 11) {
  animation-delay: 430ms;
}

/* =========================================================================
 * Reduced motion
 * ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  .bes-legal__content > .bes-legal__section {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .bes-legal__section,
  .bes-legal__toc-list a,
  .bes-legal__section-num,
  .bes-legal__section-num::after,
  .bes-legal__download,
  .bes-legal__download::before,
  .bes-legal__download svg {
    transition: none !important;
  }
}

/* =========================================================================
 * Responsive tweaks
 * ====================================================================== */

@media (max-width: 1023px) {
  /* TOC becomes a horizontal snap-scroll strip above the content */
  .bes-legal__toc {
    position: relative;
    margin-bottom: 24px;
  }

  .bes-legal__toc-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .bes-legal__toc-list li {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .bes-legal__toc-list a {
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 8px 14px;
    white-space: nowrap;
  }

  .bes-legal__toc-list a::before {
    display: none;
  }

  .bes-legal__toc-list a:hover,
  .bes-legal__toc-list a.is-active {
    padding-left: 14px;
    border-left-color: transparent;
    border-bottom-color: var(--bes-gold);
    background: rgba(234, 193, 23, 0.08);
  }
}

@media (max-width: 639px) {
  .bes-legal__section {
    padding: 28px 22px 24px 68px;
    margin-bottom: 16px;
  }

  .bes-legal__section-num {
    left: 22px;
    top: 26px;
    font-size: 1.75rem;
  }

  .bes-legal__section h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
  }

  .bes-legal__section p {
    font-size: 0.9375rem;
    line-height: 1.7;
  }
}

/* =========================================================================
 * Print stylesheet
 * ====================================================================== */

@media print {
  .bes-legal__toc,
  .bes-legal__download,
  .bes-legal__foot-download {
    display: none !important;
  }

  .bes-legal__layout {
    display: block;
  }

  .bes-legal__content > .bes-legal__section {
    animation: none !important;
  }

  .bes-legal__section {
    opacity: 1 !important;
    transform: none !important;
    border: 0;
    border-left: 2pt solid #000;
    padding: 0 0 12pt 12pt;
    margin: 0 0 16pt;
    box-shadow: none;
    page-break-inside: avoid;
    background: transparent;
  }

  .bes-legal__section-num {
    color: #000 !important;
    position: relative;
    left: 0;
    top: 0;
    display: inline-block;
    font-size: 1.2rem;
    margin-bottom: 4pt;
  }

  .bes-legal__section-num::after {
    background: #000;
  }

  .bes-legal__section h2 {
    color: #000 !important;
    font-size: 12pt !important;
    text-transform: none !important;
  }

  .bes-legal__section p,
  .bes-legal__section li {
    font-size: 10.5pt;
    line-height: 1.5;
    color: #000 !important;
  }
}
