/* donce.dev terminal: tokyo night with the cyberpunk dial turned up */

:root {
  --bg-deep: #07080f;
  --bg: #0b0c14;
  --panel: rgba(22, 22, 30, 0.86);
  --panel-edge: #292e42;
  --fg: #a9b1d6;
  --fg-bright: #c0caf5;
  --comment: #565f89;
  --cyan: #7dcfff;
  --blue: #7aa2f7;
  --purple: #bb9af7;
  --magenta: #ff007c;
  --green: #9ece6a;
  --yellow: #e0af68;
  --red: #f7768e;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --pixel: "VT323", var(--mono);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  overscroll-behavior: none;
}

body.term-body {
  font-family: var(--mono);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

::selection {
  background: var(--magenta);
  color: var(--bg-deep);
}

.term {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--app-height, 100dvh);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 0, 124, 0.16), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(125, 207, 255, 0.14), transparent 60%),
    var(--bg);
}

/* ---------- background ---------- */

.term__bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.term__grid {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: -10%;
  height: 55%;
  background-image:
    linear-gradient(rgba(187, 154, 247, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(187, 154, 247, 0.22) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, black 10%, transparent 85%);
  animation: grid-run 3s linear infinite;
}

@keyframes grid-run {
  to { background-position: 0 48px, 0 0; }
}

.term__kana {
  position: absolute;
  top: 50%;
  writing-mode: vertical-rl;
  font-size: 15px;
  letter-spacing: 0.5em;
  color: rgba(255, 0, 124, 0.32);
  text-shadow: 0 0 8px rgba(255, 0, 124, 0.5);
  transform: translateY(-50%);
  white-space: nowrap;
}

.term__kana--left { left: 18px; }
.term__kana--right {
  right: 18px;
  color: rgba(125, 207, 255, 0.3);
  text-shadow: 0 0 8px rgba(125, 207, 255, 0.5);
}

.term__fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.38) 100%);
  animation: flicker 6s infinite steps(1);
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 0.86; }
  48% { opacity: 1; }
  83% { opacity: 0.92; }
}

/* ---------- window ---------- */

.term__window {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  height: 100%;
  max-height: 860px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(255, 0, 124, 0.25),
    0 0 32px rgba(255, 0, 124, 0.18),
    0 0 80px rgba(125, 207, 255, 0.1),
    inset 0 0 60px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.term__window::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--magenta), var(--purple), var(--cyan));
  box-shadow: 0 0 12px var(--magenta);
}

.term__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--panel-edge);
  font-family: var(--pixel);
  font-size: 20px;
  line-height: 1;
  color: var(--comment);
  flex-shrink: 0;
}

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

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

.term__dots i:nth-child(2) { background: var(--yellow); }
.term__dots i:nth-child(3) { background: var(--green); }

.term__title {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-bright);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.term__status {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.term__led {
  width: 8px;
  height: 8px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

/* ---------- log ---------- */

.term__log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 8px;
  font-size: 14px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-edge) transparent;
  -webkit-overflow-scrolling: touch;
}

.term__line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.6em;
}

.term__line--boot { color: var(--comment); }
.term__line--boot .ok { color: var(--green); }
.term__line--boot .warn { color: var(--yellow); }
.term__line--dim { color: var(--comment); margin-bottom: 8px; }
.term__line--thinking { color: var(--purple); }

.term__line--user {
  margin-top: 14px;
  color: var(--fg-bright);
}

.term__answer {
  margin: 4px 0 2px;
  padding-left: 12px;
  border-left: 2px solid rgba(255, 0, 124, 0.45);
}

.term__prompt {
  color: var(--magenta);
  text-shadow: 0 0 8px rgba(255, 0, 124, 0.55);
  white-space: nowrap;
}

.term__hl {
  color: var(--yellow);
}

