/* Big Count site. Palette is the icon's: the board's near-black, amber
   chalk and chalk white, on the app's warm page and ink.
   scripts/generate-og-image.sh carries the same colours. */
:root {
  --board: #1d1d24;
  --board-deep: #0e0e12;
  --amber: #f7b23b;
  --amber-deep: #e59f22;
  --chalk: #f4f2ec;
  --wash: #ece8df;
  --ink: #14141a;
  --muted: #5c5a55;
  --paper: #f6f4ef;
  --line: #ddd8cc;
  --chalk-dim: #b4b1a8;
  --chalk-line: rgba(244, 242, 236, 0.16);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  /* A word wider than the page breaks rather than widening it: a heading at
     a phone's largest text size, an address with no spaces in it. */
  overflow-wrap: break-word;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 24px; }
a { color: var(--board-deep); }

/* ---- header ---- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; row-gap: 10px;
  padding: 14px 24px;
  background: var(--board);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand .name { min-width: 0; }
.brand .mark { border-radius: 8px; display: block; }
.nav .brand .mark { border: 1px solid rgba(255, 255, 255, 0.35); }
.brand .name { font-size: 1.25rem; font-weight: 700; color: var(--chalk); }
.nav-links {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px 20px; margin-left: auto;
}
.nav-links a {
  color: var(--chalk); text-decoration: none;
  font-size: 0.95rem; opacity: 0.92;
}
.nav-links a:hover { opacity: 1; text-decoration: underline; }
.nav-links .nav-cta {
  background: var(--amber); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; font-weight: 600; opacity: 1;
}
.nav-links .nav-cta:hover { text-decoration: none; background: var(--amber-deep); }

.lead { font-size: 1.1rem; color: var(--muted); margin-bottom: 28px; max-width: 34rem; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.open-btn {
  display: inline-flex; align-items: center; min-height: 48px;
  background: var(--amber); color: var(--ink); text-decoration: none;
  padding: 10px 24px; border-radius: 12px;
  font-size: 1.05rem; font-weight: 600;
  transition: background 0.15s ease;
}
.open-btn:hover { background: var(--amber-deep); }
.cta-note { margin-top: 14px; font-size: 0.92rem; color: var(--muted); }

/* ---- sections ---- */
main .wrap:not(.hero) { padding-top: 24px; padding-bottom: 24px; }
h2 { font-size: 1.7rem; margin-bottom: 10px; }

