/* Tally Steps — tallysteps.com
 *
 * The app's tokens, transcribed. Greyscale throughout: no colour anywhere, and
 * every mark is text or a stroke. The one deliberate departure is that the site
 * follows the visitor's system appearance the way the app does, rather than
 * committing to paper.
 */

:root {
  /* Dark is the default, matching the App Store set. `prefers-color-scheme:
     light` opts back out, and the toggle beats both. */
  --paper: #0d0d0c;
  --raised: #131312;
  --ink: #f5f5f2;
  --ink-2: #77776f;
  --ink-3: #77776f;
  --ink-4: #66665f;
  --rule: #26261f;
  --track: #26261f;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;

  --page: min(1040px, 100% - 3rem);
  --step: clamp(3.5rem, 9vw, 7rem);
}

@media (prefers-color-scheme: light) {
  :root {
    --paper: #ffffff;
    --raised: #f6f6f4;
    --ink: #111111;
    --ink-2: #6f6f6b;
    --ink-3: #9a9a96;
    --ink-4: #b6b6b1;
    --rule: #dededa;
    --track: #ececea;
  }
}

/* The toggle wins over the system in both directions. */
:root[data-theme="light"] {
  --paper: #ffffff;
  --raised: #f6f6f4;
  --ink: #111111;
  --ink-2: #6f6f6b;
  --ink-3: #9a9a96;
  --ink-4: #b6b6b1;
  --rule: #dededa;
  --track: #ececea;
}

:root[data-theme="dark"] {
  --paper: #0d0d0c;
  --raised: #131312;
  --ink: #f5f5f2;
  --ink-2: #77776f;
  --ink-3: #77776f;
  --ink-4: #66665f;
  --rule: #26261f;
  --track: #26261f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

.wrap { width: var(--page); margin-inline: auto; }

/* Wider than the reading column, for anything where the image is the point. */
.wrap.wide { width: min(1400px, 100% - 3rem); }

/* Every label in the design is uppercase mono with wide tracking. */
.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.numeral {
  font-variant-numeric: tabular-nums;
  font-weight: 200;
  letter-spacing: -0.04em;
}

a { color: inherit; }

/* Header ------------------------------------------------------------------ */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--rule);
}

header .wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 60px;
}

.wordmark {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  margin-right: auto;
}

nav { display: flex; gap: 1.5rem; align-items: center; }

nav a {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.2s;
}

nav a:hover { color: var(--ink); }

@media (max-width: 620px) {
  nav a[data-optional] { display: none; }
}

/* The theme switch is a stroke, like everything else. */
.theme {
  width: 30px;
  height: 30px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
}

.theme:hover { border-color: var(--ink-3); }
.theme svg { width: 14px; height: 14px; }

/* Hero -------------------------------------------------------------------- */

.hero {
  padding: var(--step) 0 calc(var(--step) * 0.7);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
}

h1 {
  font-size: clamp(2.75rem, 7.6vw, 5.5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 0.96;
  margin: 0.75rem 0 1.5rem;
}

.lede {
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 46ch;
  margin: 0 0 2rem;
}

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.9rem 1.4rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.82; }

.btn.ghost {
  background: none;
  color: var(--ink);
  border-color: var(--rule);
}

.btn.ghost:hover { border-color: var(--ink); opacity: 1; }

/* Hero screenshot --------------------------------------------------------- */

.hero-shot { display: grid; place-items: center; }

.hero-shot img {
  width: clamp(240px, 30vw, 320px);
  height: auto;
  display: block;
  border-radius: 34px;
  border: 1px solid var(--rule);
  box-shadow: 0 30px 70px -34px rgb(0 0 0 / 0.6);
}

/* Sections ---------------------------------------------------------------- */

section { padding: var(--step) 0; border-top: 1px solid var(--rule); }

.section-head { max-width: 52ch; margin-bottom: 3rem; }

h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0.6rem 0 0.9rem;
}

.section-head p { color: var(--ink-2); line-height: 1.65; margin: 0; }

/* Screens ----------------------------------------------------------------- */

.screens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
}

@media (min-width: 760px) {
  /* Two across, and it stays two. Four across a 1400px page leaves each phone
     around 310px — a thumbnail of a thumbnail, when the app is mostly one large
     numeral. Two lets each one be about a third larger. */
  .screens { grid-template-columns: repeat(2, 1fr); }
}

.screen { text-align: center; }

.screen button {
  all: unset;
  display: block;
  width: 100%;
  cursor: zoom-in;
  border-radius: 30px;
}

.screen button:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

