/* Foldnex Legal Presentation — Authentic Teslatlas Light Apple System */
:root {
  color-scheme: light;
  --black: #151c2c;
  --white: #fafaf8;
  --grey: #f0f2f6;
  --border: 1px solid #dfe3e9;
  --blue: #4059e8;
  --muted: #606a7b;
}

html:has(.foldnex-legal-page),
body:has(.foldnex-legal-page) {
  background: var(--white) !important;
  color: var(--black) !important;
}

body:has(.foldnex-legal-page) #main-content,
html[data-daylight-text] #main-content:has(.foldnex-legal-page) {
  background: transparent !important;
  background-color: transparent !important;
  padding-top: 0 !important;
}

body:has(.foldnex-legal-page) .site-navbar,
body:has(.foldnex-legal-page) .site-day-night-button,
body:has(.foldnex-legal-page) .world-pilot,
body:has(.foldnex-legal-page) #bg,
body:has(.foldnex-legal-page) .hero-starfield,
body:has(.foldnex-legal-page) .wave-canvas,
body:has(.foldnex-legal-page) .wave-scrim,
body:has(.foldnex-legal-page) canvas {
  display: none !important;
}

/* ==========================================================================
   DAYLIGHT ISOLATION & HIGH-SPECIFICITY OVERRIDES
   ========================================================================== */

html[data-daylight-text] #main-content .foldnex-legal-page {
  background: var(--white) !important;
  color: var(--black) !important;
}

/* Legal Headings — Main title & sticky section h2 titles */
html[data-daylight-text] #main-content .foldnex-legal-page h1,
html[data-daylight-text] #main-content .foldnex-legal-page .legal-section > h2,
html[data-daylight-text] #main-content .foldnex-legal-page :is(h1, h2, h3, h4, h5, h6):not(.highlight *) {
  color: var(--black) !important;
  -webkit-text-fill-color: var(--black) !important;
  background-image: none !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .meta {
  color: var(--muted) !important;
  -webkit-text-fill-color: var(--muted) !important;
}

/* Dark Highlight Banner */
html[data-daylight-text] #main-content .foldnex-legal-page .highlight {
  background: #111b32 !important;
  border-bottom-color: #dfe3e9 !important;
  color: #ffffff !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .highlight p {
  color: #e5e5e5 !important;
  -webkit-text-fill-color: #e5e5e5 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .highlight strong {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Header & Nav */
html[data-daylight-text] #main-content .foldnex-legal-page .legal-top {
  background: transparent !important;
  border-color: #dfe3e9 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .legal-brand {
  color: var(--black) !important;
  -webkit-text-fill-color: var(--black) !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .legal-nav a {
  color: #4b5563 !important;
  -webkit-text-fill-color: #4b5563 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .legal-nav a:hover,
html[data-daylight-text] #main-content .foldnex-legal-page .legal-nav a[aria-current="page"] {
  color: var(--blue) !important;
  -webkit-text-fill-color: var(--blue) !important;
}

/* Section Body & Elements */
html[data-daylight-text] #main-content .foldnex-legal-page .legal-section {
  border-color: #dfe3e9 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page :where(.legal-section, div, article) :where(p, li, td, th) {
  color: var(--black) !important;
  -webkit-text-fill-color: var(--black) !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page th {
  background: var(--grey) !important;
  color: var(--black) !important;
  -webkit-text-fill-color: var(--black) !important;
  border-color: #dfe3e9 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page td {
  border-color: #dfe3e9 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page code {
  background: var(--grey) !important;
  color: var(--black) !important;
  -webkit-text-fill-color: var(--black) !important;
  border-color: #dfe3e9 !important;
}

/* Footer */
html[data-daylight-text] #main-content .foldnex-legal-page .footer {
  background: var(--grey) !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .footer p,
html[data-daylight-text] #main-content .foldnex-legal-page .legal-links a {
  color: #4b5563 !important;
  -webkit-text-fill-color: #4b5563 !important;
}

html[data-daylight-text] #main-content .foldnex-legal-page .legal-links a:hover {
  color: var(--blue) !important;
  -webkit-text-fill-color: var(--blue) !important;
}

/* ==========================================================================
   PAGE COMPONENT LAYOUT
   ========================================================================== */

.foldnex-legal-page {
  position: relative;
  z-index: 20;
  min-height: 100vh;
  background: var(--white) !important;
  background-color: #fafaf8 !important;
  color: var(--black) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.foldnex-legal-page * {
  box-sizing: border-box;
}

.foldnex-legal-page a {
  color: inherit;
}

.foldnex-legal-page a:hover {
  color: var(--blue);
}

/* Header is STATIC and TRANSPARENT (matches Teslatlas app-legal-v6.css) */
.foldnex-legal-page .legal-top {
  position: static;
  max-width: 1280px;
  margin: auto;
  padding-inline: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 5rem;
  background: transparent;
  border-bottom: var(--border);
}

.foldnex-legal-page .legal-brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  font-size: 1.15rem;
  font-weight: 650;
  text-decoration: none;
  color: var(--black);
}

