/*
 * Shared by every page under pairs.mathheartcode.com.
 *
 * Served from the same S3 prefix as the pages themselves, so it needs no cache behavior of its
 * own: the distribution's *default* behavior targets this origin, and only /v1/* and /decks/*
 * are routed away from it.
 *
 * The palette is DESIGN.md's, not a fresh one — cream #FFF4E3 and brown-black #201911 for the
 * grounds (never neutral grey), pink #FF8FB8 → violet #9D7BEC for anything that reads as the
 * product's own voice, plum for text on cream.
 */

:root {
  color-scheme: light dark;

  --ground: #FFF4E3;
  --ground-tint: #FDE9D2;
  --card: #FFFFFF;
  --ink: #2E2119;
  --ink-soft: #6B5A4C;
  --rule: #E7D6BE;
  --pink: #FF8FB8;
  --violet: #9D7BEC;
  --plum: #5D3157;
  --link: #7B4FD0;

  --radius: 18px;
  --measure: 34rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #201911;
    --ground-tint: #2B2119;
    --card: #3B2144;
    --ink: #F4E7D8;
    --ink-soft: #C4AE9A;
    --rule: #4E3B2C;
    --plum: #E9C7DF;
    --link: #C7A9FF;
  }
}

* { box-sizing: border-box; }

html {
  /* Percentage rather than px so the reader's own browser text size is respected. */
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 1.25rem 5rem;
  background:
    radial-gradient(120% 80% at 15% -10%, var(--ground-tint) 0%, transparent 60%),
    var(--ground);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

main, header, footer { max-width: var(--measure); margin-inline: auto; }

/* MARK: - Masthead */

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

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

/* The two cardies, corner to corner, as a favicon-sized mark. */
.cardies { display: block; width: 30px; height: 30px; flex: none; }

h1 {
  font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 1.25rem 0 0.35rem;
}

.updated { color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 2rem; }

h2 {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  margin: 2.75rem 0 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

h2:first-of-type { border-top: 0; padding-top: 0; }

h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }

p, li { margin: 0 0 1rem; }
ul { padding-inline-start: 1.25rem; }
li { margin-bottom: 0.6rem; }

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

/*
 * ⚠️ **Negative tracking is for Latin headings only.** `h1` and `h2` pull letters together by
 * 1–2%, which tightens a Latin headline and makes CJK glyphs collide — they are drawn on a
 * full-width em square with their optical spacing already built in, so there is no gap to take
 * back. `site.js` writes the chosen language onto <html> and every section carries its own `lang`,
 * so `:lang()` reaches the headings from one rule either way.
 *
 * `.wordmark` is deliberately left out: it is the brand, it is Latin in every language, and it
 * should be set identically on all five pages.
 *
 * Line height is raised for the same readers: 1.6 is comfortable for the alphabet and cramped for
 * characters with this much internal structure.
 *
 * ⚠️ **One authoring rule that no stylesheet can enforce: do not wrap a CJK paragraph in the
 * source.** HTML collapses a newline to a space, which is invisible between English words and a
 * real gap between two ideographs — so every <p> and <li> in a `ja` or `zh-Hans` section is one
 * long line, however wide it makes the file. Reflowing them to a comfortable column reintroduces a
 * space after every sentence, and it renders as a typographic error rather than as a diff.
 */
:lang(ja), :lang(zh-Hans) { line-height: 1.8; }
:lang(ja) :is(h1, h2, h3),
:lang(zh-Hans) :is(h1, h2, h3) { letter-spacing: normal; }

/*
 * ⚠️ **Arabic is joined script, and tracking pulls it apart.** Any `letter-spacing` other than
 * `normal` opens a gap inside the joins between letters in Safari, so a word reads as a row of
 * broken pieces rather than as tighter or looser text. The headings and the uppercase table
 * headers both track, so both are reset here; `text-transform: uppercase` does nothing to Arabic
 * and is left alone.
 *
 * `ui-rounded` has no Arabic glyphs, so without the line below the browser falls back glyph by
 * glyph to whatever it likes. Naming SF Arabic Rounded keeps an Apple device in the same rounded
 * voice as the Latin; elsewhere the list runs on to Segoe UI and Noto, which do carry Arabic.
 * The line height is raised for the same reason as Chinese and Japanese: the script's dots and
 * marks above and below the line need room that 1.6 does not leave.
 *
 * The page's *direction* is not set here. `site.js` writes `dir="rtl"` onto <html> along with
 * `lang`, and each Arabic section carries `dir="rtl"` itself. Every horizontal rule in this file
 * is written in logical terms (`padding-inline-start`, `text-align: start`, `margin-inline`) so it
 * follows without an override; the one exception is the picker's chevron, below.
 */
:lang(ar) {
  font-family: ui-rounded, "SF Arabic Rounded", "SF Arabic", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans Arabic", system-ui, sans-serif;
  line-height: 1.8;
}
:lang(ar) :is(h1, h2, h3, th) { letter-spacing: normal; }

/* A Latin name inside Arabic text is wrapped in <bdi> so it keeps its own order. A short one also
 * keeps its own line: `AES-256-GCM` broken at a hyphen puts its halves on two right-to-left lines
 * in the wrong order. Long ones — the postal addresses — are left free to wrap. */
.term { white-space: nowrap; }

strong { font-weight: 700; }

/* MARK: - The summary card
 *
 * The one thing a parent reads if they read nothing else, so it gets the product's own gradient
 * edge rather than another rule.
 */

.summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 0.75rem;
  margin-bottom: 2.5rem;
  border: 1px solid var(--rule);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.04);
  position: relative;
  overflow: hidden;
}