.points { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.box {
  background: var(--wash); border-radius: 20px;
  padding: 36px 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.box.wide { grid-column: 1 / -1; }
.box h2 {
  font-size: 2.1rem; line-height: 1.1; letter-spacing: -0.01em;
  color: var(--board-deep); margin-bottom: 8px; text-wrap: balance;
}
.box p { font-size: 1.1rem; color: var(--ink); max-width: 560px; }
.soon {
  align-self: flex-start;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--board-deep); border: 1px solid var(--board-deep);
  border-radius: 999px; padding: 2px 10px; margin-bottom: 12px;
}

.get h2 { font-size: 1.4rem; }
.get p { color: var(--muted); max-width: 40rem; }
.get .actions { margin-top: 16px; }

/* ---- the home page: the icon's board ----
   No cards: a count to press, drawn as a tally,
   then what the app does as a ledger numbered in tally marks. tally.js
   draws every mark. Sizes that must fit a 320px phone at 3.1x text are
   capped in vw (test/site/narrow_layout.test.cjs). */
.defs { position: absolute; }
/* Light and dark, by the system's setting as the app's are: ink on the
   app's paper, or chalk on the icon's board. Every colour the home page
   uses is one of these. */
body.board {
  --ground: var(--paper); --mark: var(--ink); --dim: var(--muted);
  --rule: var(--line); --count: var(--ink); --strike: #b47500;
  --accent-text: #8a5a00;
  --minus-face: #e3ded2; --minus-edge: #b9b3a4;
  background-color: var(--ground); color: var(--mark);
}
@media (prefers-color-scheme: dark) {
  body.board {
    --ground: var(--board); --mark: var(--chalk); --dim: var(--chalk-dim);
    --rule: var(--chalk-line); --count: var(--amber); --strike: var(--amber);
    --accent-text: var(--amber);
    --minus-face: #3a3a45; --minus-edge: #08080b;
    /* A faint smudge of old chalk, as on the icon. */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1024' height='1024'%3E%3Cfilter id='s' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.004 0.012' numOctaves='4' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2.4 0 0 0 -0.9'/%3E%3C/filter%3E%3Crect width='1024' height='1024' filter='url(%23s)' opacity='0.035'/%3E%3C/svg%3E");
  }
}
.board .brand .name { color: var(--mark); }
.board .brand .mark { border-color: var(--rule); }
.board a { color: var(--mark); }
.board .wrap { max-width: 1040px; }
.board .nav { background: none; padding-top: 20px; }
.board .nav-links a { text-decoration: underline; text-underline-offset: 4px; }
.board .lead, .board .cta-note, .board .entry p { color: var(--dim); }
.board .open-btn { color: var(--ink); }

.board .hero { padding-top: 40px; padding-bottom: 72px; }
.hero h1 {
  font-size: min(4.6rem, 11vw); line-height: 1.02; font-weight: 800;
  letter-spacing: -0.035em; max-width: 13ch; text-wrap: balance;
}

.counting {
  /* The keys sit under the number and the marks fill the space beside the
     two, so a tally that wraps onto another row never moves a key out from
     under the finger pressing it: the second row is the one that gives. */
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  align-items: start; gap: 28px 48px;
  margin: 56px 0 24px;
}
.big {
  /* One line, whatever it reaches: tally.js says how many characters it
     is (--n), and past two the number is drawn smaller, not broken. */
  font-size: min(15rem, 34vw, calc(75vw / var(--n, 2))); line-height: 0.82; font-weight: 800;
  white-space: nowrap; overflow-wrap: normal;
  letter-spacing: -0.05em; font-variant-numeric: tabular-nums;
  color: var(--count);
}
.marks {
  grid-column: 2; grid-row: 1 / span 2;
  display: flex; flex-wrap: wrap; align-content: start;
  gap: 16px 22px; min-height: min(6rem, 15vw);
}
.five { width: min(6rem, 15vw); height: min(6rem, 15vw); display: block; overflow: visible; }
.five path { fill: none; stroke-linecap: round; stroke: var(--mark); }
.five path.strike { stroke: var(--strike); }
.five path.new { stroke-dasharray: 1; animation: chalk-stroke 0.16s ease-out; }
@keyframes chalk-stroke { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* The app's keys: a face standing proud of an edge, which a press closes.
   Fixed in px, as the app's are in dp, so text size never moves them. */
.keys { grid-column: 1; grid-row: 2; display: flex; gap: 12px; }
.keys[hidden] { display: none; }
.key {
  --depth: 6px;
  font: inherit; font-size: 30px; font-weight: 700; line-height: 1;
  height: 62px; border: 0; border-radius: 18px; cursor: pointer;
  margin-bottom: var(--depth);
  box-shadow: 0 var(--depth) 0 var(--edge);
  background: var(--face); color: var(--on);
  transition: transform 0.06s ease-out, box-shadow 0.06s ease-out;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
.key:active, .key.down { transform: translateY(var(--depth)); box-shadow: 0 0 0 var(--edge); }
.key:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; }
.key.plus { --face: var(--amber); --edge: #a56d0c; --on: var(--ink); flex: 0 0 240px; }
.key.minus { --face: var(--minus-face); --edge: var(--minus-edge); --on: var(--mark); flex: 0 0 76px; }

.intro { margin-top: 36px; max-width: 40rem; }
.intro .lead { font-size: 1.3rem; line-height: 1.45; margin: 0 0 24px; max-width: none; color: var(--mark); }
.intro .actions > a { min-height: 54px; box-sizing: border-box; }

/* What it does, numbered as a tally: one mark, two, and the fifth struck. */
.board main .ledger { padding-top: 0; padding-bottom: 40px; }
.entry {
  display: grid; grid-template-columns: min(8.5rem, 20vw) minmax(0, 1fr);
  gap: 12px 32px; align-items: start;
  padding: 36px 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 16px;
}
.entry .n { display: block; }
.entry .five { width: min(3.6rem, 12vw); height: min(3.6rem, 12vw); }
.entry h2 {
  font-size: min(2.4rem, 8vw); line-height: 1.08; font-weight: 800;
  letter-spacing: -0.025em; margin-bottom: 10px; text-wrap: balance;
}
.entry p { font-size: 1.15rem; max-width: 34rem; }
.entry .actions { margin-top: 22px; }
.board .soon {
  display: inline-block; vertical-align: middle;
  border: 0; padding: 0; margin: 0 0 0 0.4em;
  font-size: 0.8rem; letter-spacing: 0.12em; color: var(--count);
}

.board footer { background: none; color: var(--mark); margin-top: 0; border-top: 1px solid var(--rule); }

@media (max-width: 720px) {
  .board .hero { padding-top: 20px; padding-bottom: 48px; }
  /* On a phone the marks go under the keys, and grow downwards. */
  .counting { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 22px; margin: 36px 0 44px; }
  .big { font-size: min(15rem, 42vw, calc(135vw / var(--n, 2))); }
  .marks { grid-column: 1; grid-row: 3; min-height: 0; }
  .key.plus { flex: 1 1 auto; }
  .intro .lead { font-size: 1.15rem; }
  .entry { grid-template-columns: minmax(0, 1fr); padding: 28px 0; }
  .entry p { font-size: 1.05rem; }
  .board .soon { display: block; margin: 10px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .five path.new { animation: none; }
  .key { transition: none; }
}

/* ---- not found ---- */
.notfound { padding-top: 72px; padding-bottom: 72px; max-width: 640px; }
.notfound h1 { font-size: 2.2rem; line-height: 1.2; margin-bottom: 12px; }
.notfound p { color: var(--muted); margin-bottom: 24px; }
/* 404.html's script sets this on a share link, before the body is drawn. */
.opening-count .notfound-only { display: none; }
html:not(.opening-count) .opening-only { display: none; }

/* ---- a shared count (c/index.html) ---- */
main .wrap.shared { padding-top: 56px; padding-bottom: 32px; max-width: 640px; }
.shared h1 {
  font-size: 2.2rem; line-height: 1.2; letter-spacing: -0.02em;
  margin-bottom: 12px; text-wrap: balance;
}
.stores { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; }
.stores[hidden] { display: none; }
/* Shaped like the stores' own badges (black, a thin grey rim, the logo and
   two lines), as Japa+'s are: drawn, not Google's badge artwork. */
.store-btn, .board .store-btn {
  display: inline-flex; align-items: center; gap: 12px;
  background: #000; color: #fff; text-decoration: none;
  border: 1px solid #a6a6a6; border-radius: 10px;
  padding: 8px 18px 8px 14px; max-width: 100%;
}
.store-btn:hover, .store-btn:focus-visible { background: #222; }
.store-btn svg { width: 26px; height: 26px; flex: none; }
.store-btn span { display: flex; flex-direction: column; line-height: 1.2; font-size: 1.1rem; font-weight: 600; }
.store-btn small { font-size: 0.7rem; font-weight: 400; letter-spacing: 0.02em; }

/* ---- footer ---- */
footer { background: var(--board); color: var(--chalk); margin-top: 32px; }
footer .wrap {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  padding-top: 20px; padding-bottom: 20px;
  font-size: 0.9rem;
}
footer a { color: var(--chalk); }
/* An address is one long word: let it break rather than widen a phone's page. */
a[href^="mailto:"] { overflow-wrap: anywhere; }
footer .name { font-size: 1rem; }
footer .brand .mark { border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 6px; }

/* ---- small screens ---- */
@media (max-width: 720px) {
  .points { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .box { padding: 28px 24px; }
  .box h2 { font-size: 1.7rem; }
  .box p { font-size: 1.05rem; }
  .nav-links { gap: 6px 14px; }
  .nav-links a { font-size: 0.9rem; }
}

/* ---- legal pages ---- */
.legal { padding-top: 40px; padding-bottom: 40px; max-width: 760px; }
.legal h1 { font-size: 1.9rem; margin-bottom: 8px; }
.legal h2 { margin-top: 32px; }
.legal h3 { font-size: 1.2rem; margin-top: 24px; margin-bottom: 6px; }
.legal p { margin-bottom: 12px; }
.legal p, .legal li { font-size: 0.97rem; }
.legal ul { padding-left: 24px; margin: 10px 0 18px; }
.legal li { margin-bottom: 8px; }

/* ---- analytics notice (analytics.js) ----
   Informs, does not ask: OK or ignoring it leaves Google Analytics on, Turn
   off stops it. Fixed to the bottom, and analytics.js pads the body by its
   height so it never covers the footer. It appears once, on load, and never
   moves or hides on focus or mid-press: a bar that changes between a finger
   going down and coming up hands the release to whatever is under it. */
.analytics-notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px -12px rgba(20, 20, 26, 0.35);
  font-size: 0.9rem;
  line-height: 1.4;
}
.analytics-notice p { margin: 0; max-width: 40rem; }
.analytics-notice a { color: var(--board-deep); }
/* At 3.1x text on a 320px phone the two buttons do not fit side by side, and
   one with a rem of padding each side barely fits alone: they stack, and the
   padding stops growing with the text (test/site/narrow_layout.test.cjs). */
.analytics-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; max-width: 100%; }
.analytics-notice button,
#analytics-switch button {
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  padding: 0.4rem min(1rem, 5vw);
  max-width: 100%;
  border-radius: 7px;
  border: 1px solid var(--board-deep);
  background: transparent;
  color: var(--board-deep);
  cursor: pointer;
}
.analytics-notice .analytics-ok { background: var(--board-deep); color: #fff; }
#analytics-switch {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  margin: 10px 0 18px; padding: 12px 16px;
  background: var(--wash); border: 1px solid var(--line); border-radius: 12px;
}
#analytics-switch[hidden] { display: none; }
#analytics-switch .analytics-state { font-size: 0.97rem; }
