/* ==========================================================================
   Legal page: Dexel core look (same base as the homepage, css/pages/home.css).
   Black, white and green. Press Start 2P for headings, labels and numbers; Inter for the long read.
   3px borders, small corners, hard pixel shadows, stepped motion; all of it stops under reduced motion.
   The clauses keep their wording; only the dress changes. Page logic lives in js/pages/legal.js.
   ========================================================================== */

.lg-body {
  --lg-bg: #FFFFFF;
  --lg-ink: #0B0B0B;
  --lg-text: #333333;
  --lg-mute: #5C5C5C;
  --lg-line: #E4E4E4;
  --lg-card: #F6F6F4;
  --lg-edge: #0B0B0B;
  --lg-shadow: #0B0B0B;
  --lg-code: #ECECE8;
  --lg-green: var(--dx-green, #3FAE4F);
  --lg-green-text: var(--dx-green-text, #1F7A34);
  --lg-pixel: var(--font-pixel, 'Press Start 2P', ui-monospace, monospace);
  --lg-step: steps(3, end);
  background: var(--lg-bg);
  color: var(--lg-text);
  font-family: var(--font-sans);
  overflow-x: hidden;
}
[data-theme="dark"] .lg-body {
  --lg-bg: #0A0A0A;
  --lg-ink: #FFFFFF;
  --lg-text: #D2D2D2;
  --lg-mute: #A8A8A8;
  --lg-line: #222222;
  --lg-card: #121212;
  --lg-edge: #4A4A4A;
  --lg-shadow: #2A2A2A;
  --lg-code: #1E1E1E;
  --lg-green-text: var(--dx-green-text, #7ED67A);
}
.lg-body .nav-bar { background-color: var(--lg-bg); border-bottom-color: var(--lg-line); }
.lg-body .brand-logo, .lg-body .polar-footer-brand-logo { image-rendering: pixelated; border-radius: 4px; }

.legal-page-wrapper {
  position: relative;
  padding: 48px 0 72px;
}
.lg-body .legal-container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}
.legal-page-wrapper a:focus-visible,
.legal-page-wrapper button:focus-visible {
  outline: 3px solid var(--lg-green);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- header ------------------------------------------------------------------------------------------ */
.legal-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 3px solid var(--lg-line);
}
.lg-body .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--lg-mute);
  text-decoration: none;
}
.lg-body .back-link:hover { color: var(--lg-ink); }

.legal-title-row { margin: 24px 0 8px; }

.lg-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-family: var(--lg-pixel);
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--lg-green-text);
}
.lg-label img { width: 24px; height: 24px; image-rendering: pixelated; }

.lg-title {
  font-family: var(--lg-pixel);
  font-weight: 400;
  font-size: clamp(22px, 3.4vw, 36px);
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--lg-ink);
  margin: 0 0 16px;
  text-shadow: 3px 3px 0 var(--lg-line);
  text-wrap: balance;
}
.lg-lede {
  font-size: 17px;
  line-height: 1.65;
  color: var(--lg-text);
  max-width: 60ch;
  margin: 0;
}

