/* Hops · Meadow: cream, forest green, carrot orange. */
:root {
  --cream: #FBF5E6;
  --cream-2: #F4EBD5;
  --cream-deep: #F1E7CE;
  --paper: #FFFFFF;
  --line: #E6DBC0;
  --forest: #1E4A37;
  --forest-deep: #143325;
  --leaf: #5E9C6B;
  --muted: #5A6E61;
  --carrot: #F0812B;
  --carrot-deep: #C05F16;
  --link: #0B57D0;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--forest-deep);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease);
}
body.playing { background: var(--cream-deep); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

.view { min-height: 100dvh; animation: view-in 0.7s var(--spring) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }

.tag {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.fine { font-size: 14px; color: var(--muted); }
.fine a { color: inherit; }

/* ---- buttons ---- */
.btn {
  appearance: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-play {
  width: min(340px, 100%);
  height: 68px;
  border-radius: 22px;
  background: var(--carrot);
  color: var(--forest-deep);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 0 var(--carrot-deep), 0 18px 30px -12px rgba(192, 95, 22, 0.55);
  transition: transform 0.5s var(--spring), box-shadow 0.2s var(--ease);
}
.btn-play:hover { transform: translateY(-2px); }
.btn-play:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--carrot-deep), 0 6px 12px -8px rgba(192, 95, 22, 0.5); transition-duration: 0.08s; }
.btn-play:disabled { opacity: 0.6; cursor: default; }

.btn-quiet {
  height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  background: transparent;
  color: var(--forest);
  border: 1.5px solid var(--forest);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.5s var(--spring), background-color 0.2s var(--ease);
}
@media (hover: hover) { .btn-quiet:hover { background: var(--cream-2); } }
.btn-quiet:active { transform: scale(0.96); transition-duration: 0.08s; }

.btn-play:focus-visible, .btn-quiet:focus-visible, .sec-h:focus-visible, .wl:focus-visible,
.bar-back:focus-visible, .bar-menu:focus-visible, .menu-item:focus-visible { outline: 3px solid var(--forest); outline-offset: 3px; }

.quiet-row { display: flex; gap: 12px; width: min(340px, 100%); margin-top: 16px; }
.quiet-row .btn-quiet { flex: 1 1 0; min-width: 0; }

/* ---- bunny ---- */
.bunny { position: relative; width: var(--size, 128px); height: var(--size, 128px); }
.bunny-body { position: absolute; inset: 0; }
.bunny .fr { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; image-rendering: pixelated; }
.bunny-shadow {
  position: absolute; left: 14%; right: 18%; bottom: -5%; height: 7%;
  background: var(--forest-deep); opacity: 0.14; border-radius: 50%;
}

/* idle: breathe + blink */
.bunny[data-anim="idle"] .bunny-body { animation: bob 1.6s steps(2, jump-none) infinite; }
.bunny[data-anim="idle"] .fr-idle { animation: idle-frame 3.6s steps(1) infinite; }
.bunny[data-anim="idle"] .fr-blink { animation: blink-frame 3.6s steps(1) infinite; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(1.6%); } }
@keyframes idle-frame { 0%, 100% { opacity: 1; } 92% { opacity: 0; } 97% { opacity: 1; } }
@keyframes blink-frame { 0%, 100% { opacity: 0; } 92% { opacity: 1; } 97% { opacity: 0; } }