.summary::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--pink), var(--violet));
}

.summary h2 { border-top: 0; padding-top: 0; margin-top: 0; font-size: 1.15rem; }
.summary ul { margin-bottom: 0.5rem; }

/* MARK: - Tables
 *
 * Wide content scrolls inside its own container so the page body never scrolls sideways on a
 * phone — the retention and data-flow tables are both wider than 375pt.
 */

.scroll { overflow-x: auto; margin: 0 0 1.5rem; -webkit-overflow-scrolling: touch; }

table { border-collapse: collapse; width: 100%; min-width: 30rem; font-size: 0.95rem; }
th, td { text-align: start; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; color: var(--ink-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* MARK: - Language switcher */

.langs { display: flex; gap: 0.35rem; }

.langs a {
  display: inline-block;
  /* 0.6rem, not more: at 0.7 the eighth pill (العربية) pushed the row ~3px past the 34rem
   * masthead and the whole row wrapped under the wordmark, in every language. */
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
  background: var(--card);
}

.langs a[aria-current="true"] {
  background: linear-gradient(90deg, var(--pink), var(--violet));
  border-color: transparent;
  color: #FFFFFF;
}

.langs a:hover { border-color: var(--violet); }

/* A label is one word; never let 日本語 or 简体中文 stack a character per line. */
.langs a { white-space: nowrap; }

/*
 * On a phone the eight pills cannot share a row with the wordmark, and on a row of their own they
 * read as clutter above the hero. So below 36rem they give way to one native <select>, dressed as
 * the current-language pill and sitting on the wordmark's row; iOS and Android open their own
 * picker from it.
 *
 * Only under `.js` — the class the inline script in each page's <head> sets. Without the script a
 * <select> changes nothing, while the links still work as plain ?lang= navigations.
 *
 * ⚠️ `font-size` is a full 1rem on purpose: iOS zooms the page into any focused form control set
 * smaller than 16px, and does not zoom back out.
 */
.lang-select { display: none; }

@media (max-width: 36rem) {
  .js .langs { display: none; }

  .js .lang-select {
    display: block;
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    color: #FFFFFF;
    padding: 0.4rem 2rem 0.4rem 0.95rem;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    /* The chevron is its own layer over the pill's gradient, drawn in the pill's white. */
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        no-repeat right 0.8rem center / 12px 8px,
      linear-gradient(90deg, var(--pink), var(--violet));
  }

  /* A background image has no logical position, so the chevron is moved across by hand. */
  html.js[dir="rtl"] .lang-select {
    padding: 0.4rem 0.95rem 0.4rem 2rem;
    background-position: left 0.8rem center, 0 0;
  }

  .js .lang-select:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

  /* A desktop-style dropdown list inherits the pill's white text; give the options the page's. */
  .lang-select option { color: var(--ink); background: var(--card); }

  /* The picker keeps its place beside the wordmark instead of wrapping under it. */
  .js .masthead { flex-wrap: nowrap; }
}

footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

footer a { color: var(--ink-soft); }

.footlinks { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 0.75rem; }

/* MARK: - Home */

.hero { text-align: center; padding-block: 3rem 1rem; }
.hero .cardies-big { width: 108px; height: 108px; margin-inline: auto; display: block; }
.hero p { color: var(--ink-soft); font-size: 1.1rem; }

/*
 * The two reasons the app exists, which are also its App Store subtitle and the opening line of
 * its description — see the note in index.html before rewriting either.
 *
 * The first is a block so the pair always breaks after it, in every language: they are two
 * separate claims, and German and French both run long enough to wrap the first one mid-phrase if
 * they are left to flow together. Full ink on the promise, soft ink on the qualifier, so the
 * hierarchy survives even though the two lines are nearly the same size.
 */
.lead { font-size: 1.15rem; color: var(--ink-soft); margin-bottom: 1.5rem; }
.lead strong { display: block; color: var(--ink); font-size: 1.3rem; line-height: 1.3; margin-bottom: 0.15rem; }

/*
 * The band of cards. Full-bleed to the reading measure, and it keeps its own aspect via the
 * width/height attributes on the tag so the page does not reflow when it loads.
 *
 * The artwork already runs off both ends (see `LandingBoard`), so there is no crop to manage
 * here: any width shows a strip of a longer table.
 */
.band {
  display: block;
  height: auto;
  border-radius: var(--radius);
  margin-block: 0 2.5rem;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.08), 0 12px 32px rgb(0 0 0 / 0.10);

  width: 100%;
}

/*
 * Wider than the reading measure, once there is room for it.
 *
 * Text wants 34rem; a picture held to the same column reads as an illustration inside a document,
 * and this band is the only thing on the page showing what the app actually looks like. So above
 * 52rem it grows 6rem past the column on each side — 46rem total.
 *
 * ⚠️ **Symmetric negative margins, not `margin-left: 50%` + `translateX(-50%)`.** That is the
 * usual breakout trick and it is the wrong one here: a transform moves what is *painted*, not
 * what is *laid out*, so the half-container left margin still overflows to the right and the
 * document's scroll width grows with it — a horizontal scrollbar on narrow screens that points at
 * nothing. Negative margins pull the box outward on both sides instead, which changes its layout
 * width and overflows nothing.
 *
 * The media query is the other half of the guard: below 52rem the band is simply the column
 * width, so there is no viewport at which the breakout can exceed it.
 */
@media (min-width: 52rem) {
  .band {
    /*
     * ⚠️ Stated, not `auto`. `.band` is an `<img>`, and `width: auto` on a replaced element means
     * its *intrinsic* width — 1500px — not "fill the container". It does not overflow visibly,
     * because `height: auto` scales with it, so the symptom is a band several times too tall
     * rather than anything that looks like a width bug.
     */
    width: calc(100% + 12rem);
    margin-inline: -6rem;
  }
}

/*
 * A story section: one board of cards and the paragraph it illustrates.
 *
 * There are two, and they are the whole reason this page stopped being a list. The app is sold on
 * two different ideas — play with your own photographs, or name a theme and have the deck painted
 * — and naming them in bullets asks the reader to picture them. Each now gets a board of its own,
 * drawn from the deck it is talking about.
 *
 * Stacked by default, side by side above 52rem, and the second one reverses so the two alternate
 * rather than marching down one edge.
 */
.story { margin: 0 0 2.75rem; }

.story img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-bottom: 1.1rem;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.08), 0 12px 32px rgb(0 0 0 / 0.10);
}

