/* Rizz Keyboard, rizzkeyboard.com
   One stylesheet for every page. No web fonts, no external requests.
   Colors follow the app's Theme.swift (charcoal ink, iOS grouped gray, white cards, iMessage blue). */

:root {
  color-scheme: light dark;

  --bg: #F2F2F7;           /* Theme.background */
  --card: #FFFFFF;         /* Theme.card */
  --surface: #F3F5F8;      /* Theme.surfaceMuted */
  --ink: #1D1D1F;          /* Theme.primary (charcoal) */
  --on-ink: #FFFFFF;
  --text: #15161A;         /* Theme.text */
  --text-2: #4B5260;       /* Theme.textSecondary */
  --muted: #646A78;        /* Theme.textMuted #8A90A0, darkened to pass WCAG AA on --bg */
  --separator: #E3E3E8;    /* Theme.separator */
  --accent: #007AFF;       /* Theme.bubbleBlue */
  --link: #0062CC;         /* bubble blue, darkened for AA contrast on white */
  --tint: #EAF2FE;         /* summary callout */
  --tint-edge: #C8DDFB;
  --focus: #007AFF;
  --shadow: 0 1px 2px rgba(21, 22, 26, 0.06), 0 4px 16px rgba(21, 22, 26, 0.05);

  --page-max: 1000px;
  --doc-max: 760px;
  --gutter: 16px;
  --radius: 16px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --surface: #2C2C2E;
    --ink: #F2F2F7;
    --on-ink: #15161A;
    --text: #F2F2F7;
    --text-2: #B9BEC8;
    --muted: #8E94A3;
    --separator: #38383C;
    --accent: #0A84FF;
    --link: #4DA3FF;
    --tint: #0E2036;
    --tint-edge: #1D3C63;
    --focus: #4DA3FF;
    --shadow: none;
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* Short pages keep the footer at the bottom of the window. */
body > main { flex: 0 0 auto; }

img { max-width: 100%; height: auto; }

a { color: var(--link); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3, h4 {
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0;
}

strong { font-weight: 600; }

hr { border: 0; border-top: 1px solid var(--separator); margin: 2rem 0; }

code, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface);
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

::selection { background: rgba(0, 122, 255, 0.22); }

/* ---------- Header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 14px var(--gutter);
}

/* Legal and support pages: line the header up with the narrower document column. */
body:has(main.doc) .site-header { max-width: var(--doc-max); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 15px;
}

.site-nav a {
  color: var(--text-2);
  text-decoration: none;
  padding: 4px 0;
}

.site-nav a:hover { color: var(--text); text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- Footer ---------- */

.site-footer {
  width: 100%;
  max-width: var(--page-max);
  margin: auto auto 0;
  padding: 24px var(--gutter) 40px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.site-footer p { margin: 0; }
.site-footer a { color: var(--text-2); }

/* ---------- Document pages (privacy, terms, support, 404) ---------- */

.doc {
  width: 100%;
  max-width: var(--doc-max);
  margin: 8px auto 24px;
  padding: 44px 48px 48px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.doc h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.doc h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--separator);
  scroll-margin-top: 16px;
}

.doc h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  scroll-margin-top: 16px;
}

.doc h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.25rem;
}

.doc [id] { scroll-margin-top: 16px; }

.doc p,
.doc ul,
.doc ol,
.doc dl,
.doc address,
.doc blockquote { margin: 0 0 1rem; }

.doc ul,
.doc ol { padding-left: 1.4rem; }

.doc li { margin: 0.3rem 0; }
.doc li > ul,
.doc li > ol { margin: 0.3rem 0 0; }
.doc li::marker { color: var(--muted); }

.doc address { font-style: normal; }

.doc dt { font-weight: 600; margin-top: 0.75rem; }
.doc dd { margin: 0.15rem 0 0; color: var(--text-2); }

.doc blockquote {
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--separator);
  color: var(--text-2);
}

.updated,
.doc .updated {
  margin: 0.5rem 0 1.75rem;
  color: var(--muted);
  font-size: 15px;
}

/* "The short version" callout at the top of legal pages. */
.summary {
  margin: 0 0 1.75rem;
  padding: 18px 22px 16px;
  background: var(--tint);
  border: 1px solid var(--tint-edge);
  border-radius: var(--radius);
}

.doc .summary h2,
.summary h2,
.summary h3 {
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  font-size: 1.0625rem;
  font-weight: 700;
}

.summary p { margin: 0 0 0.5rem; }
.summary ul { margin: 0; padding-left: 1.25rem; }
.summary li { margin: 0.35rem 0; }
.summary li::marker { color: var(--accent); }
.summary > :last-child { margin-bottom: 0; }

/* Table of contents card. */
.toc {
  margin: 0 0 2rem;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
}

.doc .toc h2,
.toc h2,
.toc h3,
.toc p:first-child {
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.doc .toc ol,
.doc .toc ul {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2 240px;
  column-gap: 28px;
}

.doc .toc li {
  margin: 0 0 0.4rem;
  break-inside: avoid;
}

.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

/* Tables scroll sideways inside their wrapper instead of widening the page. */
.table-wrap {
  margin: 0 0 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--separator);
  border-radius: 12px;
  /* Edge shadows hint that there is more to scroll. */
  background:
    linear-gradient(to right, var(--card) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--card) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.14), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.14), transparent) right center / 12px 100% no-repeat scroll;
  background-color: var(--card);
}

.table-wrap table {
  width: 100%;
  min-width: 30rem;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.45;
}

.table-wrap th,
.table-wrap td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--separator);
}

.table-wrap th {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
}

.table-wrap tr:last-child td { border-bottom: 0; }

