/* afterdust — everything is self-hosted; the page makes no third-party requests. */

/* Press Start 2P (SIL Open Font License 1.1), subset to the wordmark and
   embedded so the page has zero external requests. It is used for the wordmark
   and nothing else: the subset has no bold, and long messages read better in
   monospace. */
@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(data:font/woff2;base64,d09GMgABAAAAAAZwAAwAAAAAFTQAAAYhAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHCoGYABuEQgKnxyWMAE2AiQDgRALgRAABCAFhAoHIBtjD1GUTs5pyL4osBuORa0qWGebyAuc/9LUz7xmiLWhJzQrIo5yiuf//97c577/0zrPTIhLX94qhqiChjwCFSgUoGbSWlXpZHr7KumZOUIFKDQKDQD/rEiYt/qdWqHuYJ33s6OARLTnjFoX51IHFe6F/dIlEolEOJxFttDOZE1GGFRp2iAcmph3lOwvVft/3/KdvU26vLskgExpEiIcCozGmGN2bufvzpX3smm3n9LbUloXFiGrqtWhFA+jsCwyJ2cW/cWH3FJLhK7GEM72/52AKausaOublQ6Ibi8PK9BgAP/J13dtmPeYUHc1APaSITnjz//V9Pw54xfXDlsl+Bq5tSG0r8wReAbUt+pG6AULYe8KOgkZzrsXSNCfv8rCLS5j5IZLj5TQyRvnoK8eAGOa/98HRA9OzZ4eB3LKChACDTvgrZ14OvgGdC/0+34504oLz70SiUW6t0o6ulBKer+caaB2BBd6egp/syyUMFuIEpyJiKU8MRFGa4uN5YUSMzPL/UxrYUFrrQ+Tt17OsGXNmgydCPbFSvLQFiUWFvqc1GxVy+s1ZlaygPBXpXFxqXDeUQI6KxSCGXRwXHc/z0qYOakvFCqbrCuHZ4FB6EV9X32nUiiDUYhUoZOfVhYWdojW0yk17eOpqmequfKGpmXsHNB9HLV3IwLrEkegRtfhTydOxhtqDBdm6sIwqSFvLAFgMI17sLnsfrYJ9CCAfl3jL4k8zI4z9oQb/SwOyJEu5YvkgdFElTYNLiVL4x6ISHeZbRc8hCwgf5nyZsnskusJIFJ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P1iwb8/aX30q51Yv9nOQX9jLl9/PFvPPwVrG1c7U2MTB1p+Xj7+UHcUQVYNu63ex5VW27wQtQPlDUO1NvMZ11Q5x0BPtrwDV1Z4vjXhKusmRq6QAqLczzuwcdI6m7aoa7XcrCXtnAJNKFwOwe76GtQSz3nroxMxgPX1Y0cLzfoAN2+8NqFgGN5ekmhLQoqzuPwT4OVoMN0TYsdTKqdpnZ4cR5ZOzusfPw==) format("woff2");
}

:root {
  --bg: #160b1d;          /* page, and the darkest part of the sunset */
  --ink-deep: #0a050d;    /* outline, visor frame, button text, deepest shadow */
  --ink: #fff4d6;         /* primary text, typed text, message text */
  --ink-dim: #c9b8c9;     /* secondary text, metadata, placeholders, counters */
  --card: #2a1532;        /* message cards and field surfaces */
  --edge: #4a2a52;        /* 1px card and field borders */

  --yellow: #ffc928;
  --orange: #f47a0b;
  --rust: #a93a16;
  --maroon: #5a1c2d;
  --coral: #ff3b55;
  --magenta: #e90c87;
  --purple: #61147a;

  --font-mark: "Press Start 2P", ui-monospace, monospace;
  --font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* No full-height hero: the form has to be reachable at 320x568 without
   scrolling, so the page starts tight against the top. */
.page {
  max-width: 30rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
}

/* --- masthead ---------------------------------------------------------- */

.masthead { text-align: center; }

.mark {
  margin: 0;
  font-family: var(--font-mark);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  color: var(--yellow);
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--ink-dim);
}

