/* Extras — the toys: WalJu's Twitch emotes (assets/emotes), the cat that peeks over the footer, the
   pet button that throws emotes, the terminal, and the light/dark toggle. Everything here is
   decorative or optional; js/extras.js drives it and the pages read fine without either file.
   Loaded last, after rounded.css, by every page except the fan pages. */

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Emotes sized to the heading they sit in. */
.walju-emote {
  width: auto;
  height: .9em;
  margin-left: .12em;
  vertical-align: -.08em;
}

/* --- Theme toggle --------------------------------------------------------- */
.walju-theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(248, 246, 239, .3);
  border-radius: 50%;
  background: none;
  color: var(--walju-cream);
  cursor: pointer;
  transition: background var(--walju-transition), color var(--walju-transition), transform var(--walju-transition);
}

.walju-theme-toggle:hover {
  background: var(--walju-cream);
  color: var(--walju-ink);
  transform: rotate(-15deg);
}

.walju-theme-toggle[hidden] { display: none; }

.walju-theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Shows where a click will take you: the moon in light mode, the sun in dark. */
.walju-theme-toggle__sun,
:root[data-theme="dark"] .walju-theme-toggle__moon { display: none; }
:root[data-theme="dark"] .walju-theme-toggle__sun { display: block; }

/* --- The lurker ------------------------------------------------------------
   Same trick as the owl on haiyzee.com and the cloud band on sommer.walju.net: waljuSilly sits
   behind the footer and comes up for a look every few seconds. The perch is zero-height, so it adds
   no layout; it only gives the cat something to be positioned against at the footer's top edge.
   The footer is lifted above it, which is what hides the buried half. */
.walju-lurk {
  position: relative;
  z-index: 0;
  height: 0;
  pointer-events: none;
}

.walju-lurk img {
  position: absolute;
  bottom: calc(var(--walju-panel-inset, 0px) * -1);
  left: clamp(58%, 66vw, 74%);
  width: clamp(58px, 6vw, 78px);
  height: auto;
  transform: translateY(74%);
  transform-origin: 50% 100%;
  animation: walju-peek 9s ease-in-out infinite;
}

.walju-footer {
  position: relative;
  z-index: 1;
}

/* Ears only for most of the loop, then up for a look around. The emote's flat bottom edge stays
   tucked behind the footer even at the top of the peek. */
@keyframes walju-peek {
  0%, 58%, 100% { transform: translateY(74%) rotate(0deg); }
  66%           { transform: translateY(10%) rotate(-5deg); }
  76%           { transform: translateY(10%) rotate(4deg); }
  86%           { transform: translateY(10%) rotate(-2deg); }
}

/* --- Footer toys ---------------------------------------------------------- */
.walju-footer__inner > div:last-child { align-items: center; }

.walju-pet {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(248, 246, 239, .1);
  cursor: pointer;
  transition: background var(--walju-transition), transform var(--walju-transition);
}

.walju-pet img {
  display: block;
  width: 28px;
  height: 28px;
}

.walju-pet:hover,
.walju-pet:focus-visible {
  background: rgba(248, 246, 239, .2);
  transform: rotate(-10deg) scale(1.12);
}

/* Squash and spring on every press, so it answers each click. */
.walju-pet.is-pressed { animation: walju-pet-press .42s ease-out; }

