/* Engu — a warm picture book. Paper, soft colour, a serif voice; the candidate bar itself drawn like the real one. */

:root {
  --paper: #f6efe2;
  --paper-deep: #ede1cc;
  --card: #fffcf6;
  --ink: #3b2f27;
  --ink-soft: #7d6d5f;
  --line: rgba(59, 47, 39, 0.13);
  --vermilion: #cc543a;
  --vermilion-ink: #fff8ee;
  --vermilion-edge: #993a26;
  --dusk: #45506a;
  --dusk-ink: #f6ecda;
  --dusk-soft: rgba(246, 236, 218, 0.72);
  --dusk-hill: #5d6e62;
  --ochre: #e6ab4c;
  --sage: #a3b18b;
  --sage-deep: #7f9468;
  --sky: #b9cdc8;
  --rose: #e8b3a0;
  --bark: #8a6a4f;
  --star: transparent;
  --sun: #efb95a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 40px -18px rgba(92, 62, 36, 0.45), 0 2px 6px rgba(92, 62, 36, 0.08);
  --grain-opacity: 0.32;

  /* the candidate bar, from CandidatePanel.swift (Look) */
  --panel: rgba(250, 249, 247, 0.9);
  --panel-edge: rgba(0, 0, 0, 0.12);
  --panel-fg: #1d1d1f;
  --panel-soft: rgba(60, 60, 67, 0.6);
  --selection: rgb(107, 107, 107);
  --changed: rgba(255, 150, 60, 0.55);

  --serif: "Iowan Old Style", "New York", ui-serif, "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Helvetica Neue", "Noto Sans SC", sans-serif;
  --system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1814;
    --paper-deep: #251f19;
    --card: #2a231d;
    --ink: #f0e5d4;
    --ink-soft: #b3a28f;
    --line: rgba(240, 229, 212, 0.13);
    --vermilion: #e06a4f;
    --vermilion-ink: #1d1814;
    --vermilion-edge: #9a3f2c;
    --dusk: #262b38;
    --dusk-hill: #3c4a40;
    --ochre: #d39a45;
    --sage: #4f5e45;
    --sage-deep: #3c4935;
    --sky: #3d5350;
    --rose: #a46c5b;
    --bark: #6b5442;
    --star: #f3e6c8;
    --sun: #f1e3c2;
    --shadow: 0 0 0 1px rgba(255, 240, 220, 0.06), 0 22px 44px -18px rgba(0, 0, 0, 0.7);
    --grain-opacity: 0.18;
    --panel: rgba(44, 44, 46, 0.92);
    --panel-edge: rgba(255, 255, 255, 0.14);
    --panel-fg: #f2f2f7;
    --panel-soft: rgba(235, 235, 245, 0.6);
    --selection: rgb(117, 117, 117);
    --changed: rgba(255, 150, 60, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* paper grain over everything */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.33  0 0 0 0 0.2  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::after { mix-blend-mode: screen; }
}

a { color: inherit; }
h1, h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}
p { margin: 0; }
.fine { font-size: 13px; color: var(--ink-soft); }

/* ---------- bar ---------- */
/* full width, the page shows through softly; a hairline appears once the page has scrolled under it */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow 0.3s ease;
}
.bar.scrolled { box-shadow: 0 1px 0 var(--line); }
.bar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 20px;
}
.brand-block { width: 28px; height: 28px; }
.bar-download {
  padding: 5px 0;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  line-height: 1.3;
}
.bar-download:hover { color: var(--vermilion); }
.bar-download:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 4px; }

/* the download button is one of the alphabet blocks: a painted face over a darker edge */
.block {
  display: inline-block;
  padding: 13px 30px 12px;
  border-radius: 8px;
  background: var(--vermilion);
  color: var(--vermilion-ink);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.06em;
  line-height: 1.3;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 0 var(--vermilion-edge),
    0 14px 22px -12px rgba(110, 36, 22, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.block:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 5px 0 var(--vermilion-edge), 0 16px 24px -12px rgba(110, 36, 22, 0.6); }
.block:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 0 var(--vermilion-edge), 0 6px 12px -8px rgba(110, 36, 22, 0.5); }
.block:focus-visible { outline: 3px solid var(--vermilion); outline-offset: 4px; }
.block.small {
  padding: 5px 14px 4px;
  font-size: 15px;
  letter-spacing: 0.04em;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 0 var(--vermilion-edge);
}
.block.small:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 0 0 var(--vermilion-edge); }

