/* ============================================================
   GAME BOY CARTRIDGE-INSERT INTRO
   Original animation. No Nintendo IP. Pure CSS + tiny JS.
   ============================================================ */

/* FOUC guard: while the intro is pending or active, hide page body
   and paint a solid dark-green backdrop so the cartridge animation
   isn't visible against half-rendered content. */
html.gb-intro-pending body > *:not(.gb-intro),
html.gb-intro-active  body > *:not(.gb-intro) {
  visibility: hidden;
}
html.gb-intro-pending,
html.gb-intro-active {
  overflow: hidden;
  background: #0f380f !important;
}
html.gb-intro-pending body,
html.gb-intro-active body {
  background: #0f380f !important;
  background-image: none !important;
}

.gb-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f380f;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(155, 188, 15, 0.045) 0 2px,
    transparent 2px 4px
  );
  font-family: 'Press Start 2P', system-ui, monospace;
  animation: gb-intro-fade-in 220ms ease-out;
}

@keyframes gb-intro-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gb-intro--exit {
  animation: gb-intro-fade-out 380ms ease-in forwards;
}
@keyframes gb-intro-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: scale(1.02); }
}

.gb-intro__skip {
  position: absolute;
  top: 22px;
  right: 22px;
  background: transparent;
  border: 2px solid #9bbc0f;
  color: #9bbc0f;
  font-family: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 1;
  text-transform: uppercase;
}
.gb-intro__skip:hover { background: #9bbc0f; color: #0f380f; }
.gb-intro__skip:focus-visible { outline: 2px solid #e0f8d0; outline-offset: 2px; }

/* ---------- Stage ---------- */

.gb-intro__stage {
  position: relative;
  width: 280px;
  height: 460px;
}

/* ---------- Cartridge (slides down from above) ---------- */

.gb-intro__cart {
  position: absolute;
  top: -140px; /* above stage */
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 90px;
  background: #c4cfa1;
  border: 4px solid #0f380f;
  box-shadow: inset 0 -10px 0 rgba(15, 56, 15, 0.18);
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14px;
  animation: gb-cart-insert 1300ms cubic-bezier(0.55, 0.05, 0.4, 1) 250ms forwards;
}

.gb-intro__cart-label {
  background: #e0f8d0;
  color: #0f380f;
  font-size: 0.55rem;
  padding: 5px 8px;
  border: 2px solid #0f380f;
  letter-spacing: 0.08em;
}

@keyframes gb-cart-insert {
  0%   { top: -140px; }
  82%  { top: 0; }
  88%  { top: 8px; }   /* tiny click rebound */
  100% { top: 0; }
}

/* ---------- GameBoy shell (sits below the slot) ---------- */

.gb-intro__shell {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: #cadc9f;
  border: 4px solid #0f380f;
  border-radius: 14px 14px 14px 60px; /* DMG bottom-left curve */
  box-shadow:
    inset 0 -8px 0 rgba(15, 56, 15, 0.12),
    inset 0 4px 0 rgba(224, 248, 208, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 18px 18px;
}

/* "click" shake when cartridge seats */
.gb-intro__shell {
  animation: gb-shell-shake 120ms ease-out 1500ms;
}
@keyframes gb-shell-shake {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(0, 2.5px); }
}

/* ---------- Screen frame + LCD ---------- */

.gb-intro__screen-frame {
  width: 100%;
  background: #8b8e75;
  border-radius: 6px 6px 28px 6px;
  padding: 18px 16px 26px;
  position: relative;
}

.gb-intro__screen {
  width: 100%;
  height: 110px;
  background: #0f380f;
  position: relative;
  overflow: hidden;
  animation: gb-screen-on 700ms steps(6, end) 1600ms forwards;
}
@keyframes gb-screen-on {
  0%   { background: #0f380f; }
  35%  { background: #306230; }
  70%  { background: #8bac0f; }
  100% { background: #9bbc0f; }
}

.gb-intro__screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(15, 56, 15, 0.08) 0 2px,
    transparent 2px 3px
  );
  pointer-events: none;
  opacity: 0;
  animation: gb-scanlines-on 200ms ease-out 2150ms forwards;
}
@keyframes gb-scanlines-on { to { opacity: 1; } }

.gb-intro__screen-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f380f;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  opacity: 0;
  animation: gb-text-in 280ms ease-out 2300ms forwards;
}
@keyframes gb-text-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gb-intro__brand {
  text-align: center;
  color: #9b1c3a;
  font-size: 0.4rem;
  letter-spacing: 0.05em;
  margin-top: 8px;
  font-style: italic;
}

/* ---------- Bottom row: power LED ---------- */

.gb-intro__bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #0f380f;
  font-size: 0.42rem;
  letter-spacing: 0.08em;
  align-self: flex-start;
  padding: 14px 4px 0;
}

.gb-intro__led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a4a4a;
  box-shadow: inset 0 0 2px rgba(0,0,0,0.6);
  animation: gb-led-on 80ms ease-in 1600ms forwards;
}
@keyframes gb-led-on {
  to { background: #c41e3a; box-shadow: 0 0 5px #ff4d6d, inset 0 0 1px #6b0c1f; }
}

/* ---------- Reduced motion: collapse to a fast fade ---------- */

@media (prefers-reduced-motion: reduce) {
  .gb-intro,
  .gb-intro *,
  .gb-intro *::before,
  .gb-intro *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition: none !important;
  }
  .gb-intro__cart       { top: 0; }
  .gb-intro__screen     { background: #9bbc0f; }
  .gb-intro__screen::before { opacity: 1; }
  .gb-intro__screen-text { opacity: 1; }
  .gb-intro__led        { background: #c41e3a; box-shadow: 0 0 5px #ff4d6d; }
}

/* ---------- Mobile ---------- */
@media (max-width: 360px) {
  .gb-intro__stage { transform: scale(0.85); }
}
