/* mEGGy. The page is the photo studio: same grey as the character images (#C8C8C8, measured),
   so Meggy stands in the page, not in a box. All state changes (sleep, hunger, cold) are code. */

@font-face {
  font-family: "Comfortaa"; font-weight: 700; font-display: swap;
  src: url("/fonts/comfortaa-700-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Comfortaa"; font-weight: 700; font-display: swap;
  src: url("/fonts/comfortaa-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Commissioner"; font-weight: 400 600; font-display: swap;
  src: url("/fonts/commissioner-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Commissioner"; font-weight: 400 600; font-display: swap;
  src: url("/fonts/commissioner-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --studio: #c8c8c8;     /* = image background */
  --ink: #1f2023;
  --ink-soft: #3f4147;
  --yolk: #f5b83d;
  --yolk-deep: #e09a12;
  --alarm: #8e1d14;

  --bg: var(--studio);
  --fg: var(--ink);
  --fg-soft: var(--ink-soft);

  --round: "Comfortaa", ui-rounded, system-ui, sans-serif;
  --text: "Commissioner", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

/* Asleep (06–12 UTC, the same moment everywhere): no night colours, because for half the world it is daytime.
   Closed eyes (meggy-sleep.jpg) and the "Asleep" label say it. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.5 var(--text);
  display: flex;
  flex-direction: column;
  transition: background-color 1.2s ease, color 1.2s ease;
}

/* Top bar */
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: max(.75rem, env(safe-area-inset-top)) 1rem .25rem;
  max-width: 34rem; width: 100%; margin: 0 auto;
}
.logo { font: 700 1.35rem/1 var(--round); letter-spacing: .01em; min-height: 2.75rem; display: flex; align-items: center; }

main {
  flex: 1;
  width: 100%; max-width: 34rem; margin: 0 auto;
  padding: 0 1rem 1.5rem;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}

/* The creature */
.stage { position: relative; width: min(100%, 26rem, 52dvh); margin: -.5rem 0 0; }
.scene {
  position: relative;
  margin: 0;
  width: 100%;
  aspect-ratio: 1;
  /* One isolated layer with one feathered edge, so the picture and the engraved text
     always fade out together and a tiny mismatch with the page grey never shows as a box. */
  isolation: isolate;
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent);
          mask-image: radial-gradient(closest-side, #000 80%, transparent);
}
/* Hunger/cold look on the whole creature. --pivot: where Meggy stands, so every squash, lean and swell keeps
   that line still: the nest rim for the egg (y 650 of 1024, scripts/split-egg.py), the feet for the bird. */
.creature {
  position: absolute; inset: 0; pointer-events: none;
  --pivot: 50% 63.5%;
  filter: var(--look, none);
  transition: filter 1.5s ease, opacity 1.5s ease;
}
.creature.bird { --pivot: 50% 85.7%; }
.creature img, .body, .breath { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.body, .breath, .moving { transform-origin: var(--pivot); }
.still[hidden] { display: none; }
/* The only tappable part: an oval over the egg (measured on the 1024px pictures: egg x 28–73 %, y 23–72 %),
   or over the bird (x 18–83 %, y 15–86 %; the chick's --grow shrinks it with her, around her feet). */
.hit {
  position: absolute; left: 27%; width: 46%; top: 22%; height: 52%; border-radius: 50%;
  pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bird .hit {
  left: 18%; width: 65%; top: 15%; height: 71%;
  transform: scale(var(--grow, 1)); transform-origin: 50% 99%;
}
body.dead .hit { display: none; }
/* --puff: deflates when hungry. --grow: the chick is smaller than the grown bird. */
.moving { transform: scale(calc(var(--puff, 1) * var(--grow, 1))); transition: transform 1.5s ease; }
/* Gravestone text. Box = the flat panel of grave.jpg (measured: x 32.5..68.3 %, below the carved egg, above
   the flowers). Sizes in cqw (% of the scene width) so the text scales with the stone. */
.scene { container-type: inline-size; }
body.dead .scene {
  -webkit-mask-image: radial-gradient(closest-side, #000 90%, transparent);
          mask-image: radial-gradient(closest-side, #000 90%, transparent);
}
.epitaph {
  position: absolute; left: 34%; width: 32.5%; top: 35.5%; height: 31.5%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqw;
  text-align: center; pointer-events: none;
  /* Engraved: dark grey letters with a light edge underneath, like a cut in white marble. */
  color: #5f5b57; text-shadow: 0 .15cqw 0 rgb(255 255 255 / .75);
  font: 600 3.15cqw/1.25 var(--text); text-wrap: balance;
}
.epitaph[hidden] { display: none; }
.epitaph p { margin: 0; }
.epitaph .ep-name { font: 700 5.6cqw/1 var(--round); letter-spacing: .02em; }
.epitaph .ep-dates { font-size: 2.85cqw; font-variant-numeric: tabular-nums; margin-bottom: 1cqw; }

/* Motion (same numbers as the app, app/src/app/index.tsx). Only Meggy moves, never the nest or the studio.
   .breath loops; .body plays one action at a time (class set by app.js, removed on animationend). */
@media (prefers-reduced-motion: no-preference) {
  body.alive .breath { animation: breathe 4.2s ease-in-out infinite; }
  body.alive .creature:not(.bird) .breath { animation-name: swell; }
  .body.poke { animation: wobble .9s linear; }
  .bird .body.poke { animation: squash .55s linear; }
  .body.rock { animation: rock 1.6s ease-in-out; }
  .body.shiver { animation: shiver .36s linear; }
  .body.hop { animation: swell-hop .7s cubic-bezier(.3, 1.6, .5, 1); }
  .bird .body.hop { animation: hop .7s cubic-bezier(.3, 1.6, .5, 1); }
}
@keyframes breathe { 50% { transform: scale(1.012, 1.02); } }
@keyframes swell { 50% { transform: scaleY(1.012); } }
/* Egg: a damped lean on the nest rim (skewX keeps the rim line still). */
@keyframes wobble {
  12% { transform: skewX(-6deg); } 30% { transform: skewX(5deg); } 48% { transform: skewX(-3.5deg); }
  66% { transform: skewX(2deg); } 84% { transform: skewX(-.8deg); }
}
/* Egg, now and then by itself: livelier as hatching nears (--rock, degrees, set by app.js). */
@keyframes rock {
  20% { transform: skewX(calc(var(--rock, 1.5) * -1deg)); } 45% { transform: skewX(calc(var(--rock, 1.5) * .8deg)); }
  70% { transform: skewX(calc(var(--rock, 1.5) * -.4deg)); }
}
@keyframes shiver { 20%, 60% { transform: skewX(-1deg) translateX(-.2%); } 40%, 80% { transform: skewX(1deg) translateX(.2%); } }
@keyframes swell-hop { 50% { transform: scaleY(1.06); } }
@keyframes squash {
  25% { transform: scale(1.08, .9); } 55% { transform: scale(.96, 1.05); } 80% { transform: scale(1.02, .98); }
}
@keyframes hop {
  30% { transform: scale(1.06, .94); }
  60% { transform: translateY(-4%); }
}

/* Thermometer next to the egg. Outside the masked scene so it never fades with it. */
.thermo {
  position: absolute; right: 2%; top: 26%;
  width: 2.25rem; display: flex; flex-direction: column; align-items: center; gap: .25rem;
  /* Warm orange → icy blue through a neutral middle (oklab), never through green. */
  --warmth: 100%;
  --mercury: color-mix(in oklab, #e8603c var(--warmth), #5b8fd6);
}
.thermo[hidden] { display: none; }
.thermo svg { width: 1.5rem; height: auto; overflow: visible; }
.thermo .tube, .thermo .bulb-ring { fill: rgb(255 255 255 / .55); stroke: var(--fg); stroke-opacity: .35; stroke-width: 1.5; }
.thermo .mercury, .thermo .bulb { fill: var(--mercury); transition: fill 1.5s ease; }
.thermo .mercury { transition: y 1.5s ease, height 1.5s ease, fill 1.5s ease; }
.temp { font: 700 .9375rem/1 var(--round); font-variant-numeric: tabular-nums; white-space: nowrap; }

.who { margin: -.75rem 0 0; color: var(--fg-soft); font-size: .9375rem; }

/* Countdown: the one loud thing besides Meggy. */
.clock { margin-top: 1rem; }
.label { margin: 0; font-weight: 600; font-size: 1rem; }
.timer {
  margin: 0;
  font: 700 clamp(3.25rem, 17vw, 5.25rem)/1.05 var(--round);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
body.urgent .timer, body.urgent .label { color: var(--alarm); }

.act { width: 100%; margin-top: 1.25rem; }
.feed {
  font: 700 1.1875rem/1.2 var(--round);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  width: 100%; min-height: 3.75rem; padding: .5rem 1.5rem;
  color: var(--ink); background: var(--yolk);
  border: 0; border-radius: 1.875rem;
  box-shadow: 0 .25rem 0 var(--yolk-deep);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease, background-color .3s ease;
}
.feed:active:not(:disabled) { transform: translateY(.25rem); box-shadow: 0 0 0 var(--yolk-deep); }
/* Already fed today (or waiting for the server): same shape, clearly not tappable. */
.feed:disabled {
  cursor: default; box-shadow: none;
  background: transparent; color: var(--fg); outline: 2px solid currentColor; outline-offset: -2px;
}
/* Before birth: plainly greyed out, not the "already fed" outline. */
.feed.soon:disabled { outline: none; background: rgb(0 0 0 / .1); color: rgb(31 32 35 / .45); }
/* Turnstile appears here only when Cloudflare needs a click. */
.bot-check { display: flex; justify-content: center; }
.bot-check:not(:empty) { margin-top: .75rem; }
.feed[hidden] { display: none; }
.msg { margin: .625rem 0 0; min-height: 1.5em; color: var(--fg-soft); }

/* Progress to the next stage. The fill is scaled, not resized: no layout work on every poll. */
.growth { width: 100%; max-width: 20rem; margin: 1rem auto 0; }
.growth[hidden] { display: none; }
.bar { height: .625rem; border-radius: .3125rem; background: rgb(0 0 0 / .1); overflow: hidden; }
.fill { height: 100%; background: var(--yolk); box-shadow: inset 0 -2px 0 var(--yolk-deep); transform-origin: left; transform: scaleX(0); }
@media (prefers-reduced-motion: no-preference) { .fill { transition: transform .6s ease; } }
.growth-text { margin: .375rem 0 0; color: var(--fg-soft); font-size: .875rem; font-variant-numeric: tabular-nums; }

.story { margin: .75rem 0 0; max-width: 30ch; color: var(--fg-soft); font-size: .9375rem; text-wrap: balance; }
.story:empty { display: none; }

.share {
  margin-top: 1.25rem;
  font: 600 1rem/1 var(--text); color: var(--fg);
  background: none; border: 0; padding: .875rem 1rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: .3em; text-decoration-thickness: 2px;
}

.foot {
  text-align: center; font-size: .75rem; color: var(--fg-soft);
  padding: 0 1rem max(1rem, env(safe-area-inset-bottom));
}
.foot a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; display: inline-block; padding: .75rem .25rem; }

button:focus-visible, a:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

body.loading main { visibility: hidden; }

/* Dead: the page is the grave, forever. */
/* The stone already tells everything; below it only the message and the share button remain. */
body.dead .clock, body.dead .story, body.dead .who { display: none; }
body.dead .timer, .timer.long { font-size: clamp(1.75rem, 8.5vw, 2.75rem); line-height: 1.2; }

/* Text pages (privacy, terms) */
body.doc { display: block; }
.doc .top a.logo { color: inherit; text-decoration: none; }
main.prose { display: block; text-align: left; max-width: 40rem; margin: 0 auto; padding: .5rem 1rem 2rem; line-height: 1.6; }
.prose ul { padding-left: 1.25rem; }
.prose h1 { font: 700 1.75rem/1.2 var(--round); margin: 1rem 0 .25rem; }
.prose h2 { font-size: 1.125rem; margin: 1.75rem 0 .25rem; }
.prose .meta { color: var(--fg-soft); margin-top: 0; }
.prose a, .doc .foot a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.prose code { font-size: .9em; background: rgb(255 255 255 / .45); padding: 0 .25em; border-radius: .25em; }
.prose hr { border: 0; border-top: 1px solid rgb(0 0 0 / .15); margin: 2rem 0 0; }
