/* ============================================================
   GIMLI LANDING — 8-bit Lord of the Rings
   ============================================================ */

/* ---------- Custom properties ---------- */
:root {
  --bg-deep:    #0a0614;
  --bg-mid:     #1a0a2e;
  --gold:       #f5c842;
  --gold-dim:   #b8941f;
  --red:        #cc3300;
  --parchment:  #f5e6c8;
  --stone:      #3a3a4a;
  --pixel-font: 'Press Start 2P', monospace;
}

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

/* ---------- Body ---------- */
body {
  min-height: 100vh;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 60%, #120824 100%);
  font-family: var(--pixel-font);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  image-rendering: pixelated;
}

/* ============================================================
   STARS
   ============================================================ */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 0;
  animation: twinkle var(--dur) ease-in-out infinite alternate;
}
@keyframes twinkle {
  0%   { opacity: 0.2; }
  100% { opacity: 1; }
}

/* ============================================================
   MOUNTAINS (pixel silhouette)
   ============================================================ */
#mountains {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 180px;
  z-index: 1;
  pointer-events: none;
  background:
    /* Peak 1 */
    linear-gradient(135deg, transparent 33%, #1a1a2e 33%, #1a1a2e 34%, transparent 34%),
    /* Peak 2 */
    linear-gradient(150deg, transparent 20%, #12122a 20%, #12122a 21%, transparent 21%),
    /* Base */
    linear-gradient(to top, #0d0d1a 0%, #0d0d1a 40%, transparent 40%);
}

/* ============================================================
   TORCHES
   ============================================================ */
.torch {
  position: fixed;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  animation: flicker 0.15s ease-in-out infinite alternate;
}
.torch-left {
  left: 5%;
  top: 30%;
  background: radial-gradient(circle, rgba(245,200,66,0.12) 0%, transparent 70%);
}
.torch-right {
  right: 5%;
  top: 30%;
  background: radial-gradient(circle, rgba(245,200,66,0.12) 0%, transparent 70%);
}
@keyframes flicker {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 1;   transform: scale(1.08); }
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
  min-height: 100vh;
}

/* ---------- Title ---------- */
#title {
  font-size: clamp(2rem, 8vw, 5rem);
  color: var(--gold);
  text-shadow:
    0 0 10px rgba(245,200,66,0.6),
    0 0 40px rgba(245,200,66,0.3),
    4px 4px 0 #3a2a00;
  letter-spacing: 0.15em;
  margin-top: 30px;
  animation: title-glow 3s ease-in-out infinite alternate;
}
@keyframes title-glow {
  0%   { text-shadow: 0 0 10px rgba(245,200,66,0.6), 0 0 40px rgba(245,200,66,0.3), 4px 4px 0 #3a2a00; }
  100% { text-shadow: 0 0 20px rgba(245,200,66,0.9), 0 0 60px rgba(245,200,66,0.5), 4px 4px 0 #3a2a00; }
}

#subtitle {
  font-size: clamp(0.6rem, 2vw, 1rem);
  color: var(--gold-dim);
  margin-top: 10px;
  letter-spacing: 0.3em;
  opacity: 0.8;
}

/* ============================================================
   GIMLI SPRITE
   ============================================================ */
#gimli-wrapper {
  position: relative;
  margin: 40px 0 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#gimli-sprite {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: clamp(180px, 30vw, 280px);
  height: auto;
  user-select: none;
  filter: drop-shadow(0 0 12px rgba(204,51,0,0.3));
  animation: idle-bob 1.2s ease-in-out infinite;
}

@keyframes idle-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Toss animation */
#gimli-wrapper.tossing #gimli-sprite {
  animation: toss 1.6s ease-out forwards;
}
@keyframes toss {
  0%   { transform: translateY(0) rotate(0deg); }
  30%  { transform: translateY(-320px) rotate(180deg); }
  50%  { transform: translateY(-400px) rotate(360deg); }
  75%  { transform: translateY(-200px) rotate(540deg); }
  100% { transform: translateY(0) rotate(720deg); }
}

