/* ── RESET ───────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── BASE ────────────────────────────────────────── */
body {
  /* Black body so fading screens reveal black, not #12151F */
  background: #000;
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  height: 100vh;
  color: #64EFF1;
}

/* ── TV OVERLAY ──────────────────────────────────── */
#tv-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#tv-overlay.fade-out {
  opacity: 0;
}

.tv-line {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 1px);
  bottom: calc(50% - 1px);
  background: #fff;
  transition: top 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              bottom 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.tv-line.expanded {
  top: 0;
  bottom: 0;
}

.tv-line.dark {
  background: #12151F;
  transition: top 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              bottom 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background-color 0.22s ease;
}

/* ── TERMINAL SCREEN ─────────────────────────────── */
#terminal-screen {
  position: fixed;
  inset: 0;
  background: #12151F;
  padding: clamp(1.2rem, 3vw, 2.5rem);
  display: none;
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  line-height: 1.75;
  transition: opacity 0.5s ease;
}

#terminal-screen.active {
  display: block;
}

.term-prompt {
  color: #64EFF1;
}

.term-secondary {
  color: #94A3B8;
}

/* Blinking block cursor */
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  background: #64EFF1;
  vertical-align: text-bottom;
  margin-left: 1px;
}

.cursor.blink {
  animation: cursorBlink 0.8s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── BOOT SCREEN ─────────────────────────────────── */
#boot-screen {
  position: fixed;
  inset: 0;
  background: #12151F;
  padding: clamp(1rem, 2vw, 1.5rem);
  display: none;
  font-size: clamp(0.6rem, 1.1vw, 0.72rem);
  line-height: 1.55;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow: hidden;
}

#boot-screen.active {
  display: block;
}

#boot-screen.visible {
  opacity: 1;
}

.boot-line {
  display: block;
  white-space: pre;
}

.boot-ts {
  color: #22C55E;
}

.boot-msg {
  color: #94A3B8;
}

/* ── EYES SCREEN ─────────────────────────────────── */
#eyes-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
}

#eyes-screen.active {
  display: flex;
}

/* ── MODU SVG ────────────────────────────────────── */
#modu-svg {
  width: min(80vw, 500px);
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* transform-box/origin for JS-driven blink (scaleY from center) */
#eye-right,
#eye-left {
  transform-box: fill-box;
  transform-origin: center;
}

/* Smile paths start invisible; toggled by JS */
#eye-right-smile,
#eye-left-smile {
  opacity: 0;
  transition: opacity 0.12s ease;
  transform-box: fill-box;
  transform-origin: center;
}

/* Bob wrapper: subtle vertical float */
#modu-bob {
  display: flex;
  align-items: center;
  justify-content: center;
}

#modu-bob.bobbing {
  animation: idleBob 4s ease-in-out infinite;
}

@keyframes idleBob {
  0%, 100% { transform: translateY(0px);  }
  50%       { transform: translateY(-2px); }
}

/* Smile bounce on SVG element */
#modu-svg.smile-bounce {
  animation: smileBounce 0.38s ease-out forwards;
}

@keyframes smileBounce {
  0%   { transform: scale(1);    }
  40%  { transform: scale(1.06); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1);    }
}

/* ── SPEECH BUBBLE ───────────────────────────────── */
#speech-bubble {
  position: fixed;
  /* upper-right of the centred Modu character */
  bottom: calc(50% + 110px);
  left: calc(50% + 52px);
  transform: none;
  background: #12151F;
  border: 1.5px solid #64EFF1;
  border-radius: 10px;
  padding: 12px 18px;
  width: max-content;
  max-width: min(360px, calc(100vw - 32px));
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(0.65rem, 1.3vw, 0.8rem);
  line-height: 1.45;
  color: #64EFF1;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 12px rgba(100, 239, 241, 0.15);
}

#speech-bubble.visible {
  opacity: 1;
}

/* Arrow at the bottom-left of the bubble, pointing toward Modu below-left */
#speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 22px;
  transform: none;
  border-left: 5px solid transparent;
  border-right: 13px solid transparent;
  border-top: 9px solid #64EFF1;
}

/* Inner fill layer */
#speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 24px;
  transform: none;
  border-left: 4px solid transparent;
  border-right: 11px solid transparent;
  border-top: 7px solid #12151F;
  z-index: 1;
}

@media (max-width: 720px) {
  #speech-bubble {
    bottom: calc(50% + 140px);
    left: auto;
    right: 16px;
    max-width: min(300px, calc(100vw - 32px));
  }
}