.table-wrap caption {
  caption-side: top;
  padding: 10px 14px 0;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Shared bits ---------- */

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.doc .card {
  background: var(--surface);
  box-shadow: none;
  margin: 0 0 1.25rem;
}

.doc .card h2,
.doc .card h3 {
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  font-size: 1.125rem;
}

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.button:hover { opacity: 0.88; text-decoration: none; }
.button:active { transform: scale(0.98); }

/* ---------- Landing page ---------- */

body > main:not(.doc) {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter) 24px;
}

body > main:not(.doc) > section { margin: 0 0 56px; }

body > main:not(.doc) > section > h2 {
  font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 20px;
  scroll-margin-top: 16px;
}

body > main:not(.doc) > section > h2 + p {
  max-width: 560px;
  margin: -8px auto 24px;
  text-align: center;
  color: var(--text-2);
}

.hero {
  padding: 40px 0 16px;
  text-align: center;
}

.hero-icon {
  display: block;
  width: 128px;
  height: 128px;
  margin: 0 auto 24px;
  border-radius: 29px; /* close to the iOS icon mask at this size */
  box-shadow: 0 10px 30px rgba(21, 22, 26, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.hero h1 {
  font-size: clamp(2.25rem, 1.6rem + 3vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tagline {
  max-width: 600px;
  margin: 14px auto 0;
  color: var(--text-2);
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  line-height: 1.45;
}

.cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 28px 0 0;
}

.cta p { margin: 0; font-size: 15px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 24px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
}

.badge small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.75;
}

/* "How it works" (ol.steps, numbered) and the feature grid (ul.steps). */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  counter-reset: step;
}

.steps > li {
  position: relative;
  margin: 0;
  padding: 22px 20px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

ol.steps > li { counter-increment: step; }

ol.steps > li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0 0 14px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 700;
  font-size: 15px;
}

.steps h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 6px;
}

.steps p {
  margin: 0;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
}

.steps p + p { margin-top: 8px; }

/* FAQ: <details> items, no JavaScript. Works on the landing page and inside .doc. */
.faq details {
  border-bottom: 1px solid var(--separator);
}

.faq details:first-of-type { border-top: 1px solid var(--separator); }

.faq summary {
  position: relative;
  display: block;
  padding: 14px 36px 14px 0;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.faq details[open] > summary::after {
  margin-top: -2px;
  transform: rotate(-135deg);
}

.faq summary:focus-visible { outline-offset: -2px; }

.faq details > :not(summary) { margin: 0 0 12px; color: var(--text-2); }
.faq details > :last-child { margin-bottom: 16px; }
.faq details ul,
.faq details ol { padding-left: 1.25rem; }

body > main:not(.doc) > section.faq,
body > main:not(.doc) > .card {
  max-width: var(--doc-max);
  margin-left: auto;
  margin-right: auto;
}

body > main:not(.doc) > section.faq {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 24px 12px;
}

body > main:not(.doc) > section.faq > h2 { text-align: left; margin-bottom: 8px; }
body > main:not(.doc) > section.faq details:first-of-type { border-top: 0; }
body > main:not(.doc) > section.faq details:last-of-type { border-bottom: 0; }

body > main:not(.doc) > .card h2 {
  text-align: left;
  font-size: 1.25rem;
  margin: 0 0 8px;
}

body > main:not(.doc) > .card p { color: var(--text-2); margin: 0 0 12px; }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .doc {
    margin: 4px 0 16px;
    padding: 28px var(--gutter) 32px;
    border-radius: 0;
    box-shadow: none;
  }

  .summary { padding: 16px 16px 14px; }
  .toc { padding: 14px 16px; }
  .doc h2 { margin-top: 2rem; }
  .hero { padding-top: 24px; }
  .hero-icon { width: 104px; height: 104px; border-radius: 24px; }
  body > main:not(.doc) > section { margin-bottom: 40px; }
  body > main:not(.doc) > section.faq { padding: 20px 16px 8px; }
}

@media (max-width: 400px) {
  body { font-size: 16px; }
  .site-nav { gap: 4px 14px; font-size: 14px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand img { width: 28px; height: 28px; border-radius: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { transition: none !important; }
}

/* ---------- Print (legal pages) ---------- */

@media print {
  :root {
    --bg: #FFFFFF;
    --card: #FFFFFF;
    --surface: #FFFFFF;
    --text: #000000;
    --text-2: #222222;
    --muted: #444444;
    --link: #000000;
    --tint: #FFFFFF;
    --tint-edge: #999999;
    --separator: #BBBBBB;
    --shadow: none;
  }

  html, body { background: #FFFFFF; }
  body { font-size: 11pt; line-height: 1.5; display: block; }

  .site-nav,
  .site-footer,
  .toc { display: none !important; }

  .site-header { padding: 0 0 12pt; max-width: none; }
  .brand img { display: none; }
  .brand::after { content: " \00B7  rizzkeyboard.com"; font-weight: 400; }

  .doc {
    max-width: none;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .doc a { text-decoration: underline; }
  .doc a[href^="http"]::after {
    content: " <" attr(href) ">";
    font-size: 0.85em;
    word-break: break-all;
  }

  .doc h2 { break-after: avoid; page-break-after: avoid; }
  .doc h2, .doc h3 { border-top-color: #BBBBBB; }
  .summary, .table-wrap, .card { break-inside: avoid; page-break-inside: avoid; }
  .table-wrap { overflow: visible; border-color: #999999; background: none; }
  .table-wrap table { min-width: 0; }
}

/* Print closed FAQ answers too (browsers without ::details-content ignore this rule). */
@media print {
  .faq details::details-content { content-visibility: visible; display: block; }
}
