/* ============================================================
   CityFrame — legal pages (terms.html, privacy.html)
   Token set and brand device mirror index.html.
   Verified contrast vs --bg #0C0D0D: fg 17.4:1 · muted 8.2:1
   faint 6.1:1 · amber 11.0:1. All text clears WCAG AA.
   ============================================================ */
:root {
  --bg: #0c0d0d;
  --bg-raise: #141616;
  --bg-raise-2: #1b1e1d;
  --fg: #f4f2ed;
  --muted: #a4a9a6;
  --faint: #8b918e;
  --line: rgba(244, 242, 237, 0.13);
  --line-strong: rgba(244, 242, 237, 0.26);
  --amber: #f4b860;
  --coral: #f07a62;
  --teal: #5cbfb3;
  --ink: #0c0d0d;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  --radius: 10px;
  --radius-lg: 16px;
  --gutter: clamp(20px, 4vw, 40px);
  --maxw: 1200px;
  --measure: 68ch;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

::selection {
  background: var(--amber);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 100;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  background: var(--amber);
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus-visible {
  top: var(--s-4);
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--fg);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
}

.brand-mark::before {
  top: 0;
  left: 0;
  border-right: 0;
  border-bottom: 0;
}

.brand-mark::after {
  right: 0;
  bottom: 0;
  border-left: 0;
  border-top: 0;
}

.brand-dot {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--amber);
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(12, 13, 13, 0.78);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  height: 68px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--fg);
}

/* ---------- Legal document ---------- */
.legal {
  padding-block: clamp(48px, 7vw, 88px) clamp(64px, 9vw, 112px);
}

.legal-head {
  max-width: var(--measure);
  margin-bottom: var(--s-7);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-4);
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.legal-head h1 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.03;
  letter-spacing: -0.032em;
  font-weight: 800;
  text-wrap: balance;
}

.serif {
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  margin: var(--s-5) 0 0;
  color: var(--faint);
  font-size: 0.875rem;
}

.lede {
  margin: var(--s-5) 0 0;
  color: var(--muted);
  font-size: clamp(1.0625rem, 1.5vw, 1.1875rem);
  line-height: 1.6;
  text-wrap: pretty;
}

/* Two-column: sticky table of contents + prose */
.legal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-7);
}

@media (min-width: 960px) {
  .legal-body {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--s-8);
    align-items: start;
  }

  .toc {
    position: sticky;
    top: 92px;
  }
}

.toc {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raise);
  padding: var(--s-5);
}

.toc h2 {
  margin: 0 0 var(--s-3);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
  display: grid;
  gap: var(--s-2);
  font-size: 0.9375rem;
}

.toc li {
  counter-increment: toc;
}

.toc a {
  display: flex;
  gap: var(--s-3);
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
  transition: color 0.2s var(--ease);
}

.toc a::before {
  content: counter(toc);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--fg);
}

.prose {
  max-width: var(--measure);
  counter-reset: section;
}

.prose section {
  padding-top: var(--s-7);
  scroll-margin-top: 92px;
}

.prose section:first-child {
  padding-top: 0;
}

.prose h2 {
  counter-increment: section;
  margin: 0 0 var(--s-4);
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.022em;
  font-weight: 700;
  text-wrap: balance;
}

.prose h2::before {
  content: counter(section) ". ";
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.prose h3 {
  margin: var(--s-6) 0 var(--s-3);
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.012em;
  font-weight: 650;
}

.prose p,
.prose li {
  color: var(--muted);
  text-wrap: pretty;
}

.prose p {
  margin: 0 0 var(--s-4);
}

.prose ul {
  margin: 0 0 var(--s-4);
  padding-left: 1.15em;
  display: grid;
  gap: var(--s-2);
}

.prose li::marker {
  color: var(--faint);
}

.prose strong {
  color: var(--fg);
  font-weight: 650;
}

.prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s var(--ease);
}

.prose a:hover,
.prose a:focus-visible {
  text-decoration-color: var(--amber);
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;
  font-size: 0.875em;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg-raise-2);
  color: var(--fg);
  word-break: break-word;
}

.callout {
  margin: 0 0 var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  border-radius: var(--radius);
  background: var(--bg-raise);
}

.callout p:last-child,
.callout ul:last-child {
  margin-bottom: 0;
}

/* Placeholder that must be replaced before publishing. */
.todo {
  background: rgba(240, 122, 98, 0.16);
  border-bottom: 1px dashed var(--coral);
  color: var(--fg);
  padding: 0 3px;
  border-radius: 3px;
}

/* Data table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin: 0 0 var(--s-4);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  min-width: 520px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
}

thead th {
  background: var(--bg-raise);
  color: var(--fg);
  font-weight: 650;
  white-space: nowrap;
}

tbody td {
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line);
  padding-block: var(--s-7);
  color: var(--muted);
  font-size: 0.9375rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-5);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-6);
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
