/* Global Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "loos-wide", sans-serif;
  height: 100vh;
  overflow: hidden;
  background-color: #e0e0e0;
}

/* Grid Background */
.grid-background {
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  opacity: 1;
  transition: transform 0.1s ease-out;
}

/* Particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  transition: transform 0.15s ease-out;
  opacity: 1;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  animation: float 20s infinite ease-in-out;
}

@keyframes float {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  50% {
    transform: translate3d(0, -10px, 0) rotate(1deg);
  }
}

/* Video Background */
#video-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.video-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.video-background video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Project Lists */
#project-list {
  list-style: none;
  opacity: 0;
  animation: fadeIn 1s ease forwards 0.6s;
}

#project-list li {
  margin-bottom: 0.75rem;
}

#project-list li:last-child {
  margin-bottom: 0;
}

.project-link {
  position: relative;
  display: inline-block;
  letter-spacing: 0.01em;
  color: #000;
  opacity: 0.5;
  font-weight: 300;
  font-family: "loos-wide", sans-serif;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0.2rem 0;
  border: none;
  background: transparent;
  border-bottom: 1px solid transparent;
  text-decoration: none;
  overflow: hidden;
}

.top-project-link {
  font-size: 1.1rem;
  opacity: 0.6;
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0;
  position: relative;
  z-index: 50;
  cursor: pointer;
  line-height: 1;
  vertical-align: baseline;
  min-width: 140px;
  width: max-content;
}

.arrow,
.top-project-link .arrow {
  position: absolute;
  left: 100%;
  top: 0;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 10px;
}

.arrow.show,
.top-project-link .arrow.show {
  opacity: 1;
  transform: translateX(0);
}

#poster-list,
#code-list {
  position: relative;
  z-index: 51;
}

#poster-list li,
#code-list li {
  position: relative;
  z-index: 52;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Typewriter Effects */
.typewriter-text {
  border-right: 2px solid #000;
  white-space: nowrap;
  opacity: 0;
}

.typewriter-text.initialized {
  opacity: 1;
}

.typewriter-text.typing,
.typewriter-text.finished {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { border-color: transparent; }
  51%, 100% { border-color: #000; }
}

.typewriter-char {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  line-height: inherit;
}

/* Explore Button */
.explore-button-container {
  position: fixed;
  top: 46.5%;
  right: 0;
  width: 80%;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  padding-top: 8rem;
}

.explore-button-wrapper {
  display: flex;
  justify-content: flex-end;
  max-width: 30rem;
  width: 100%;
  margin-top: -0.5rem;
}

.explore-button {
  padding: 0.4rem 0.8rem;
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.06));
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 25px;
  color: #000;
  font-family: "loos-wide", sans-serif;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  cursor: pointer;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    inset 0 0 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
  min-width: 120px;
  text-align: center;
}

.explore-button:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 6px rgba(0, 0, 0, 0.06),
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    0 4px 6px rgba(0, 0, 0, 0.05);
}

.explore-button-text {
  position: relative;
  display: inline-block;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.explore-button-text.slide-out {
  opacity: 0;
  transform: translateX(-15px);
}

.explore-button-text.slide-in {
  opacity: 1;
  transform: translateX(0);
}

/* Project Containers */
.project-container {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  opacity: 0;
  animation: imageReveal 0.6s ease forwards;
  cursor: pointer;
  pointer-events: auto;
}

.project-container img {
  height: 100vh;
  width: auto;
  object-fit: contain;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes imageReveal {
  from {
    opacity: 0;
    transform: scale3d(0.9, 0.9, 1) translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
  }
}

#bio-text {
  opacity: 0;
  animation: fadeIn 0.5s ease forwards 0.4s;
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Magnetic Letters */
.magnetic-letter {
  display: inline-block;
  transition: transform 0.1s ease-out;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.magnetic-letter.magnetic {
  transition: none;
  will-change: transform, opacity, z-index;
  transform: translate3d(0, 0, 0);
}

/* Modal */
#modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: none;
  backdrop-filter: blur(0px);
}

#modal.visible {
  visibility: visible;
  animation: modalIn 0.5s ease forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(8px);
  }
}

#modal-content {
  max-width: 90%;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.9);
  transition: transform 0.5s ease;
}

#modal.visible #modal-content {
  transform: scale(1);
}

#close-modal-btn {
  position: fixed;
  top: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  z-index: 9999;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
}

#close-modal-btn:hover {
  opacity: 0.7;
  animation: closeButtonSpin 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes closeButtonSpin {
  to {
    transform: scale(1.1) rotate(360deg);
  }
}

.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: translate3d(-50%, -50%, 0) rotate(360deg);
  }
}

#modal-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  display: none;
}

.video-container {
  position: relative;
  width: 100%;
  max-width: 80vw;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}

.video-container video {
  width: 100%;
  height: 100%;
}

/* GitHub Card */
.github-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 3rem;
  max-width: 480px;
  width: 100%;
  font-family: "loos-wide", sans-serif;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.15),
    0 4px 6px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  display: none;
  text-align: left;
}