/* hop: crouch, leap, land */
.bunny[data-anim="hop"] .bunny-body { animation: hop-arc 0.72s infinite; }
.bunny[data-anim="hop"] .fr-crouch { animation: hop-crouch 0.72s steps(1) infinite; }
.bunny[data-anim="hop"] .fr-air { animation: hop-air 0.72s steps(1) infinite; }
.bunny[data-anim="hop"] .fr-idle { animation: hop-land 0.72s steps(1) infinite; }
.bunny[data-anim="hop"] .bunny-shadow { animation: hop-shadow 0.72s infinite; }
@keyframes hop-arc {
  0%, 18% { transform: translateY(0); animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
  50% { transform: translateY(-34%); animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  82%, 100% { transform: translateY(0); }
}
@keyframes hop-crouch { 0% { opacity: 1; } 18%, 100% { opacity: 0; } }
@keyframes hop-air { 0% { opacity: 0; } 18% { opacity: 1; } 82%, 100% { opacity: 0; } }
@keyframes hop-land { 0% { opacity: 0; } 82%, 100% { opacity: 1; } }
@keyframes hop-shadow { 0%, 18%, 82%, 100% { transform: scale(1); opacity: 0.14; } 50% { transform: scale(0.6); opacity: 0.07; } }

/* ---- landing ---- */
#landing { position: relative; display: grid; place-items: center; overflow: hidden; }
.meadow { position: absolute; inset: auto 0 0 0; height: 44dvh; pointer-events: none; }
.meadow svg { display: block; width: 100%; height: 100%; }
.meadow .clouds { transform-box: view-box; }
.meadow-bunny { display: none; position: absolute; left: 14%; bottom: 8%; --size: clamp(150px, 12vw, 200px); }
.hero {
  position: relative;
  width: min(560px, 100%);
  padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) 30dvh max(28px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.hero-bunny { --size: clamp(120px, 34vw, 176px); margin: 22px 0 6px; }
.hero h1 { font-size: clamp(72px, 22vw, 124px); font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; color: var(--forest); }
.pitch { margin: 18px 0 30px; font-size: clamp(19px, 5vw, 22px); line-height: 1.35; font-weight: 500; color: var(--forest-deep); max-width: 21em; text-wrap: balance; }
.hero .fine { margin-top: 18px; }

/* ---- loading ---- */
#loading { display: grid; place-items: center; }
.loading-inner { padding: 28px max(28px, env(safe-area-inset-right)) 28px max(28px, env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.loading-inner .bunny { --size: 132px; margin-bottom: 26px; }
.load-lead { font-size: 19px; font-weight: 600; color: var(--muted); }
.load-target { font-size: clamp(40px, 12vw, 72px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; color: var(--forest); text-wrap: balance; overflow-wrap: anywhere; }
.loading-inner .fine { margin-top: 10px; max-width: 24em; }

/* ---- play ---- */
#play { overflow-x: clip; }
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(4px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--cream-deep) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  backdrop-filter: saturate(1.8) blur(20px);
}
.bar-back, .bar-menu {
  flex: none; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 14px; color: var(--forest); cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.5s var(--spring), opacity 0.2s var(--ease), background-color 0.2s var(--ease);
}
.bar-back svg, .bar-menu svg { width: 22px; height: 22px; }
.bar-back:active:not(:disabled), .bar-menu:active { transform: scale(0.9); transition-duration: 0.08s; }
.bar-back:disabled { opacity: 0.28; cursor: default; }
@media (hover: hover) { .bar-back:hover:not(:disabled), .bar-menu:hover { background: var(--cream-2); } }
.bar-target { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.bar-target strong { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; color: var(--forest); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  flex: none; padding: 4px 10px; border-radius: 999px;
  background: var(--cream-2); color: var(--forest); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.bar-clicks { flex: none; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timer { flex: none; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--forest); transition: color 0.6s var(--ease); }
.timer.low { color: var(--carrot-deep); }

.menu {
  position: absolute; top: calc(100% + 6px); right: max(10px, env(safe-area-inset-right)); z-index: 7;
  min-width: 200px; padding: 6px; border-radius: 16px;
  background: var(--paper); border: 1px solid var(--line);
  box-shadow: 0 18px 40px -20px rgba(20, 51, 37, 0.45);
  display: flex; flex-direction: column;
  animation: pop-in 0.4s var(--spring) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }
.menu-item {
  appearance: none; border: 0; background: none; font: inherit; cursor: pointer;
  min-height: 44px; padding: 10px 12px; border-radius: 10px; text-align: left;
  color: var(--forest-deep); font-size: 16px; font-weight: 600;
}
@media (hover: hover) { .menu-item:hover { background: var(--cream-2); } }

/* the loading track: a thin line with a small hopping bunny */
.track { position: absolute; left: 0; right: 0; top: 100%; height: 3px; background: var(--line); }
.track-bunny { position: absolute; top: 3px; left: -28px; opacity: 0; transition: opacity 0.2s var(--ease); }
.track-bunny .bunny { --size: 24px; }
.track.loading .track-bunny { opacity: 1; animation: travel 1.6s linear infinite; }
@keyframes travel { from { left: -28px; } to { left: 100%; } }

/* the article sheet */
.article {
  background: var(--paper);
  min-height: calc(100dvh - 64px);
  padding: 28px max(20px, env(safe-area-inset-right)) calc(72px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  font-size: 17px; line-height: 1.6;
  overflow-wrap: break-word;
}
.article.in-fwd { animation: slide-fwd 0.55s var(--spring) both; }
.article.in-back { animation: slide-back 0.55s var(--spring) both; }
@keyframes slide-fwd { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slide-back { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

.article > .lead > *, .sec-in > * { max-width: 68ch; }
.article h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin-bottom: 20px; color: var(--forest); text-wrap: balance; }
.article p, .article ul, .article ol, .article dl, .article blockquote { margin: 0 0 16px; }
.article ul, .article ol { padding-left: 1.4em; }
.article li { margin-bottom: 6px; padding-left: 0.15em; }
.article li::marker { color: var(--muted); }
.article li > ul, .article li > ol { margin: 6px 0 0; }
.article dt { font-weight: 700; margin-top: 8px; }
.article dd { margin: 2px 0 8px 1.2em; }
.article blockquote { margin: 20px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--leaf); color: var(--forest-deep); }
.article blockquote p:last-child { margin-bottom: 0; }
.article h3 { font-size: 21px; font-weight: 750; letter-spacing: -0.015em; line-height: 1.25; margin: 28px 0 10px; color: var(--forest); }
.article h4, .article h5, .article h6 { font-size: 17px; font-weight: 700; line-height: 1.3; margin: 22px 0 8px; color: var(--forest); }
.article sup, .article sub { font-size: 0.72em; line-height: 0; }
.article .wl { color: var(--link); text-decoration: none; }
@media (hover: hover) { .article .wl:hover { text-decoration: underline; } }

.sec { border-top: 1px solid var(--line); }
.sec:last-of-type { border-bottom: 1px solid var(--line); }
.sec-h {
  width: 100%; min-height: 56px; padding: 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: none; border: 0; color: var(--forest-deep); cursor: pointer; text-align: left;
  font: 700 21px/1.2 var(--sans); letter-spacing: -0.015em;
}
.sec-h svg { flex: none; width: 14px; height: 14px; color: var(--muted); transition: transform 0.55s var(--spring); }
.sec.open .sec-h svg { transform: rotate(180deg); }
.sec-b { display: grid; grid-template-rows: 0fr; visibility: hidden; transition: grid-template-rows 0.42s var(--ease), visibility 0s 0.42s; }
.sec.open .sec-b { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows 0.42s var(--ease), visibility 0s; }
.sec-in { min-height: 0; overflow: hidden; }
.sec.open .sec-in { padding-bottom: 8px; }
.article .credit { margin-top: 28px; font-size: 13px; color: var(--muted); }

/* ---- results ---- */
.results-inner {
  width: min(560px, 100%); margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.res-bunny { --size: 112px; margin: 22px 0 10px; }
.res-time { font-size: clamp(88px, 27vw, 136px); font-weight: 800; letter-spacing: -0.05em; line-height: 0.95; font-variant-numeric: tabular-nums; color: var(--forest); }
.res-time.out { font-size: clamp(52px, 16vw, 88px); letter-spacing: -0.04em; line-height: 1; }
.res-hops { margin-top: 12px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.res-hops em { font-style: normal; color: var(--carrot-deep); white-space: nowrap; }
.res-path { margin-top: 6px; font-size: 17px; color: var(--muted); min-height: 1.5em; }

.card { width: 100%; margin-top: 22px; padding: 18px 18px 14px; background: var(--cream-2); border-radius: 24px; text-align: left; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card h3 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.card-note { font-size: 14px; font-weight: 600; color: var(--carrot-deep); text-align: right; }
.chart { min-height: 150px; display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { font: 500 10px var(--sans); fill: var(--muted); }
.chart .you { font: 700 11px var(--sans); fill: var(--forest-deep); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--forest); stroke-width: 1.5; }
.chart .area { fill: var(--leaf); fill-opacity: 0.28; }
.chart .curve { fill: none; stroke: var(--forest); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .m-line { stroke: var(--carrot); stroke-width: 2; stroke-dasharray: 3 3; }
.chart .m-pill { fill: var(--carrot); }
.chart .m-dot { fill: var(--carrot); stroke: var(--cream-2); stroke-width: 2.5; }
.chart .curve { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s 0.15s var(--ease) forwards; }
.chart .area { opacity: 0; animation: fade 0.8s 0.5s var(--ease) forwards; }
.chart .marker { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; animation: pop 0.8s 0.9s var(--spring) forwards; }
.chart-foot { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }

.route { list-style: none; margin: 0; padding: 0; }
.route li { display: flex; align-items: baseline; gap: 12px; padding: 7px 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.route li + li { border-top: 1px solid var(--line); }
.route .n { flex: none; width: 1.6em; font: 600 12px var(--mono); color: var(--muted); }

#shareBtn { margin-top: 28px; }
.res-buttons { width: min(340px, 100%); margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.res-buttons .btn-play { width: 100%; }
.res-buttons .btn-quiet { flex: 1 1 0; min-width: 0; }
#shareBtn[hidden] + .res-buttons { margin-top: 28px; }
#nextRace { margin-top: 22px; font-variant-numeric: tabular-nums; }
.credit { margin-top: 10px; font-size: 12px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 999px;
  background: var(--forest-deep); color: var(--cream); font-size: 15px; font-weight: 600;
  transform: translate(-50%, calc(100% + 80px)); opacity: 0; transition: transform 0.6s var(--spring), opacity 0.3s var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 380px) {
  .bar { gap: 8px; }
  .bar-target strong { font-size: 17px; }
  .timer { font-size: 23px; }
  .bar-clicks { font-size: 13px; }
}

@media (min-width: 760px) {
  body { font-size: 18px; }
  .bar {
    gap: 16px;
    padding-left: max(20px, calc((100vw - 760px) / 2 - 36px));
    padding-right: max(20px, calc((100vw - 760px) / 2 - 36px));
  }
  .bar-target strong { font-size: 24px; }
  .bar-clicks { font-size: 15px; }
  .timer { font-size: 34px; }
  .article {
    max-width: 760px;
    min-height: 0;
    margin: 28px auto 64px;
    padding: 48px 56px;
    border-radius: 28px;
    box-shadow: 0 1px 0 rgba(20, 51, 37, 0.06), 0 24px 60px -30px rgba(20, 51, 37, 0.35);
    font-size: 18px; line-height: 1.65;
  }
  .article h1 { font-size: 52px; margin-bottom: 24px; }
  .sec-h { font-size: 22px; }
  .hero { padding-bottom: 26dvh; }
}

@media (min-width: 900px) {
  #landing { align-items: start; }
  .meadow { height: 48vh; }
  .meadow .clouds { animation: drift 80s ease-in-out infinite; }
  .meadow-bunny { display: block; }
  .hero-bunny { display: none; }
  .hero { width: min(720px, 100%); padding-top: max(9vh, 48px); padding-bottom: 26vh; }
  .hero .tag { margin-bottom: 26px; }
  .hero h1 { font-size: clamp(124px, 11vw, 168px); }
  .pitch { font-size: 24px; margin: 22px 0 34px; }
}
@keyframes drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .chart .curve { stroke-dashoffset: 0; }
  .chart .area, .chart .marker { opacity: 1; }
  .bunny .fr-idle { opacity: 1 !important; }
  .bunny .fr-blink, .bunny .fr-crouch, .bunny .fr-air { opacity: 0 !important; }
  .track.loading .track-bunny { animation: none; left: 12px; }
  .meadow .clouds { animation: none; }
}
