:root {
  --bg: #fbfaf7;
  --fg: #16151a;
  --muted: #6b6870;
  --accent: #ff5a36;
  --accent-fg: #ffffff;
  --line: #e7e4de;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111014;
    --fg: #f4f2ee;
    --muted: #9c98a3;
    --accent: #ff6a48;
    --accent-fg: #111014;
    --line: #2a2830;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.btn {
  display: inline-block;
  padding: 0.95rem 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font: 600 1.125rem/1 inherit;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
}

/* ---------- Landing ---------- */

.landing {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem 16px;
  text-align: center;
}
.landing h1 {
  font-size: clamp(2.5rem, 9vw, 5rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}
.landing p {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 32ch;
  margin: 0 auto 2rem;
  line-height: 1.5;
  text-wrap: balance; /* no one-word last lines */
}
.landing .demo {
  font-size: clamp(5rem, 24vw, 9rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

.ctas {
  display: flex;
  flex-wrap: wrap; /* stacks only if the screen is too narrow for both */
  justify-content: center;
  align-items: center;
  gap: 1rem 1.5rem;
}
.link-cta {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  padding: 0.25rem 0.1rem;
}
.link-cta:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.link-cta:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; border-radius: 4px; }
.link-cta[hidden] { display: none; }

/* ---------- Counter ---------- */

.counter-page {
  height: 100vh;
  height: 100dvh; /* real screen height, incl. installed iOS app */
  display: flex;
  flex-direction: column;
  overscroll-behavior: none; /* no pull-to-refresh / bounce */
}

.counter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(8px, env(safe-area-inset-top)) 8px 0;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { color: var(--fg); }
.icon-btn:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }

.menu {
  /* reset UA popover centering, pin under the hamburger */
  position: fixed;
  inset: auto;
  top: calc(max(8px, env(safe-area-inset-top)) + 52px);
  right: 8px;
  margin: 0;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.14);
}
.menu::backdrop { background: transparent; }

.menu-item {
  display: block;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--line); outline: none; }

.pad {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  /* The key line: take over all touch gestures (no scroll, no zoom, no double-tap zoom) */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  outline: none;
  padding-bottom: env(safe-area-inset-bottom);
}

.count {
  --chars: 1;
  display: block;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  /* tabular digits are ~0.6em wide, so 150vw / chars keeps it inside ~90vw */
  font-size: min(calc(150vw / max(var(--chars), 1)), 55vh);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Brand fonts (preview) ---------- */
@font-face { font-family: "Doto"; font-weight: 700; font-display: swap; src: url("/fonts/doto-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Doto"; font-weight: 800; font-display: swap; src: url("/fonts/doto-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Doto"; font-weight: 900; font-display: swap; src: url("/fonts/doto-latin-900-normal.woff2") format("woff2"); }
@font-face { font-family: "DSEG7"; font-weight: 700; font-display: block; src: url("/fonts/DSEG7Classic-Bold.woff2") format("woff2"); }

:root { --brand: "Doto", ui-monospace, monospace; --digits: "DSEG7", ui-monospace, monospace; }

.landing h1 { font-family: var(--brand); font-weight: 900; letter-spacing: 0; }
/* CTAs: Doto is wide, so size the pair fluidly to always fit one row.
   The whole row is ~24em wide, so (viewport - 32px gutters) / 24 never overflows. */
.landing .ctas {
  flex-wrap: nowrap;
  column-gap: 0.95em;
  font-size: min(1.125rem, calc((100vw - 32px) / 24));
}
.landing .btn,
.landing .link-cta {
  font-family: var(--brand);
  font-weight: 900;
  font-size: 1em;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.landing .btn { padding: max(0.95rem, 0.9em) 1.2em; } /* keeps a 44px+ tap target */
.landing .link-cta { padding-inline: 0; }

/* Seven-segment number with unlit "8" segments behind it */
.seg { font-family: var(--digits); font-weight: 700; letter-spacing: 0.04em; display: inline-grid; }
.seg > * { grid-area: 1 / 1; text-align: right; }
.seg-ghost { opacity: 0.06; } /* unlit segments: half as visible as before for more contrast */
.landing .demo.seg { font-size: clamp(4.5rem, 22vw, 8rem); margin-bottom: 2rem; }

/* Counter number in DSEG7. Digits are ~0.86em wide incl. spacing,
   so 82vw / chars keeps any length inside the screen. */
.count.seg {
  font-size: min(calc(82vw / max(var(--chars), 1)), 40vh);
  letter-spacing: 0.04em;
}
.count.seg .seg-lit { display: block; }


/* "@taptocount.com" home link in the counter header */
.counter-bar .brand-link { font-family: var(--brand); font-weight: 800; }

/* ---------- Landing footer ---------- */
/* Body is a full-screen flex column: content centered in the space that's
   left, footer pinned to the bottom. 100dvh is the real screen height
   (including in an installed iOS app, where 100% can come up short);
   100vh is the fallback for older browsers. */
.landing-page {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
}
.landing-page .landing { flex: 1 0 auto; min-height: 0; } /* grid + place-items centers it */
.site-footer {
  margin-top: auto;
  padding: 1rem 16px max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-family: var(--brand);
  font-weight: 800;
  font-size: 0.95rem;
}
.site-footer .handle { text-decoration: none; }
.site-footer .handle:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
