/* ==========================================================================
   R · Cosmos. After cosmos.so. Milky glass buttons at the top, the one that
   matters in black. On a phone, the sections sit at the bottom in one wide
   capsule of milky glass, with a round black button beside it, a hand waving
   hello. Nothing covers the work: no white fades, top or bottom.
   ========================================================================== */

/* --- Top: the same milky glass as the capsule, and Contact in black --------------------- */

/* With nothing covering the work, the name and links sit on their own glass so they read over
   any image. */
.page-r .o-pill:not(.o-pill--dark),
.r-bar,
.r-round {
  background: rgb(255 255 255 / 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  box-shadow:
    inset 0 0 0 1.5px rgb(255 255 255 / 0.75),
    inset 0 1px 1px rgb(255 255 255 / 0.9),
    0 0 0 0.5px rgb(0 0 0 / 0.06),
    0 10px 30px rgb(0 0 0 / 0.1);
}

.page-r .o-pill { height: var(--pill-h); padding: 0 20px; }
.page-r .o-top__nav { color: #555; }

.page-r .o-pill--dark {
  background: rgb(10 10 10 / 0.92);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12), 0 10px 30px rgb(0 0 0 / 0.18);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

@media (hover: hover) {
  .page-r .o-pill:not(.o-pill--dark):hover { background: rgb(255 255 255 / 0.9); color: var(--fg); }
}

/* --- Bottom: the capsule ------------------------------------------------------------------ */

.page-r .r-dock {
  font-size: var(--t-ui, inherit);
  gap: 10px;
  align-items: center;
  bottom: 24px;
}

/* The capsule is sized for a thumb: 64px tall on a phone, like Cosmos'. */
.r-bar,
.r-round {
  height: var(--dock-h, 60px);
  border-radius: 999px;
}

@media (max-width: 900px) {
  .page-r { --dock-h: 64px; }
  .page-r .r-dock { gap: 8px; max-width: calc(100vw - 2 * var(--gutter)); }
  .page-r .r-bar { padding: 0 6px; }
  .page-r .r-bar a { padding: 0 13px; }
}

.r-bar {
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.r-bar a {
  display: grid;
  place-items: center;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  color: #555;
  font-weight: var(--strong);
  white-space: nowrap;
  transition: color 0.15s ease;
}

.r-bar a[aria-current="page"] { color: var(--fg); }

/* Say hi: black, a hand that waves when you reach for it. */
.r-round {
  display: grid;
  place-items: center;
  width: var(--dock-h, 60px);
  background: rgb(10 10 10 / 0.92);
  box-shadow:
    inset 0 0 0 1.5px rgb(255 255 255 / 0.22),
    inset 0 1px 1px rgb(255 255 255 / 0.3),
    0 10px 30px rgb(0 0 0 / 0.2);
  color: #fff;
  transition: transform 0.15s ease;
}

.r-round svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(-8deg);
  transform-origin: 50% 95%;
}

/* The wave: two small swings from the wrist and back to rest, 600ms. It says hello on its own a
   moment after the page opens, then every 5 seconds; hovering or tapping waves once more. The
   keyframes are set for 5s: change --wave-every and they need rescaling (the wave is 600ms). */
:root { --wave-ease: cubic-bezier(0.37, 0, 0.63, 1); --wave-every: 5s; }

.r-round svg { animation: r-idle var(--wave-every) var(--wave-ease) 1.4s infinite; }

@keyframes r-idle {
  0%, 12.6%, 100% { transform: rotate(-8deg); }
  3.6% { transform: rotate(6deg); }
  8.1% { transform: rotate(-12deg); }
}

@media (hover: hover) and (pointer: fine) {
  .r-round:hover svg:not(.fist) { animation: r-wave 0.6s var(--wave-ease); }
}

@keyframes r-wave {
  0%, 100% { transform: rotate(-8deg); }
  30% { transform: rotate(6deg); }
  65% { transform: rotate(-12deg); }
}

@media (prefers-reduced-motion: reduce) {
  .r-round svg { animation: none !important; }
}

.r-bar a:active,
.r-round:active { transform: scale(0.96); }

/* On a phone: the capsule and Say hi at the bottom, over the work. */
@media (max-width: 900px) {
  .page-r .o-top__end > .o-pill--dark { display: none; }
  .focus-open .page-r .o-top__end > .f-close { display: inline-flex; }



  /* The capsule stays over an open project too: Work takes you back to the wall. */
  .focus-open .page-r .r-dock { z-index: 450; }

  .page-r .o-exit { display: none; }
}

/* Work and About are separate pills: the bar only holds them. */
.page-r .r-bar {
  gap: 8px;
  padding: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.page-r .r-bar a {
  height: var(--dock-h, 60px);
  padding: 0 24px;
  background: rgb(255 255 255 / 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  box-shadow:
    inset 0 0 0 1.5px rgb(255 255 255 / 0.75),
    inset 0 1px 1px rgb(255 255 255 / 0.9),
    0 0 0 0.5px rgb(0 0 0 / 0.06),
    0 10px 30px rgb(0 0 0 / 0.1);
}

/* --- Contact on a computer: the hand that opens into Contact ---------------------------- */

/* A round hand that waves now and then; on hover the button opens just enough for Contact, which
   fades and settles in beside the hand. Exponential out: 380ms to open, 260ms to close. */
:root { --expo-out: cubic-bezier(0.16, 1, 0.3, 1); }

/* At rest a perfect circle: as tall as the other buttons and exactly as wide. */
.page-r .s-hi {
  position: relative;
  overflow: hidden;
  gap: 0;
  min-width: var(--pill-h);
  padding: 0 calc((var(--pill-h) - 22px) / 2);
  transition: padding 260ms var(--expo-out);
}

.s-hi__text,
.s-hi__hand { display: inline-grid; place-items: center; }

.s-hi__hand { order: -1; }

.s-hi__hand svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(-8deg);
  transform-origin: 50% 95%;
  animation: r-idle var(--wave-every) var(--wave-ease) 1.4s infinite;
}

/* The width opens through a grid track, so the word never squashes; the word itself only fades and
   moves 4px. */
.s-hi__text {
  grid-template-columns: 0fr;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    grid-template-columns 260ms var(--expo-out),
    opacity 150ms ease-out,
    transform 260ms var(--expo-out),
    margin 260ms var(--expo-out);
}

.s-hi__text > span { overflow: hidden; }

.page-r .s-hi:is(:hover, :focus-visible) { padding: 0 16px 0 12px; transition-duration: 380ms; }

.s-hi:is(:hover, :focus-visible) .s-hi__text {
  grid-template-columns: 1fr;
  opacity: 1;
  transform: none;
  margin-left: 6px;
  transition:
    grid-template-columns 380ms var(--expo-out),
    opacity 260ms ease-out 80ms,
    transform 380ms var(--expo-out),
    margin 380ms var(--expo-out);
}

@media (hover: hover) and (pointer: fine) {
  .s-hi:hover .s-hi__hand svg:not(.fist) { animation: r-wave 0.6s var(--wave-ease); }
}

/* Touch has no hover: the button stays a hand. */
@media not ((hover: hover) and (pointer: fine)) {
  .page-r .s-hi:hover { padding: 0 calc((var(--pill-h) - 22px) / 2); }
  .s-hi:hover .s-hi__text { grid-template-columns: 0fr; opacity: 0; margin-left: 0; }
}

/* --- The fist bump: the thanks, when the email is copied and when the form is sent -------- */

/* The two fists slide in and meet, then the burst pops above them. In Contact the fist sits on top
   of the hand and takes its place while "Email copied!" shows. */
/* The click: Contact squashes, then springs back past its size (a spring that overshoots about a
   third of the way) and settles, 650ms. It plays on each copy (focus.js restarts it), so it can't
   be held; while pressed the button stays a touch smaller, as every pill does. */
.page-s :is(.s-hi, .r-round)[data-copied] { animation: hi-boing 650ms; }

/* The footer's Contact is a wide pill, so it squashes less. */
.page-s .s-footer__mail[data-copied] { --squash: 0.96; animation: hi-boing 650ms; }

@keyframes hi-boing {
  0% { scale: 1; animation-timing-function: cubic-bezier(0.25, 0.1, 0, 1); }
  20% {
    scale: var(--squash, 0.9);
    animation-timing-function: linear(0, 0.112, 0.377, 0.695, 0.982, 1.187, 1.292, 1.304, 1.248, 1.157, 1.06, 0.979, 0.927, 0.905, 0.91, 0.933, 0.963, 0.992, 1.014, 1.026, 1.03, 1.026, 1.018, 1.008, 1, 0.994, 1);
  }
  100% { scale: 1; }
}

/* The swap: the icon going shrinks deep, fades and blurs a little while the other grows in from
   the same spot, 300ms. Both stay in the button, so the swap back plays the same way. */
.hi-icon { display: grid; place-items: center; flex-shrink: 0; }
.hi-icon > svg,
.s-hi__hand > svg {
  grid-area: 1 / 1;
  transition:
    opacity 300ms cubic-bezier(0.25, 0.1, 0, 1),
    scale 300ms cubic-bezier(0.25, 0.1, 0, 1),
    filter 300ms cubic-bezier(0.25, 0.1, 0, 1);
}

.r-round .fist,
.s-hi__hand .fist { opacity: 0; scale: 0.3; filter: blur(3px); transform: none; animation: none; }

[data-copied] :is(.hi-icon, .s-hi__hand) > svg:not(.fist) { opacity: 0; scale: 0.3; filter: blur(3px); }
[data-copied] :is(.hi-icon, .s-hi__hand) > .fist { opacity: 1; scale: 1; filter: none; }

.fist g { transform-box: fill-box; }
.fist__burst { transform-origin: 50% 100%; }

:is([data-copied], .ct-done:not([hidden])) .fist__l { animation: fist-l 320ms var(--expo-out); }
:is([data-copied], .ct-done:not([hidden])) .fist__r { animation: fist-r 320ms var(--expo-out); }
:is([data-copied], .ct-done:not([hidden])) .fist__burst { animation: fist-burst 520ms var(--expo-out); }

@keyframes fist-l { from { transform: translateX(-3px); } }
@keyframes fist-r { from { transform: translateX(3px); } }
@keyframes fist-burst { 0%, 45% { opacity: 0; transform: scale(0.4); } }

/* The UFO on the 404 flies in from the top left and settles, then its beam is written from the ship
   down, holds, and slides out the bottom, over and over, while the ship hovers. The beam hovers
   with the ship, so it never comes loose from it. */
.ufo g { transform-box: fill-box; }
.ufo { animation: ufo-in 700ms var(--expo-out) both; }
.ufo__body { animation: ufo-hover 2.4s ease-in-out 700ms infinite; }
.ufo__beam path { stroke-dasharray: 1 2; animation: ufo-beam 2.4s 550ms infinite backwards; }

@keyframes ufo-in { from { opacity: 0; transform: translate(-10px, -8px) rotate(-10deg); } }
@keyframes ufo-hover { 50% { transform: translateY(-1px); } }
@keyframes ufo-beam {
  0% { stroke-dashoffset: 1.5; animation-timing-function: cubic-bezier(0.25, 0.1, 0, 1); }
  45%, 70% { stroke-dashoffset: 0; animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  100% { stroke-dashoffset: -1.5; }
}

@media (prefers-reduced-motion: reduce) {
  .page-s :is(.s-hi, .r-round, .s-footer__mail)[data-copied],
  .fist g,
  .ufo,
  .ufo g,
  .ufo path { animation: none !important; }
  .hi-icon > svg,
  .s-hi__hand > svg { transition: opacity 150ms ease-out !important; scale: 1 !important; filter: none !important; }
}

/* --- "Email copied": a small label that rises from the button, holds, and fades ---------- */

.hi-toast {
  position: fixed;
  z-index: 600;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: var(--t-ui, var(--t-sm));
  font-weight: var(--strong);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, var(--from, 6px)) scale(0.97);
  transition: opacity 150ms ease-in, transform 150ms ease-in;
}

.hi-toast[data-show] {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  transition: opacity 200ms ease-out, transform 250ms var(--expo-out);
}

@media (prefers-reduced-motion: reduce) {
  .s-hi,
  .s-hi__text,
  .s-hi__hand,
  .hi-toast { transition: none !important; }
  .s-hi__hand svg { animation: none !important; }
}
