/* ==========================================================================
   CubeWard legal pages — shared shell
   Used by: /legal/terms/, /legal/delete-account/,
            /legal/privacy/android/, /legal/privacy/ios/

   Usage
   -----
   1) <link rel="stylesheet" href="/assets/legal.css">  (no other stylesheet needed)
   2) <header class="topbar"><div class="shell nav"> brand + .navlinks </div></header>
   3) <main class="shell"> <article class="doc"> …content… </article>
      <div class="site-foot"> … </div> </main>

   Header and document share the same .shell width (920px on desktop) so the
   header is never wider than the card below it.
   ========================================================================== */

:root {
  --bg: #0b120e;
  --panel: rgba(25, 40, 29, .84);
  --panel-strong: rgba(22, 35, 26, .96);
  --line: rgba(232, 216, 169, .15);
  --line-strong: rgba(232, 216, 169, .26);
  --text: #f5f0e4;
  --body-text: #d3dcd1;
  --muted: #98a397;
  --gold: #e4ca7f;
  --gold-2: #bb9651;
  --green: #91b77f;
  --radius: 24px;
  --shadow: 0 28px 80px rgba(0,0,0,.36);
  --shell: 920px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  background:
    radial-gradient(950px 520px at 12% -5%, rgba(104, 145, 91, .24), transparent 61%),
    radial-gradient(760px 460px at 93% 11%, rgba(187, 150, 81, .14), transparent 63%),
    linear-gradient(180deg, #101b14 0%, var(--bg) 52%, #080d0a 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .2;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}

a { color: var(--gold); text-decoration-color: rgba(228,202,127,.42); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }

/* One width for header, document and page footer */
.shell { width: min(var(--shell), calc(100% - 36px)); margin-left: auto; margin-right: auto; }

/* ---------- Top bar ---------- */
.topbar {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid rgba(232,216,169,.10);
  background: rgba(8, 13, 10, .74);
  backdrop-filter: blur(18px) saturate(130%);
}
.nav {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; min-width: 0; }
.brand img {
  display: block;
  width: auto;
  height: 55px;
  max-width: min(320px, 52vw);
  object-fit: contain;
  object-position: left center;
}
.navlinks {
  --nav-gap: 16px;
  display: flex;
  align-items: center;
  gap: var(--nav-gap);
  margin-left: auto;
  font-size: 14px;
  color: #d8dfd6;
  white-space: nowrap;
}
.navlinks a {
  text-decoration: none;
  opacity: .78;
  transition: opacity .18s ease;
}
.navlinks a:hover { opacity: 1; }
/* Hairline between adjacent links: Support | Terms of Service | Delete Account */
.navlinks a + a {
  border-left: 1px solid rgba(232,216,169,.22);
  padding-left: var(--nav-gap);
}

/* ---------- Document ---------- */
.doc {
  width: 100%;
  margin: 34px auto 0;
  padding: 52px 56px 40px;
  /* Long bare URLs (privacy policy) must wrap instead of pushing the page wide */
  overflow-wrap: break-word;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    radial-gradient(700px 320px at 88% -8%, rgba(228,202,127,.07), transparent 62%),
    var(--panel-strong);
  box-shadow: var(--shadow);
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(228,202,127,.28);
  background: rgba(13,20,15,.58);
  color: #eedca5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.kicker .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(145,183,127,.11);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.4vw, 35px);
  line-height: 1.18;
  letter-spacing: -.025em;
  color: #f7f2e6;
}
.subtitle {
  margin: 0 0 20px;
  font-size: clamp(17px, 1.9vw, 20px);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -.01em;
}
.meta {
  margin: 0 0 30px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}
.meta strong { color: #d7dfd5; font-weight: 600; }

h2 {
  margin: 2.6rem 0 .9rem;
  font-size: clamp(19px, 2vw, 22px);
  line-height: 1.35;
  letter-spacing: -.012em;
  color: #f0dca1;
}
h2:first-of-type { margin-top: 0; }
h3 {
  margin: 1.7rem 0 .5rem;
  font-size: 16px;
  letter-spacing: .01em;
  color: #e6e0d0;
}
p { margin: 0 0 1.05rem; color: var(--body-text); }
ul, ol { margin: 0 0 1.15rem; padding-left: 1.35rem; color: var(--body-text); }
li { margin-bottom: .45rem; }
li:last-child { margin-bottom: 0; }
strong { color: #f1ebda; font-weight: 700; }
em { color: #e8e2d2; }

.notice {
  margin: 0 0 1.4rem;
  padding: 18px 22px;
  border-left: 3px solid var(--gold-2);
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}
.notice h3 { margin-top: 0; color: #f2e3b6; }
.notice p { margin: 0; color: #ddd7c6; font-size: 15px; }
.notice p + p { margin-top: .7rem; }
.notice ol, .notice ul { margin-bottom: 0; }
.notice li { color: #ddd7c6; }

/* Small platform tag, e.g. Android / iOS */
.plat {
  display: inline-block;
  vertical-align: middle;
  padding: 1px 8px;
  margin: 0 2px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #c3ccbf;
  white-space: nowrap;
}

address {
  font-style: normal;
  margin: 0 0 1.2rem;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.022);
  color: var(--body-text);
  line-height: 2;
}
address strong { color: var(--gold); }

/* Legacy in-document footer line */
.doc > footer {
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Document footer with the three legal links ---------- */
.doc-foot {
  margin-top: 3.2rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--line);
}
.doc-foot-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.legal-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.legal-links li { margin: 0; }
.lk-card {
  display: block;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.022);
  color: #eee6d2;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
a.lk-card { text-decoration: none; }
.lk-card:hover {
  border-color: rgba(228,202,127,.42);
  background: rgba(228,202,127,.06);
  transform: translateY(-2px);
}
.lk-label {
  display: block;
  margin-bottom: 3px;
  font-weight: 700;
  color: #f4eeda;
}
.lk-sub { display: block; color: var(--muted); font-size: 12.5px; }
.lk-sub a { color: #d9d3c2; text-decoration-color: rgba(228,202,127,.34); }
.lk-sub a:hover { color: var(--gold); }
.lk-sub a[aria-current="page"] { color: var(--gold); font-weight: 700; }
.lk-sub .sep { color: rgba(228,202,127,.4); }
.lk-card[aria-current="page"] {
  border-color: rgba(228,202,127,.42);
  background: rgba(228,202,127,.07);
}
.lk-card[aria-current="page"] .lk-label { color: var(--gold); }

/* ---------- Page footer ---------- */
.site-foot {
  padding: 26px 0 54px;
  color: #8f9a91;
  font-size: 13px;
  line-height: 1.7;
}
.site-foot .foot {
  display: flex;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
}
.foot-brand, .foot-meta { min-width: 0; }
/* Side-by-side layout: the right-hand block hugs the right edge */
.foot-meta { text-align: right; }
.foot-copy { margin: 0 0 6px; }
/* "All rights reserved." gets its own line on phones, stays inline on desktop */
.copy-2 { display: inline; }

/* Footer links wrap in two deliberate groups, never mid-item:
     Privacy iOS · Privacy Android
     Delete Account · Terms of Service                                    */
.foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  column-gap: 10px;
  row-gap: 2px;
  margin: 0;
}
.fl-g {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
/* Divider between the two groups. Absolutely positioned so it never affects
   the wrap decision, and removed below the width where the groups stack —
   that way no line ever starts or ends with a stray dot.                    */
.fl-g + .fl-g { position: relative; }
.fl-g + .fl-g::before {
  content: "\00b7";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  color: rgba(228,202,127,.38);
}
@media (max-width: 403px) {
  .fl-g + .fl-g::before { content: none; }
}
.foot-links .sep { color: rgba(228,202,127,.38); }
.site-foot a { color: #b1bab0; text-decoration: none; }
.site-foot a:hover { color: var(--gold); }

/* Once the two footer blocks stack, keep exactly one empty line between each
   block, and break the copyright before "All rights reserved.".             */
@media (max-width: 733px) {
  .site-foot .foot { flex-direction: column; row-gap: 1.7em; }
  /* Stacked layout reads from the left, like the phones expect */
  .foot-meta { text-align: left; }
  .foot-links { justify-content: flex-start; }
  .foot-copy { margin-bottom: 1.7em; }
}
@media (max-width: 460px) {
  .copy-2 { display: block; }
}

/* ---------- Back-to-top button (shown once the page is scrolled) ---------- */
.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(228,202,127,.34);
  border-radius: 50%;
  background: rgba(13,20,15,.74);
  backdrop-filter: blur(10px) saturate(120%);
  color: #f0dca1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(.94);
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(0,0,0,.42);
  transition: opacity .22s ease, transform .22s ease, border-color .18s ease, background .18s ease;
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: rgba(228,202,127,.62); background: rgba(20,30,23,.92); }
.to-top:focus-visible { outline: 2px solid rgba(228,202,127,.7); outline-offset: 3px; }
.to-top svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  .shell { width: min(var(--shell), calc(100% - 22px)); }
  .doc { padding: 34px 24px 28px; margin-top: 20px; border-radius: 20px; }
  .legal-links { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { position: static; }
  /* Leave room for the floating back-to-top button at the end of the page */
  .site-foot { padding-bottom: 78px; }
  .nav {
    min-height: 0;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 0 12px;
  }
  .brand img { height: 38px; max-width: 44vw; }
  .navlinks {
    --nav-gap: 12px;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    margin-left: 0;
    flex-wrap: wrap;
    row-gap: 8px;
    font-size: 13px;
    white-space: normal;
  }
}

@media (max-width: 430px) {
  .doc { padding: 26px 18px 24px; border-radius: 16px; }
  .navlinks { font-size: 12.5px; gap: 8px 12px; }
  .notice { padding: 16px 16px; }
  address { padding: 16px 16px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .to-top { transition: none; transform: none; }
  .lk-card { transition: none; }
  .lk-card:hover { transform: none; }
}

/* ---------- Print (used by reviewers when saving a policy) ---------- */
@media print {
  body { background: #fff; color: #000; }
  body::before, .topbar, .site-foot, .to-top { display: none; }
  .doc {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    background: #fff;
  }
  h1, h2, h3, p, li, strong, em, address, .subtitle, .meta { color: #000 !important; }
  .notice { border-left-color: #000; background: none; }
  a { color: #000; text-decoration: underline; }
}