.term__log a {
  color: var(--cyan);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.term__log a:hover {
  color: var(--bg-deep);
  background: var(--cyan);
  text-decoration: none;
}

.term__log a.term__cmd {
  color: var(--purple);
  text-decoration: none;
  background: rgba(187, 154, 247, 0.1);
  padding: 0 4px;
  border-radius: 3px;
}

.term__log a.term__cmd:hover {
  color: var(--bg-deep);
  background: var(--purple);
}

.term__banner {
  margin: 14px 0 4px;
  font-family: var(--mono);
  font-size: clamp(6px, 2.05vw, 13px);
  line-height: 1.12;
  color: var(--cyan);
  text-shadow: 2px 0 rgba(255, 0, 124, 0.75), -2px 0 rgba(125, 207, 255, 0.6), 0 0 14px rgba(125, 207, 255, 0.45);
  animation: glitch 5s infinite steps(1);
  overflow: hidden;
}

@keyframes glitch {
  0%, 100% { transform: none; }
  92% { transform: translateX(3px) skewX(-6deg); color: var(--magenta); }
  93% { transform: translateX(-2px); }
  94% { transform: none; color: var(--cyan); }
}

/* ---------- input ---------- */

.term__input-line {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--panel-edge);
  background: rgba(7, 8, 15, 0.55);
  font-size: 15px;
  line-height: 1.6;
  cursor: text;
  flex-shrink: 0;
}

.term__typed {
  color: var(--fg-bright);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-right: -8px;
}

.term__caret {
  display: inline-block;
  width: 0.62em;
  height: 1.15em;
  align-self: center;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

.term__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  /* 16px keeps iOS from zooming on focus */
  font-size: 16px;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  cursor: text;
}

.term__chips {
  display: flex;
  gap: 8px;
  padding: 0 18px 14px;
  background: rgba(7, 8, 15, 0.55);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.term__chips::-webkit-scrollbar { display: none; }

.term__chip {
  flex-shrink: 0;
  font: inherit;
  font-family: var(--pixel);
  font-size: 19px;
  line-height: 1;
  padding: 6px 12px 5px;
  color: var(--cyan);
  background: rgba(125, 207, 255, 0.06);
  border: 1px solid rgba(125, 207, 255, 0.35);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}

.term__chip:hover,
.term__chip:focus-visible {
  color: var(--bg-deep);
  background: var(--cyan);
  outline: none;
}

/* ---------- the snack goblin ---------- */

.term__critters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.critter {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  transform-origin: center;
}

.critter canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 6px rgba(158, 206, 106, 0.55));
  pointer-events: auto;
  cursor: pointer;
}

.critter__bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 8px 3px;
  font-family: var(--pixel);
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
  color: var(--green);
  background: var(--bg-deep);
  border: 2px solid var(--green);
  box-shadow: 3px 3px 0 rgba(158, 206, 106, 0.35);
  animation: bubble 1.6s ease-out forwards;
}

@keyframes bubble {
  0% { opacity: 0; margin-top: 6px; }
  12%, 80% { opacity: 1; margin-top: 0; }
  100% { opacity: 0; margin-top: -8px; }
}

.critter__crumb {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--green);
  animation: crumb 0.8s ease-in forwards;
}

.critter__crumb:nth-child(odd) { background: var(--yellow); }

@keyframes crumb {
  to { transform: translate(var(--drift), 46px); opacity: 0; }
}

.critter__heart {
  position: absolute;
  font-family: var(--pixel);
  font-size: 20px;
  color: var(--magenta);
  text-shadow: 0 0 8px var(--magenta);
  opacity: 0;
  animation: heart 1.2s ease-out forwards;
}

@keyframes heart {
  0% { opacity: 0; transform: translateY(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-48px); }
}

.critter__food {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--pixel);
  font-size: 26px;
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow);
  animation: food-drop 0.4s ease-out;
}

