/* =========================================================
   SRILEX BUDITRA — LEGAL PAGES
   Responsive / Mobile-first refinement
   Privacy • Terms • Security
   ========================================================= */

.legal-page {
  position: relative;
  isolation: isolate;
  overflow: visible;
  background: transparent;
  color: var(--text, #f5f5f5);
}

.legal-container,
.legal-layout {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.legal-hero {
  position: relative;
  padding: clamp(112px, 14vw, 150px) 0 clamp(64px, 8vw, 90px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
}

.legal-hero::before {
  content: "";
  position: absolute;
  width: min(500px, 80vw);
  aspect-ratio: 1;
  top: -260px;
  right: -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34,197,238,.14), transparent 68%);
  pointer-events: none;
}

.legal-hero::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 180px;
  left: -140px;
  bottom: -120px;
  border-radius: 50%;
  background: rgba(255,181,27,.07);
  filter: blur(45px);
  pointer-events: none;
}

.legal-back {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(30px, 5vw, 45px);
  color: inherit;
  text-decoration: none;
  font-size: .9rem;
  opacity: .72;
  transition: opacity .25s ease, transform .25s ease;
}

.legal-back:hover,
.legal-back:focus-visible { opacity: 1; transform: translateX(-4px); }

.legal-eyebrow {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 7px 10px;
  border: 1px solid rgba(55,100,126,.75);
  border-radius: 999px;
  background: rgba(8,34,56,.62);
  color: var(--gold, #ffb51b);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
}

.legal-hero h1 {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0;
  font-size: clamp(2.75rem, 8vw, 6.5rem);
  line-height: .94;
  letter-spacing: -.055em;
  text-wrap: balance;
}

.legal-hero h1 span { color: var(--gold, #ffb51b); opacity: .72; }

.legal-intro {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 28px 0 0;
  color: #bdcede;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.75;
}

.legal-meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 34px;
  font-size: .68rem;
  letter-spacing: .08em;
}

.legal-meta span { color: #8ca6b9; }
.legal-meta strong { color: #dce8f1; font-weight: 700; }

.legal-content-section { padding: clamp(58px, 8vw, 90px) 0 110px; }

.legal-layout {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: clamp(38px, 7vw, 90px);
  align-items: start;
}

.legal-sidebar {
  min-width: 0;
  align-self: start;
  position: sticky;
  top: 94px;
  z-index: 5;
}


.legal-toc {
  position: relative;
  top: auto;
  padding: 24px;
  border: 1px solid rgba(31,91,123,.65);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(6,36,58,.9), rgba(3,24,40,.86));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 18px 50px rgba(0,0,0,.18);
  backdrop-filter: blur(16px);
}

.toc-label {
  display: block;
  margin-bottom: 14px;
  color: #8ba5b7;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.legal-toc nav { display: flex; flex-direction: column; gap: 2px; }

.legal-toc a {
  position: relative;
  display: block;
  min-width: 0;
  padding: 9px 8px 9px 14px;
  border-radius: 9px;
  color: #93a9b9;
  text-decoration: none;
  font-size: .83rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  transition: color .2s ease, background .2s ease, padding-left .2s ease;
}

.legal-toc a::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 2px;
  height: 0;
  border-radius: 2px;
  background: var(--gold, #ffb51b);
  transform: translateY(-50%);
  transition: height .2s ease;
}

.legal-toc a:hover,
.legal-toc a:focus-visible,
.legal-toc a:target {
  color: #f4f9fc;
  background: rgba(34,197,238,.07);
  padding-left: 17px;
}

.legal-toc a:hover::before,
.legal-toc a:focus-visible::before { height: 20px; }

.legal-article { min-width: 0; max-width: 820px; }

.legal-block {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 24px;
  min-width: 0;
  padding: 0 0 58px;
  margin: 0 0 58px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  scroll-margin-top: 100px;
}

.legal-number {
  padding-top: 8px;
  color: #6e8799;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.legal-block > div:last-child { min-width: 0; }

.legal-block h2 {
  margin: 0 0 20px;
  color: #f7fbff;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.12;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.legal-block h3 {
  margin: 0 0 14px;
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  line-height: 1.35;
}

.legal-block p {
  max-width: 780px;
  margin: 0 0 18px;
  color: #b8cbd8;
  font-size: .98rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

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

.legal-list li {
  position: relative;
  padding: 12px 0 12px 25px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: #b8cbd8;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.legal-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--gold, #ffb51b);
  opacity: .9;
}

.legal-note,
.legal-highlight,
.legal-contact-card {
  border: 1px solid rgba(42,100,132,.62);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(7,43,69,.58), rgba(3,25,42,.62));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}

.legal-note {
  margin-top: 28px;
  padding: 20px 22px;
  border-left: 2px solid var(--gold, #ffb51b);
  line-height: 1.75;
  color: #c9d8e3;
}

.legal-note strong { display: block; margin-bottom: 6px; color: #f5f9fc; }

.legal-highlight {
  position: relative;
  margin-top: 30px;
  padding: 28px;
  overflow: hidden;
}

.legal-highlight::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -130px;
  bottom: -150px;
  border-radius: 50%;
  background: rgba(34,197,238,.08);
}

.legal-highlight > * { position: relative; z-index: 1; }
.legal-highlight span,
.legal-contact-card > span {
  display: block;
  margin-bottom: 14px;
  color: #8ba5b7;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .15em;
}

.legal-link {
  display: inline-flex;
  max-width: 100%;
  margin-top: 8px;
  padding: 4px 0;
  color: var(--gold, #ffb51b);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  overflow-wrap: anywhere;
  transition: opacity .2s ease, transform .2s ease;
}

.legal-link:hover,
.legal-link:focus-visible { opacity: 1; transform: translateX(4px); }

.legal-contact-card {
  margin-top: 30px;
  padding: clamp(22px, 4vw, 38px);
}

.legal-contact-card h3 { font-size: clamp(1.35rem, 3vw, 2rem); }
.legal-contact-card a { display: inline-flex; margin-top: 10px; color: var(--gold, #ffb51b); font-weight: 700; overflow-wrap: anywhere; }

.legal-closing { padding: 64px 0 10px; }
.legal-closing > span {
  display: block;
  margin-bottom: 16px;
  color: #6f899b;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
}
.legal-closing h2 {
  max-width: 800px;
  margin: 0 0 18px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: .98;
  letter-spacing: -.05em;
  text-wrap: balance;
}
.legal-closing p { max-width: 620px; margin: 0; color: #8fa7b8; line-height: 1.8; }

/* =========================================================
   DESKTOP STICKY TOC V2 — audited
   The sidebar remains in the document flow and sticks to the
   viewport while the legal article continues scrolling.
   ========================================================= */
@media (min-width: 901px) {
  .legal-page,
  .legal-content-section,
  .legal-layout,
  .legal-article {
    overflow: visible !important;
    min-width: 0;
  }

  .legal-layout {
    position: relative;
    align-items: start;
  }

  .legal-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 94px !important;
    align-self: start !important;
    width: 100%;
    min-width: 0;
    height: fit-content;
    max-height: calc(100vh - 114px);
    overflow: visible !important;
    z-index: 20;
  }

  .legal-toc {
    position: relative !important;
    top: auto !important;
    width: 100%;
    max-height: calc(100vh - 114px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .legal-article {
    width: 100%;
    max-width: 820px;
  }
}

@media (max-width: 900px) {
  .legal-layout {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .legal-article { max-width: none; }

  .legal-sidebar {
    position: relative;
    top: auto;
    z-index: auto;
  }

  .legal-toc {
    position: relative;
    top: auto;
    padding: 20px;
  }

  .legal-toc nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 14px;
  }
}

/* Mobile: single-column, no horizontal overflow, touch-friendly navigation. */
@media (max-width: 640px) {
  .legal-container,
  .legal-layout { width: min(calc(100% - 24px), 1180px); }

  .legal-hero { padding: 102px 0 54px; }
  .legal-back { margin-bottom: 28px; font-size: .82rem; }
  .legal-eyebrow { font-size: .6rem; }
  .legal-hero h1 { font-size: clamp(2.6rem, 13vw, 4.1rem); }
  .legal-intro { margin-top: 22px; font-size: .96rem; line-height: 1.72; }

  .legal-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
    margin-top: 26px;
  }

  .legal-content-section { padding: 44px 0 76px; }

  .legal-toc {
    padding: 18px;
    border-radius: 16px;
  }

  .toc-label { margin-bottom: 11px; }

  .legal-toc nav {
    grid-template-columns: 1fr;
    max-height: 310px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-right: 3px;
  }

  .legal-toc a {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 14px;
    font-size: .79rem;
  }

  .legal-layout { gap: 28px; }

  .legal-block {
    grid-template-columns: 1fr;
    gap: 9px;
    padding-bottom: 42px;
    margin-bottom: 42px;
    scroll-margin-top: 84px;
  }

  .legal-number {
    padding-top: 0;
    color: var(--gold, #ffb51b);
    font-size: .68rem;
  }

  .legal-block h2 {
    margin-bottom: 15px;
    font-size: clamp(1.55rem, 8vw, 2rem);
  }

  .legal-block p { font-size: .91rem; line-height: 1.78; }
  .legal-list li { font-size: .9rem; }
  .legal-note,
  .legal-highlight,
  .legal-contact-card { border-radius: 15px; }
  .legal-note { padding: 17px 18px; }
  .legal-highlight { padding: 21px; }
  .legal-contact-card { padding: 21px; }
  .legal-closing { padding-top: 48px; }
  .legal-closing h2 { font-size: clamp(2rem, 11vw, 3.3rem); }
}

/* Very small phones */
@media (max-width: 380px) {
  .legal-container,
  .legal-layout { width: calc(100% - 20px); }
  .legal-hero h1 { font-size: 2.45rem; }
  .legal-toc { padding: 15px; }
  .legal-block p,
  .legal-list li { font-size: .88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .legal-back,
  .legal-toc a,
  .legal-link { transition: none; }
}

/* =========================================================
   MOBILE BOUNDARY GUARD V2
   ========================================================= */
@media (max-width: 900px) {
  .legal-page,
  .legal-hero,
  .legal-content-section,
  .legal-container,
  .legal-layout,
  .legal-sidebar,
  .legal-toc,
  .legal-article,
  .legal-block {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .legal-container,
  .legal-layout {
    width: calc(100% - 24px);
  }

  .legal-toc,
  .legal-toc nav {
    min-width: 0;
    max-width: 100%;
  }

  .legal-toc a,
  .legal-block p,
  .legal-list li,
  .legal-note,
  .legal-highlight,
  .legal-contact-card,
  .legal-link {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .legal-highlight,
  .legal-contact-card,
  .legal-note {
    overflow: hidden;
  }

  .legal-block > div:last-child {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  .legal-container,
  .legal-layout {
    width: calc(100% - 20px);
  }
}

/* =========================================================
   DESKTOP STICKY TOC V4 — viewport scroll-container fix
   The global site stylesheet sets body overflow-x:hidden.
   On desktop that can make body an overflow container and
   interfere with viewport-based sticky positioning.
   clip prevents horizontal overflow without creating a
   scroll container, while leaving vertical page scrolling
   on the document viewport.
   ========================================================= */
@media (min-width: 901px) {
  html,
  body {
    overflow-x: clip !important;
    overflow-y: visible !important;
  }

  .legal-page,
  .legal-content-section,
  .legal-layout,
  .legal-sidebar,
  .legal-article {
    overflow-x: visible !important;
  }

  .legal-layout {
    display: grid;
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    align-items: start;
  }

  .legal-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 94px !important;
    align-self: start !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    z-index: 20;
  }

  .legal-toc {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-height: calc(100vh - 114px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* Keep the already-correct mobile behavior untouched. */
@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }
}
