/* Heft launch site. Tokens from docs/site/BRIEF.md. */

:root {
  --paper: #f5f0e6; /* page */
  --paper-raised: #fbf8f2; /* cards, app frame */
  --paper-deep: #ebe3d3; /* alternate section band */
  --ink: #1f2d27; /* pine ink, body text */
  --ink-muted: #5a6159;
  --line: #d9cfbc; /* hairlines, contour lines */
  --line-strong: #b9ac93;
  --ember: #b4471f; /* primary action */
  --ember-ink: #fffaf3; /* text on ember */
  --good: #2f6b3a; /* lighter deltas */
  --warn: #9a5a00; /* heavier deltas */
  --focus: #2c6e8f;
  --chart-1: #2f5d50;
  --chart-2: #c0582b;
  --chart-3: #a87a12;
  --chart-4: #3f6f9a;
  --chart-5: #7a4e7e;
  --chart-6: #5f8a2e;
  --chart-7: #9c3b4a;
  --chart-8: #6e6253;

  --shadow: 0 1px 2px rgb(31 45 39 / 0.08), 0 12px 32px rgb(31 45 39 / 0.1);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --content: 72rem;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --section-gap: clamp(5rem, 12vw, 9rem);
  --radius: 14px;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a17;
    --paper-raised: #1c2420;
    --paper-deep: #10150f;
    --ink: #ece4d4;
    --ink-muted: #a9a596;
    --line: #33403a;
    --line-strong: #4a5a52;
    --ember: #e8743f;
    --ember-ink: #1a120d;
    --good: #7cc58a;
    --warn: #e6b14a;
    --focus: #7fc3d9;
    --chart-1: #6fb3a0;
    --chart-2: #ef8a5a;
    --chart-3: #e3bf5c;
    --chart-4: #7fa8d6;
    --chart-5: #b993c0;
    --chart-6: #a6c46a;
    --chart-7: #e07a8a;
    --chart-8: #b8a990;

    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
  }
}

/* Base */

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

html {
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 50;
  line-height: 1.08;
  text-wrap: balance;
}

p {
  margin: 0;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#contours path {
  vector-effect: non-scaling-stroke;
}

.peak {
  stroke: var(--ember);
}

.weight,
.eyebrow,
.step-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  margin-bottom: 1rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow span {
  white-space: nowrap;
}

.section-title {
  max-width: 22ch;
  font-size: clamp(1.9rem, 4vw, 3rem);
  letter-spacing: -0.015em;
}

.micro {
  color: var(--ink-muted);
  font-size: 0.875rem;
}

main > section + section {
  margin-top: var(--section-gap);
}

/* Links and buttons */

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
.tile-b:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 1.75rem;
  border-radius: 999px;
  background: var(--ember);
  color: var(--ember-ink);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.08);
  transition:
    transform 160ms var(--ease),
    opacity 160ms var(--ease);
}

.cta:hover {
  transform: translateY(-2px);
}

.cta:active {
  transform: translateY(0) scale(0.98);
  opacity: 0.9;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 160ms var(--ease);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.text-link,
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

.nav-link {
  text-decoration-color: transparent;
  font-weight: 400;
  color: var(--ink-muted);
}

.text-link:hover,
.nav-link:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.text-link:active,
.nav-link:active {
  opacity: 0.7;
}

/* Header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  text-decoration: none;
}

.brand:active {
  opacity: 0.7;
}

.mark {
  flex: none;
  color: var(--ink);
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  font-variation-settings: "SOFT" 50;
  letter-spacing: -0.01em;
}

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

@media (max-width: 30rem) {
  .nav-link {
    display: none;
  }
}

/* Contour motif */

.contour {
  position: absolute;
  z-index: -1;
  color: var(--line);
  opacity: 0.4;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .contour {
    opacity: 0.6;
  }
}

/* Hero */

.hero {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  overflow-clip-margin: 0;
  padding-top: clamp(2rem, 6vw, 5rem);
}

.contour-hero {
  top: -2rem;
  right: -18vw;
  width: max(46rem, 70vw);
  height: max(30rem, 46vw);
}

.hero-grid {
  display: grid;
  gap: 3.5rem;
  align-items: center;
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: 5fr 7fr;
    gap: 4rem;
  }
}

.hero h1 {
  font-size: clamp(2.6rem, 7vw, 5.25rem);
  letter-spacing: -0.025em;
  line-height: 1.02;
}

@media (min-width: 900px) {
  .hero h1 {
    font-size: clamp(2.6rem, 4.6vw, 4.25rem);
  }
}

.lede {
  margin-top: 1.5rem;
  max-width: 34rem;
  color: var(--ink-muted);
  font-size: 1.15rem;
}

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

.hero .micro {
  margin-top: 1rem;
}

