﻿/* ============================================================
   404 | Lost in Space
   ============================================================ */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05071a;
  color: #f0f4ff;
  font-family: "Poppins", sans-serif;
  -webkit-font-smoothing: antialiased;
}

:root {
  --accent: #06b6d4;
  --purple: #7c3aed;
  --text: #f0f4ff;
  --muted: rgba(200, 210, 230, 0.6);
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
}

/*BACKGROUND CANVAS + ORBS*/

#error-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  animation: orbDrift 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 500px;
  height: 500px;
  top: -200px;
  left: -200px;
  background: radial-gradient(
    circle,
    rgba(124, 58, 237, 0.3) 0%,
    transparent 70%
  );
  animation-duration: 13s;
}
.orb-2 {
  width: 400px;
  height: 400px;
  bottom: -150px;
  right: -150px;
  background: radial-gradient(
    circle,
    rgba(37, 99, 235, 0.22) 0%,
    transparent 70%
  );
  animation-duration: 18s;
  animation-delay: -5s;
}
.orb-3 {
  width: 300px;
  height: 300px;
  top: 40%;
  left: 55%;
  background: radial-gradient(
    circle,
    rgba(6, 182, 212, 0.18) 0%,
    transparent 70%
  );
  animation-duration: 16s;
  animation-delay: -9s;
}
@keyframes orbDrift {
  to {
    transform: translate(40px, 50px) scale(1.12);
  }
}

/*PAGE GRID desktop: 2 columns, mobile: 1 column*/

.page {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 45% 55%;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "space content"
    "footer footer";
}

/*LEFT space visual*/

.space-side {
  grid-area: space;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2vh 2vw;
  gap: clamp(10px, 2vh, 24px);
  position: relative;
  overflow: hidden;
}

/* Big 404 */
.big-404 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vw, 16px);
  line-height: 1;
  user-select: none;
}

.d {
  font-size: clamp(4rem, 10vw, 9rem);
  font-weight: 900;
  background: linear-gradient(135deg, #a78bfa 0%, #818cf8 40%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 0 18px rgba(129, 140, 248, 0.45));
}
.d:first-child {
  animation-delay: 0.08s;
}
.d-zero {
  animation-delay: 0.18s;
}
.d:last-child {
  animation-delay: 0.28s;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.4) rotateY(90deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotateY(0);
  }
}

/* Planet zero */
.zero-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.planet {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.planet-ring {
  position: absolute;
  width: 130%;
  height: 30%;
  border: 2px solid rgba(124, 58, 237, 0.6);
  border-radius: 50%;
  transform: rotateX(75deg);
  animation: ringRotate 8s linear infinite;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.35);
}
@keyframes ringRotate {
  to {
    transform: rotateX(75deg) rotate(360deg);
  }
}

/* Astronaut scene */
.astro-scene {
  position: relative;
  width: clamp(140px, 22vw, 260px);
  height: clamp(120px, 18vh, 200px);
  flex-shrink: 0;
}

.astronaut {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(40px, 5vw, 64px);
  animation: floatAstronaut 4s ease-in-out infinite;
}
@keyframes floatAstronaut {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, -65%);
  }
}

