/* Easter eggs. Everything here stays hidden until an egg fires. */

/* toast: one line from the board */
.egg-toast {
  position: fixed; z-index: 60; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% calc(100% + 40px); max-width: min(560px, calc(100vw - 32px));
  background: var(--ink-c); color: var(--cream); border-radius: 16px; padding: 13px 18px;
  font: 600 16px/1.35 var(--body); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.6);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: translate 0.45s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.3s, visibility 0s 0.45s;
}
.egg-toast.on { translate: -50% 0; opacity: 1; visibility: visible; transition: translate 0.45s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.2s; }
.egg-toast:empty { display: none; }
.egg-toast b { color: var(--orange); font-family: var(--mono); font-weight: 500; }

/* clackophone */
.egg-keys {
  position: absolute; left: 50%; top: 100%; translate: -50% 14px; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: min(420px, calc(100vw - 40px));
  font-size: 16px;
}
.egg-keys-on .hero-copy { visibility: hidden; }
.egg-keys-on .hint { visibility: hidden; }
.egg-keys button {
  aspect-ratio: 1; border: 0; border-radius: 12px; cursor: pointer;
  font: 700 24px/1 'Flap', var(--display); color: var(--ink-c);
  background: linear-gradient(#f8ebd0, #e1cca2); box-shadow: 0 4px 0 #a3825a, 0 8px 14px -6px rgba(40, 12, 0, 0.6);
}
.egg-keys button.hit { translate: 0 3px; box-shadow: 0 1px 0 #a3825a; }
.egg-keys .done { grid-column: 1 / -1; aspect-ratio: auto; padding: 10px; font: 700 14px/1 var(--body); background: var(--ink-c); color: var(--cream); box-shadow: none; }

/* ghost cursor for #lmutfy */
.egg-ghost {
  position: fixed; z-index: 55; width: 28px; height: 28px; pointer-events: none; left: 0; top: 0;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)); transition: translate 0.9s cubic-bezier(0.5, 0, 0.2, 1);
}
.egg-ghost.tap svg { scale: 0.85; }

/* barrel roll and askew */
/* confession booth: sits under the board like the clackophone keys */
.egg-booth {
  position: absolute; left: 50%; top: 100%; translate: -50% 14px; z-index: 5; width: min(460px, calc(100vw - 40px));
  display: grid; gap: 10px; padding: 16px; border-radius: 18px; text-align: left;
  background: repeating-linear-gradient(90deg, rgba(20, 8, 2, 0.5) 0 6px, rgba(20, 8, 2, 0.32) 6px 12px);
  box-shadow: inset 0 0 0 2px rgba(255, 214, 180, 0.25), 0 20px 40px -20px rgba(20, 6, 0, 0.8);
  font: 600 15px/1.35 var(--body); color: var(--cream);
}
.egg-booth p { margin: 0; padding-right: 36px; }
.egg-booth form { display: flex; gap: 8px; }
.egg-booth input { flex: 1; min-width: 0; border: 0; border-radius: 12px; padding: 12px 14px; font: 500 16px/1.2 var(--body); background: var(--cream); color: var(--ink-c); }
.egg-booth button { border: 0; border-radius: 12px; padding: 0 16px; cursor: pointer; font: 700 15px/1 var(--body); background: var(--ink-c); color: var(--cream); }
.egg-booth .x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0; background: rgba(35, 31, 27, 0.5); font-size: 18px; }
.egg-booth .verdict { font: 700 17px/1.35 var(--display); }
.egg-booth .again { justify-self: start; height: 40px; background: var(--cream); color: var(--ink-c); }

