/* Klee website. Colours and type are the app's own. */

:root {
  color-scheme: dark;

  --bg: #13151a;     /* window background in the app */
  --band: #24262a;   /* the band behind what you said */
  --rule: #282a2f;   /* the line above the input box */
  --edge: #3d434d;   /* window edge */
  --fg: #d7d9e2;
  --dim: #858a9a;
  --blue: #7aa2f7;   /* the whale, the prompt mark, links, the one button */
  --green: #9ece6a;  /* a finished step */
  --amber: #e0af68;  /* something waiting on a person */

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", "Roboto Mono",
    Consolas, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI",
    Roboto, "Microsoft YaHei", sans-serif;

  --column: 1040px;
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 62ch;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.75 var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* Both languages are in the page; the one not chosen is hidden. */
html[data-lang="en"] [lang="zh-Hans"],
html[data-lang="zh"] [lang="en"] { display: none !important; }

p, h1, h2, h3, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }

a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 3px; }

.column {
  width: 100%;
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

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

/* ---------- Staging notice: only shown on workers.dev and localhost (see lang.js) ---------- */

.staging { display: none; }
html[data-env="staging"] .staging {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--dim);
  font-size: 13px;
}
.staging p { border-left: 2px solid var(--amber); padding-left: 12px; }
.staging b { color: var(--amber); font-weight: 600; }

/* ---------- Top: language switch ---------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 20px;
  font-size: 13px;
}
.top .home { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 600; }
.top .home .whale { width: 26px; }

.langs { display: flex; gap: 4px; margin-left: auto; }
.langs button {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 8px;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.langs button:hover { color: var(--fg); }
.langs button[aria-pressed="true"] { color: var(--fg); text-decoration: none; cursor: default; }

/* ---------- The whale: the app's template image, tinted the same way ---------- */

.whale {
  display: block;
  flex: none;
  aspect-ratio: 385 / 367;
  background: var(--blue);
  -webkit-mask: url(/img/whale.png) center / contain no-repeat;
  mask: url(/img/whale.png) center / contain no-repeat;
}

/* ---------- Headings (the home page and the legal pages adjust size and spacing) ---------- */