/* No rule above it: the picture is the separator here, and `h2`'s border would draw a line
 * between a heading and the image it belongs to. */
.story h2 {
  border-top: 0;
  padding-top: 0;
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}

.story p { color: var(--ink-soft); margin-bottom: 0; }

@media (min-width: 52rem) {
  .story {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem;
    align-items: center;
    /* Same breakout as `.band`, so the page has one wide column rather than two competing ones. */
    margin-inline: -6rem;
  }

  .story img { margin-bottom: 0; }
  /* Picture on the right for the second story. `order` only, so the DOM keeps heading-after-image
   * for a screen reader in both. */
  .story.reverse img { order: 2; }
}

/*
 * What is left over once the two stories have their own sections — the promises that are not about
 * how a deck is made, and so have no board to show.
 *
 * A card rather than a bullet, because after two illustrated sections a bare `<li>` reads as a
 * footnote, and "no accounts, no advertising, no tracking" is the line a parent is actually
 * scanning for. Stays a list: there may be more of these later, and the styling already holds.
 */
.points { list-style: none; padding-inline-start: 0; margin: 0 0 1rem; }

.points li {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.85rem;
  color: var(--ink-soft);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.points strong { color: var(--ink); }

/*
 * The App Store badge — Apple's artwork, unmodified, one per language section.
 *
 * This was a pink→purple gradient pill reading “Get Pairs on the App Store”, which was not wrong
 * so much as not what is asked for: the App Store Marketing Guidelines say to include the badge
 * “in all digital and printed marketing materials as a clear call to action”, and they are
 * specific about how it may then appear. Black is the preferred badge (the grey border is part of
 * the artwork, not a stroke of ours), it may not be modified, angled or animated, and there is one
 * per layout, subordinate to the main message. That is what retired the pill: a badge dropped
 * inside chrome of our own is the modification the rule is aimed at, so it sits on the page
 * background instead.
 *
 * ⚠️ The five SVGs are Apple's own localized files, taken from App Store Marketing Tools
 * (toolbox.marketingtools.apple.com). Never hand-translate one — “never translate App Store or
 * create your own localized badge” is one of the few outright prohibitions in the guidelines, and
 * a translated `alt` string is close enough to that line to be worth avoiding too, which is why
 * each `alt` is the wording Apple's own badge for that language carries.
 *
 * 44px against a 40px onscreen minimum, which also clears the 44pt tap target. The margin is the
 * required clear space, one quarter of the badge height (11px); it is larger here because the
 * hero wants the air anyway, but it must never go below that.
 */
.badge { display: inline-block; margin: 1rem 0.75rem 0.75rem; }
.badge img { display: block; height: 44px; width: auto; }

/* The trademark credit line the guidelines require, once per language section, set quieter than
 * the copyright it follows: it is legal notification, not something to read. */
.tm { max-width: 46ch; font-size: 0.78rem; line-height: 1.45; opacity: 0.75; }

@media (prefers-reduced-motion: no-preference) {
  a { transition: opacity 120ms ease, border-color 120ms ease; }
}