.a-head {
  width: 60%;
  margin: 0 auto;
  aspect-ratio: 1;
  background: radial-gradient(circle at 35% 35%, #fff, #d4d4d4);
  border-radius: 50%;
  position: relative;
  box-shadow:
    inset -2px -2px 4px rgba(0, 0, 0, 0.2),
    0 0 10px rgba(124, 58, 237, 0.4);
}
.a-visor {
  position: absolute;
  width: 45%;
  height: 55%;
  background: radial-gradient(
    circle,
    rgba(100, 160, 255, 0.85) 0%,
    transparent 70%
  );
  border-radius: 50%;
  top: 22%;
  left: 27%;
  box-shadow: 0 0 8px rgba(100, 160, 255, 0.6);
}
.a-head::after {
  content: "";
  position: absolute;
  width: 80%;
  height: 90%;
  border: 1.5px solid rgba(124, 58, 237, 0.55);
  border-radius: 50%;
  top: -5%;
  left: 10%;
}

.a-body {
  width: 50%;
  margin: 4px auto 0;
  height: clamp(18px, 3vh, 32px);
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}

.a-arms {
  display: flex;
  gap: 60%;
  justify-content: center;
  position: absolute;
  width: 100%;
  top: 39%;
}
.a-arm {
  width: 12%;
  height: clamp(16px, 2.5vh, 26px);
  background: linear-gradient(to bottom, #7c3aed, #4c1d95);
  border-radius: 3px;
  animation: swingArm 2s ease-in-out infinite;
}
.a-arm:last-child {
  animation-delay: -1s;
}
@keyframes swingArm {
  0%,
  100% {
    transform: rotate(-15deg);
  }
  50% {
    transform: rotate(15deg);
  }
}

.a-legs {
  display: flex;
  gap: 14%;
  justify-content: center;
  position: absolute;
  bottom: -2px;
  width: 55%;
  left: 22%;
}
.a-leg {
  width: 10%;
  height: clamp(14px, 2vh, 22px);
  background: linear-gradient(to bottom, #5b21b6, #3b0764);
  border-radius: 3px;
  animation: kickLeg 1.6s ease-in-out infinite;
}
.a-leg:last-child {
  animation-delay: -0.8s;
}
@keyframes kickLeg {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Floating emoji items */
.fi {
  position: absolute;
  font-size: clamp(16px, 2.2vw, 28px);
  animation: floatEmoji 5s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.3));
  pointer-events: none;
}
.fi-1 {
  top: 10%;
  left: 5%;
  animation-delay: 0s;
}
.fi-2 {
  top: 5%;
  right: 8%;
  animation-delay: 0.6s;
}
.fi-3 {
  bottom: 15%;
  left: 8%;
  animation-delay: 1.2s;
}
.fi-4 {
  bottom: 10%;
  right: 5%;
  animation-delay: 1.8s;
}
.fi-5 {
  top: 50%;
  left: 2%;
  animation-delay: 2.4s;
}
@keyframes floatEmoji {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(8px, -12px) rotate(6deg);
  }
  66% {
    transform: translate(-6px, -8px) rotate(-4deg);
  }
}

/*RIGHT content*/

.content-side {
  grid-area: content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 2vh clamp(20px, 4vw, 60px) 2vh clamp(16px, 3vw, 40px);
  gap: clamp(6px, 1.2vh, 16px);
  overflow: hidden;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 2px;
}
.brand-logo {
  width: clamp(28px, 3.5vw, 42px);
  height: clamp(28px, 3.5vw, 42px);
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.5));
  animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
.brand-name {
  font-size: clamp(0.7rem, 1.6vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #c4b5fd, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Title */
.title {
  font-size: clamp(1.5rem, 4vw, 2.8rem);
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.35s forwards;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.subtitle {
  font-size: clamp(0.75rem, 1.8vw, 1.05rem);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.45s forwards;
}

.msg {
  font-size: clamp(0.7rem, 1.5vw, 0.9rem);
  color: var(--muted);
  line-height: 1.55;
  max-width: 42ch;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.55s forwards;
}

/* Fun fact pill */
.fact-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
  font-size: clamp(0.65rem, 1.3vw, 0.8rem);
  padding: 5px 14px;
  border-radius: 50px;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.65s forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.fact-pill i {
  font-size: 0.85em;
  flex-shrink: 0;
}

/* Buttons */
.btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.75s forwards;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: clamp(8px, 1.2vh, 12px) clamp(16px, 2vw, 26px);
  border-radius: 50px;
  font-size: clamp(0.72rem, 1.4vw, 0.88rem);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #fff;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.6);
}
.btn-shine {
  position: absolute;
  top: -50%;
  left: -80%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 60%
  );
  transform: skewX(-15deg);
  pointer-events: none;
}
.btn-primary:hover .btn-shine {
  animation: shineSwipe 0.55s ease forwards;
}
@keyframes shineSwipe {
  to {
    left: 130%;
  }
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.55);
  transform: translateY(-1px);
}

/* Nav grid */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(5px, 0.8vw, 10px);
  width: 100%;
  opacity: 0;
  animation: fadeUp 0.6s ease-out 0.85s forwards;
}
.nt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: clamp(7px, 1vh, 12px) 4px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: clamp(0.6rem, 1.2vw, 0.78rem);
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.nt i {
  font-size: clamp(13px, 1.6vw, 20px);
  color: var(--accent);
  transition: color 0.2s;
}
.nt:hover {
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.38);
  transform: translateY(-3px);
}
.nt:hover i {
  color: #a78bfa;
  animation: iconSpin 0.45s ease;
}
@keyframes iconSpin {
  50% {
    transform: rotate(180deg) scale(1.15);
  }
  to {
    transform: rotate(360deg) scale(1);
  }
}
.nt-glow {
  background: linear-gradient(
    135deg,
    rgba(124, 58, 237, 0.18),
    rgba(37, 99, 235, 0.12)
  );
  border-color: rgba(124, 58, 237, 0.32);
  color: #c4b5fd;
}
.nt-glow:hover {
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.25);
}

/*FOOTER copyright only*/

