/*
 * The join page in the app's own colours and type (apps/mobile/src/theme/colors.ts; test/tokens.test.ts holds
 * these values to the app's). A pale sage ground with ink text in the light, a green-black ground with bone
 * text in the dark. Moss is money coming to someone and brick is money they owe, always beside a sign that
 * says the same. Marigold is the one primary action, "Open in Evensies", and nothing else.
 */
:root {
  --bg: #EFF2EE;
  --surface: #FFFFFF;
  --hairline: #D9E0D8;
  --text: #14161C;
  --text-muted: #5B655C;
  --text-faint: #65706A;
  --accent: #E4A61C;
  --accent-text: #14161C;
  --positive: #1A7A51;
  --negative: #B9432A;
  --fill: rgba(20, 22, 28, 0.07);
  --display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1512;
    --surface: #1D2C25;
    --hairline: #30433A;
    --text: #EDE8DA;
    --text-muted: #9AA59D;
    --text-faint: #8A968E;
    --accent: #F0B429;
    --accent-text: #14161C;
    --positive: #4CC08C;
    --negative: #F07A5C;
    --fill: rgba(237, 232, 218, 0.12);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/22px var(--body);
}

p {
  margin: 0;
}

/* Hidden means hidden, whatever display a rule below gives the element: the help index's search hides rows and topics. */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
}

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

/* One column at phone width, the app's 16pt gutter, inside the notch and the home indicator. */
.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 34rem;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 24px;
}

.wordmark {
  font: 800 20px/24px var(--display);
  letter-spacing: -0.2px;
  text-decoration: none;
}

/* Type, the app's scale: title, heading, body, label, caption. */
.title {
  margin: 0;
  font: 800 28px/32px var(--display);
  letter-spacing: -0.4px;
  overflow-wrap: anywhere;
}

.heading {
  margin: 0;
  font: 700 20px/24px var(--display);
}

.body {
  font-size: 17px;
  line-height: 22px;
}

.label {
  font: 600 15px/20px var(--body);
}

.caption {
  font-size: 13px;
  line-height: 17px;
}

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

.hero {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
}

.status {
  padding-top: 24px;
}

/* A section's name, as the app sets it: small, muted, sentence case. */
.section-title {
  margin: 0 0 8px;
  font: 600 13px/17px var(--body);
  color: var(--text-muted);
}

/* Who is in the group: an avatar and a name, wrapping as the names need. */
.people {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.people li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.person {
  overflow-wrap: anywhere;
}

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #14161C;
  font: 800 13px/1 var(--display);
}

