/* ============================================================
   ARTi Legal — styles.css
   Static HTML legal-document site for legal.arti.social
   No external dependencies. No analytics. No tracking.

   Design tokens derived from the ARTi iOS app:
   - Apple system .purple (#AF52DE light / #BF5AF2 dark) as brand accent
   - SF Pro Text body, SF Pro Rounded for select brand display
   - Button corner radius 14
   - Semantic-color cascade (tertiary → secondary → primary) for legal copy
   - Spectrum gradient reserved for ARTi+ premium touches (used here as a
     single 3px accent stripe under the header — light brand signal only)
============================================================ */

:root {
  /* Brand */
  --color-accent: #AF52DE;          /* Apple system purple — matches in-app .purple */
  --color-accent-hover: #9A3FCA;
  --color-accent-bg: rgba(175, 82, 222, 0.08);

  /* Neutrals — mapped to Apple HIG semantic intentions */
  --color-text: #0A0A0F;            /* .primary */
  --color-text-muted: #4A4A52;      /* .secondary */
  --color-text-faint: #8E8E93;      /* .tertiary — Apple iOS tertiaryLabel */
  --color-bg: #FFFFFF;
  --color-bg-subtle: #F7F7F8;
  --color-border: #E5E5E7;
  --color-border-strong: #D1D1D6;

  /* ARTi spectrum (used sparingly — one 3px stripe under the header) */
  --gradient-spectrum: linear-gradient(
    90deg,
    #AF52DE 0%,    /* purple */
    #FF2D92 14%,   /* pink */
    #FF9500 28%,   /* orange */
    #FFCC00 42%,   /* yellow */
    #34C759 57%,   /* green */
    #5AC8FA 71%,   /* cyan */
    #007AFF 85%,   /* blue */
    #AF52DE 100%   /* purple */
  );

  /* Typography — match ARTi iOS app */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro",
               "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: -apple-system-rounded, "SF Pro Rounded", "SF Pro",
                  "Inter", system-ui, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing scale (matches TermsView in-app: 24/8/4) */
  --space-1: 0.5rem;     /* 8 */
  --space-2: 1rem;       /* 16 */
  --space-3: 1.5rem;     /* 24 — section spacing */
  --space-4: 2rem;       /* 32 */
  --space-6: 3rem;       /* 48 */
  --space-8: 4rem;       /* 64 */

  /* Layout */
  --content-max-width: 720px;
  --content-padding: 1.5rem;
  --header-height: 56px;
  --radius: 14px;        /* matches ARTIActionButton in-app */
  --radius-sm: 10px;

  /* Press animation (matches ARTIButtonStyle) */
  --press-scale: 0.96;
  --press-opacity: 0.7;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #F2F2F7;
    --color-text-muted: #B5B5BA;       /* iOS .secondary in dark */
    --color-text-faint: #8E8E93;
    --color-bg: #0A0A0F;
    --color-bg-subtle: #15151C;
    --color-border: #2C2C2E;
    --color-border-strong: #3A3A3C;
    --color-accent: #BF5AF2;             /* Apple system purple in dark */
    --color-accent-hover: #D6A5F5;
    --color-accent-bg: rgba(191, 90, 242, 0.12);
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 1rem); }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; display: block; }

/* Skip link (accessibility) */
.skip-link {
  position: absolute; top: -100px; left: 0;
  padding: 0.75rem 1rem;
  background: var(--color-accent); color: #fff;
  text-decoration: none; z-index: 100;
}
.skip-link:focus { top: 0; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--color-border);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(10,10,15,0.85); }
}
/* Spectrum accent stripe — the only ARTi+ brand touch on these pages */
.site-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--gradient-spectrum);
  opacity: 0.85;
}
.header-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 var(--content-padding);
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: inline-flex; align-items: center; gap: 4px;
  text-decoration: none; transition: transform 0.2s var(--spring);
  /* Hide the alt text fallback that screen readers will use via aria-label on the link */
  font-size: 0;
}
.brand:hover { transform: translateY(-1px); }
.brand:active { transform: scale(var(--press-scale)); opacity: var(--press-opacity); }
.brand-logo {
  /* CSS mask: the SVG provides the silhouette; background-color fills it.
     Clean way to recolor a black template SVG with the brand color. */
  display: inline-block;
  width: 64px; height: 22px;
  background-color: var(--color-accent);
  -webkit-mask-image: url("/arti-logo.svg");
          mask-image: url("/arti-logo.svg");
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}

