/* Alfred's homepage: one sans for every word, figures and captions included, monospace only for
   what you type, and the system's math face for the formula. Colours are the icon's. System
   fonts only: the page loads nothing from anyone else.
   Appearance has three states: data-theme="light" or "dark" when the reader chose one, nothing
   for the system's. Every colour is a token defined on :root first. */

:root {
  --paper: #f3f5f2;
  --ink: #1f1e1b;
  --ink-2: #54554f;
  --ink-3: #6f706a;
  --rule: #d9ddd6;
  --faint: #c4c9c1;
  --green: #3f8f76;
  --green-text: #2a6a56;
  --code: #e7ebe5;
  --note: #4b675d;
  --mark-tile: #1f1e1b;
  --mark-line: #faf9f5;
  --mark-accent: #3f8f76;
  --shadow: 0 10px 30px rgb(31 30 27 / 0.12), 0 1px 3px rgb(31 30 27 / 0.08);
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* A classical scale from 17 px: 13, 15, 17, 21, 28, 36, 48, 64. */
  --s-1: 0.765rem;
  --s0: 0.882rem;
  --s1: 1rem;
  --s2: 1.235rem;
  --s3: 1.647rem;
  --s4: 2.118rem;
  --s5: 2.824rem;
  --s6: 3.765rem;
  --gutter: 32px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1a1a18;
    --ink: #f1f3ef;
    --ink-2: #b9bbb4;
    --ink-3: #93958f;
    --rule: #34352f;
    --faint: #4a4b45;
    --green: #4fa58a;
    --green-text: #6cc0a4;
    --code: #262723;
    --note: #9db5ab;
    --mark-tile: #3a3935;
    --mark-accent: #4fa58a;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1a1a18;
  --ink: #f1f3ef;
  --ink-2: #b9bbb4;
  --ink-3: #93958f;
  --rule: #34352f;
  --faint: #4a4b45;
  --green: #4fa58a;
  --green-text: #6cc0a4;
  --code: #262723;
  --note: #9db5ab;
  --mark-tile: #3a3935;
  --mark-accent: #4fa58a;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45), 0 1px 3px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* Each language reads in its own faces. */
:root:lang(en) {
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
:root:lang(ja) {
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
}
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3, :lang(ja) dt { word-break: auto-phrase; }

/* English or Japanese is swapped in before the reader sees the Chinese it is written in. */
.pending body { visibility: hidden; }

* { box-sizing: border-box; }

html { font-size: 17px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--s1);
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}
:lang(en) body { line-height: 1.6; }

h1, h2, h3, p, dl, dd, figure { margin: 0; }
p, dd { text-wrap: pretty; }

a { color: var(--green-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 3px; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

code { font-family: var(--mono); font-size: 0.88em; }
p code, dd code { padding: 1px 5px; border-radius: 4px; background: var(--code); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
/* A rule as wide as the text above it, not the padded box. */
.ruled { background: linear-gradient(var(--rule), var(--rule)) var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px no-repeat; }

/* The mark: the icon drawn in the page's tokens, so its tile stays visible on a dark page. */
.mark { flex: none; display: block; }
.mark-tile { fill: var(--mark-tile); }
.mark-rays { stroke: #fff; }
.mark-line { stroke: var(--mark-line); }
.mark-accent { stroke: var(--mark-accent); }

/* The bar: the mark and the name, the sections, then the language and the appearance as icons. */
.bar { display: flex; align-items: center; gap: 28px; height: 76px; }
.bar .name { display: flex; align-items: center; gap: 12px; font-size: 1.12rem; font-weight: 600; letter-spacing: 0.005em; color: var(--ink); text-decoration: none; }
.bar .name .mark { width: 32px; height: 32px; }
.sections { margin-left: auto; display: flex; gap: 24px; font-size: var(--s0); }
.sections a { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.sections a:hover { color: var(--ink); }
/* The desktop section and its link show once a release of the app is known. */
.sections a[hidden], .section[hidden] { display: none; }
.controls { display: flex; align-items: center; gap: 6px; margin-right: -8px; }
/* A page without the sections still keeps the controls at the right. */
.name + .controls { margin-left: auto; }

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.icon-button svg { width: 21px; height: 21px; }
.icon-button svg[hidden] { display: none; }
.icon-button:hover, .icon-button[aria-expanded="true"] { background: var(--code); color: var(--ink); }
.icon-button:active { transform: scale(0.94); }
/* The button's name, shown under it after a moment's hover; it is the aria-label, so it is
   always the current one. */
@media (hover: hover) {
  .icon-button::after {
    content: attr(aria-label);
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--ink);
    color: var(--paper);
    font-size: var(--s-1);
    line-height: 1.6;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
  }
  .icon-button:hover::after { opacity: 1; transition-delay: 0.5s; }
  .icon-button[aria-expanded="true"]::after { display: none; }
}

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 156px;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: menu-in 0.14s ease-out;
  transform-origin: top right;
}
.menu[hidden] { display: none; }
.menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--s0);
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--code); color: var(--ink); outline: none; }
.menu button[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.menu button[aria-checked="true"]::after {
  content: "";
  width: 10px;
  height: 5px;
  margin-bottom: 3px;
  border-left: 1.7px solid var(--green);
  border-bottom: 1.7px solid var(--green);
  transform: rotate(-45deg);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* What Alfred is, and the attention behind its icon. */
.hero { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 64px; align-items: center; padding-top: 56px; padding-bottom: 104px; }
.hero h1 { margin-bottom: 28px; font-size: var(--s5); line-height: 1.3; font-weight: 600; letter-spacing: 0.01em; text-wrap: balance; }
:lang(en) .hero h1 { font-size: var(--s4); line-height: 1.2; letter-spacing: -0.015em; }
/* Japanese runs a few characters longer per line than the Chinese it sits beside. */
:lang(ja) .hero h1 { font-size: 2.5rem; }
.hero .lede { margin-bottom: 14px; font-size: var(--s2); line-height: 1.7; color: var(--ink-2); max-width: 27em; }
/* Where it runs and where you use it: facts that change, kept apart from the line above. */
.hero .avail { margin-bottom: 32px; font-size: var(--s0); line-height: 1.7; color: var(--ink-3); }
/* The lines are short phrases: break only at punctuation and spaces, never inside one. */
:lang(zh) .hero .lede, :lang(zh) .hero .avail { word-break: keep-all; }
:lang(ja) .hero .lede, :lang(ja) .hero .avail { word-break: auto-phrase; }
:lang(en) .hero .lede { line-height: 1.55; max-width: 32em; }

.figure svg { display: block; width: 100%; height: auto; overflow: visible; }
.figure figcaption { margin-top: 18px; font-size: var(--s0); line-height: 1.8; color: var(--ink-2); max-width: 40em; }
.figure figcaption b { font-weight: 600; color: var(--ink); margin-right: 0.8em; }
.figure figcaption i { font-family: math, serif; }
/* The icon's note: a green-grey of its own, quieter than the text and the green line. */
.hero-figure figcaption { color: var(--note); }
.formula { margin: 0 0 4px; font-size: 1.1rem; color: var(--ink); text-align: left; math-style: normal; }

#attention .ray, #attention .leg { stroke: var(--ink); }
#attention .accent { stroke: var(--green); }

/* Sections: the heading and its one paragraph on the left, the substance on the right. */
.section { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 64px; padding-top: 88px; padding-bottom: 88px; }
.section-head h2 { font-size: var(--s4); line-height: 1.3; font-weight: 600; margin-bottom: 16px; }
.section-head p { color: var(--ink-2); max-width: 22em; }
:lang(en) .section-head p { max-width: 26em; }

.points { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 56px; }
.point h3 { font-size: var(--s2); line-height: 1.45; font-weight: 600; margin-bottom: 10px; text-wrap: balance; }
.point p { color: var(--ink-2); }
.point .tag { margin-top: 12px; font-size: var(--s0); color: var(--ink-3); }

/* The measurements. */
.figures { display: grid; gap: 72px; }
.panels { display: grid; gap: 28px; max-width: 600px; }
.panel-title { font-size: var(--s0); color: var(--ink); margin-bottom: 8px; }

.figure .dot.alfred { fill: var(--green); }
.figure .dot.other { fill: var(--ink); }
.figure .dot.miss { fill: none; stroke: var(--faint); stroke-width: 1.2; }
.figure .span { stroke-width: 7; stroke-linecap: round; }
.figure .span.alfred { stroke: var(--green); }
.figure .span.other { stroke: var(--ink); }
.figure .axis { stroke: var(--faint); stroke-width: 1; }
.figure text { font-family: var(--sans); font-variant-numeric: tabular-nums; fill: var(--ink-2); }
.figure .value { font-size: 12px; fill: var(--ink); }
.figure .name { font-size: 12px; fill: var(--ink); }
.figure .name.alfred { fill: var(--green-text); }
.figure .tick { font-size: 11px; fill: var(--ink-3); }
.figure .head { font-size: 11px; fill: var(--ink); }
.figure .label { font-size: 11px; fill: var(--ink); }
.figure .model { font-size: 10px; fill: var(--ink-3); }
#links svg { max-width: 580px; }
/* The same scale as figure 3: its 484 units are 580 px. */
#brief svg { max-width: 528px; }
/* A tag's link leads to the figure or the note that backs the point. */
.figure { scroll-margin-top: 24px; }
.point .tag a { color: inherit; text-decoration-color: var(--faint); }
.point .tag a:hover { color: var(--ink); text-decoration-color: currentColor; }

/* Principles. */
.principles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 56px; }
.principles dt { font-size: var(--s2); font-weight: 600; line-height: 1.45; margin-bottom: 10px; text-wrap: balance; }
.principles dd { color: var(--ink-2); }

/* The command, and installing. */
/* A click anywhere on the command copies it; the icon shows on hover, and always on touch. */
.install { position: relative; min-width: 0; max-width: 36em; border: 1px solid var(--rule); border-radius: 10px; background: var(--code); cursor: pointer; transition: border-color 0.15s; }
.install:hover { border-color: var(--faint); }
.install code {
  display: block;
  padding: 14px 16px;
  font-size: var(--s0);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  user-select: all;
  -webkit-user-select: all;
  mask-image: linear-gradient(to right, #000 calc(100% - 64px), transparent calc(100% - 8px));
}
.install .copy {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}
.install .copy svg { width: 19px; height: 19px; }
.install:hover .copy, .install .copy:focus-visible { opacity: 1; }
.install .copy:hover { background: var(--paper); color: var(--ink); }
@media (hover: none) { .install .copy { opacity: 1; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 9px 18px 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-size: var(--s0);
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s, transform 0.18s;
}
.toast:empty { display: none; }
.toast.shown { opacity: 1; transform: translate(-50%, 0); }
.toast svg { flex: none; width: 16px; height: 16px; color: var(--mark-accent); }
.install-note { margin-top: 14px; font-size: var(--s0); color: var(--ink-3); }
.install-note a { margin-left: 0.6em; white-space: nowrap; }
/* minmax(0, 1fr): the command does not wrap, and must not widen the column. */
.steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 40em; }
.steps .install { margin-bottom: 10px; }
.steps .downloads { margin-top: 0; }
.steps p { color: var(--ink-2); }
.steps .aside { font-size: var(--s0); color: var(--ink-3); }

/* The releases: the latest open, the rest a line each until opened. */
.release-list { margin: 0; padding: 0; list-style: none; max-width: 44em; }
.release { border-top: 1px solid var(--rule); }
.release:first-child { border-top: 0; }
.release.latest { padding-bottom: 28px; }
.release-top { display: block; padding: 18px 0; }
.release.latest .release-top { padding-top: 0; }
summary.release-top { position: relative; padding-right: 32px; cursor: pointer; list-style: none; }
summary.release-top::-webkit-details-marker { display: none; }
summary.release-top::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 27px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
details[open] > summary.release-top::after { transform: translateY(3px) rotate(225deg); }
summary.release-top:hover .release-version { color: var(--green-text); }
.release-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.release-version { font-size: var(--s2); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.release.latest .release-version { font-size: var(--s3); }
.release-date { font-size: var(--s0); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.badge { align-self: center; padding: 0 9px; border: 1px solid var(--rule); border-radius: 999px; font-size: var(--s-1); line-height: 1.75; color: var(--ink-2); }
.release-summary { display: block; margin-top: 6px; color: var(--ink-2); }
.release-summary code, .notes code { padding: 1px 5px; border-radius: 4px; background: var(--code); white-space: nowrap; }
.release-body { padding-bottom: 8px; }
details .release-body { padding-bottom: 26px; }
.notes { color: var(--ink-2); }
.notes ul { margin: 0; padding-left: 1.15em; list-style: disc; }
.notes li + li { margin-top: 6px; }
.notes p + *, .notes ul + * { margin-top: 10px; }
.release-aside { margin-top: 10px; font-size: var(--s0); color: var(--ink-3); }
/* Two by two: macOS on one row, Linux on the next. */
.downloads { display: grid; grid-template-columns: repeat(2, max-content); gap: 8px; margin-top: 20px; }
.downloads a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  color: var(--ink);
  font-size: var(--s0);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}
.downloads a:hover { background: var(--code); border-color: var(--faint); color: var(--ink); }
.downloads svg { width: 15px; height: 15px; color: var(--ink-3); }
.files { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: var(--s0); }
.release-all { margin-top: 20px; font-size: var(--s0); }

/* The privacy policy and the terms. Each page holds all three languages; CSS shows the reader's,
   and English when no script has run. */
.l10n { display: none; }
:root:not([data-lang]) .l10n:lang(en),
:root[data-lang="en"] .l10n:lang(en),
:root[data-lang="zh"] .l10n:lang(zh),
:root[data-lang="ja"] .l10n:lang(ja) { display: revert; }

.legal { padding-top: 48px; padding-bottom: 96px; }
.doc-head { max-width: 44em; padding-bottom: 56px; }
.doc-head h1 { margin-bottom: 10px; font-size: var(--s5); line-height: 1.25; font-weight: 600; letter-spacing: 0.01em; }
:lang(en) .doc-head h1 { letter-spacing: -0.015em; }
.updated { font-size: var(--s0); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.doc-head .lede { margin-top: 20px; font-size: var(--s2); line-height: 1.7; color: var(--ink-2); }
.doc-head .lede + .lede { margin-top: 12px; }
:lang(en) .doc-head .lede { line-height: 1.55; }
/* A translation says first that the English governs, and offers it. */
.governs { margin-bottom: 32px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--code); font-size: var(--s0); line-height: 1.7; color: var(--ink-2); }
.governs button {
  margin-left: 0.6em;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green-text);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
}
.governs button:hover { color: var(--ink); }
/* Each part: its heading on the left, as the homepage's sections have it, the text at a reading
   measure on the right. */
.clause { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 64px; padding: 32px 0; border-top: 1px solid var(--rule); }
.clause h2 { font-size: var(--s2); line-height: 1.45; font-weight: 600; text-wrap: balance; }
.clause-body { max-width: 40em; color: var(--ink-2); }
.clause-body > * + * { margin-top: 12px; }
.clause-body ul { margin-bottom: 0; padding-left: 1.15em; }
.clause-body li + li { margin-top: 8px; }
.clause-body strong { font-weight: 600; color: var(--ink); }
.clause-body code { padding: 1px 5px; border-radius: 4px; background: var(--code); overflow-wrap: anywhere; }

@media (max-width: 960px) {
  .clause { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}

@media (max-width: 720px) {
  .legal { padding-top: 24px; padding-bottom: 64px; }
  .doc-head { padding-bottom: 40px; }
  .doc-head h1 { font-size: 1.76rem; }
  .doc-head .lede { font-size: var(--s1); }
  .clause { padding: 24px 0; }
}

.foot { display: flex; gap: 14px; align-items: flex-start; padding-top: 40px; padding-bottom: 56px; font-size: var(--s0); color: var(--ink-3); }
.foot .mark { width: 20px; height: 20px; margin-top: 3px; }
.foot p { max-width: 46em; }
.foot-text { display: grid; gap: 8px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.foot-links a { color: var(--ink-2); text-decoration: none; }
.foot-links a:hover { color: var(--ink); text-decoration: underline; }
.foot-links a[aria-current="page"] { color: var(--ink); }

@media (max-width: 1040px) {
  .sections { display: none; }
  .controls { margin-left: auto; }
}

@media (max-width: 960px) {
  .section { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .section-head p, :lang(en) .section-head p { max-width: 34em; }
}

@media (max-width: 720px) {
  :root { --gutter: 16px; }
  .bar { height: 64px; gap: 12px; }
  .bar .name { font-size: var(--s1); gap: 10px; }
  .bar .name .mark { width: 28px; height: 28px; }
  .controls { gap: 8px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 48px; padding-top: 24px; padding-bottom: 64px; }
  .hero h1 { font-size: 1.76rem; }
  :lang(en) .hero h1 { font-size: 1.53rem; }
  :lang(ja) .hero h1 { font-size: 1.76rem; }
  .hero .lede { font-size: var(--s1); }
  .hero-figure { max-width: 420px; }
  .section { padding-top: 56px; padding-bottom: 56px; }
  .points, .principles { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  /* The charts shrink to the screen; their words should not shrink as much. */
  #week .value, #week .name { font-size: 18px; }
  #week .tick { font-size: 16px; }
  #links .head, #links .label, #brief .head, #brief .label { font-size: 13px; }
  #links .model, #brief .model { font-size: 12px; }
  .downloads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .downloads a { padding: 0 8px; gap: 5px; font-size: var(--s-1); }
}

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