/* Light only: there is no dark theme, and "only" stops browsers' auto-dark from inverting the page. */
:root {
  color-scheme: only light;
  --bg: #f3f3f5;
  --red: #cf0000;
  --ink: #000;
  --muted: #666; /* 5.7:1 on white */
  --ring: #000;
  /* Burger tile: exactly 2/3 of the 261x219 px source repeat, so the asset renders at 1.5x density. */
  --tw: 174px;
  --th: 146px;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  /* App feel: no text highlighting, no iOS long-press link/image callout. Zoom and keyboard use are untouched. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

img,
a { -webkit-user-drag: none; }

/* Exception: the status line can say "Copy this link: …", so it must stay selectable. */
.status {
  -webkit-user-select: text;
  user-select: text;
}

/* Drifting burger wallpaper: one tile of travel per loop, so the wrap is seamless; transform-only, so it stays on the compositor. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: calc(-1 * var(--tw));
  bottom: calc(-1 * var(--th));
  z-index: -1;
  pointer-events: none;
  background: url(burger-tile.webp) 0 0 / var(--tw) var(--th) repeat;
  animation: drift 40s linear infinite;
  will-change: transform;
}

@keyframes drift {
  to { transform: translate3d(calc(-1 * var(--tw)), calc(-1 * var(--th)), 0); }
}

/* Red striped rows (header + footer). The stripes sit on a wider pseudo-element that slides one
   stripe period (20px / cos 45deg = 28.284px) per loop, so the wrap is seamless; transform-only. */
.stripes {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--red);
}

.stripes::before {
  content: "";
  position: absolute;
  inset: 0 0 0 -28.284px;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(-45deg, rgb(255 255 255 / .14) 0 10px, transparent 10px 20px);
  animation: stripes 6s linear infinite;
}

@keyframes stripes {
  to { transform: translateX(28.284px); }
}

/* Square white badges with a heavy black border */
.badge {
  margin: 0;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

/* Header */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  /* Content stays inside a centred 1140px row; the red bar itself stays full width. */
  padding: calc(.5rem + env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right), calc((100% - 1140px) / 2)) .5rem max(.75rem, env(safe-area-inset-left), calc((100% - 1140px) / 2));
}

.tag,
.share {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .75rem;
  font-size: .9375rem;
  text-transform: lowercase;
}

/* Top-left title: plain white text on the red bar (5.9:1 on #cf0000). */
.tag {
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 1.375rem;
  text-shadow: 0 1px 2px rgb(0 0 0 / .35);
}

.share {
  gap: .375rem;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease; /* icon strokes with currentColor, so it follows */
}

.share svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Right side of the header: share + pause toggle */
.actions {
  display: flex;
  align-items: center;
  gap: .25rem;
}

/* Pause toggle: white filled icon on the red bar, 44px target. Shows "play" while paused. */
.still {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / .35));
}

.still svg {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.still .icon-play,
.still[aria-pressed="true"] .icon-pause { display: none; }
.still[aria-pressed="true"] .icon-play { display: block; }

.still:focus-visible { outline: 3px solid #fff; outline-offset: 0; }

/* lucide-motion "pause · default-loop": the two bars nudge apart once on hover. */
@keyframes lmi-pause--default-loop-rect1 {
  0% { transform: translate(0px, 0); }
  50% { transform: translate(1.5px, 0); }
  100% { transform: translate(0px, 0); }
}

@keyframes lmi-pause--default-loop-rect2 {
  0% { transform: translate(0px, 0); }
  50% { transform: translate(-1.5px, 0); }
  100% { transform: translate(0px, 0); }
}

.lmi-pause--default-loop-rect1,
.lmi-pause--default-loop-rect2 { transform: translate(0px, 0); }
.still:hover .lmi-pause--default-loop-rect1 { animation: lmi-pause--default-loop-rect1 .78s ease-in-out 0s 1 normal both; }
.still:hover .lmi-pause--default-loop-rect2 { animation: lmi-pause--default-loop-rect2 .78s ease-in-out 0s 1 normal both; }

/* Paused (html.is-still, set by the toggle): no CSS animation or transition anywhere; end states still apply. */
.is-still *,
.is-still *::before,
.is-still *::after {
  animation: none !important;
  transition: none !important;
}

.is-still .bubble.pop { visibility: hidden; }

/* Short landscape phones: a pinned bar would eat too much of the screen. */
@media (max-height: 430px) and (orientation: landscape) {
  .bar { position: relative; }
}

/* Main */
main {
  position: relative;
  flex: 1;
  display: grid;
  /* Equal flexible rows above and below keep the button itself centred; bubble sits on it, counter hangs under it. */
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  gap: 1rem;
  padding: 1.5rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
}

/* Burgers fade in under the header and out above the footer. */
main::before,
main::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4.5rem;
  pointer-events: none;
}

/* Very faint fades: just a hint of haze at the edges. */
main::before { top: 0; background: linear-gradient(rgb(243 243 245 / .25), transparent); }
main::after { bottom: 0; background: linear-gradient(transparent, rgb(243 243 245 / .25)); }

.sound {
  position: relative;
  display: block;
  width: min(84vw, 440px);
  overflow: hidden; /* clips the shimmer; the focus outline is drawn outside and isn't clipped */
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 80ms ease-out;
}

.sound img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.sound .down {
  position: absolute;
  inset: 0;
  opacity: 0;
}

/* Shimmer: a light band sweeps across now and then (app.js adds .shimmer at random intervals). */
.sound::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / .45) 50%, transparent 65%);
  transform: translateX(-100%);
}