/* Tabs: two chunky pixel buttons, the active one green and pressed in */
.legal-tab-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 24px;
}
.legal-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  font-family: var(--lg-pixel);
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--lg-ink);
  background: var(--lg-bg);
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--lg-shadow);
  cursor: pointer;
  transition: transform 120ms var(--lg-step), box-shadow 120ms var(--lg-step);
}
.legal-tab-btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--lg-shadow); }
.legal-tab-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--lg-shadow); }
.legal-tab-btn.active {
  background: var(--lg-green);
  color: var(--dx-on-green, #0B0B0B);
  border-color: var(--lg-ink);
  box-shadow: 4px 4px 0 #23803A;
}
[data-theme="dark"] .legal-tab-btn.active { border-color: var(--lg-green); }

/* Meta row */
.legal-meta-spec {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.legal-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--lg-card);
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
}
.legal-meta-lbl {
  font-family: var(--lg-pixel);
  font-size: 10px;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--lg-mute);
}
.legal-meta-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--lg-ink);
  overflow-wrap: anywhere;
}
.lg-body .inline-link {
  color: var(--lg-green-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}
.lg-body .inline-link:hover { text-decoration-style: dotted; }

/* --- layout: contents on the left, the long read on the right ------------------------------------ */
.legal-tab-pane { display: block; }
.legal-layout-split {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.legal-sidebar {
  position: sticky;
  top: 88px;
}
.legal-sidebar-sticky {
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 18px 14px 16px;
  background: var(--lg-card);
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
  box-shadow: 6px 6px 0 var(--lg-green);
  scrollbar-width: thin;
}
.legal-sidebar-title {
  display: block;
  margin: 0 4px 14px;
  font-family: var(--lg-pixel);
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--lg-ink);
}
.legal-nav-list { display: flex; flex-direction: column; gap: 2px; }
.legal-nav-link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px 8px 18px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--lg-text);
  text-decoration: none;
  border-radius: 2px;
}
.legal-nav-link::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  background: transparent;
}
.legal-nav-link:hover { color: var(--lg-ink); background: var(--lg-bg); }
.legal-nav-link.active { color: var(--lg-ink); font-weight: 600; background: var(--lg-bg); }
.legal-nav-link.active::before { background: var(--lg-green); box-shadow: 2px 2px 0 var(--lg-ink); }
.legal-nav-num {
  flex: 0 0 22px;
  font-family: var(--lg-pixel);
  font-size: 10px;
  color: var(--lg-mute);
}
.legal-nav-link.active .legal-nav-num { color: var(--lg-green-text); }

/* Reading meter: fills in four-pixel steps as you scroll */
.lg-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 4px 0;
  padding-top: 14px;
  border-top: 3px solid var(--lg-line);
}
.lg-progress-label {
  font-family: var(--lg-pixel);
  font-size: 10px;
  line-height: 1.5;
  color: var(--lg-mute);
}
.lg-progress-bar {
  display: block;
  height: 12px;
  border: 3px solid var(--lg-edge);
  background: var(--lg-bg);
}
.lg-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--lg-green);
  background-image: repeating-linear-gradient(90deg, transparent 0 8px, rgba(0, 0, 0, 0.18) 8px 10px);
}
.lg-progress.is-done .lg-progress-label { color: var(--lg-green-text); }

/* --- the long read --------------------------------------------------------------------------------- */
.legal-content-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

/* The short version box */
.lg-short {
  margin: 0 0 40px;
  padding: 22px 24px;
  background: var(--lg-card);
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
  box-shadow: 6px 6px 0 var(--dx-gold, #FFCC33);
}
.lg-short-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-family: var(--lg-pixel);
  font-size: 13px;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--lg-ink);
}
.lg-short-title img { width: 20px; height: 20px; image-rendering: pixelated; }
.lg-short-note { margin: 0 0 14px; font-size: 14px; color: var(--lg-mute); }
.lg-short-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lg-short-list li {
  position: relative;
  padding-left: 22px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--lg-text);
}
.lg-short-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 8px;
  background: var(--lg-green);
  box-shadow: 2px 2px 0 var(--lg-ink);
}
.lg-short-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--lg-green-text);
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-clause {
  padding: 36px 0 34px;
  border-top: 3px solid var(--lg-line);
  scroll-margin-top: 90px;
}
.lg-short + .legal-clause { border-top: 0; padding-top: 4px; }
.legal-clause-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.legal-clause-num {
  align-self: flex-start;
  padding: 6px 8px;
  font-family: var(--lg-pixel);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--dx-on-green, #0B0B0B);
  background: var(--lg-green);
  box-shadow: 3px 3px 0 var(--lg-ink);
}
[data-theme="dark"] .legal-clause-num { box-shadow: 3px 3px 0 #23803A; }
.legal-clause-header h2 {
  margin: 0;
  max-width: 40ch;
  font-family: var(--lg-pixel);
  font-weight: 400;
  font-size: clamp(14px, 1.45vw, 17px);
  line-height: 1.7;
  letter-spacing: 0;
  color: var(--lg-ink);
  text-wrap: balance;
}
.legal-clause-content { max-width: 70ch; }
.legal-clause-content p {
  font-size: 16px;
  line-height: 1.75;
  color: var(--lg-text);
  margin: 0 0 16px;
}
.legal-clause-content p:last-child { margin-bottom: 0; }
.legal-clause-content ul { list-style: none; margin: 12px 0 16px; padding: 0; }
.legal-clause-content li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--lg-text);
}
.legal-clause-content li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  background: var(--lg-mute);
}
.legal-clause-content strong { color: var(--lg-ink); font-weight: 600; }
.legal-clause-content code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 1px 6px;
  color: var(--lg-ink);
  background: var(--lg-code);
  border: 2px solid var(--lg-line);
  border-radius: 2px;
  overflow-wrap: anywhere;
}