@keyframes food-drop {
  from { transform: translate(-50%, -150%); opacity: 0; }
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .term {
    padding: 0;
    padding-top: env(safe-area-inset-top);
  }

  .term__window {
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .term__kana,
  .term__status-text,
  .term__input-line .term__host {
    display: none;
  }

  .term__bar {
    padding: 10px 12px 8px;
    font-size: 18px;
  }

  .term__log {
    padding: 12px 12px 6px;
    font-size: 13px;
  }

  .term__answer {
    padding-left: 9px;
  }

  .term__input-line {
    padding: 10px 12px;
    font-size: 14px;
  }

  .term__chips {
    padding: 0 12px calc(10px + env(safe-area-inset-bottom));
  }

  .term__chip {
    font-size: 18px;
  }
}

/* ---------- Lord Beerus (do not wake) ---------- */

.beerus {
  position: absolute;
  z-index: 2;
  font-size: 16px;
  line-height: 1;
}

.beerus canvas {
  display: block;
  /* 54px sprite at 1.5x */
  width: 81px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: brightness(1.12) drop-shadow(0 0 6px rgba(187, 154, 247, 0.35));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* default: napping on top of the input bar */
.term__input-line > .beerus {
  right: 12px;
  bottom: calc(100% - 4px);
}

/* wide screens: in the page corner, on the grid floor */
.term > .beerus {
  left: 28px;
  bottom: 18px;
  font-size: 20px;
}

.term > .beerus canvas {
  width: 162px;
}

.beerus__z {
  position: absolute;
  top: 18%;
  font-family: var(--pixel);
  color: var(--purple);
  text-shadow: 0 0 8px rgba(187, 154, 247, 0.8);
  pointer-events: none;
  opacity: 0;
  animation: snore 2.6s ease-out forwards;
}

@keyframes snore {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(26px, -54px) scale(1.2); }
}

.beerus__say {
  position: absolute;
  bottom: 92%;
  padding: 4px 8px 3px;
  font-family: var(--pixel);
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
  color: var(--purple);
  background: var(--bg-deep);
  border: 2px solid var(--purple);
  box-shadow: 3px 3px 0 rgba(187, 154, 247, 0.35);
  pointer-events: none;
  animation: bubble 2s ease-out forwards;
}

.term > .beerus .beerus__say {
  left: 4px;
  width: max-content;
  max-width: 150px;
  white-space: normal;
}

.term__input-line > .beerus .beerus__say { right: 10%; }

.critter--erased canvas {
  pointer-events: none;
  animation: hakai 0.9s steps(6) forwards;
}

@keyframes hakai {
  0% { filter: drop-shadow(0 0 6px var(--purple)) brightness(1.6) saturate(0.4); }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.8);
    filter: drop-shadow(0 0 14px var(--purple)) brightness(2.2) saturate(0);
  }
}

.critter--respawn canvas {
  animation: respawn 0.45s steps(5);
}

@keyframes respawn {
  from { opacity: 0; transform: scale(0.3); }
}

.critter__dust {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--purple);
  box-shadow: 0 0 6px var(--purple);
  opacity: 0;
  animation: dust 1.2s ease-out forwards;
}

@keyframes dust {
  0% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: 0; transform: translate(var(--drift), -56px); }
}

/* keep the last log lines clear of Beerus when he naps on the input bar */
@media (max-width: 1279px) {
  .term__log {
    padding-bottom: 50px;
  }
}

@media (min-width: 641px) and (max-width: 1279px) {
  .term__input-line > .beerus canvas {
    width: 108px;
  }

  .term__log {
    padding-bottom: 64px;
  }
}

@media (min-width: 1600px) {
  .term > .beerus canvas {
    width: 216px;
  }
}

/* ---------- hakai: what happens after the fifth wake ---------- */

.beerus--annoyed canvas {
  filter: brightness(1.12) drop-shadow(0 0 8px rgba(255, 0, 124, 0.7));
  animation: annoyed 0.24s steps(2) infinite;
}

@keyframes annoyed {
  50% { transform: translateX(1px); }
}

.angry-beerus {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  transform-origin: center;
}

.angry-beerus canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 0 8px rgba(187, 154, 247, 0.9)) drop-shadow(0 0 22px rgba(255, 0, 124, 0.45));
  animation: rage-aura 1.2s ease-in-out infinite;
}