/* full-width 。，at the end of a centred line: drop the empty half of the glyph so the ink centres */
.end { margin-inline-end: -0.5em; }

::selection { background: color-mix(in srgb, var(--vermilion) 28%, transparent); }

/* ---------- hero ---------- */
.hero {
  text-align: center;
  padding: 72px 16px 8px;
  max-width: 760px;
  margin: 0 auto;
}
.eyebrow {
  font-size: 15px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}
h1 { font-size: clamp(40px, 7.4vw, 76px); line-height: 1.15; }
.lede { margin-top: 20px; font-size: clamp(18px, 2.4vw, 21px); color: var(--ink-soft); }
.cta { margin-top: 34px; display: grid; justify-items: center; gap: 12px; }

/* ---------- the illustrated stage ---------- */
.stage {
  position: relative;
  margin-top: 28px;
  height: clamp(420px, 46vw, 560px);
  overflow: clip;
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.sun { fill: var(--sun); opacity: 0.85; }
.stars circle { fill: var(--star); }
.bird { fill: none; stroke: var(--ink-soft); stroke-width: 2.2; stroke-linecap: round; opacity: 0.6; }
.hill.far { fill: var(--sky); }
.hill.near { fill: var(--sage); }
.trunk { stroke: var(--bark); stroke-width: 7; stroke-linecap: round; }
.crown { fill: var(--sage-deep); }
.crown.alt { fill: var(--ochre); opacity: 0.85; }
.blocks .face { stroke: rgba(59, 47, 39, 0.18); stroke-width: 1.5; }
.blocks .b1 { fill: var(--vermilion); }
.blocks .b2 { fill: var(--ochre); }
.blocks .b3 { fill: var(--rose); }
.blocks .b4 { fill: #9fb6b8; }
.blocks .top { fill: #f3dcbf; }
.blocks .side { fill: #d9b48c; }
.blocks text { font-family: var(--serif); font-size: 40px; font-weight: 600; fill: #fff8ee; text-anchor: middle; }
.edge { fill: var(--paper); }
.sprout { fill: none; stroke: var(--sage-deep); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .blocks .b4 { fill: #5f7a7c; }
  :root:not([data-theme="light"]) .blocks .top { fill: #8d7660; }
  :root:not([data-theme="light"]) .blocks .side { fill: #6e5946; }
  :root:not([data-theme="light"]) .blocks text { fill: #f6e9d6; }
}

/* a sheet of paper, taped to the page */
.sheet {
  position: absolute;
  left: 50%;
  top: 34px;
  transform: translateX(-50%) rotate(-1.2deg);
  width: min(560px, calc(100% - 32px));
  margin: 0;
  padding: 32px 32px 72px;
  background: var(--card);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.sheet::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 26px;
  transform: translateX(-50%) rotate(2deg);
  background: color-mix(in srgb, var(--ochre) 45%, transparent);
  border-radius: 2px;
}

/* ---------- the text line and candidate bar (shared by every demo) ---------- */
.doc {
  font-family: var(--system);
  font-size: 19px;
  line-height: 28px;
  min-height: 28px;
  white-space: pre-wrap;
  color: var(--ink);
  letter-spacing: 0;
}
.doc .done.fresh { animation: settle 1.6s ease-out; border-radius: 3px; }
@keyframes settle { from { background: color-mix(in srgb, var(--vermilion) 22%, transparent); } to { background: transparent; } }
.marked { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.caret {
  display: inline-block;
  width: 2px;
  height: 22px;
  margin-left: 1px;
  vertical-align: -4px;
  background: var(--vermilion);
  border-radius: 1px;
  animation: blink 1.1s steps(1) infinite;
}
.sheet.typing .caret { animation: none; }
@keyframes blink { 50% { opacity: 0; } }

.panel {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 9px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 0 0 1px var(--panel-edge), 0 10px 28px -6px rgba(40, 30, 20, 0.28), 0 2px 6px rgba(40, 30, 20, 0.08);
  font-family: var(--system);
  color: var(--panel-fg);
  white-space: nowrap;
  z-index: 2;
  letter-spacing: 0;
}
.panel[hidden] { display: none; }
.item {
  display: inline-flex;
  align-items: baseline;
  height: 26px;
  line-height: 26px;
  padding: 0 9px 0 7px;
  border-radius: 6px;
  font-size: 15px;
}
.item .n {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--panel-soft);
  margin-right: 5px;
}
.item .q { color: var(--panel-soft); }
.item.sel { background: var(--selection); color: #fff; }
.item.sel .n { color: rgba(255, 255, 255, 0.8); }
.item.sel .q { color: rgba(255, 255, 255, 0.55); }
.item mark {
  color: inherit;
  background: var(--changed);
  border-radius: 3px;
  padding: 0 2.5px;
  margin: 0 -2.5px;
}
.item .drop {
  display: inline-block;
  position: relative;
  width: 0;
}
.item .drop::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}
.item .dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.33;
  transform: translateY(-8px);
}
.pager { display: inline-flex; align-items: center; padding: 0 4px; color: var(--panel-soft); font-size: 16px; font-weight: 500; gap: 8px; }
.pager .off { opacity: 0.35; }

/* the key just pressed, under the sheet */
.key {
  position: absolute;
  right: 36px;
  top: calc(100% + 18px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.key.show { opacity: 1; }
.key kbd { transition: transform 0.12s ease, box-shadow 0.12s ease; }
.key.down kbd { transform: translateY(2px); box-shadow: 0 0 0 1px var(--line), 0 0 0 var(--line); }

/* ---------- pages ---------- */
.pages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 96px 16px 40px;
}
.page { text-align: center; }
.page h2 { font-size: 26px; margin-top: 26px; }
.mini {
  position: relative;
  margin: 0;
  height: 132px;
  padding: 30px 24px 0;
  text-align: left;
  background: var(--card);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.page:nth-child(1) .mini { transform: rotate(-1deg); }
.page:nth-child(2) .mini { transform: rotate(0.8deg); }
.page:nth-child(3) .mini { transform: rotate(-0.6deg); }
.mini .doc { font-size: 17px; }
.mini .item:nth-child(n+3) { display: none; }

/* ---------- keys ---------- */
.keys {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 16px 24px;
  text-align: center;
}
.keys h2 { font-size: clamp(28px, 4vw, 38px); }
.keys ul {
  list-style: none;
  margin: 44px 0 0;
  padding: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 28px 44px;
}
.keys li { display: grid; justify-items: center; gap: 14px; font-size: 15px; color: var(--ink-soft); }
kbd {
  display: inline-grid;
  place-items: end start;
  min-width: 52px;
  height: 52px;
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--line), 0 3px 0 var(--line), 0 8px 18px -10px rgba(92, 62, 36, 0.4);
  font-family: var(--system);
  font-size: 13px;
  color: var(--ink);
}
kbd.wide { width: 200px; place-items: center; }
kbd .space { width: 26px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.key kbd .space { width: 20px; height: 8px; }
kbd.mid { min-width: 96px; }
kbd:not(.wide):not(.mid) { place-items: center; font-size: 20px; }
.key kbd { height: 34px; min-width: 34px; font-size: 12px; place-items: center; padding: 4px 10px; }
.key kbd.wide { width: 120px; }

/* ---------- privacy: the house at dusk, words safe inside ---------- */
.privacy { padding: 72px 16px 8px; }
.privacy-in {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 56px;
  padding: 56px 64px;
  border-radius: 28px;
  background: var(--dusk);
  color: var(--dusk-ink);
}
.privacy .eyebrow { color: var(--dusk-soft); margin-bottom: 14px; }
.privacy h2 { font-size: clamp(30px, 4vw, 42px); line-height: 1.3; }
.privacy .lede { margin-top: 18px; font-size: 18px; color: var(--dusk-soft); max-width: 30em; }
.home { width: 100%; height: auto; }
.home .moon { fill: #f4e7c8; }
.home .twinkle { fill: #f4e7c8; opacity: 0.8; }
.home .hill { fill: var(--dusk-hill); }
.home .wall { fill: #efdcc0; }
.home .roof { fill: var(--vermilion); }
.home .chimney { fill: #b9583a; }
.home .smoke { fill: none; stroke: rgba(244, 231, 200, 0.5); stroke-width: 4; stroke-linecap: round; }
.home .window { fill: #ffd98a; }
.home .inside { font-family: var(--serif); font-size: 17px; font-weight: 600; fill: #8a5a2e; }
.home .door { fill: #8f6a4c; }
.home .knob { fill: #f2c46d; }
.home .path { fill: color-mix(in srgb, #efdcc0 55%, var(--dusk-hill)); }
.home .sprout { fill: none; stroke: #a9bf92; stroke-width: 3; stroke-linecap: round; }

/* ---------- foot ---------- */
.foot {
  text-align: center;
  padding: 72px 16px calc(48px + env(safe-area-inset-bottom));
  color: var(--ink-soft);
  font-size: 15px;
  display: grid;
  justify-items: center;
  gap: 6px;
}
.sprig { width: 80px; height: 24px; margin-bottom: 10px; }
.sprig path { fill: none; stroke: var(--sage-deep); stroke-width: 2; stroke-linecap: round; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .privacy-in { grid-template-columns: 1fr; gap: 28px; padding: 40px 24px 44px; text-align: center; }
  .home { max-width: 340px; margin: 0 auto; }
  .privacy .lede { margin-left: auto; margin-right: auto; }
  .pages { grid-template-columns: 1fr; max-width: 460px; gap: 56px; }
}
@media (max-width: 560px) {
  .hero { padding-top: 48px; }
  .stage { height: 440px; }
  .sheet { top: 24px; padding: 26px 20px 64px; }
  /* keep the blocks in view: show the left part of the scene at the stage's own scale */
  .scene { right: auto; left: -70px; width: 943px; }
  .pages { padding-top: 64px; }
  .doc { font-size: 17px; }
  .item:nth-child(n+4) { display: none; }
  kbd.wide { width: 150px; }
  .keys ul { gap: 28px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
  .block, .bar, .key, .key kbd { transition: none; }
}

/* 404 */
.lost { min-height: 80vh; display: grid; align-content: center; }

/* /update: the same block mark the app's update dialog shows */
.update .mark { justify-self: center; margin-bottom: 28px; }
.update .mark img { display: block; width: 72px; height: 72px; }
.update .lede { font-variant-numeric: tabular-nums; }
.update > * { transition: opacity 0.2s ease; }
.update.checking #update-cta { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
button.block { border: 0; cursor: pointer; }
.quiet { color: var(--ink-soft); font-size: 15px; text-underline-offset: 3px; }
.quiet:hover { color: var(--ink); }

/* ---------- phone: hand the download over to the Mac ---------- */
/* a touch screen without hover is a phone or tablet: Engu cannot be installed there */
.on-phone { display: none; }
@media (hover: none) and (pointer: coarse) {
  .on-computer { display: none; }
  .on-phone { display: grid; }
}
button.block { border: 0; cursor: pointer; }
button.quiet { background: none; border: 0; padding: 4px 8px; font: inherit; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
/* WeChat's browser can neither download a calendar file nor share: say how to send it to the computer */
.wechat-hint { max-width: 20em; margin: 0 auto; font-size: 17px; text-wrap: balance; }

/* ---------- which computer (platform.js) ---------- */
/* Windows sees the Windows download once there is one; until then the Mac page, with a note in
   place of the button. While the release record loads, the space is kept but nothing is shown. */
:root:not([data-os="windows"][data-windows="ready"]) .win { display: none; }
:root[data-os="windows"][data-windows="ready"] .mac { display: none; }
:root:not([data-os="windows"][data-windows="soon"]) .win-soon { display: none; }
:root[data-os="windows"][data-windows="soon"] .mac-cta { display: none; }
:root[data-os="windows"][data-windows="pending"] :is(.hero .eyebrow, .hero .cta, .bar-download) { visibility: hidden; }
:root:not([data-os="windows"]) .win-key, :root[data-os="windows"] .mac-key { display: none; }
/* a phone hands the link to "the Mac", or to "the computer" once Windows is out too */
:root:not([data-windows="ready"]) .any-computer, :root[data-windows="ready"] .one-computer { display: none; }
:root[data-windows="pending"] #handoff { visibility: hidden; }
/* a block not yet painted: same shape as the download button, nothing to press */
.block.idle,
.block.idle:hover {
  background: var(--paper-deep);
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--line);
  transform: none;
  cursor: default;
}
