/*
 * One stylesheet for the whole site.
 *
 * The palette is lifted straight from Backstory's design tokens
 * (`src/theme/theme.ts`) so the site and the app feel like one product:
 * Apple-minimal, one confident accent (indigo), semantic colours that flip
 * between light and dark.
 *
 * Rules of the road:
 *  - Colours come from the custom properties below. Never hard-code a hex in a
 *    rule; add a token instead, so light and dark stay in step.
 *  - Mobile first. Most visitors arrive from an App Store listing on a phone.
 */

:root {
  --background: #f2f2f7;
  --card: #ffffff;
  --card-raised: #ffffff;
  --label: #1c1c1e;
  --secondary-label: #6e6e73;
  --tertiary-label: rgb(60 60 67 / 0.45);
  --separator: rgb(60 60 67 / 0.12);
  /*
   * Two indigos, deliberately.
   *
   * --accent is TEXT indigo. It has to clear 4.5:1 against the page AND against
   * --accent-tint, because badges and callouts put accent text on that tint —
   * same hue on same hue is the pairing that fails WCAG most often.
   *
   * --accent-solid is Backstory's exact accent, used only as a FILL under white
   * text. White on the darker text-indigo would be the failure in reverse.
   */
  --accent: #4b49c4;
  --accent-solid: #5856d6;
  --accent-tint: rgb(88 86 214 / 0.12);
  --on-accent: #ffffff;

  --radius: 14px;
  --measure: 34rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #000000;
    --card: #1c1c1e;
    --card-raised: #2c2c2e;
    --label: #ffffff;
    --secondary-label: rgb(235 235 245 / 0.6);
    --tertiary-label: rgb(235 235 245 / 0.35);
    --separator: rgb(84 84 88 / 0.36);
    --accent: #8e8cff;
    --accent-solid: #5e5ce6;
    --accent-tint: rgb(94 92 230 / 0.18);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, 'Segoe UI', Roboto,
    sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.masthead {
  background: var(--card);
  border-bottom: 1px solid var(--separator);
  padding: 0.9rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--label);
  white-space: nowrap;
}

.masthead nav {
  display: flex;
  gap: 1.1rem;
  font-size: 0.9375rem;
}

.masthead nav a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

/*
 * Three app names do not fit beside the wordmark on a phone. Rather than
 * shrink them to unreadable, drop the nav — the home page is one tap away and
 * lists all three anyway.
 */
@media (max-width: 34rem) {
  .masthead nav {
    display: none;
  }
}

main {
  padding: 2.5rem 0 3.5rem;
}

/* ── Type ──────────────────────────────────────────────────────────────── */

h1 {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 0.6rem;
  font-weight: 700;
}

h2 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin: 2.5rem 0 0.6rem;
  font-weight: 600;
}

h3 {
  font-size: 1.0625rem;
  margin: 1.6rem 0 0.3rem;
  font-weight: 600;
}

p,
li {
  max-width: var(--measure);
}

.lede {
  font-size: 1.125rem;
  color: var(--secondary-label);
  margin: 0 0 1.75rem;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

.small {
  font-size: 0.9375rem;
}

/* ── Home: app cards ───────────────────────────────────────────────────── */

.apps {
  display: grid;
  gap: 0.6rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.apps li {
  max-width: none;
}

.app-card {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding: 0.9rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.app-card:hover {
  background: var(--accent-tint);
}

.app-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  flex: none;
  object-fit: cover;
  background: var(--separator);
}

.app-card h2 {
  margin: 0 0 0.1rem;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

.app-card p {
  margin: 0;
  color: var(--secondary-label);
  font-size: 0.9375rem;
}

.app-card .chev {
  margin-left: auto;
  color: var(--tertiary-label);
  flex: none;
}

/* ── App page header ───────────────────────────────────────────────────── */

.app-head {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.app-head .app-icon {
  width: 76px;
  height: 76px;
  border-radius: 17px;
}

.app-head h1 {
  margin: 0 0 0.15rem;
}

.badge {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}

.store-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0;
}

.store-links a {
  display: inline-block;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  background: var(--accent-solid);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.store-links a:hover {
  opacity: 0.9;
}

/* ── Screenshots ───────────────────────────────────────────────────────── */

/*
 * A scrolling row rather than a wrapping grid: on a phone this shows one shot
 * and the edge of the next, which reads as "swipe me" and keeps the copy below
 * within reach. `scroll-snap` makes the swipe land cleanly on each phone.
 */
.shots {
  display: flex;
  gap: 1rem;
  margin: 1.75rem 0 2.5rem;
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.shots figure {
  flex: none;
  width: 210px;
  margin: 0;
  scroll-snap-align: start;
}

.shots img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 20px;
  background: var(--card);
}

.shots figcaption {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--secondary-label);
}

/* Bleed the row to the screen edges on phones so it reads as scrollable. */
@media (max-width: 34rem) {
  .shots {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

/* ── Grouped list: the shell every table and callout sits in ───────────── */

.table-scroll {
  overflow-x: auto;
  margin: 0.9rem 0 1.5rem;
  border-radius: var(--radius);
  background: var(--card);
}

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

th,
td {
  text-align: left;
  padding: 0.75rem 1rem;
  vertical-align: top;
  border-bottom: 1px solid var(--separator);
}

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

th {
  font-weight: 600;
  white-space: nowrap;
  color: var(--secondary-label);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td:first-child {
  font-weight: 500;
}

/* ── Callout ───────────────────────────────────────────────────────────── */

.callout {
  background: var(--accent-tint);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}

.callout p {
  margin: 0;
}

/* ── Sub-nav on app pages ──────────────────────────────────────────────── */

.pagelinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.15rem;
  padding: 1rem 0 0;
  margin: 2.5rem 0 0;
  border-top: 1px solid var(--separator);
  font-size: 0.9375rem;
  list-style: none;
}

.pagelinks li {
  margin: 0;
  max-width: none;
}

/* ── Footer ────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--separator);
  padding: 1.75rem 0 2.5rem;
  color: var(--secondary-label);
  font-size: 0.9375rem;
}

footer a {
  color: var(--accent);
}

footer .wrap > * + * {
  margin-top: 0.3rem;
}

/* ── Motion ────────────────────────────────────────────────────────────── */

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