.screen img {
  width: 100%;
  /* Capped so a very wide window does not produce a screenshot taller than the
     screen looking at it — the limit here is vertical, not horizontal. */
  max-width: 440px;
  margin-inline: auto;
  height: auto;
  border-radius: 30px;
  border: 1px solid var(--rule);
  background: var(--raised);
  display: block;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.screen:hover img { transform: translateY(-8px); }

.screen figcaption {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Feature rows ------------------------------------------------------------ */

.rows { display: grid; gap: 0; }

.row {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 1.5rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}

.row:first-child { border-top: 1px solid var(--rule); }

.row-index {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  padding-top: 0.35rem;
}

.row h3 {
  margin: 0 0 0.4rem;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.row p { margin: 0; color: var(--ink-2); line-height: 1.6; max-width: 58ch; }

/* Watch ------------------------------------------------------------------- */

.watch {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
  align-items: center;
}

.watch img {
  width: 100%;
  max-width: 190px;
  height: auto;
  border-radius: 30px;
  display: block;
  margin-inline: auto;
  border: 1px solid var(--rule);
}

/* Prose (privacy, support) ------------------------------------------------ */

.prose { max-width: 68ch; padding: var(--step) 0; }
.prose h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 0.5rem; }
.prose h2 { font-size: 1.25rem; font-weight: 500; margin: 2.75rem 0 0.75rem; letter-spacing: -0.01em; }
.prose p, .prose li { color: var(--ink-2); line-height: 1.7; }
.prose strong { color: var(--ink); font-weight: 500; }
.prose ul { padding-left: 1.1rem; }
.prose li { margin-bottom: 0.5rem; }
.prose a { color: var(--ink); text-underline-offset: 3px; }

.updated {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* Footer ------------------------------------------------------------------ */

footer { border-top: 1px solid var(--rule); padding: 3rem 0 4rem; }

footer .wrap {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

footer a {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-decoration: none;
}

footer a:hover { color: var(--ink); }

.footer-note {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}

/* Reveal on scroll -------------------------------------------------------- */

/* Scoped to .js, which the script adds to <html> on load. Without JavaScript —
   or if it throws before the observer is wired — everything stays visible, which
   is the only acceptable default for content hidden by an animation. */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.js .reveal.seen { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
}

/* Compare — drag between light and dark ------------------------------------ */

.compare {
  position: relative;
  max-width: 420px;
  margin-inline: auto;
  aspect-ratio: 1320 / 2868;
  border-radius: 34px;
  overflow: hidden;
  border: 1px solid var(--rule);
  touch-action: none;
  cursor: ew-resize;
  user-select: none;
}

.compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The top image is revealed by a clip, so both stay pixel-aligned. */
.compare .over { clip-path: inset(0 0 0 var(--split, 50%)); }

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  background: var(--ink);
  transform: translateX(-1px);
  pointer-events: none;
}

.compare-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.compare-tags {
  display: flex;
  justify-content: space-between;
  max-width: 420px;
  margin: 1rem auto 0;
}

/* Heatmap ----------------------------------------------------------------- */

.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-width: 420px;
}

.heat button {
  all: unset;
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: outline-color 0.15s;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.heat button:hover,
.heat button[aria-pressed="true"] { outline-color: var(--ink); }

.heat button:focus-visible { outline-color: var(--ink); }

.heat-readout {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  padding-left: clamp(0rem, 4vw, 3rem);
}

.heat-wrap {
  display: grid;
  grid-template-columns: minmax(0, 420px) 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

@media (max-width: 700px) {
  .heat-wrap { grid-template-columns: 1fr; }
  .heat-readout { padding-left: 0; }
}

.heat-count { font-size: clamp(2.25rem, 6vw, 3.25rem); line-height: 1; }

.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 420px;
  margin-top: 1rem;
}

.heat-legend .bar {
  flex: 1;
  height: 6px;
  background: linear-gradient(to right, var(--track), var(--ink));
}

/* Widget switcher --------------------------------------------------------- */

.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 2rem; }

.tab {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  border: 1px solid var(--rule);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { border-color: var(--ink-3); color: var(--ink); }

.tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.widget-stage {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 2.5rem;
  border: 1px solid var(--rule);
  background: var(--raised);
  border-radius: 20px;
}

.widget-stage img {
  max-width: 100%;
  height: auto;
  display: block;
  animation: settle 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes settle {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* Lightbox ---------------------------------------------------------------- */

dialog.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
}

dialog.lightbox::backdrop {
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
}

dialog.lightbox img {
  max-width: min(92vw, 460px);
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 34px;
  border: 1px solid var(--rule);
  display: block;
  cursor: zoom-out;
}

/* Background grid --------------------------------------------------------- */

/* A faint ruled grid, faded at the edges by a fixed vignette so it never reaches
   the corners. It sits above the body's background and below everything else. */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.55;
  -webkit-mask-image: radial-gradient(80% 70% at 50% 30%, #000 20%, transparent 80%);
  mask-image: radial-gradient(80% 70% at 50% 30%, #000 20%, transparent 80%);
}

/* A soft patch that follows the pointer. Moved with `transform` rather than by
   repositioning a mask, so it stays on the compositor and does not repaint the
   grid on every frame. Greyscale, like everything else here. */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 600px;
  height: 600px;
  z-index: 0;
  pointer-events: none;
  margin: -300px 0 0 -300px;
  background: radial-gradient(circle, color-mix(in srgb, var(--ink) 9%, transparent), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
  will-change: transform;
}

.cursor-glow.on { opacity: 1; }

/* No pointer to follow, and nothing that trails a cursor belongs in a reduced
   motion setting. */
@media (hover: none), (prefers-reduced-motion: reduce) {
  .cursor-glow { display: none; }
}

/* Content rides above both layers. */
main, footer { position: relative; z-index: 1; }