/* --- the form ---------------------------------------------------------- */

.say { margin: 1.5rem 0 0; }

.prompt {
  display: block;
  margin: 0 0 0.625rem;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

#body, #nick {
  width: 100%;
  border: 1px solid var(--edge);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

#body {
  display: block;
  height: 4.75rem;
  padding: 0.875rem;
  font-size: 1rem;        /* 16px keeps iOS Safari from zooming on focus */
  line-height: 1.5;
  resize: none;
}

#body::placeholder, #nick::placeholder { color: var(--ink-dim); opacity: 1; }

.counter {
  margin: 0.375rem 0 0;
  font-size: 0.6875rem;
  line-height: 1.3;
  text-align: right;
  color: var(--ink-dim);
}

.nick-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* "from" is the field's real label, not decoration. */
.nick-label {
  flex: 0 0 auto;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--ink-dim);
}

#nick {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.75rem;
  padding: 0 0.875rem;
  font-size: 1rem;        /* 16px, same reason as the textarea */
  line-height: 1.4;
}

.say-button {
  display: block;
  width: 100%;
  min-height: 3rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--yellow);
  border-radius: 0.5rem;
  background: var(--yellow);
  color: var(--ink-deep);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.say-button[disabled] { cursor: default; opacity: 0.75; }

:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

#body:focus-visible, #nick:focus-visible { border-color: var(--yellow); }

/* --- the popo and the two newest cards --------------------------------- */

.scene {
  position: relative;   /* the burped card floats over the whole scene */
  display: grid;
  grid-template-columns: 40% 1fr;
  gap: 0.75rem;
  align-items: end;
  margin-top: 2rem;
}

.scene-popo {
  position: relative;
  display: flex;
  justify-content: center;
}

/* Flat sunset bands, clipped to an oval. No page-wide glow: the brightness
   stays inside this circle, the button, the wordmark and the card edges. */
.sunset {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 1.25rem;
  width: 7.5rem;
  height: 7.5rem;
  transform: translateX(-50%);
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--yellow)  0    20%,
    var(--orange)  20%  40%,
    var(--coral)   40%  60%,
    var(--magenta) 60%  80%,
    var(--purple)  80%  100%
  );
  opacity: 0.5;
}

/* The whole character plus his label is one control. */
.popo {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.popo-art { display: block; line-height: 0; }

.popo-art svg {
  display: block;
  height: 8rem;
  width: auto;
  overflow: visible;
}

.belly {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink-dim);
}

/* --- cards ------------------------------------------------------------- */

.wall-near, .wall {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wall-near {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.wall {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.post {
  min-height: 5.5rem;
  padding: 1rem;
  border: 1px solid var(--edge);
  border-left: 4px solid var(--accent, var(--yellow));
  border-radius: 0.5rem;
  background: var(--card);
  transform: rotate(var(--tilt, 0deg));
}

.post-body {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;      /* a manual line break is the author's choice */
  overflow-wrap: anywhere;    /* one long unbroken token cannot escape the card */
}

.post-meta {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--ink-dim);
}

.post-meta .who { font-weight: 700; }

.post.ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left-color: var(--edge);
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--ink-dim);
  transform: none;
}

.hide-button {
  margin-top: 0.5rem;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--edge);
  border-radius: 0.25rem;
  background: none;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
}

/* --- the burped-up card ------------------------------------------------- */

.burp-card {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 9.5rem;
  width: min(20rem, 100%);
  padding: 1rem;
  transform: translateX(-50%);
  border: 1px solid var(--edge);
  border-left: 4px solid var(--accent, var(--yellow));
  border-radius: 0.5rem;
  background: var(--card);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.burp-card[data-open="1"] { opacity: 1; visibility: visible; }

/* --- dust --------------------------------------------------------------- */

.dust {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 2rem;
  width: 0;
  height: 0;
  pointer-events: none;
}

.mote {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--rust);
  animation: mote 0.65s ease-out forwards;
}

