html, body {
  overflow-x: hidden;
  scroll-behavior: smooth;
}
body {
    margin: 0;
    font-family: 'Besley', serif;
    background: #fff;
    color: #0232A1;
  }

  /* Scroll Animation Styles */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @keyframes scaleIn {
    from {
      opacity: 0;
      transform: scale(0.95);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }

  .animate-on-scroll {
    opacity: 1;
  }

  .fade-in-element {
    opacity: 0;
  }

  .fade-in-element.animated {
    animation: fadeIn 1s ease-out forwards;
  }
  body header{
    margin: 0;
    font-family: 'Besley', serif;
    background: #fff;
    color: #0232A1;
  }
  .header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 32px 0;
    position: relative;
    flex-wrap: wrap;
    width: 75%;
    margin-left: auto;
    margin-right: auto;
    animation: scaleIn 1s ease-out;
  }
h3 {
  font-family: 'Besley', serif;
  font-weight:100;
}
p {
  font-family: 'neue haas grotesk', sans-serif;
  font-weight:100;
  font-size: 12px;
}

  /* Full-width line after header on desktop */
  @media (min-width: 769px) {
    .header::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: calc(-12.5vw);
      width: 100vw;
      height: 1px;
      background-color: #0232A1;
      transform: scaleX(0);
      transform-origin: left;
      animation: drawHorizontal 0.8s ease-out 0.3s forwards;
    }
  }

  @media (max-width: 768px) {
    .header {
      width: 100%;
      padding: 32px 0 48px 0;
      min-height: fit-content;
    }

    .name {
      overflow: visible;
      padding: 0 16px;
    }
  }
  .name {
    font-size: 26vw;
    line-height: .85;
    flex-grow: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

  @keyframes drawHorizontal {
    from {
      transform: scaleX(0);
    }
    to {
      transform: scaleX(1);
    }
  }

  @keyframes drawVertical {
    from {
      transform: scaleY(0);
    }
    to {
      transform: scaleY(1);
    }
  }
  .contact {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1px;
    font-family: 'besley', serif;
    font-size: 13;
    font-weight:200;
    flex-wrap: wrap;
    position: relative;
    background-color: transparent;
    color: #0232A1;
    width: 100vw;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
    z-index: 1000;
  }

  /* Content area at 75% width on desktop */
  @media (min-width: 769px) {
    .contact {
      padding-left: 12.5%;
      padding-right: 12.5%;
    }
  }

  .contact.scrolled {
    position: fixed;
    top: 0;
    left: 0;
    background-color: #0232A1;
    color: #FFF;
    width: 100vw;
  }

  .contact.scrolled a {
    color: #FFF !important;
  }

  @media (max-width: 768px) {
    .contact {
      padding: 8px 32px;
    }
  }
  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr; /* Fixed 4 columns */
    gap: 0;
    width: 75%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
  }
  
  @media (min-width: 769px) {
    .grid::before {
      content: '';
      position: absolute;
      top: 0;
      left: calc(-100vw / 6);
      right: calc(-100vw / 6);
      height: 1px;
      background-color: #0232A1;
      transform: scaleX(0);
      transform-origin: left;
      animation: drawHorizontal 0.8s ease-out 0.4s forwards;
    }
  }

  @media (max-width: 768px) {
    .grid {
      width: 100%;
      border-top: 1px solid #0232A1;
      border-left: 1px solid #0232A1;
    }
  }
  .about-me {
    grid-column: 1; /* Always in the first column */
    grid-row: 1 / span 5; /* Spans 5 rows to accommodate all projects */
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    background-color: #fff;
    color: #0232A1;
    box-sizing: border-box;
    position: sticky; /* Keeps it static while scrolling */
    top: 0;
    height: 100%; /* Full viewport height */
    overflow-y: auto; /* Scrollable if content overflows */
    border-left: 1px solid #0232A1;
    border-right: 1px solid #0232A1;
    border-top: 1px solid #0232A1;
  }

  /* Animated overlay for left border */
  .about-me::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: #fff;
    transform: scaleY(1);
    transform-origin: top;
    z-index: 5;
    animation: hideVertical 0.8s ease-out 0.5s forwards;
  }

  /* Animated overlay for right border */
  .about-me::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: #fff;
    transform: scaleY(1);
    transform-origin: top;
    z-index: 5;
    animation: hideVertical 0.8s ease-out 0.8s forwards;
  }

  @keyframes hideVertical {
    from {
      transform: scaleY(1);
    }
    to {
      transform: scaleY(0);
    }
  }

  .about-me h3 {
    animation: fadeIn 1s ease-out 0.3s both;
  }

  .about-me p {
    animation: fadeIn 1s ease-out 0.5s both;
  }

  .about-me h4 {
    font-family: 'Besley', serif;
    font-weight: 400;
    font-size: 16px;
    margin-top: 24px;
    margin-bottom: 12px;
    padding-top: 24px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
    position: relative;
    border-top: 1px solid #0232A1;
    animation: fadeIn 1s ease-out 0.7s both;
  }

  .about-me h4::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #fff;
    transform: scaleX(1);
    transform-origin: left;
    animation: hideHorizontal 0.8s ease-out 1.2s forwards;
  }

  .about-me h4:first-of-type {
    padding-top: 24px;
  }

  .tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    animation: fadeIn 1s ease-out 0.9s both;
  }

  .skill-tag {
    font-family: 'neue haas grotesk', sans-serif;
    font-size: 9px;
    font-weight: 500;
    color: #0232A1;
    background-color: transparent;
    border: 1px solid #0232A1;
    border-radius: 16px;
    padding: 4px 12px;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: default;
    text-transform: uppercase;
  }

  .skill-tag:hover {
    background-color: #0232A1;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(2, 50, 161, 0.2);
  }

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

  .skill-tag:hover {
    animation: bounce 0.5s ease;
  }

  .grid > div:not(.about-me) {
    grid-column: span 1; /* Projects occupy columns 2-4 */
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border-right: 1px solid #0232A1;
    border-bottom: 1px solid #0232A1;
  }

  /* White overlay on right border that animates away to reveal border */
  .grid > div:not(.about-me)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: #fff;
    transform: scaleY(1);
    transform-origin: top;
    z-index: 10;
  }

  /* White overlay on bottom border that animates away to reveal border */
  .grid > div:not(.about-me)::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #fff;
    transform: scaleX(1);
    transform-origin: left;
    z-index: 10;
  }

  /* Apply staggered hide animations to each grid item */
  .grid > div:not(.about-me):nth-child(2)::after { animation: hideVertical 0.8s ease-out 0.5s forwards; }
  .grid > div:not(.about-me):nth-child(3)::after { animation: hideVertical 0.8s ease-out 0.6s forwards; }
  .grid > div:not(.about-me):nth-child(4)::after { animation: hideVertical 0.8s ease-out 0.7s forwards; }

  .grid > div:not(.about-me):nth-child(2)::before { animation: hideHorizontal 0.8s ease-out 0.8s forwards; }
  .grid > div:not(.about-me):nth-child(3)::before { animation: hideHorizontal 0.8s ease-out 0.8s forwards; }
  .grid > div:not(.about-me):nth-child(4)::before { animation: hideHorizontal 0.8s ease-out 0.8s forwards; }
  .grid > div:not(.about-me):nth-child(5)::before { animation: hideHorizontal 0.8s ease-out 0.9s forwards; }
  .grid > div:not(.about-me):nth-child(6)::before { animation: hideHorizontal 0.8s ease-out 0.9s forwards; }
  .grid > div:not(.about-me):nth-child(7)::before { animation: hideHorizontal 0.8s ease-out 0.9s forwards; }
  .grid > div:not(.about-me):nth-child(8)::before { animation: hideHorizontal 0.8s ease-out 1.0s forwards; }
  .grid > div:not(.about-me):nth-child(9)::before { animation: hideHorizontal 0.8s ease-out 1.0s forwards; }
  .grid > div:not(.about-me):nth-child(10)::before { animation: hideHorizontal 0.8s ease-out 1.0s forwards; }
  .grid > div:not(.about-me):nth-child(11)::before { animation: hideHorizontal 0.8s ease-out 1.1s forwards; }
  .grid > div:not(.about-me):nth-child(12)::before { animation: hideHorizontal 0.8s ease-out 1.1s forwards; }
  .grid > div:not(.about-me):nth-child(13)::before { animation: hideHorizontal 0.8s ease-out 1.1s forwards; }

  @keyframes hideHorizontal {
    from {
      transform: scaleX(1);
    }
    to {
      transform: scaleX(0);
    }
  }

  /* Grid spacers for empty cells */
  .grid-spacer {
    grid-column: span 1;
    position: relative;
    aspect-ratio: 1 / 1;
    background-color: #fff;
    border-right: 1px solid #0232A1;
    border-bottom: 1px solid #0232A1;
  }

  /* White overlay on right border */
  .grid-spacer::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: #fff;
    transform: scaleY(1);
    transform-origin: top;
    z-index: 10;
  }

  /* White overlay on bottom border */
  .grid-spacer::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #fff;
    transform: scaleX(1);
    transform-origin: left;
    z-index: 10;
  }

  /* Animate spacer 14 (position after elephant puzzle) */
  .grid-spacer:nth-of-type(14)::after { animation: hideVertical 0.8s ease-out 0.8s forwards; }
  .grid-spacer:nth-of-type(14)::before { animation: hideHorizontal 0.8s ease-out 1.2s forwards; }

  /* Animate spacer 15 (last position in row 5) */
  .grid-spacer:nth-of-type(15)::after { animation: hideVertical 0.8s ease-out 0.9s forwards; }
  .grid-spacer:nth-of-type(15)::before { animation: hideHorizontal 0.8s ease-out 1.2s forwards; }

  .project-image {
    width: 75%;
    height: 75%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
    margin: auto;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
  }
  .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0232A1;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    opacity: 0;
    transform: rotateY(180deg);
    transition: opacity 0.6s ease, transform 0.6s ease;
    padding: 16px;
    backface-visibility: hidden;
    box-sizing: border-box;
  }
  .overlay h3 {
    font-family: besley, serif;
    font-weight: 200;
    margin-top: 0;
    margin-bottom: 8px;
    font-size: min(4vw, 18px);
    line-height: 1.2;
    margin-left: 16px;
    margin-right: 16px;
  }
  .overlay p {
    font-family: 'neue haas grotesk', sans-serif;
    font-weight: 100;
    font-size: 12px;
    line-height: 1.2;
    margin: 0;
    margin-left: 16px;
    margin-right: 16px;
  }

  /* Adjust text alignment in hover state */
  .grid > div:hover .overlay h3 {
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 8px;
    margin-left: 16px;
    margin-right: 16px;
    text-align: center !important;
  }

  .grid > div:hover .overlay p {
    font-size: 12px;
    font-weight: 100;
    margin: 0;
    margin-left: 16px;
    margin-right: 16px;
    text-align: center !important;
  }
  .grid > div:not(.about-me):hover {
    z-index: 10;
    aspect-ratio: 1 / 1; /* Maintain the square aspect ratio on hover */
  }

  .grid > div:hover .project-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    position: absolute;
    left: 0;
    top: 0;
    transform: none;
  }

  .grid > div:hover .overlay {
    opacity: 1;
    transform: rotateY(0deg);
    justify-content: flex-end !important;
    align-items: center !important;
    text-align: center !important;
  }

  footer {
    text-align: center;
    padding: 12px 0;
    font-family: 'Besley', serif;
    font-size: 12px;
    color: #0232A1;
    width: 75%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
  }

  footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(-12.5vw);
    width: 100vw;
    height: 1px;
    background-color: #0232A1;
    animation: drawHorizontal 1s ease-out 0.7s backwards;
    transform-origin: left;
  }

  footer img {
    width: 12px;
    height: auto;
    vertical-align: top;
    margin-right: 4px;
    transition: transform 0.3s ease;
    cursor: pointer;
  }

  footer img:hover {
    transform: rotate(180deg) scale(1.2);
  }
  @media (max-width: 768px) {
    .grid {
      grid-template-columns: 1fr 1fr 1fr; /* Revert to 3 columns */
    }
    .about-me {
      grid-column: 1 / span 3; /* Spans all columns on smaller screens */
      grid-row: auto; /* No fixed row span */
      position: relative; /* No sticky behavior */
      height: auto;
      border-bottom: 1px solid #0232A1;
    }
    .grid-spacer {
      display: none; /* Hide grid spacers on mobile */
    }
  }
  @media (max-width: 480px) {
    .grid {
      grid-template-columns: 1fr; /* Single column layout */
    }
    .about-me {
      grid-column: 1; /* Stays in its own row */
    }
  }