h1 {
  margin-top: clamp(28px, 5vw, 48px);
  max-width: 21em;
  font: 600 clamp(1.7rem, 1.05rem + 2.7vw, 2.75rem) / 1.28 var(--mono);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
html[data-lang="zh"] h1 { letter-spacing: 0; }

.chev { flex: none; width: 8px; height: 13px; color: var(--blue); transform: translateY(1px); }

/* ---------- Home: one screen ---------- */

body.one { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* Between the language switch and the footer. The typing fills it; the words sit on top. */
.stage { position: relative; flex: 1 0 auto; display: flex; align-items: flex-start; }

.front { position: relative; z-index: 1; padding-top: 22px; padding-bottom: 176px; }

/* The words stand on solid background with a soft edge, so no typed line ever shows through.
   Below them the background thins out gradually, so lines fade as they move up underneath. */
.hero { position: relative; max-width: 31rem; background: var(--bg); box-shadow: 0 0 20px 22px var(--bg); }
.hero::after {
  content: "";
  position: absolute;
  top: 100%;
  left: calc(-1 * var(--gutter));   /* no wider than the page, or a phone would scroll sideways */
  right: calc(-1 * var(--gutter));
  height: 64px;
  background: linear-gradient(to bottom, var(--bg) 30%, transparent);
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand .whale { width: 50px; }
.brand .name { font-size: 26px; font-weight: 700; line-height: 1.2; }
.brand small {
  padding: 1px 7px 2px;
  border: 1px solid var(--amber);
  border-radius: 4px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.hero h1 {
  margin-top: 26px;
  max-width: none;
  font-size: clamp(1.45rem, 1.1rem + 1.5vw, 2.05rem);
  line-height: 1.34;
}

.says { margin-top: 18px; font-size: 15.5px; }
.says li + li { margin-top: 6px; }

.get { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 9.5em;
  padding: 9px 18px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit;
  line-height: 1.4;
  text-align: left;
  text-decoration: none;
}
.btn b { font-size: 16px; font-weight: 700; }
.btn small { font-size: 12px; font-weight: 500; }
.btn.mac { background: var(--blue); color: #0e1016; }
.btn.mac:hover { background: #93b4fa; text-decoration: none; }
.btn.mac:focus-visible { outline-offset: 4px; border-radius: 7px; }
/* Not available yet: greyed out, and it is a disabled button, so it cannot be clicked or focused. */
.btn.win { background: transparent; border-color: var(--rule); color: #666b7a; cursor: not-allowed; }

.needs { margin-top: 14px; color: var(--dim); font-size: 13px; }

/* ---------- Home: the typing behind the words (typing.js fills .term) ---------- */

.backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  --left: max(var(--gutter), calc((100% - var(--column)) / 2));
}
/* Older lines fade out towards the top, long ones towards the right edge. */
.backdrop::before,
.backdrop::after { content: ""; position: absolute; z-index: 1; }
.backdrop::before { inset: 0 0 auto 0; height: 45%; background: linear-gradient(to bottom, var(--bg) 8%, transparent); }
.backdrop::after { inset: 0 0 0 auto; width: 56px; background: linear-gradient(to right, transparent, var(--bg)); }

/* Lines are added at the bottom and push the earlier ones up, as in a terminal. */
.term {
  position: absolute;
  left: var(--left);
  right: 0;
  bottom: 14px;
  opacity: 0.42;
  font-size: 12.5px;
  line-height: 1.9;
}

.t { padding-right: 24px; overflow-wrap: anywhere; }
.t::before { content: ""; display: inline-block; flex: none; }
.t .cmd,
.t .hint { margin-left: 1.2ch; color: var(--dim); }

/* A flex row, so that a long sentence wraps beside the mark, not under it. */
.t-ask { display: flex; align-items: flex-start; margin: 1.3em 0 0.35em -12px; padding: 2px 24px 2px 12px; background: var(--band); }
.t-ask:first-child { margin-top: 0; }
.t-ask::before { width: 6px; height: 6px; margin: 0.7em 14px 0 1px; border: solid var(--blue); border-width: 2px 2px 0 0; transform: rotate(45deg); }

.t-step { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-step::before { width: 7px; height: 7px; margin: 0 13px 1px 1px; border-radius: 50%; background: var(--green); }

.t-file::before { content: "→"; margin-right: 12px; color: var(--dim); }
.t-file .txt { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }

.t-done::before { width: 9px; height: 5px; margin: 0 12px 4px 1px; border: solid var(--green); border-width: 0 0 2px 2px; transform: rotate(-45deg); }

/* The cursor after the text being typed. */
.t.typing .txt::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--blue);
}

/* ---------- Bottom line ---------- */

.status {
  margin-top: clamp(72px, 10vw, 120px);
  padding-bottom: 40px;
  color: var(--dim);
  font-size: 13px;
}
.status::before { content: ""; display: block; margin-bottom: 18px; border-top: 1px solid var(--rule); }
.status-line { display: flex; flex-wrap: wrap; gap: 4px 0; }
/* inline-block keeps the link underline off the separator */
.status-line > * + *::before { content: "·"; display: inline-block; margin: 0 0.8em; color: var(--dim); text-decoration: none; }
.status a { color: var(--dim); }
.status a:hover { color: var(--fg); }

.one .status { margin-top: 0; padding-bottom: 22px; }
.one .status::before { margin-bottom: 14px; }
.one .status-line > span { color: var(--dim); }

/* ---------- Privacy and terms ---------- */

.legal { padding-top: clamp(36px, 6vw, 64px); }
.legal h1 { margin-top: 0; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
.legal .updated { margin-top: 10px; color: var(--dim); font-size: 13px; }

.legal article {
  margin-top: 36px;
  max-width: 44rem;
  font: 400 16px/1.78 var(--sans);
}
.legal article > p + p,
.legal article > ul + p,
.legal article > p + ul { margin-top: 14px; }
.legal h2 {
  margin: 44px 0 14px;
  font: 600 17px/1.5 var(--mono);
  color: var(--fg);
}
.legal h3 { margin: 26px 0 10px; font: 600 15px/1.5 var(--mono); }
.legal ul { padding-left: 1.3em; list-style: disc; }
.legal ul li + li { margin-top: 8px; }
.legal ul li::marker { color: var(--dim); }
.legal strong { font-weight: 600; color: #eceef5; }
.legal address { font-style: normal; }

/* The summary at the top of the privacy policy. */
.where { margin-top: 18px; border-top: 1px solid var(--rule); }
.where div { display: grid; grid-template-columns: 14em 1fr; gap: 6px 24px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.where dt { font: 600 14px/1.6 var(--mono); }
.where dd { color: var(--fg); }

/* ---------- /paid and the not-found page: one line ---------- */

.oneline { padding-top: clamp(72px, 18vh, 200px); min-height: 52vh; }
.oneline .whale { width: 58px; }
.done { display: flex; align-items: baseline; gap: 14px; margin-top: 36px; max-width: 30em; font: 600 clamp(1.25rem, 1rem + 1.2vw, 1.7rem) / 1.5 var(--mono); }
.done svg { flex: none; width: 0.85em; height: 0.85em; color: var(--green); transform: translateY(0.06em); }
.done .chev { width: 0.5em; height: 0.8em; color: var(--blue); }
.oneline .after { margin-top: 18px; padding-left: calc(0.85em * 1.5 + 14px); color: var(--dim); }

/* ---------- Wide screens: the words on the left, the typing beside them ---------- */

@media (min-width: 960px) {
  .stage { align-items: center; }
  .front { padding-top: 40px; padding-bottom: 72px; }
  .brand .whale { width: 56px; }
  .term { left: calc(var(--left) + 35rem); bottom: 22px; opacity: 0.5; font-size: 13.5px; }
}

/* ---------- Narrower than that ---------- */

/* The bottom line no longer fits on one line: space the items apart instead of putting dots
   between them, and give the closing sentence a line to itself. */
@media (max-width: 959px) {
  .one .status-line { gap: 4px 20px; }
  .one .status-line > * + *::before { display: none; }
  .one .status-line > span { flex-basis: 100%; margin-top: 2px; }
}

@media (max-width: 720px) {
  .where div { grid-template-columns: 1fr; }

  .says { font-size: 15px; }
}

/* Keep the two buttons side by side on small phones. */
@media (max-width: 420px) {
  .get { gap: 10px; }
  .btn { min-width: 0; padding: 9px 14px 10px; }
  .btn b { font-size: 15px; }
}
@media (max-width: 340px) {
  .get { gap: 8px; }
  .btn { padding: 9px 12px 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn.mac { transition: background-color 0.12s ease; }
  .t.typing .txt::after { animation: blink 1.06s steps(1, end) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

@media print {
  body { background: #fff; color: #000; }
  .top .langs, .staging, .backdrop { display: none !important; }
}