.sound.shimmer::after { animation: shimmer 900ms ease-in-out; }

@keyframes shimmer {
  to { transform: translateX(100%); }
}

.sound.is-pressed { transform: scale(.97); }
.sound.is-pressed .down { opacity: 1; }

/* "poke me bruh" speech bubble; the tail is two stacked triangles (black edge, white fill). */
.bubble {
  align-self: end;
  position: relative;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / .22)); /* follows the tail too, unlike box-shadow */
  animation: bob 1.4s ease-in-out infinite alternate;
  padding: .25rem .875rem;
  font-size: .9375rem;
  font-style: italic;
  font-weight: 300;
}

.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-style: solid;
  border-color: transparent;
}

.bubble::before { border-width: 14px 14px 0; border-top-color: var(--ink); }
.bubble::after { border-width: 9px 9px 0; border-top-color: #fff; }

@keyframes bob {
  to { transform: translateY(-4px); }
}

/* After the first press: pop, then stay invisible (visibility keeps its space, so the button doesn't jump). */
.bubble.pop { animation: pop 280ms ease-in forwards; }

/* Back after idling: pop in, then resume the bob. */
.bubble.back { animation: appear 280ms ease-out, bob 1.4s ease-in-out 280ms infinite alternate; }

@keyframes appear {
  from { transform: scale(.3); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
}

@keyframes pop {
  40% { transform: scale(1.15); opacity: 1; }
  to { transform: scale(.3); opacity: 0; visibility: hidden; }
}

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

/* Counter + status, under the centred button */
.below {
  align-self: start;
  display: grid;
  justify-items: center;
  gap: 1rem;
  max-width: 100%;
}

/* Lifetime counter */
.count {
  margin-top: 1.75rem;
  max-width: 100%;
  /* Faint light-grey stripes, same angle and rhythm as the red bars. */
  background: repeating-linear-gradient(-45deg, #efefef 0 10px, #fff 10px 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .375rem 1.5rem .625rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* Room for "12,345" before the box grows; past that the box widens, and once it would outgrow the
   screen the number shrinks to fit (app.js sets --len to its character count). Never wraps. */
.count > span {
  display: inline-block;
  min-width: 6ch;
  text-align: center;
  white-space: nowrap;
  font-size: min(clamp(2.75rem, 14vw, 4.5rem), calc((100vw - 6rem) / (var(--len, 1) * .62)));
  font-weight: 800;
  letter-spacing: -.02em;
}

.count .cap { white-space: nowrap; }

/* Odometer (app.js): each digit is a 0-9,0 strip in a one-digit window, rolled upward like a car's mileage counter. */
.odo-wheel {
  display: inline-block;
  height: 1.1em;
  overflow: hidden;
  vertical-align: top;
  /* Faint fade at the window's top and bottom edges: rolling digits ease in and out; a resting digit sits clear of it. */
  -webkit-mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent);
  mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent);
}

.odo-strip {
  display: block;
  white-space: pre;
  will-change: transform;
}

/* The two caption rows under the number: white fill behind the text only, over the striped box. */
/* Thin white outline around the dark text (8-way 1px shadow: works in every browser, unlike text-stroke). */
.cap {
  font-weight: 600;
  text-shadow:
    -1px -1px 0 #fff, 0 -1px 0 #fff, 1px -1px 0 #fff,
    -1px 0 0 #fff, 1px 0 0 #fff,
    -1px 1px 0 #fff, 0 1px 0 #fff, 1px 1px 0 #fff;
}

/* "u contributed: N" — this visitor's own presses for the session */
.mine {
  margin-top: .375rem;
  font-size: .875rem;
  font-weight: 600;
}

.mine b {
  display: inline-block;
  font-weight: 800;
}

.count .tick { animation: tick 160ms ease-out; }

@keyframes tick {
  from { transform: translateY(-35%) scale(1.15); }
}

.status {
  min-height: 2rem;
  padding: .25rem .75rem;
  font-size: .9375rem;
  text-align: center;
}

/* Empty status stays in the accessibility tree (opacity, not display/visibility) so its updates are announced. */
.status:empty { opacity: 0; }

/* Milestone marquee: movie-theater bulb rows that slide in over the header and footer.
   Yellow and white bulbs alternate and swap every 0.4 s (2.5 flashes/s, under the WCAG 3/s limit). */
.marquee {
  --bulb: 26px;
  --gap: 40px;
  position: fixed;
  left: 0;
  right: 0;
  z-index: 15;
  height: calc(var(--bulb) + 20px);
  pointer-events: none;
  background: #1a1a1a;
  border-block: 3px solid #000;
  transition: transform 450ms cubic-bezier(.2, .9, .3, 1.2);
}

.marquee--top { top: 0; transform: translateY(calc(-100% - env(safe-area-inset-top))); margin-top: env(safe-area-inset-top); }
.marquee--bottom { bottom: 0; transform: translateY(calc(100% + env(safe-area-inset-bottom))); margin-bottom: env(safe-area-inset-bottom); }
.marquee.is-on { transform: none; }

.marquee::before,
.marquee::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle closest-side, var(--c1) 0 68%, var(--c2) 70% 90%, transparent 94%) 0 50% / calc(var(--gap) * 2) var(--bulb) repeat-x;
  animation: bulbs 800ms steps(1) infinite;
}