/* Header nav */
.header-nav { position: relative; }
.nav-toggle {
  background: transparent; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 0.4rem 0.8rem;
  font: inherit; font-weight: 500;
  color: var(--color-text); cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.15s var(--spring);
}
.nav-toggle:hover { border-color: var(--color-accent); color: var(--color-accent); }
.nav-toggle:active { transform: scale(var(--press-scale)); opacity: var(--press-opacity); }
.nav-toggle[aria-expanded="true"] { border-color: var(--color-accent); color: var(--color-accent); }
.nav-toggle[aria-expanded="true"] + .nav-list { display: block; }
.nav-list {
  display: none; position: absolute; top: calc(100% + 0.5rem); right: 0;
  min-width: 240px; padding: 0.5rem;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); list-style: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
.nav-list a {
  display: block; padding: 0.5rem 0.75rem;
  color: var(--color-text); text-decoration: none;
  border-radius: 4px; font-size: 0.95rem;
}
.nav-list a:hover { background: var(--color-bg-subtle); color: var(--color-accent); }
.nav-list .divider { border-top: 1px solid var(--color-border); margin: 0.4rem 0; }
.nav-list a[aria-current="page"] { color: var(--color-accent); font-weight: 600; }

/* Main content */
.content {
  max-width: var(--content-max-width); margin: 0 auto;
  padding: var(--space-6) var(--content-padding) var(--space-8);
}
.content > article > h1 {
  font-family: var(--font-rounded);
  font-size: 2.125rem; line-height: 1.15; font-weight: 800;
  letter-spacing: -0.025em; margin-bottom: 0.5rem;
}
.meta {
  color: var(--color-text-faint); font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

/* Typographic styles for article body — match TermsView (.title3.bold for sections) */
.content h2 {
  font-family: var(--font-rounded);
  font-size: 1.3125rem; line-height: 1.3; font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: var(--space-6); margin-bottom: var(--space-1);
  scroll-margin-top: calc(var(--header-height) + 1rem);
  padding-top: 0.25rem;
}
.content h3 {
  font-size: 1.0625rem; line-height: 1.4; font-weight: 600;
  margin-top: var(--space-3); margin-bottom: var(--space-1);
  scroll-margin-top: calc(var(--header-height) + 1rem);
  color: var(--color-text);
}
.content h4 {
  font-size: 1rem; font-weight: 600;
  margin-top: var(--space-3); margin-bottom: 0.5rem;
}
.content p { margin-bottom: var(--space-2); }
.content ul, .content ol {
  margin-bottom: var(--space-2); padding-left: 1.5rem;
}
.content li { margin-bottom: 0.4rem; }
.content li > ul, .content li > ol { margin-top: 0.4rem; }

.content a {
  color: var(--color-accent); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 2px;
}
.content a:hover { color: var(--color-accent-hover); }

.content strong { font-weight: 700; }
.content em { font-style: italic; }
.content code {
  font-family: var(--font-mono); font-size: 0.92em;
  background: var(--color-bg-subtle);
  padding: 0.1rem 0.4rem; border-radius: 4px;
  border: 1px solid var(--color-border);
}
.content pre {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--color-bg-subtle); padding: var(--space-2);
  border-radius: var(--radius); border: 1px solid var(--color-border);
  overflow-x: auto; margin-bottom: var(--space-2);
}
.content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0 0.5rem 1rem; margin: var(--space-2) 0;
  color: var(--color-text-muted); font-style: italic;
}
.content hr {
  border: none; border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* Tables */
.content table {
  width: 100%; border-collapse: collapse;
  margin-bottom: var(--space-3); font-size: 0.95rem;
}
.content thead { background: var(--color-bg-subtle); }
.content th, .content td {
  padding: 0.6rem 0.8rem; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
.content th { font-weight: 600; }
.content tbody tr:hover { background: var(--color-bg-subtle); }

/* Mobile: wrap tables horizontally instead of breaking layout */
@media (max-width: 640px) {
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .content table { min-width: 480px; }
}

/* Anchored heading link icon (appears on hover) */
.heading-anchor {
  opacity: 0; margin-left: 0.4rem; color: var(--color-text-faint);
  text-decoration: none; font-weight: 400;
}
h2:hover .heading-anchor, h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }

/* Index landing page */
.policy-grid {
  display: grid; gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-6);
}
@media (min-width: 720px) { .policy-grid { grid-template-columns: 1fr 1fr; } }
.policy-card {
  display: block; padding: var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  text-decoration: none; color: inherit;
  transition: border-color 0.2s, transform 0.2s var(--spring),
              box-shadow 0.2s, background-color 0.2s;
}
.policy-card:hover {
  border-color: var(--color-accent); transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(175, 82, 222, 0.08);
}
.policy-card:active {
  transform: scale(var(--press-scale));
  opacity: var(--press-opacity);
  transition: transform 0.1s, opacity 0.1s;
}
.policy-card h2 {
  font-size: 1.15rem; margin: 0 0 0.5rem; color: var(--color-text);
}
.policy-card p {
  color: var(--color-text-muted); font-size: 0.95rem; margin: 0 0 0.75rem;
}
.policy-card .card-meta { font-size: 0.85rem; color: var(--color-text-faint); }
.policy-card .arrow { color: var(--color-accent); margin-left: 0.4rem; }