.github-card:hover {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1));
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-3px);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.15),
    0 6px 20px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.github-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

#github-name {
  font-family: "loos-extrawide", sans-serif;
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0;
  color: #000;
  letter-spacing: -0.02em;
}

.github-language {
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.7);
  font-family: "loos-extrawide", sans-serif;
  padding: 0.3rem 0.8rem;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(10px);
}

.github-description {
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.7);
  margin-bottom: 2rem;
  font-weight: 400;
}

.github-footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-top: 1rem;
}

.github-link {
  font-size: 1.2rem;
  position: relative;
  cursor: pointer;
  white-space: nowrap;
  font-family: "loos-extrawide", sans-serif;
  font-weight: bold;
  letter-spacing: -0.05em;
  text-transform: lowercase;
  transition: transform 0.1s ease-out;
  user-select: none;
  text-decoration: none;
  color: #000;
}

.github-link .typewriter-char {
  display: inline-block;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header */
h1, h2, h3, h4, h5, h6, header a {
  font-family: "loos-extrawide", sans-serif;
}

.header-link {
  font-size: 5rem;
  font-weight: bold;
  letter-spacing: -0.05em;
  text-transform: lowercase;
  transition: transform 0.1s ease-out;
  align-self: baseline;
  user-select: none;
  cursor: default;
}

#info-link {
  font-size: 2rem;
  align-self: baseline;
  position: relative;
  margin-right: 60px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

#info-link .typewriter-char {
  display: inline-block;
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0);
}

.about-arrow,
.repo-arrow {
  position: absolute;
  left: 100%;
  top: 0;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 0.5rem;
  white-space: nowrap;
}

.header-link .typewriter-char {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.flicker-text {
  animation: oldLampFlicker 4s infinite;
}

@keyframes oldLampFlicker {
  0%, 100% { opacity: 0.2; }
  2% { opacity: 0.18; }
  4% { opacity: 0.22; }
  6% { opacity: 0.15; }
  8% { opacity: 0.25; }
  10% { opacity: 0.12; }
  12% { opacity: 0.28; }
  14% { opacity: 0.16; }
  16% { opacity: 0.24; }
  18% { opacity: 0.19; }
  20% { opacity: 0.26; }
  22% { opacity: 0.14; }
  24% { opacity: 0.21; }
  26% { opacity: 0.17; }
  28% { opacity: 0.23; }
  30% { opacity: 0.2; }
  35% { opacity: 0.18; }
  40% { opacity: 0.22; }
  45% { opacity: 0.16; }
  50% { opacity: 0.24; }
  55% { opacity: 0.19; }
  60% { opacity: 0.21; }
  65% { opacity: 0.17; }
  70% { opacity: 0.25; }
  75% { opacity: 0.15; }
  80% { opacity: 0.23; }
  85% { opacity: 0.18; }
  90% { opacity: 0.22; }
  95% { opacity: 0.16; }
}

/* Video Active State */
body.video-active {
  background-color: #000;
}

body.video-active video {
  mix-blend-mode: normal;
}

body.video-active #video-background {
  opacity: 1;
}

body.video-active .particles {
  opacity: 0;
}

body.video-active .grid-background {
  opacity: 0;
}

body.video-active .explore-button {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

body.video-active .explore-button:hover {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
  border-color: rgba(255, 255, 255, 0.3);
}

body.video-active .typewriter-text {
  color: #fff;
  border-right-color: #fff;
}

body.video-active #bio-text {
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 75% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 30 !important;
  padding-top: 8rem !important;
  pointer-events: none !important;
  transform: translateY(0) !important;
}

body.video-active .explore-button-container {
  position: fixed !important;
  top: 46.5% !important;
  right: 0 !important;
  width: 75% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  z-index: 100 !important;
  pointer-events: none !important;
  padding-top: 8rem !important;
}

body.video-active .explore-button-wrapper {
  display: flex !important;
  justify-content: flex-start !important;
  max-width: 36rem !important;
  width: 100% !important;
  padding-left: 7rem !important;
}

body.video-active .explore-button {
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.video-active .project-link,
body.video-active .project-container,
body.video-active #info-link {
  cursor: default !important;
  pointer-events: none;
}

body.video-active .magnetic-letter,
body.video-active #info-link .typewriter-char {
  position: fixed !important;
  z-index: 5000;
  transform-origin: center center;
  transition: none !important;
  pointer-events: none;
  mix-blend-mode: normal;
  color: #fff !important;
}

body.video-active {
  cursor: default;
}

body.video-active *,
body.video-active::before,
body.video-active::after {
  cursor: inherit;
  display: initial;
}