/* Landing shake */
#gimli-wrapper.landed #gimli-sprite {
  animation: land-shake 0.4s ease-out;
}
@keyframes land-shake {
  0%   { transform: translateY(0); }
  20%  { transform: translateY(8px); }
  40%  { transform: translateY(-4px); }
  60%  { transform: translateY(4px); }
  80%  { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}


/* ============================================================
   THE BUTTON
   ============================================================ */
#toss-btn, #toss-again-btn {
  font-family: var(--pixel-font);
  font-size: clamp(0.6rem, 2.5vw, 1rem);
  color: #fff;
  background: var(--red);
  border: none;
  padding: 16px 32px;
  cursor: pointer;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.1s, box-shadow 0.2s;

  /* Pixel border via box-shadow */
  box-shadow:
    /* outer border */
    -4px 0 0 0 #000,
     4px 0 0 0 #000,
     0 -4px 0 0 #000,
     0  4px 0 0 #000,
    /* glow */
     0  0  20px rgba(204,51,0,0.4);
}
#toss-btn:hover, #toss-again-btn:hover {
  transform: scale(1.05);
  box-shadow:
    -4px 0 0 0 #000,
     4px 0 0 0 #000,
     0 -4px 0 0 #000,
     0  4px 0 0 #000,
     0  0  30px rgba(204,51,0,0.7);
}
#toss-btn:active, #toss-again-btn:active {
  transform: scale(0.95);
}
#toss-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   MEME CONTAINER
   ============================================================ */
#meme-container {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: meme-slide-in 0.6s ease-out;
}
@keyframes meme-slide-in {
  0%   { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}

#meme-frame {
  background: var(--parchment);
  padding: 16px;
  max-width: 90vw;
  /* pixel border */
  box-shadow:
    -4px 0 0 0 #5a4a30,
     4px 0 0 0 #5a4a30,
     0 -4px 0 0 #5a4a30,
     0  4px 0 0 #5a4a30,
    -8px 0 0 0 #3a2a10,
     8px 0 0 0 #3a2a10,
     0 -8px 0 0 #3a2a10,
     0  8px 0 0 #3a2a10;
}

#meme-img {
  display: block;
  max-width: min(90vw, 800px);
  max-height: 75vh;
  width: auto;
  height: auto;
  image-rendering: auto; /* memes should be smooth */
}

#meme-title {
  font-family: var(--pixel-font);
  font-size: 0.55rem;
  color: #3a2a10;
  text-align: center;
  margin-top: 8px;
  max-width: 800px;
  word-break: break-word;
}

#toss-again-btn {
  margin-top: 24px;
  background: var(--stone);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

/* Screen-reader only (SEO text visible to crawlers) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Screen shake ---------- */
body.shake {
  animation: screen-shake 0.3s ease-out;
}
@keyframes screen-shake {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3px, 2px); }
  40%  { transform: translate(3px, -2px); }
  60%  { transform: translate(-2px, 1px); }
  80%  { transform: translate(2px, -1px); }
  100% { transform: translate(0, 0); }
}

/* ============================================================
   SOCIAL LINKS (bottom-right corner)
   ============================================================ */
#social-links {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  gap: 14px;
  align-items: center;
}

#social-links a {
  display: block;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.15s;
  text-decoration: none;
  line-height: 0;
}

#social-links a:hover {
  opacity: 1;
  transform: scale(1.25);
  filter: drop-shadow(0 0 8px rgba(245,200,66,0.6));
}

#social-links a img {
  width: 32px;
  height: 32px;
  display: block;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #gimli-sprite {
    width: 140px;
  }
  #toss-btn, #toss-again-btn {
    font-size: 0.55rem;
    padding: 12px 20px;
  }
  #social-links {
    bottom: 12px;
    right: 12px;
    gap: 10px;
  }
  #social-links a img {
    width: 24px;
    height: 24px;
  }
}