.contact-block {
  margin-top: var(--space-6); padding: var(--space-3);
  background: var(--color-bg-subtle); border-radius: var(--radius);
  font-size: 0.95rem;
}
.contact-block h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.contact-block ul { list-style: none; padding: 0; }
.contact-block li { margin-bottom: 0.3rem; }
.contact-block code {
  background: transparent; border: none; padding: 0;
  font-family: var(--font-sans); color: var(--color-accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-6) var(--content-padding);
  background: var(--color-bg-subtle);
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: grid; gap: var(--space-4);
}
@media (min-width: 720px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
.footer-company strong { color: var(--color-text); }
.footer-company address { font-style: normal; margin-top: 0.4rem; }
.footer-nav h3 {
  font-size: 0.85rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-faint); margin-bottom: 0.6rem;
}
.footer-nav ul { list-style: none; padding: 0; }
.footer-nav li { margin-bottom: 0.3rem; }
.footer-nav a {
  color: var(--color-text-muted); text-decoration: none;
}
.footer-nav a:hover { color: var(--color-accent); }
.copyright {
  grid-column: 1 / -1; padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem; color: var(--color-text-faint);
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--color-accent); outline-offset: 2px;
  border-radius: 4px;
}

/* Print stylesheet (legal/audit teams print these) */
@media print {
  .site-header, .site-footer, .skip-link, .heading-anchor { display: none !important; }
  body { color: #000; background: #fff; font-family: var(--font-serif); font-size: 11pt; line-height: 1.45; }
  .content { max-width: 100%; padding: 0; margin: 0; }
  .content h1 { font-size: 18pt; }
  .content h2 { font-size: 14pt; page-break-after: avoid; }
  .content h3 { font-size: 12pt; page-break-after: avoid; }
  .content a { color: #000; text-decoration: underline; }
  .content a[href^="http"]::after {
    content: " (" attr(href) ")"; font-size: 9pt; color: #555;
  }
  .content table, .content tr, .content td, .content th { page-break-inside: avoid; }
  .meta { color: #555; }
}