@keyframes mote {
  from { transform: translate(0, 0); opacity: 0.9; }
  to   { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

/* --- foot --------------------------------------------------------------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.count, .sound {
  margin: 0;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--ink-dim);
}

.sound {
  padding: 0.25rem 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* --- motion -------------------------------------------------------------
   He sways. He does not bob: vertical movement reads as a hop, and he is a
   guardian, not a mascot. */

.popo-all {
  transform-box: view-box;
  transform-origin: 8px 20px;
  animation: sway 4800ms ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(-1deg); }
  50%      { transform: rotate(1deg); }
}

/* Blink: the visor stays opaque. The lower edge thickens for a moment, which
   reads as a blink without ever showing an eye. */
.popo[data-blink="1"] .popo-lid { opacity: 1; }
.popo-lid { opacity: 0; }

.popo[data-pose="chomp"] .popo-mouth-open { opacity: 0; }
.popo[data-pose="chomp"] .popo-mouth-shut { opacity: 1; }
.popo-mouth-shut { opacity: 0; }

.popo[data-pose="burp"] .popo-all { animation: burp 650ms ease-out 1; }

@keyframes burp {
  0%   { transform: translateY(0) scaleY(1); }
  35%  { transform: translateY(0.6px) scaleY(0.94); }
  60%  { transform: translateY(-0.5px) scaleY(1.03); }
  100% { transform: translateY(0) scaleY(1); }
}

.post.is-new { animation: land 250ms ease-out 1; }

@keyframes land {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.post.is-leaving { transition: transform 450ms cubic-bezier(.5,.05,.85,.4), opacity 450ms ease-in; }

.belly.is-bumped { animation: bump 320ms ease-out 1; }

@keyframes bump {
  0%, 100% { transform: scale(1); }
  45%      { transform: scale(1.35); }
}

/* --- desktop ------------------------------------------------------------ */

@media (min-width: 48rem) {
  .page { max-width: 48rem; padding-left: 1.5rem; padding-right: 1.5rem; }

  .masthead, .say { max-width: 32rem; margin-left: auto; margin-right: auto; }

  /* The character moves to the middle of his own scene and the wall becomes a
     plain two-column grid beneath him. One vertical flow, no sticky column. */
  .scene { display: block; }

  .scene-popo { margin-bottom: 1rem; }

  .popo-art svg { height: 10rem; }

  .burp-card { bottom: 12rem; }

  .sunset { width: 9.5rem; height: 9.5rem; }

  .wall-near { display: none; }

  .wall {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
  }

  /* An unpaired last card sits in the middle rather than hugging the left.
     Which card that is depends on where the full-width ones fell, so it is
     worked out by measuring rows, not by counting siblings. */
  .wall > .post.is-alone {
    grid-column: 1 / -1;
    width: calc(50% - 0.5rem);
    margin-inline: auto;
  }

  .wall > .post.ghost { grid-column: 1 / -1; width: auto; }

  .post.is-wide { grid-column: 1 / -1; width: auto; margin-inline: 0; }
}

/* --- reduced motion ------------------------------------------------------
   Nothing travels, floats, fades or bumps. The chomp and burp still happen,
   as single static poses, and a burped card still gets its full reading time.
   Sound is not touched here: that is the toggle's business. */

@media (prefers-reduced-motion: reduce) {
  .popo-all { animation: none; }
  .popo[data-pose="burp"] .popo-all { animation: none; }
  .post.is-new { animation: none; }
  .post.is-leaving { transition: none; }
  .belly.is-bumped { animation: none; }
  .burp-card { transition: none; }
  .mote { display: none; }
}