body.video-active #project-list {
  z-index: 300;
  position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    overflow: hidden !important;
    font-size: 16px;
    height: 100vh;
  }

  .fixed.top-8.left-8 {
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 50;
  }

  .flex.items-baseline {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .text-2xl {
    font-size: 1.5rem !important;
    margin-bottom: 0.2rem;
  }

  .fixed.top-8.left-8 div[style*="margin-left"] {
    margin-left: 0 !important;
  }

  #poster-preview-container {
    display: none !important;
  }

  .flex.h-screen {
    flex-direction: column;
    height: 100vh !important;
    min-height: 100vh;
    padding: 0;
    overflow: hidden;
  }

  .w-1\/4.h-screen {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: 50vh;
    padding: 5rem 1rem 1rem;
    margin-top: 80px;
    display: flex;
    justify-content: center;
    overflow-y: auto;
  }

  #project-list {
    text-align: center;
    width: 100%;
    max-width: 300px;
  }

  .project-link {
    font-size: 1.2rem !important;
    padding: 0.3rem 0;
    display: block;
    text-align: center;
  }

  .top-project-link {
    font-size: 1.1rem !important;
    margin-bottom: 0.4rem;
    min-width: auto;
    text-align: left;
  }

  .w-3\/4.h-screen {
    width: 100% !important;
    height: auto !important;
    margin-left: 0 !important;
    position: relative;
    min-height: auto;
    flex: 1;
  }

  .fixed.inset-y-0.right-0.w-3\/4 {
    position: fixed !important;
    top: auto !important;
    bottom: 15rem !important;
    left: 1rem !important;
    right: 1rem !important;
    width: auto !important;
    padding: 0.5rem !important;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    min-height: auto;
  }

  .max-w-xl.text-black.text-2xl {
    font-size: 1rem !important;
    line-height: 1.3 !important;
    max-width: none !important;
    text-align: left !important;
  }

  .explore-button-container {
    position: fixed !important;
    top: auto !important;
    bottom: 13rem !important;
    left: 1rem !important;
    width: 16rem !important;
    padding: 0.5rem !important;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .explore-button {
    font-size: 1.1rem !important;
    padding: 0.3rem 0.7rem !important;
    min-width: 100px;
    border-radius: 18px !important;
  }

  #project-image-container {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: 40vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
  }

  .project-container {
    height: auto !important;
    max-height: 50vh;
    width: 100% !important;
    display: flex;
    justify-content: center;
  }

  .project-container img {
    height: auto !important;
    max-height: 50vh;
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }

  header {
    position: fixed !important;
    bottom: 1rem !important;
    left: 1rem !important;
    right: 1rem !important;
    padding: 0.5rem !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  #logo-link {
    font-size: 2rem !important;
  }

  #info-link {
    font-size: 1.2rem !important;
    margin-right: 0 !important;
  }

  .fixed.bottom-10.left-8 {
    position: fixed !important;
    bottom: 5rem !important;
    left: 1rem !important;
    right: 1rem !important;
    padding: 0.5rem !important;
    text-align: left;
  }

  .text-black.text-lg {
    font-size: 0.8rem !important;
    line-height: 1.4 !important;
    text-align: left !important;
    max-width: none;
    margin: 0;
  }

  #bio-marquee p br {
    display: none;
  }

  #modal-content {
    max-width: 95% !important;
    max-height: 85vh !important;
    margin: 1rem;
  }

  #modal-image {
    max-height: 70vh !important;
  }

  .github-card {
    max-width: 90% !important;
    padding: 1.5rem !important;
    margin: 1rem;
  }

  #github-name {
    font-size: 1.3rem !important;
  }

  .github-description {
    font-size: 0.9rem !important;
  }

  .github-link {
    font-size: 1rem !important;
  }

  #close-modal-btn {
    top: 1rem !important;
    right: 1rem !important;
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  .particles {
    opacity: 1 !important;
  }

  .grid-background {
    opacity: 1 !important;
    background-size: 50px 50px !important;
  }

  .project-link:hover,
  .top-project-link:hover,
  .explore-button:hover {
    transform: none !important;
    opacity: inherit !important;
  }

  #video-background {
    transform: none !important;
  }

  .magnetic-letter.magnetic {
    transform: none !important;
  }

  .arrow {
    display: none !important;
  }
}

@media (max-width: 768px) {
  body:has(.flicker-text) {
    overflow: auto !important;
  }

  body:has(.flicker-text) .flex.h-screen {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 2rem 1.5rem;
  }

  body:has(.flicker-text) .w-3\/4.h-screen {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  body:has(.flicker-text) .fixed.inset-y-0 {
    position: static;
    width: 100%;
    padding: 0;
    justify-content: center;
  }

  body:has(.flicker-text) .text-black.text-right > div {
    text-align: center;
  }

  body:has(.flicker-text) .text-9xl {
    font-size: 4rem;
  }

  body:has(.flicker-text) .text-2xl {
    font-size: 1.2rem;
    line-height: 1.6;
  }

  body:has(.flicker-text) header {
    padding: 1rem;
  }

  body:has(.flicker-text) .header-link {
    font-size: 1.2rem;
    padding: 0.4rem 1rem;
    cursor: pointer !important;
  }
}