/* The weigh-in card */

.weigh-card {
  margin: 0;
  justify-self: center;
  width: min(100%, 34rem);
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
  rotate: -1.5deg;
}

.card-title {
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--ink);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  font-variation-settings: "SOFT" 50;
}

.card-body {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 4vw, 2.5rem);
  margin-top: 1.5rem;
}

.donut {
  position: relative;
  flex: none;
  width: 220px;
  height: 220px;
}

.donut svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.donut circle {
  fill: none;
  stroke-width: 22;
}

.donut-track {
  stroke: var(--line);
  opacity: 0.5;
}

.seg {
  stroke: var(--c);
  stroke-dasharray: var(--len) 100;
  stroke-dashoffset: var(--off);
}

.donut-centre {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.donut-total {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "SOFT" 50;
  letter-spacing: -0.02em;
  line-height: 1;
}

.donut-label {
  margin-top: 0.35rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.totals {
  flex: 1;
  margin: 0;
  display: grid;
}

.totals div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.totals div:last-child {
  border-bottom: 0;
}

.totals dt {
  color: var(--ink-muted);
}

.totals dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
}

.accent {
  color: var(--ember);
}

@media (max-width: 640px) {
  .weigh-card {
    rotate: 0deg;
  }

  .card-body {
    flex-direction: column;
    align-items: stretch;
  }

  .donut {
    width: 180px;
    height: 180px;
    align-self: center;
  }

  .donut-total {
    font-size: 1.75rem;
  }

  .actions .cta {
    width: 100%;
  }
}

/* The problem */

.beat {
  max-width: calc(36rem + 2 * var(--gutter));
  text-align: center;
}

.beat-line {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-variation-settings: "SOFT" 50;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.beat-sub {
  margin-top: 1.5rem;
  color: var(--ink-muted);
}

/* How it works */

.steps-wrap {
  position: relative;
  margin-top: 3rem;
}

.steps {
  display: grid;
  gap: 2.75rem;
  margin: 0;
  padding: 0 0 0 2.25rem;
  list-style: none;
}

.step {
  position: relative;
}

.step-dot {
  position: absolute;
  top: 0.55rem;
  left: -2.25rem;
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.step-num {
  display: block;
  color: var(--line-strong);
  font-size: 2.75rem;
  font-weight: 500;
  line-height: 1;
}

.glyph {
  display: block;
  width: 32px;
  height: 32px;
  margin-block: 1.25rem 0.75rem;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.step h3,
.tile h3 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.step p {
  margin-top: 0.5rem;
  color: var(--ink-muted);
  max-width: 22rem;
}

.trail {
  position: absolute;
  overflow: visible;
}

.trail line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 1 1;
}

.trail-x {
  display: none;
}

.trail-y {
  top: 0.8rem;
  bottom: 0;
  left: 4px;
  width: 2px;
  height: calc(100% - 0.8rem);
}

@media (min-width: 900px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    padding: 2.5rem 0 0;
  }

  .step-dot {
    top: -2.5rem;
    left: 0;
    translate: 0 -4px;
  }

  .trail-x {
    display: block;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    translate: 0 -1px;
  }

  .trail-y {
    display: none;
  }
}

/* Features */

.bento {
  display: grid;
  gap: 1.25rem;
  margin-top: 3rem;
}

@media (min-width: 900px) {
  .bento {
    grid-template-columns: repeat(6, 1fr);
  }

  .tile-a {
    grid-column: 1 / 5;
    grid-row: 1;
  }

  .tile-b {
    grid-column: 5 / 7;
    grid-row: 1;
  }

  .tile-c {
    grid-column: 1 / 4;
    grid-row: 2;
  }

  .tile-d {
    grid-column: 4 / 7;
    grid-row: 2;
  }
}

.tile {
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
}

.tile p {
  margin-top: 0.6rem;
  color: var(--ink-muted);
}

.illo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 9.5rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  border-radius: 10px;
  background: var(--paper);
}

/* Tile A: the split bar */

.split-bar,
.split-labels {
  display: grid;
  grid-template-columns: 46.3fr 43.2fr minmax(4.25rem, 10.5fr);
  gap: 3px;
}

.split-bar {
  height: 2.25rem;
}

.band {
  border-radius: 4px;
}

.band-base {
  background: var(--chart-1);
}

.band-cons {
  background: var(--chart-3);
}

.band-worn {
  background: var(--chart-8);
}

.split-labels {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.split-labels > span {
  display: grid;
  line-height: 1.35;
}

.split-labels b {
  color: var(--ink-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

/* Tile B: units toggle */

.units {
  align-items: center;
  gap: 1rem;
}

.pill {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.pill-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--ink);
  transition: transform 240ms var(--ease);
}

.pill-opt {
  position: relative;
  padding: 0.3rem 0.9rem;
  text-align: center;
  transition: opacity 240ms var(--ease);
}

.pill-metric {
  color: var(--paper);
}

.pill-imperial {
  color: var(--ink-muted);
}

.units-figure {
  display: grid;
  font-size: 1.9rem;
  font-weight: 500;
}

.units-figure > span {
  grid-area: 1 / 1;
  text-align: center;
  transition: opacity 240ms var(--ease);
}

.fig-imperial {
  opacity: 0;
}

.tile-b:hover .pill-thumb,
.tile-b:focus-within .pill-thumb {
  transform: translateX(100%);
}

.tile-b:hover .pill-metric,
.tile-b:focus-within .pill-metric {
  color: var(--ink-muted);
}

.tile-b:hover .pill-imperial,
.tile-b:focus-within .pill-imperial {
  color: var(--paper);
}

.tile-b:hover .fig-metric,
.tile-b:focus-within .fig-metric {
  opacity: 0;
}

.tile-b:hover .fig-imperial,
.tile-b:focus-within .fig-imperial {
  opacity: 1;
}

/* Tile C: the compare table */

.diff table {
  width: 100%;
  max-width: 20rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.diff th {
  padding: 0.3rem 0;
  font-weight: 400;
  text-align: left;
}

.diff td {
  text-align: right;
}

.diff tfoot th,
.diff tfoot td {
  padding-top: 0.55rem;
  border-top: 1px solid var(--line-strong);
  font-weight: 600;
}

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

/* Tile D: notebook and padlock */

.lock {
  align-items: center;
  color: var(--ink);
}

.lock svg {
  width: 7.5rem;
  height: auto;
}

/* The real app */

.section-sub {
  margin-top: 1rem;
  max-width: 36rem;
  color: var(--ink-muted);
}

.frame {
  margin-top: 2.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}

.frame-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-bottom: 1px solid var(--line);
}

.dots {
  position: absolute;
  left: 14px;
  display: flex;
  gap: 6px;
}

.dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
}

.frame-label {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.frame iframe {
  display: block;
  width: 100%;
  height: min(80vh, 760px);
  border: 0;
  background: var(--paper);
}

@media (max-width: 600px) {
  .frame {
    border-radius: 28px;
  }

  .frame-bar {
    display: none;
  }

  .frame iframe {
    height: 640px;
  }
}

.tries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 1.5rem 0 0.75rem;
  padding: 0;
  list-style: none;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.tries li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tries li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ember);
}

/* Closing call to action */

.closing {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding-block: clamp(5rem, 12vw, 8rem);
  background: var(--paper-deep);
}

.contour-closing {
  top: 50%;
  left: 50%;
  width: max(80rem, 130vw);
  height: max(52rem, 85vw);
  margin: calc(max(52rem, 85vw) / -2) 0 0 calc(max(80rem, 130vw) / -2);
}

.closing-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.closing h2 {
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  letter-spacing: -0.025em;
}

.closing-inner .cta {
  margin-top: 0.75rem;
}

@media (max-width: 640px) {
  .closing-inner .cta {
    width: 100%;
  }
}

/* Footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 2rem 2.5rem;
  font-size: 0.95rem;
  /* The hairline spans the content width, not the side padding. */
  background: linear-gradient(var(--line), var(--line)) top center / calc(100% - 2 * var(--gutter))
    1px no-repeat;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.footer-credit {
  color: var(--ink-muted);
}

/* Motion: only when main.js has checked prefers-reduced-motion and added .motion. */

@media (prefers-reduced-motion: no-preference) {
  .motion .seg {
    animation: seg-draw 600ms var(--ease) both;
    animation-delay: calc(var(--i) * 90ms);
  }

  .motion .weigh-card {
    animation: card-in 600ms var(--ease) 200ms both;
  }

  .motion .reveal {
    opacity: 0;
    translate: 0 12px;
    transition:
      opacity 600ms var(--ease),
      translate 600ms var(--ease);
    transition-delay: calc(var(--i, 0) * 80ms);
  }

  .motion .frame.reveal {
    translate: 0 24px;
  }

  .motion .reveal.is-in {
    opacity: 1;
    translate: 0 0;
  }

  .motion [data-trail] .trail line {
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 800ms var(--ease);
  }

  .motion [data-trail].is-in .trail line {
    stroke-dashoffset: 0;
  }

  .motion .contour-closing {
    animation: drift 60s ease-in-out infinite alternate paused;
  }

  .motion .closing.in-view .contour-closing {
    animation-play-state: running;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0ms !important;
  }
}

@keyframes seg-draw {
  from {
    stroke-dasharray: 0 100;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

@keyframes drift {
  to {
    translate: 20px -10px;
  }
}