.marquee::before { --c1: #ffe066; --c2: #ffb800; }
.marquee::after { --c1: #fff; --c2: #ddd; background-position: var(--gap) 50%; animation-delay: -400ms; }

@keyframes bulbs {
  50% { opacity: .25; }
}

/* 404 page (lost.php): empty bars at the homepage's height, one giant red badge that links home. */
.lost .bar { min-height: calc(60px + env(safe-area-inset-top)); }
.lost footer { min-height: calc(60px + env(safe-area-inset-bottom)); }

.lost-badge {
  grid-row: 2; /* main's centred row */
  margin: 0;
  font-size: clamp(2.75rem, 13vw, 7rem);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  letter-spacing: -.03em;
}

.lost-badge a {
  display: block;
  padding: .3em .55em .35em;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgb(0 0 0 / .18);
  transition: filter .2s ease, color .25s ease;
}

/* "tap to leave, rando": message box that pops up in the footer bar and links home. */
.leave {
  align-self: center;
  padding: .375rem .875rem;
  font-size: .9375rem;
  font-style: italic;
  text-decoration: none;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / .22));
  animation: appear 280ms ease-out 600ms backwards, bob 1.4s ease-in-out 880ms infinite alternate;
}

.leave:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.lost-badge a:focus-visible { outline: 3px solid var(--ring); outline-offset: 4px; }

@media (hover: hover) {
  .lost-badge a:hover { color: #1a1a1a; filter: brightness(1.08); } /* charcoal on the brightened red: just over 3:1, the large-text minimum */
}

/* Burger/fire confetti layer (app.js) */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}

/* Footer */
footer {
  display: flex;
  justify-content: center;
  padding: .75rem max(.5rem, env(safe-area-inset-right)) calc(.75rem + env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left));
}

.credit {
  border: 2px solid var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  padding: .375rem .5rem;
  line-height: 1.35;
  text-align: center;
}

.credit span { font-size: .9375rem; }

.spatula--flip { transform: scaleX(-1); } /* trailing icon faces the other way */

.spatula {
  vertical-align: -3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* "——— crafted by … ———": thin dark-grey rules fill the card on either side of the top line. */
.credit-row {
  display: flex;
  align-items: center;
  gap: .625rem;
  align-self: stretch;
}

.credit-row::before,
.credit-row::after {
  content: "";
  flex: 1;
  min-width: .75rem;
  height: 2px;
  background: #333;
}

.credit a {
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color .2s ease;
}

/* Legal line: one line from 9px up. The line is ~40.5em wide; 36px = footer + badge side padding + border. */
.credit small {
  display: block;
  margin-top: .25rem;
  color: var(--muted);
  font-size: clamp(9px, calc((100vw - 36px) / 40.5), 12px);
  font-style: italic;
  font-weight: 100;
  letter-spacing: -.01em;
  text-transform: lowercase;
  white-space: nowrap;
}

/* Under ~390px even 9px doesn't fit on one line: wrap instead of shrinking further or scrolling sideways. */
@media (max-width: 389px) {
  .credit small { white-space: normal; text-wrap: balance; }
}

@media (hover: hover) {
  .sound:hover { filter: brightness(1.06); }
  .share:hover { background: #000; color: #fff; }
  .leave:hover { background: #f0f0f0; }
  .credit a:hover { color: var(--red); text-decoration-style: solid; } /* #cf0000 on white: 5.9:1 */
}

.sound:focus-visible { outline: 3px solid var(--ring); outline-offset: 4px; }
.credit a:focus-visible { color: var(--red); outline: 3px solid var(--ring); outline-offset: 2px; }
/* White ring: a black one would merge with the share badge's black border on the red bar. */
.share:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  body::before,
  .stripes::before,
  .bubble,
  .leave,
  .sound.shimmer::after { animation: none; }
  .sound { transition: none; }
  .count .tick { animation: none; }
  .bubble.pop { animation: none; visibility: hidden; }
  .bubble.back { animation: none; }
  .marquee { transition: none; }
  .marquee::before, .marquee::after { animation: none; }
}
