/* =========================
   Navigation Links - Enhanced
========================= */
.nav-link {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-link:focus {
  background-color: rgba(255, 255, 255, 0.15);
}

.drawer__link {
  display: block;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.2s ease;
}

.drawer__link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* =========================
   Reset & Base - Optimized
========================= */
* { 
  box-sizing: border-box; 
}

html, body {
  margin: 0; 
  padding: 0; 
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, Inter, system-ui, Arial, sans-serif;
  color: #fff;
  background: transparent;
  overflow: hidden;
  font-display: swap;
}

h1, h2 { 
  margin: 0 0 .6rem; 
  color: #fff; 
}

p, a, span { 
  margin: 0; 
  color: #fff; 
}

a { 
  text-decoration: none; 
}

:focus-visible { 
  outline: 2px solid #fff; 
  outline-offset: 2px; 
}

/* =========================
   Background - GPU Optimized with Mobile Vertical Support
========================= */
.gradient-bg {
  position: fixed; 
  inset: 0; 
  height: 100%;
  width: 500%;
  background:
    radial-gradient(120% 100% at 20% 50%, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 55%),
    linear-gradient(90deg,
      #0a0a0b 0%,
      #141516 10%,
      #1d1e20 20%,
      #2c2d30 32%,
      #3d3e42 45%,
      #56585d 58%,
      #7a7c82 70%,
      #a9abb0 82%,
      #d9dade 92%,
      #ffffff 100%
    );
  z-index: -2;
  will-change: transform;
  transform: translate3d(0,0,0);
  backface-visibility: hidden;
}

/* Mobile vertical gradient - stacked version */
@media (max-width: 1024px) {
  .gradient-bg {
    width: 100%;
    height: 500%;
    background:
      radial-gradient(100% 120% at 50% 20%, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0) 55%),
      linear-gradient(180deg,
        #0a0a0b 0%,
        #141516 10%,
        #1d1e20 20%,
        #2c2d30 32%,
        #3d3e42 45%,
        #56585d 58%,
        #7a7c82 70%,
        #a9abb0 82%,
        #d9dade 92%,
        #ffffff 100%
      );
  }
}

/* =========================
   Header - Performance Optimized
========================= */
.site-header {
  position: fixed; 
  top: 0; 
  left: 0; 
  right: 0; 
  height: 60px; 
  z-index: 10;
  display: flex; 
  align-items: center; 
  gap: .8rem; 
  padding: 0 .8rem;
  color: #fff;
  background: rgba(10,10,12,.55);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  will-change: transform;
}

.brand { 
  display: flex; 
  align-items: center; 
  gap: .5rem; 
}

.brand__logo { 
  border-radius: 6px; 
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  will-change: auto;
}

.brand__name { 
  font-weight: 700; 
  letter-spacing: .3px; 
  white-space: nowrap; 
}

.nav__menu { 
  margin-left: auto; 
  display: flex; 
  gap: 1rem; 
}

/* Hamburger - Enhanced */
.hamburger {
  display: none; 
  width: 40px; 
  height: 40px;
  border: 1px solid rgba(255,255,255,.2); 
  border-radius: 10px; 
  background: transparent;
  cursor: pointer;
}