/* funeral: the page goes grey, stones rise from the bottom */
html.egg-funeral main, html.egg-funeral .foot { filter: grayscale(1) brightness(0.7); }
main, .foot { transition: filter 1.2s ease; }
.egg-yard { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; height: min(46vh, 380px); pointer-events: none; }
.egg-yard::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(10, 8, 6, 0), rgba(10, 8, 6, 0.85) 70%); transition: opacity 0.6s;
}
.egg-yard.down::before, .egg-yard.down .egg-yard-title { opacity: 0; }
.egg-yard-title {
  position: absolute; left: 0; right: 0; top: 4px; margin: 0; text-align: center; opacity: 0; transition: opacity 1s;
  font: 500 13px/1 var(--mono); letter-spacing: 0.3em; text-transform: uppercase; color: rgba(242, 228, 200, 0.75);
}
.egg-yard-title.on { opacity: 1; }
.egg-stones { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 1.6vw, 18px); padding: 0 12px; }
.egg-stone, .egg-stone-gap { width: clamp(78px, 10.5vw, 132px); flex: none; }
.egg-stone {
  pointer-events: auto; cursor: pointer; border: 0; height: clamp(150px, 22vh, 210px); padding: 26px 6px 0;
  border-radius: 999px 999px 6px 6px / 60px 60px 6px 6px; display: grid; align-content: start; justify-items: center; gap: 8px;
  background: linear-gradient(#8d8a86, #6d6a66 60%, #5b5854); color: #e9e6e1;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), inset 0 -10px 20px rgba(0, 0, 0, 0.35), 0 10px 20px -8px rgba(0, 0, 0, 0.7);
  translate: 0 110%; transition: translate 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.egg-stone.up { translate: 0 18%; }
.egg-yard.down .egg-stone { translate: 0 120%; transition-duration: 0.5s; transition-timing-function: cubic-bezier(0.6, 0, 0.9, 0.4); }
.egg-stone .flaps { font-size: clamp(9px, 1.15vw, 14px); --flap-gap: 0.03em; }
.egg-stone small { font: 500 11px/1 var(--mono); opacity: 0.8; }
.egg-stone.alive {
  position: relative; height: clamp(180px, 27vh, 250px); color: var(--cream);
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 196, 142, 0.35), rgba(255, 196, 142, 0) 60%), linear-gradient(#e0612a, #d9541e 50%, #b8460f);
  box-shadow: inset 0 2px 0 rgba(255, 220, 190, 0.6), 0 0 60px rgba(217, 84, 30, 0.55), 0 14px 26px -8px rgba(0, 0, 0, 0.7);
  transition-duration: 0.7s; transition-timing-function: cubic-bezier(0.2, 1.4, 0.4, 1);
}
.egg-stone.alive .flaps { font-size: clamp(18px, 2.4vw, 30px); }
.egg-stone.alive.up { translate: 0 6%; }
.egg-yard.quake .egg-stones { animation: egg-quake 0.09s linear 10; }
@keyframes egg-quake { 25% { translate: -3px 1px; } 75% { translate: 3px -1px; } }
.egg-dirt { position: absolute; left: 50%; top: 10px; width: 7px; height: 7px; border-radius: 2px; background: #4a3424; pointer-events: none; opacity: 0; }
.egg-stone.burst .egg-dirt { animation: egg-dirt 0.9s cubic-bezier(0.2, 0.6, 0.6, 1) forwards; }
@keyframes egg-dirt { 0% { opacity: 1; translate: 0 0; } 60% { opacity: 1; } 100% { opacity: 0; translate: var(--dx) calc(var(--dy) + 260px); rotate: 300deg; } }
.egg-f {
  position: fixed; z-index: 46; translate: -50% 0; pointer-events: none;
  font: 800 34px/1 var(--display); color: var(--cream); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  animation: egg-f 1.5s ease-out forwards;
}
@keyframes egg-f { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-120px) scale(1.4); } }

/* jame: runners with legs, and a BRB sign */
.egg-runner { position: fixed; z-index: 30; pointer-events: none; line-height: 1; }
.egg-runner .flaps { --flap-glyph: 1em; display: inline-flex; }
.egg-leg {
  position: absolute; top: 100%; width: 0.05em; height: 0.2em; background: var(--ink-c); border-radius: 0 0 0.03em 0.03em;
  transform-origin: 50% 0; opacity: 0; transition: opacity 0.15s;
}
.egg-leg::after { content: ''; position: absolute; bottom: 0; left: -0.01em; width: 0.1em; height: 0.035em; background: var(--ink-c); border-radius: 0.02em; }
.egg-leg.l { left: 30%; }
.egg-leg.r { left: 62%; }
.egg-runner.running .egg-leg { opacity: 1; animation: egg-stride 0.18s ease-in-out infinite alternate; }
.egg-runner.running .egg-leg.r { animation-delay: -0.09s; }
@keyframes egg-stride { from { rotate: 28deg; } to { rotate: -28deg; } }
.egg-brb {
  position: absolute; left: 50%; top: 0.08em; z-index: 4; translate: -50% 0; transform-origin: 50% -0.1em;
  font: 800 0.22em/1 var(--display); letter-spacing: 0.06em; color: var(--ink-c); background: var(--cream);
  padding: 0.3em 0.55em; border-radius: 0.2em; box-shadow: 0 0.12em 0.25em -0.08em rgba(40, 12, 0, 0.7);
  animation: egg-swing 1.4s ease-in-out infinite alternate;
}
.egg-brb::before { content: ''; position: absolute; left: 50%; bottom: 100%; width: 0.06em; height: 0.35em; background: rgba(35, 31, 27, 0.6); translate: -50% 0; }
.egg-brb.drop { animation: egg-drop 0.5s cubic-bezier(.5, 0, 1, .5) forwards; }
@keyframes egg-swing { from { rotate: -9deg; } to { rotate: 9deg; } }
@keyframes egg-drop { to { translate: -50% 3em; rotate: 30deg; opacity: 0; } }