@keyframes rage-aura {
  50% { filter: drop-shadow(0 0 12px rgba(187, 154, 247, 1)) drop-shadow(0 0 32px rgba(255, 0, 124, 0.65)); }
}

.angry-beerus--rise canvas {
  animation: rage-rise 0.6s steps(6), rage-aura 1.2s ease-in-out 0.6s infinite;
}

@keyframes rage-rise {
  from { transform: scale(0.4); filter: brightness(3) drop-shadow(0 0 30px var(--purple)); }
}

.angry-beerus__say {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 9px 3px;
  font-family: var(--pixel);
  font-size: 20px;
  line-height: 1;
  white-space: nowrap;
  color: var(--bg-deep);
  background: var(--purple);
  border: 2px solid var(--fg-bright);
  box-shadow: 3px 3px 0 rgba(255, 0, 124, 0.6);
  pointer-events: none;
  animation: bubble 2s ease-out forwards;
}

.hakai-mote {
  position: absolute;
  width: 3px;
  height: 3px;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  pointer-events: none;
  animation: hakai-mote 1.4s ease-out forwards;
}

@keyframes hakai-mote {
  0% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)); }
}

.hakai-flash {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, rgba(187, 154, 247, 0.55), rgba(255, 0, 124, 0.25) 45%, transparent 75%);
  opacity: 0;
  animation: hakai-flash 1.3s ease-out forwards;
}

@keyframes hakai-flash {
  10% { opacity: 1; }
  100% { opacity: 0; }
}

.hakai-shake {
  animation: hakai-shake 0.12s steps(2) 5;
}

@keyframes hakai-shake {
  0% { transform: translate(3px, -2px); }
  50% { transform: translate(-3px, 2px); }
}

.term__window.hakai-aura {
  border-color: var(--purple);
  box-shadow:
    0 0 0 2px var(--purple),
    0 0 40px rgba(187, 154, 247, 0.8),
    0 0 120px rgba(255, 0, 124, 0.35);
  transition: box-shadow 0.4s, border-color 0.4s;
}

.hakai-crumble {
  animation: hakai-crumble 0.8s ease-in forwards !important;
}

@keyframes hakai-crumble {
  25% {
    opacity: 1;
    color: #f3eaff;
    text-shadow: 0 0 8px var(--purple), 0 0 18px var(--purple);
    filter: brightness(1.5);
  }
  100% { opacity: 0; transform: translateY(-8px); filter: blur(4px) brightness(2); }
}

.hakai-fade {
  border-color: transparent !important;
  background: transparent !important;
  transition: border-color 1.2s, background 1.2s;
}

.term__window.hakai-gone {
  animation: hakai-gone 0.9s ease-in forwards;
}

@keyframes hakai-gone {
  to { opacity: 0; transform: scale(0.97); filter: blur(6px) brightness(1.6); }
}

.term--erased .term__grid,
.term--erased .term__kana {
  animation: hakai-fade-out 1.2s ease-in forwards;
}

@keyframes hakai-fade-out {
  to { opacity: 0; filter: blur(4px); }
}

/* sits above the critters so the refresh button can never be covered */
.term__void {
  position: absolute;
  inset: 0;
  z-index: 52;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  font-family: var(--pixel);
  font-size: 22px;
  line-height: 1.2;
  color: var(--comment);
  animation: void-in 1.2s ease-out both;
}

.term__void p {
  margin: 0;
}

.term__void p:first-child {
  color: var(--fg);
}

.term__void-button {
  font: inherit;
  color: var(--purple);
  background: rgba(187, 154, 247, 0.08);
  border: 1px solid rgba(187, 154, 247, 0.5);
  padding: 2px 10px;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
}

.term__void-button:hover,
.term__void-button:focus-visible {
  color: var(--bg-deep);
  background: var(--purple);
  outline: none;
}

@keyframes void-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .term__grid,
  .term__fx,
  .term__banner,
  .term__led,
  .term__caret,
  .beerus--annoyed canvas,
  .angry-beerus canvas,
  .hakai-shake {
    animation: none;
  }
}