.foldnex-legal-page .legal-brand img {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  object-fit: contain;
}

.foldnex-legal-page .legal-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: .88rem;
  font-weight: 650;
}

.foldnex-legal-page .legal-nav a {
  color: #4b5563;
  text-decoration: none;
  transition: color 150ms;
}

.foldnex-legal-page .legal-nav a:hover {
  color: var(--blue);
}

.foldnex-legal-page .legal-nav a[aria-current="page"] {
  color: var(--blue);
  font-weight: 700;
}

/* Title Section is 100% wide with calc centering (matches Teslatlas) */
.foldnex-legal-page .legal-title {
  min-height: auto;
  padding: 64px max(24px, calc((100vw - 1120px) / 2)) 48px;
  border-bottom: var(--border);
}

.foldnex-legal-page h1 {
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 1.03;
  font-weight: 700;
  letter-spacing: -.045em;
  color: var(--black);
  margin: 0;
}

.foldnex-legal-page .meta {
  margin-top: 20px;
  font-size: .92rem;
  font-weight: 500;
  color: var(--muted);
}

/* Highlight Banner: 32px padding, bottom border only */
.foldnex-legal-page .highlight {
  background: #111b32;
  color: #fff;
  padding: 32px max(24px, calc((100vw - 1120px) / 2));
  border-bottom: var(--border);
}

.foldnex-legal-page .highlight p {
  max-width: 1120px;
  font-size: .93rem;
  line-height: 1.65;
  color: #e5e5e5;
  margin: 0;
}

.foldnex-legal-page .highlight strong {
  color: #fff;
  font-weight: 700;
}

/* Legal Section: max-width 1200px, fixed padding 40px (NO calc! Yields 1120px content) */
.foldnex-legal-page .legal-section {
  display: grid;
  grid-template-columns: minmax(12rem, .55fr) minmax(0, 1.45fr);
  column-gap: 56px;
  max-width: 1200px;
  margin: auto;
  padding: 40px;
  border-bottom: var(--border);
}

.foldnex-legal-page .legal-section > h2 {
  grid-column: 1;
  grid-row: 1 / span 20;
  align-self: start;
  position: sticky;
  top: 32px;
  font-size: 1.4rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -.025em;
  color: var(--black);
  margin: 0;
}

.foldnex-legal-page .legal-section > :not(h2) {
  grid-column: 2;
}

.foldnex-legal-page .legal-section p,
.foldnex-legal-page .legal-section li,
.foldnex-legal-page .legal-section td,
.foldnex-legal-page .legal-section th {
  font-size: .96rem;
  line-height: 1.72;
  color: var(--black);
  margin: 0;
}

.foldnex-legal-page .legal-section p + p {
  margin-top: 0.85rem;
}

.foldnex-legal-page .legal-section a {
  text-underline-offset: 3px;
}

.foldnex-legal-page .legal-section ul {
  margin: 0.8rem 0 0;
  padding-left: 1.25rem;
}

.foldnex-legal-page .legal-section li + li {
  margin-top: 0.35rem;
}

.foldnex-legal-page .legal-section code {
  background: var(--grey);
  border: 1px solid #dfe3e9;
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .88rem;
}

.foldnex-legal-page .table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.foldnex-legal-page table {
  width: 100%;
  border-collapse: collapse;
  min-width: 32rem;
}

.foldnex-legal-page th,
.foldnex-legal-page td {
  border: var(--border);
  padding: .75rem 1rem;
  text-align: left;
  vertical-align: top;
}

.foldnex-legal-page th {
  background: var(--grey);
  font-weight: 650;
}

/* Footer: Full-width light grey band */
.foldnex-legal-page .footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 32px 40px;
  background: var(--grey);
}

.foldnex-legal-page .legal-links {
  display: inline-flex;
  gap: 1.5rem;
  font-size: .86rem;
  font-weight: 650;
}

.foldnex-legal-page .made-by {
  font-size: .86rem;
  color: var(--muted);
}

/* Mobile Responsiveness (matches Teslatlas @media (max-width: 760px)) */
@media (max-width: 760px) {
  .foldnex-legal-page .legal-top {
    padding: 20px 24px;
    gap: 16px;
    min-height: auto;
  }
  .foldnex-legal-page .legal-title {
    padding-block: 42px 35px;
    padding-inline: 24px;
  }
  .foldnex-legal-page .highlight {
    padding: 28px 24px;
  }
  .foldnex-legal-page .legal-section {
    display: block;
    padding: 32px 24px;
  }
  .foldnex-legal-page .legal-section > h2 {
    position: static;
    margin-bottom: 20px;
  }
  .foldnex-legal-page .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 28px 24px;
  }
}