.page-footer {
  grid-area: footer;
  text-align: center;
  font-size: clamp(0.62rem, 1.2vw, 0.75rem);
  color: rgba(148, 163, 184, 0.45);
  padding: clamp(5px, 1vh, 10px) 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(5, 7, 26, 0.65);
  backdrop-filter: blur(6px);
}

/*RESPONSIVE BREAKPOINTS*/

/*Tablet (900px): shrink two-col layout*/
@media (max-width: 900px) {
  .space-side {
    padding: 1.5vh 1.5vw;
  }
  .content-side {
    padding: 1.5vh 3vw;
    gap: clamp(4px, 1vh, 12px);
  }
  .nav-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/*Mobile (640px): single column*/
@media (max-width: 640px) {
  .page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "space"
      "content"
      "footer";
  }

  .space-side {
    padding: clamp(8px, 2vh, 16px) 16px clamp(4px, 1vh, 8px);
    gap: clamp(6px, 1.5vh, 14px);
    flex-direction: row;
    align-items: center;
    justify-content: center;
  }

  .big-404 {
    flex-shrink: 0;
  }
  .d {
    font-size: clamp(2.8rem, 14vw, 5rem);
  }

  .astro-scene {
    width: clamp(80px, 22vw, 130px);
    height: clamp(80px, 18vh, 120px);
    flex-shrink: 0;
  }

  .content-side {
    padding: clamp(6px, 1.5vh, 12px) clamp(14px, 4vw, 24px);
    align-items: center;
    text-align: center;
    gap: clamp(4px, 0.8vh, 10px);
    justify-content: flex-start;
  }

  .msg {
    max-width: 95%;
  }
  .fact-pill {
    max-width: 96%;
  }

  .btns {
    justify-content: center;
  }

  .nav-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }
  .nt {
    padding: 8px 4px;
    font-size: 0.62rem;
  }
  .nt i {
    font-size: 15px;
  }
}

/*Small phones (400px)*/
@media (max-width: 400px) {
  .space-side {
    flex-direction: column;
    padding: 8px 12px 4px;
    gap: 6px;
  }
  .astro-scene {
    width: 120px;
    height: 70px;
  }
  .astronaut {
    width: 36px;
  }
  .d {
    font-size: 2.4rem;
  }
  .fi {
    font-size: 14px;
  }

  .title {
    font-size: 1.3rem;
  }
  .subtitle {
    font-size: 0.7rem;
  }
  .msg {
    font-size: 0.68rem;
    line-height: 1.4;
  }

  .fact-pill {
    font-size: 0.62rem;
    padding: 4px 10px;
  }
  .btn {
    padding: 7px 12px;
    font-size: 0.7rem;
  }

  .nav-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .nt {
    padding: 6px 3px;
    font-size: 0.58rem;
    border-radius: 8px;
  }
  .nt i {
    font-size: 13px;
  }
}

/*Landscape on short phones (height < 500px)*/
@media (max-height: 500px) and (orientation: landscape) {
  .page {
    grid-template-columns: 38% 62%;
    grid-template-rows: 1fr auto;
    grid-template-areas: "space content" "footer footer";
  }
  .space-side {
    padding: 1vh 1vw;
    gap: 6px;
  }
  .content-side {
    padding: 1vh 2vw;
    gap: 4px;
  }
  .astro-scene {
    height: 80px;
  }
  .title {
    font-size: 1.2rem;
  }
  .subtitle {
    font-size: 0.72rem;
  }
  .msg {
    font-size: 0.68rem;
    line-height: 1.3;
  }
  .fact-pill {
    padding: 3px 10px;
    font-size: 0.65rem;
  }
  .btn {
    padding: 6px 12px;
    font-size: 0.7rem;
  }
  .nav-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .nt {
    padding: 6px 3px;
    font-size: 0.6rem;
  }
  .nt i {
    font-size: 12px;
  }
}

/*Canvas Background*/
#error-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/*Floating Orbs*/
.error-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 12s ease-in-out infinite alternate;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -180px;
  left: -180px;
  background: radial-gradient(
    circle,
    rgba(124, 58, 237, 0.28) 0%,
    transparent 70%
  );
  animation-duration: 14s;
}

.orb-2 {
  width: 350px;
  height: 350px;
  bottom: -100px;
  right: -100px;
  background: radial-gradient(
    circle,
    rgba(37, 99, 235, 0.22) 0%,
    transparent 70%
  );
  animation-duration: 18s;
  animation-delay: -4s;
}

.orb-3 {
  width: 280px;
  height: 280px;
  top: 50%;
  right: 10%;
  background: radial-gradient(
    circle,
    rgba(6, 182, 212, 0.18) 0%,
    transparent 70%
  );
  animation-duration: 16s;
  animation-delay: -8s;
}

@keyframes orbFloat {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(40px, 50px) scale(1.15);
  }
}