/* sticker fling */
.sticker.egg-grab { cursor: grabbing; transition: none; }
.sticker { touch-action: pan-y; }
.sticker img { -webkit-user-drag: none; user-select: none; }

/* desk tent card: only on paper */
.egg-tent { display: none; }
@media print {
  @page { size: portrait; margin: 0; }
  body > *:not(.egg-tent) { display: none !important; }
  html, body { background: #fff !important; }
  .egg-tent {
    display: grid !important; grid-template-rows: 1fr 1fr; height: 100vh; width: 100vw;
    font-family: 'Bricolage', system-ui, sans-serif; color: #231f1b;
  }
  .egg-tent .half {
    display: grid; place-content: center; justify-items: center; gap: 4mm; text-align: center;
    border-bottom: 0.4mm dashed #999;
  }
  .egg-tent .half:first-child { rotate: 180deg; }
  .egg-tent .big { font: 800 62mm/0.9 'Flap', 'Barlow', sans-serif; color: #d9541e; letter-spacing: -1mm; }
  .egg-tent .for { font: 700 7mm/1.2 'Bricolage', sans-serif; }
  .egg-tent .meh { font: 500 4.5mm/1.3 'Bricolage', sans-serif; color: #6b6057; }
  .egg-tent .fold { font: 500 3mm/1 monospace; color: #999; }
}

/* touch: spell on the board */
.board { touch-action: manipulation; }
.board.egg-spell .flap { touch-action: none; cursor: ns-resize; }
.board.egg-spell .flap-window { outline: 0.02em solid rgba(242, 228, 200, 0.55); outline-offset: 0.04em; }
.board.egg-spell .hint { opacity: 0; }

/* touch: swipe a toy account to sign out */
.acct.egg-sw:not(.slide) { transition: translate 0.34s cubic-bezier(0.2, 0.85, 0.25, 1); }
.acct.egg-swiping { transition: none !important; }
.egg-out {
  position: absolute; top: 0; bottom: 0; left: calc(100% + 10px); width: 94px; border: 0; border-radius: 20px;
  background: #d23a26; color: #fff; font: 700 15px/1.1 var(--display); cursor: pointer; opacity: 0; pointer-events: none;
}
.acct.egg-open .egg-out { pointer-events: auto; }
.acct.egg-gone { opacity: 0.4; }

/* touch: pull to refresh at the top of the page */
html { overscroll-behavior-y: contain; }
.egg-ptr {
  --k: 0;
  position: fixed; z-index: 40; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--cream, #f2e4c8); color: var(--orange, #d9541e); box-shadow: 0 8px 20px -8px rgba(40, 12, 0, 0.6);
  translate: -50% calc(var(--k) * 60px - 70px); rotate: calc(var(--k) * 300deg); opacity: 0; pointer-events: none;
}
.egg-ptr.on { opacity: 1; }
.egg-ptr:not(.on) { transition: translate 0.3s, opacity 0.3s; }
.egg-ptr svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: calc(0.35 + var(--k) * 0.65); }
.egg-ptr.ready svg { opacity: 1; }
.motion .egg-ptr.spin svg { animation: egg-ptr-spin 0.7s linear infinite; }
@keyframes egg-ptr-spin { to { rotate: 360deg; } }

@media (prefers-reduced-motion: reduce) {
  .egg-toast, .egg-ghost, .egg-stone, .egg-yard::before { transition: none; }
  .egg-yard.quake .egg-stones, .egg-stone.burst .egg-dirt, .egg-f { animation: none; }
  .egg-f { opacity: 0; }
  .acct.egg-sw:not(.slide), .egg-ptr:not(.on) { transition: none; }
}