/* Retention table */
.lg-table-wrap {
  margin: 18px 0 4px;
  overflow-x: auto;
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
}
.lg-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; text-align: left; }
.lg-table th {
  padding: 12px 14px;
  font-family: var(--lg-pixel);
  font-weight: 400;
  font-size: 10px;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--lg-ink);
  background: var(--lg-card);
  border-bottom: 3px solid var(--lg-edge);
}
.lg-table td {
  padding: 12px 14px;
  line-height: 1.55;
  color: var(--lg-text);
  vertical-align: top;
  border-bottom: 2px solid var(--lg-line);
}
.lg-table tr:last-child td { border-bottom: 0; }
.lg-table td:first-child { font-weight: 600; color: var(--lg-ink); }

/* --- easter egg: the very last full stop ----------------------------------------------------------- */
.lg-dot {
  position: relative;
  display: inline-block;
  cursor: default;
}
.lg-dot.is-found {
  color: var(--lg-green-text);
  animation: lg-hop 480ms steps(4, end) 2;
}
@keyframes lg-hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.lg-bubble {
  position: absolute;
  z-index: 40;
  max-width: min(280px, calc(100vw - 32px));
  padding: 12px 14px;
  font-family: var(--lg-pixel);
  font-size: 10px;
  line-height: 1.7;
  color: var(--lg-ink);
  background: var(--lg-bg);
  border: 3px solid var(--lg-edge);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--lg-green);
  animation: lg-pop 240ms steps(3, end);
}
@keyframes lg-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.lg-pixel-bit {
  position: absolute;
  z-index: 39;
  width: 6px;
  height: 6px;
  pointer-events: none;
  animation: lg-bit 700ms steps(6, end) forwards;
}
@keyframes lg-bit {
  from { transform: translate(0, 0); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

/* --- responsive ------------------------------------------------------------------------------------ */
@media (max-width: 960px) {
  .legal-meta-spec { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legal-layout-split { grid-template-columns: 1fr; gap: 28px; }
  .legal-sidebar { position: static; }
  .legal-sidebar-sticky { max-height: none; }
  .legal-nav-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; }
}

@media (max-width: 600px) {
  .legal-page-wrapper { padding: 28px 0 48px; }
  .lg-body .legal-container { padding: 0 16px; }
  .lg-lede { font-size: 16px; }
  .legal-tab-switcher { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .legal-tab-btn { padding: 0 8px; font-size: 10px; }
  .lg-body .legal-meta-spec { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .legal-meta-cell { padding: 12px; }
  .legal-meta-val { font-size: 14px; }
  .legal-nav-list { grid-template-columns: 1fr; }
  .legal-sidebar-sticky { box-shadow: 4px 4px 0 var(--lg-green); }
  .lg-short { padding: 18px 16px; box-shadow: 4px 4px 0 var(--dx-gold, #FFCC33); }
  .lg-short-list li, .legal-clause-content p, .legal-clause-content li { font-size: 15.5px; }
  .legal-clause { padding: 28px 0 26px; }
  .legal-clause-header h2 { font-size: 13px; line-height: 1.75; }
}

@media (prefers-reduced-motion: reduce) {
  .legal-tab-btn, .lg-dot.is-found, .lg-bubble, .lg-pixel-bit { transition: none; animation: none; }
  .legal-tab-btn:hover, .legal-tab-btn:active { transform: none; }
  .lg-pixel-bit { display: none; }
}
