/* Reset & base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0a0e2a;
}

body {
  font-family: Arial, sans-serif;
}

/* Stage fills viewport */
.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Background — stretched to fit exactly */
.bg {
  position: absolute;
  inset: 0;
  background-image: url("image/about-bg.jpg");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 0;
}

/* Title — top-left (260px / 1920 = 13.54%) */
.title {
  position: absolute;
  top: 5%;
  left: 3%;
  width: 13.54%;
  z-index: 10;
  pointer-events: none;
  user-select: none;
}

/* ================= MENU SYSTEM =================
   Z-index stack (back to front):
   telescope (1) → bed (5) → floaters (50) → diary-overlay (100)
   → menu overlay (190) → menu items (195) → toggle button (200)
*/

#menu-toggle {
  display: none;
}

.toggle-button {
  position: fixed;
  top: 20px;
  right: 2%;
  width: 150px;
  height: 150px;
  cursor: pointer;
  z-index: 200;
}

.toggle-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s;
}

.toggle-button img:hover {
  transform: rotate(40deg) scale(1.2);
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  z-index: 190;
  pointer-events: none;
  transition: background-color 0.5s ease;
}

#menu-toggle:checked ~ .overlay {
  background-color: rgba(0, 0, 0, 0.5);
  pointer-events: all;
}

.menu-item {
  position: fixed;
  transform: scale(0);
  opacity: 0;
  transition:
    transform 0.5s ease,
    opacity 0.5s ease;
  z-index: 195;
}

.menu-item img {
  width: 380px;
  height: 380px;
  cursor: pointer;
  transition: transform 0.3s;
  display: block;
}

.menu-item img:hover {
  transform: rotate(10deg) scale(1.1);
}

#home {
  top: 50vh;
  left: 40vw;
}
#about {
  top: 30vh;
  left: 15vw;
}
#portfolio {
  top: 5vh;
  left: 35vw;
}
#contact {
  top: 20vh;
  left: 55vw;
}

#menu-toggle:checked ~ .menu-item {
  opacity: 1;
  transform: scale(1);
}

/* ================= TELESCOPE ================= */

.telescope-fixed {
  position: absolute;
  bottom: -8%;
  left: 4.17%;
  width: 27.4%;
  z-index: 1;
  cursor: pointer;
  transition:
    transform 0.3s ease,
    filter 0.3s ease;
  transform-origin: bottom center;
}
.telescope-fixed img {
  width: 100%;
  display: block;
}
.telescope-fixed:hover {
  transform: scale(1.02);
  filter: drop-shadow(0 0 6px rgba(255, 220, 120, 0.2));
}

/* ================= BED =================
   Hidden on desktop (the desktop bg already includes the bed).
   Shown on mobile as a separate element so telescope can sit behind it.
*/

.bed {
  display: none;
  position: absolute;
  bottom: -11%;
  left: 28%;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  user-select: none;
}

/* ================= FLOATING ITEMS ================= */

.floater {
  position: absolute;
  z-index: 50;
  isolation: isolate;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  will-change: transform;
  transition: filter 0.3s ease;
  transform-origin: center center;
}
.floater:hover {
  filter: drop-shadow(0 0 5px rgba(255, 220, 120, 0.18));
}
.floater.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 0 8px rgba(255, 220, 120, 0.28));
}

/* Sizes (desktop) */
.diary {
  width: 14.06%;
}
.pillow {
  width: 31.25%;
}
.pencil-ps,
.pencil-ai,
.pencil-id,
.pencil-pr,
.pencil-fg {
  width: 11.46%;
}

/* ================= DIARY OVERLAY ================= */

.diary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease;
}
.diary-overlay[hidden] {
  display: none;
}
.diary-overlay-img img {
  max-width: 90vw;
  max-height: 90vh;
  display: block;
  object-fit: contain;
}
.diary-overlay-close {
  position: absolute;
  top: 3%;
  right: 3%;
  width: 50px;
  height: 50px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 101;
  transition: transform 0.2s ease;
}
.diary-overlay-close img {
  width: 100%;
  height: 100%;
}
.diary-overlay-close:hover {
  transform: rotate(90deg) scale(1.1);
}

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

/* ================= MOBILE ================= */

@media (max-width: 768px) {
  .bg {
    background-image: url("image/about-bg-mobile.png");
  }

  .pillow {
    left: 69% !important;
    top: 83% !important;
  }

  .title {
    top: 3%;
    left: 5%;
    width: 30%;
  }

  /* BED: 640/390 = 164vw wide, 16:9 aspect, anchored to bottom, centered (extends off both sides) */
  .bed {
    display: block;
    width: 164vw;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  /* TELESCOPE: 241/390 = 62vw, lifted up so most of it sits above the bed line.
     Behind the bed because telescope z-index (1) < bed z-index (5). */
  .telescope-fixed {
    bottom: 16vh;
    left: -10%;
    width: 69%;
  }

  .toggle-button {
    top: 3%;
    right: 4%;
    width: 20vw;
    height: 20vw;
    max-width: 120px;
    max-height: 120px;
    min-width: 70px;
    min-height: 70px;
  }

  .menu-item img {
    width: 53vw;
    aspect-ratio: 9 / 10;
    height: auto;
    max-width: 380px;
    max-height: 422px;
  }

  /* Your menu positions — kept as-is edited done */
  #portfolio {
    top: 10vh;
    left: 40vw;
  }
  #about {
    top: 26vh;
    left: 4vw;
  }
  #contact {
    top: 35vh;
    left: 43vw;
  }
  #home {
    top: 53vh;
    left: 20vw;
  }

  /* Floaters at exact Figma proportions */
  .diary {
    width: 39%;
  } /* 139.8 / 390 */
  .pillow {
    width: 68%;
  } /* 267.1 / 390 */
  .pencil-ps,
  .pencil-ai,
  .pencil-id,
  .pencil-pr,
  .pencil-fg {
    width: 32%;
  }

  .diary-overlay-close {
    width: 40px;
    height: 40px;
  }
}