/* The app's avatar hues (AVATAR_HUES in its ui.tsx), chosen from the name the same way. */
.hue-0 { background: #7FB59A; }
.hue-1 { background: #D99A7E; }
.hue-2 { background: #8FA8D8; }
.hue-3 { background: #B99AD0; }
.hue-4 { background: #79B8BF; }
.hue-5 { background: #C9A0A8; }
.hue-6 { background: #A9B97A; }

/* The inset grouped list: rows on one surface, rounded at the ends, a hairline between, no shadow. */
.list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  background: var(--surface);
  border-radius: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
  min-height: 56px;
  padding: 12px 16px;
}

.row + .row {
  border-top: 1px solid var(--hairline);
}

.row-title {
  flex: 1 1 9rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.amount {
  font: 700 17px/22px var(--display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The page's one loud thing: what each payment is, in the app's hero face. */
.amount.big {
  font: 800 28px/32px var(--display);
  letter-spacing: -0.4px;
}

.amount.positive {
  color: var(--positive);
}

.amount.negative {
  color: var(--negative);
}

.amount.even {
  color: var(--text-muted);
  font: 400 15px/20px var(--body);
}

.notice {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-radius: 16px;
}

.get-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stores .button {
  flex: 1 1 12rem;
}

/* Buttons, as the app's: a pill, 50pt tall. */
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  font: 600 17px/22px var(--body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
}

/* The text colour, faint, over the ground: never a white pill with black words. */
.secondary {
  background: var(--fill);
  color: var(--text);
}

.code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.legal {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 17px;
}

/*
 * The privacy policy, terms and support page (scripts/legal.mjs): the same column, read as prose. Paragraphs get
 * a longer line height than the app's rows, since these are read rather than scanned; the table of what is
 * stored is drawn as the app's inset grouped lists, one per thing stored.
 */
.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.switch {
  color: var(--text-muted);
  font: 600 15px/20px var(--body);
  text-underline-offset: 3px;
}

/*
 * The help center's language menu (scripts/legal.mjs `languageSwitch`): the page's language in the header, set as the
 * switch is, which opens the other languages as the app's inset grouped list under it. A <details>, so it opens without
 * script; the page around it does not move.
 */
.languages {
  position: relative;
}

.languages summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: -12px 0;
  color: var(--text-muted);
  font: 600 15px/20px var(--body);
  cursor: pointer;
  list-style: none;
}

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

/* A chevron drawn by two borders, pointing down while closed and up while open. */
.languages summary::after {
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  content: "";
}

.languages[open] summary::after {
  margin-top: 4px;
  transform: rotate(225deg);
}

.languages ul {
  position: absolute;
  top: calc(100% + 16px);
  right: 0;
  z-index: 1;
  min-width: 11rem;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 0 0 1px var(--hairline);
  list-style: none;
}

.languages li + li {
  border-top: 1px solid var(--hairline);
}

.languages a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  font: 400 17px/22px var(--body);
  text-decoration: none;
}

.languages a:focus-visible {
  outline-offset: -3px;
}

.doc {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-top: 8px;
}

.doc-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc > section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc p,
.doc li {
  line-height: 26px;
  overflow-wrap: break-word;
}

.doc ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding-left: 1.25em;
}

.doc a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.doc strong {
  font-weight: 600;
}

.facts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fact {
  overflow: hidden;
  background: var(--surface);
  border-radius: 16px;
}

.fact h3 {
  margin: 0;
  padding: 14px 16px 12px;
  font: 700 17px/22px var(--display);
  overflow-wrap: break-word;
}

.fact dl {
  margin: 0;
}

.fact dt {
  padding: 12px 16px 2px;
  border-top: 1px solid var(--hairline);
  color: var(--text-muted);
  font: 600 13px/17px var(--body);
}

.fact dd {
  margin: 0;
  padding: 0 16px 12px;
  font-size: 15px;
  line-height: 21px;
  overflow-wrap: break-word;
}

/* Numbered steps in a help article, set like the lists. */
.doc ol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding-left: 1.5em;
}

/* The link from a help article back to the index, above its question. */
.crumb {
  align-self: flex-start;
  color: var(--text-muted);
  font: 600 15px/20px var(--body);
  text-underline-offset: 3px;
}

/*
 * The help center's index (scripts/help.mjs): each topic's articles as the app's inset grouped list, the whole row a
 * link, the article's name over its one-line description.
 */
.doc .list {
  gap: 0;
  padding-left: 0;
}

/* Between the rows on show: the search hides some, and the first one left has no line above it. */
.entry:not([hidden]) ~ .entry:not([hidden]) {
  border-top: 1px solid var(--hairline);
}

/*
 * The help index's search (scripts/help.mjs): a field on the list's surface, at 17px so iOS does not zoom to it, and the
 * line under it said only when no article matches.
 */
.search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 400 17px/22px var(--body);
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search p:not(:empty) {
  margin-top: 12px;
}

.entry a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 56px;
  padding: 12px 16px;
  text-decoration: none;
}

.entry a:focus-visible {
  outline-offset: -3px;
}

/*
 * In a language an article is not written in yet (scripts/help.mjs): the note above it that says it is shown in English,
 * on the list's surface, and the word that says so under its row on the index.
 */
.note {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 21px;
}

/* Above `.doc p`'s reading line height: a note is a line or two, set as the list's captions are. */
.doc-head .note {
  margin: 6px 0;
  line-height: 21px;
}

.entry .tag {
  color: var(--text-faint);
}

/* Where to write when the answer is not here: the last line of the index and of every article. */
.more {
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
  color: var(--text-muted);
}

.legal a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

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

/* The field the copy command selects the invite link in where a browser has no clipboard API (src/copy.ts): there
   for a moment, never seen, and at 16px so iOS does not zoom to it. */
.copy-buffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
}