@keyframes walju-pet-press {
  0%   { transform: rotate(-12deg) scale(.82); }
  40%  { transform: rotate(8deg) scale(1.3); }
  70%  { transform: rotate(-6deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

.walju-term-button {
  padding: 9px 13px;
  border: 1px solid rgba(248, 246, 239, .28);
  border-radius: 999px;
  background: none;
  color: var(--walju-cream);
  font: 700 12px/1 ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  cursor: pointer;
  transition: background var(--walju-transition), color var(--walju-transition);
}

.walju-term-button:hover {
  background: var(--walju-cream);
  color: var(--walju-ink);
}

.walju-term-button[hidden],
.walju-pet[hidden] { display: none; }

/* One thrown emote. --dx/--dy are the offset from where it lands back to the button, so it flies
   out from under the button rather than fading in on the spot; all three are set per emote in JS. */
.walju-burst {
  position: fixed;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  --rot: 0deg;
  --dx: 0px;
  --dy: 0px;
  animation: walju-pop .85s forwards;
}

.walju-burst img {
  display: block;
  width: 100%;
  height: 100%;
}

/* Expo-ish out so it lands almost at once, a small overshoot, then a plain ease-in lift away. */
@keyframes walju-pop {
  0%   { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.25) rotate(var(--rot)); animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
  30%  { opacity: 1; transform: translate(0, 0) scale(1.18) rotate(var(--rot)); animation-timing-function: ease-out; }
  48%  { opacity: 1; transform: translate(0, 0) scale(1) rotate(var(--rot)); animation-timing-function: ease-in; }
  100% { opacity: 0; transform: translate(0, -14px) scale(.9) rotate(var(--rot)); }
}

/* --- Terminal ------------------------------------------------------------- */
.walju-term {
  width: min(700px, calc(100% - 32px));
  height: min(480px, calc(100% - 64px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(168, 213, 162, .22);
  border-radius: var(--walju-r-lg, 24px);
  background: #0c1f17;
  color: #d7e5d4;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
  font: 14px/1.6 ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

.walju-term[open] {
  display: flex;
  flex-direction: column;
}

.walju-term::backdrop {
  background: rgba(6, 18, 12, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.walju-term__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid rgba(168, 213, 162, .14);
  background: rgba(168, 213, 162, .05);
}

.walju-term__dots {
  display: flex;
  gap: 7px;
}

.walju-term__dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--walju-coral);
}

.walju-term__dots i:nth-child(2) { background: #e8c76a; }
.walju-term__dots i:nth-child(3) { background: var(--walju-sky); }

.walju-term__bar p {
  flex: 1;
  margin: 0;
  color: #9fb8a6;
  font-size: 12px;
  text-align: center;
}

.walju-term__close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #9fb8a6;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.walju-term__close:hover { background: rgba(248, 246, 239, .1); color: #fff; }

.walju-term__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 4px;
  overscroll-behavior: contain;
}

.walju-term__log p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.walju-term__log a { color: var(--walju-sky); }
.walju-term__log a:hover { color: var(--walju-coral); }
.walju-term__log code { color: var(--walju-coral); }
.walju-term__muted { color: #7f9a88; }
.walju-term__echo { margin-top: 10px !important; color: #fff; }
.walju-term__echo span,
.walju-term__prompt label { color: var(--walju-sky); }

.walju-term__emote {
  display: block;
  width: 56px;
  height: 56px;
  margin: 6px 0;
}

.walju-term__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.walju-term__grid figure {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 0;
  padding: 8px 4px;
  border-radius: 14px;
  background: rgba(248, 246, 239, .05);
}

.walju-term__grid img {
  width: 44px;
  height: 44px;
}

.walju-term__grid figcaption {
  color: #9fb8a6;
  font-size: 11px;
}

.walju-term__prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 18px 16px;
}

.walju-term__prompt label { flex: none; }

.walju-term__prompt input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: #fff;
  font: inherit;
  caret-color: var(--walju-coral);
}

/* The caret is the focus cue here; the site-wide focus ring would box in the prompt. */
.walju-term__prompt input:focus-visible { outline: 0; }

@media (max-width: 760px) {
  .walju-term { font-size: 13px; }
  /* Phones would otherwise zoom the page on focus for anything under 16px. */
  .walju-term__prompt input { font-size: 16px; }
  .walju-term__prompt label { font-size: 12px; }
  .walju-header__inner .walju-theme-toggle { width: 38px; height: 38px; margin-left: auto; }
  .walju-header__inner .walju-theme-toggle + .walju-resume-link { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  /* The global reduce rule would freeze the cat on its last keyframe, i.e. ears only. Park it up. */
  .walju-lurk img { animation: none; transform: translateY(30%); }
  .walju-burst { animation: none; opacity: .75; }
  .walju-pet.is-pressed { animation: none; }
}