.hamburger span { 
  display: block; 
  width: 18px; 
  height: 2px; 
  background: #fff; 
  margin: 6px auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Drawer - Optimized Animations */
.drawer {
  position: fixed; 
  top: 0; 
  left: 0; 
  height: 100%; 
  width: min(82vw,320px); 
  z-index: 30;
  background: rgba(16,16,18,.96);
  border-right: 1px solid rgba(255,255,255,.08);
  transform: translateX(-105%);
  transition: transform .35s cubic-bezier(0.4, 0.0, 0.2, 1);
  padding: 1rem 1rem 2rem;
  will-change: transform;
}

.drawer.open { 
  transform: translateX(0); 
}

.drawer__nav { 
  display: flex; 
  flex-direction: column; 
  gap: 1rem; 
  margin-top: 1rem; 
}

.drawer__link { 
  padding: .6rem .2rem; 
  border-bottom: 1px solid rgba(255,255,255,.08); 
}

.backdrop {
  position: fixed; 
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0; 
  pointer-events: none;
  transition: opacity .25s ease; 
  z-index: 25;
}

.backdrop.show { 
  opacity: 1; 
  pointer-events: auto; 
}

/* =========================
   Viewport Track
========================= */
.track {
  position: fixed; 
  top: 60px; 
  left: 0; 
  right: 0; 
  bottom: 0;
  overflow: hidden;
}

/* Vertical scrolling for mobile devices */
@media (max-width: 1024px) {
  .track {
    bottom: 44px; /* Account for footer height */
    overflow-y: auto;
    overflow-x: hidden;
  }
}

/* =========================
   Horizontal Scroller - Fixed
========================= */
.h-scroll {
  display: flex; 
  height: 100%; 
  width: 100%;
  overflow-x: auto; 
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  outline: none;
  touch-action: pan-x; 
  overscroll-behavior-x: contain;
  will-change: scroll-position;
}

/* Vertical scrolling for mobile/tablet */
@media (max-width: 1024px) {
  .h-scroll {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
    height: auto;
    min-height: 100%;
  }
}

/* Hide scrollbars */
.h-scroll::-webkit-scrollbar { 
  display: none; 
}

.h-scroll { 
  scrollbar-width: none; 
  -ms-overflow-style: none;
}

/* =========================
   Panels - Fixed Layout
========================= */
.panel {
  flex: 0 0 100vw; /* Fixed width, no grow/shrink */
  height: 100%;
  display: grid; 
  place-items: center;
  scroll-snap-align: start;
  padding: 2rem;
  text-align: center;
  contain: layout style;
  position: relative;
}

/* Vertical layout for mobile/tablet */
@media (max-width: 1024px) {
  .panel {
    flex: none;
    width: 100%;
    min-height: 100vh;
    height: auto;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
  }
  
  .panel#portfolio {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2rem;
    padding-bottom: 3rem;
    min-height: 100vh;
  }
  
  .panel#hero {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* =========================
   HERO - Responsive Typography
========================= */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  max-width: 1200px;
  width: min(92vw, 1200px);
  margin: 0 auto;
  padding: 2rem;
}

.hero-text { 
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-text h1 { 
  font-size: clamp(2rem, 4vw, 3.5rem); 
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero-text .lead { 
  opacity: 0.9; 
  font-size: clamp(1rem, 2vw, 1.25rem);
  margin: 0;
}

.hero-image { 
  display: flex; 
  justify-content: center;
  align-items: center;
}

.hero-image img {
  max-width: 100%;
  height: auto;
}

/* =========================
   About Section
========================= */
.about-wrap {
  display: flex; 
  flex-direction: row; 
  align-items: center; 
  justify-content: center;
  gap: 2rem; 
  width: 100%; 
  max-width: 1200px; 
  margin: 0 auto; 
  padding: 2rem;
}

.about-text { 
  flex: 1; 
  text-align: left; 
}

.about-image { 
  flex: 1; 
  display: flex; 
  justify-content: center; 
}

.about-image img {
  max-width: 100%; 
  height: auto;
}

/* =========================
   Portfolio - Grid Optimized with Mobile Improvements
========================= */
.parallax-wrap { 
  width: min(900px, 90vw); 
  margin: 0 auto; 
  text-shadow: 0 1px 12px rgba(0,0,0,.35);
}

.portfolio-grid {
  display: grid; 
  gap: 1rem; 
  margin-top: 1rem;
  grid-template-columns: repeat(3, 1fr);
  width: min(900px, 90vw); 
  margin-inline: auto;
}

.portfolio-item {
  display: block;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 12px; 
  padding: .8rem;
  transition: transform .15s cubic-bezier(0.4, 0.0, 0.2, 1), 
              filter .15s ease;
  cursor: pointer;
  will-change: transform;
  overflow: hidden; /* Ensure content doesn't overflow */
}

.portfolio-item:hover { 
  transform: translateY(-2px) translateZ(0); 
  filter: brightness(1.03); 
}

.portfolio-item img { 
  width: 100%; 
  height: auto; 
  max-height: 120px; /* Constrain height */
  object-fit: cover; /* Maintain aspect ratio while filling */
  border-radius: 10px; 
  display: block; 
  margin-bottom: .5rem;
}

.portfolio-item span { 
  display: block; 
  font-weight: 600; 
  font-size: 0.9rem;
  line-height: 1.3;
}

.on-white { 
  color: #000; 
}

/* =========================
   Portfolio Modal
========================= */
.portfolio-modal {
  position: fixed; 
  inset: 0;
  display: none;
  align-items: center; 
  justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 60;
}

.portfolio-modal.show { 
  display: flex; 
}

.modal-content {
  width: min(92vw, 960px);
  background: rgba(20,20,22,0.78);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  position: relative;
}

.modal-close {
  position: absolute; 
  top: 10px; 
  right: 10px;
  width: 36px; 
  height: 36px; 
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: #fff; 
  font-size: 18px; 
  line-height: 34px; 
  cursor: pointer;
}

.modal-body {
  display: grid; 
  grid-template-columns: 1.2fr 1fr; 
  min-height: 360px;
}

.modal-image {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2); /* optional subtle backdrop behind image */
}

.modal-image img { 
  display: block; 
  width: 100%; 
  height: 100%; 
  object-fit: contain; 
}

.modal-text { 
  padding: 1.6rem; 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
}

.modal-text h3 { 
  margin: 0 0 .5rem; 
  font-size: 1.5rem; 
  color: #fff; 
}

.modal-text a {
  align-self: flex-start; 
  margin-top: 1rem; 
  padding: .6rem 1rem;
  border-radius: 12px; 
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08); 
  color: #fff; 
  font-weight: 600; 
  text-decoration: none;
}

/* =========================
   Footer
========================= */
.site-footer {
  position: fixed; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  height: 44px; 
  z-index: 10;
  display: flex; 
  align-items: center; 
  justify-content: center;
  background: rgba(10,10,12,.45); 
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .85rem;
}

/* =========================
   Responsive Breakpoints - Updated
========================= */
@media (max-width: 1024px) {
  .portfolio-grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1.2rem;
  }
  
  .portfolio-item img {
    max-height: 100px;
  }
}

@media (max-width: 900px) {
  .nav__menu { 
    display: none; 
  }
  .hamburger { 
    display: inline-block; 
  }
  .brand__name { 
    font-size: 1rem; 
  }
}

@media (max-width: 768px) {
  .panel { 
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .panel#hero {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .hero-grid { 
    grid-template-columns: 1fr; 
    text-align: center; 
    gap: 1.5rem;
    align-items: center;
    justify-items: center;
  }
  
  .hero-text { 
    text-align: center;
    max-width: 100%;
  }
  
  .hero-text h1 {
    margin-bottom: 1rem;
  }
  
  .hero-image {
    order: -1; /* Put image above text on mobile */
  }
  
  .hero-image img { 
    height: auto; 
    max-width: 280px;
    width: 100%;
  }
  
  .about-wrap { 
    flex-direction: column; 
    text-align: center; 
  }
  
  .about-text { 
    text-align: center; 
  }
  
  /* Portfolio improvements for tablet */
  .portfolio-grid {
    gap: 1rem;
    width: min(600px, 85vw);
  }
  
  .portfolio-item {
    padding: 1rem;
  }
  
  .portfolio-item img {
    max-height: 80px;
  }

  .on-white { 
  color: #fff; 
  }
  
  .modal-body { 
    grid-template-columns: 1fr; 
  }
  
  .modal-image { 
    max-height: 42vh; 
  }

  .modal-image img { 
    height: auto;
  }
}

@media (max-width: 640px) {
  .panel#portfolio {
    padding-top: 1rem;
    padding-bottom: 4rem;
    min-height: auto; /* Allow content to determine height */
  }
  
  .parallax-wrap {
    width: min(400px, 90vw);
    max-height: none;
  }
  
  .portfolio-grid { 
    grid-template-columns: 1fr; 
    gap: 1.5rem;
    width: min(400px, 85vw);
    padding: 0 1rem;
    margin-bottom: 2rem;
  }
  
  .portfolio-item {
    padding: 1.2rem;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.25);
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
  }
  
  .portfolio-item:hover {
    transform: translateY(-4px) translateZ(0);
    filter: brightness(1.05);
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
  }
  
  .portfolio-item img {
    max-height: 140px;
    border-radius: 8px;
    margin-bottom: .8rem;
  }
  
  .portfolio-item span {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
  }
  
  .brand__logo { 
    width: 26px; 
    height: 26px; 
  }
  
  /* Stack animation for mobile - add some stagger effect */
  .portfolio-item:nth-child(1) {
    animation-delay: 0.1s;
  }
  
  .portfolio-item:nth-child(2) {
    animation-delay: 0.2s;
  }
  
  .portfolio-item:nth-child(3) {
    animation-delay: 0.3s;
  }
  
  /* Subtle entrance animation */
  .portfolio-item {
    animation: slideInUp 0.6s ease-out backwards;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .portfolio-grid {
    width: min(320px, 90vw);
    gap: 1.2rem;
  }
  
  .portfolio-item {
    padding: 1rem;
  }
  
  .portfolio-item img {
    max-height: 120px;
  }
  
  .portfolio-item span {
    font-size: 0.9rem;
  }
}

/* Keyframe for mobile animation */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   Accessibility & Performance
========================= */
@media (prefers-reduced-motion: reduce) {
  .portfolio-item {
    animation: none !important;
  }
  
  * { 
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; 
  }
}