/* Only hide gallery thumbnail preview videos until ready, not slider/carousel videos */
.gallery-video-thumbnail:not(.preview-ready) video {
  opacity: 0;
}

/* Ensure modal container positions close button correctly */
.lightbox-flip-wrapper {
  position: relative !important;
}

/* Unified close button for all lightboxes */
.lightbox-close {
  color: #1a1a1a !important;
  background: none !important;
  border: none !important;
  font-size: 2rem !important;
  position: absolute !important;
  top: -24px !important;
  right: -24px !important;
  z-index: 100 !important;
  cursor: pointer !important;
  text-shadow: 0 2px 8px #0005;
  transition: color 0.2s;
}

@media (prefers-color-scheme: dark) {
  .lightbox-close {
    color: #f1f0ec !important;
    text-shadow: 0 2px 8px #fff5;
  }
}

/* Always show pointer cursor on clickable links */
a,
.gallery-item a,
.gallery-item img[data-full],
.gallery-video-thumbnail,
.nav-link,
.instagram-link {
  cursor: pointer !important;
}

/* === MOBILE ARTIST INFO === */
@media (max-width: 600px) {
  .profile-header {
    display: block;
    margin: 24px auto 12px auto;
    padding: 0;
    text-align: center;
    border-bottom: none;
    background: none;
  }

  .profile-image {
    display: block;
    width: 80vw;
    max-width: 220px;
    min-width: 120px;
    height: auto;
    aspect-ratio: 1/1;
    border-radius: 12px !important;
    object-fit: cover;
    object-position: center top;
    margin: 0 auto 12px auto;
    border: 1px solid var(--color-black);
  }

  .artist-details {
    display: block;
    text-align: center;
    margin: 0 auto 12px auto;
    padding: 0 8vw;
  }

  .artist-name {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
    color: var(--color-black);
    text-transform: uppercase;
    white-space: normal;
    display: block;
  }

  .artist-title {
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--color-gray-500);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
  }
}

.profile-nav {
  flex: 1;
  padding: 20px 0;
  width: max-content;
  margin: 0 auto;
}

.profile-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  width: max-content;
}

.profile-nav li {
  margin: 0;
}

/* Refined nav link styling with smooth underline */
.nav-link {
  position: relative;
  display: block;
  padding: 16px 32px;
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-gray-600);
  text-decoration: none;
  transition: all var(--motion-duration-fast) var(--motion-ease-out);
  border-left: 3px solid transparent;
  will-change: background, color, border-color;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  height: 1px;
  background: var(--color-black);
  opacity: 0;
  transform: scaleX(0);
  transition: transform var(--motion-duration-medium) var(--motion-ease-out),
    opacity var(--motion-duration-medium) var(--motion-ease-out);
}

.nav-link:hover {
  color: var(--color-black);
  background: var(--color-gray-100);
}

.nav-link:hover::after,
.nav-link:focus::after {
  opacity: 0.3;
  transform: scaleX(1);
}

.nav-link.active {
  color: var(--color-black);
  font-weight: 500;
  border-left-color: var(--color-black);
  background: var(--gradient-subtle);
}

.nav-link.active::after {
  opacity: 1;
  transform: scaleX(1);
}

/* Anchor offset for in-grid anchors in gallery */
.gallery-item>a[id] {
  display: block;
  height: 0;
  scroll-margin-top: var(--header-height);
}

.masonry-grid>.gallery-section-heading {
  grid-column: 1 / -1;
  grid-row: auto;
  /* Visually hidden styles already applied below */
}

/* When sidebar is fixed, offset main content so grid does not go under sidebar */
/* margin-left removed: grid handles layout now */

/* === TYPOGRAPHY & BASE === */
@import url('https://fonts.googleapis.com/css2?family=Helvetica+Neue:wght@300;400;500;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-black: #111;
  --color-white: #fff;
  --color-gray-100: #f5f5f5;
  --color-gray-200: #e0e0e0;
  --color-gray-300: #ccc;
  --color-gray-400: #aaa;
  --color-gray-500: #666;
  --color-gray-600: #333;
  --color-gray-700: #3a3a38;
  --color-gray-800: #2a2a28;
  --color-gray-900: #1a1a18;

  --gradient-subtle: linear-gradient(135deg,
      rgba(255, 255, 255, 0.05) 0%,
      rgba(0, 0, 0, 0.02) 100%);
  --gradient-overlay: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%);

  --blur-sm: blur(8px);
  --blur-md: blur(16px);
  --blur-lg: blur(24px);

  --color-dark-gray: #181818;
  --color-light-gray: #f5f5f5;
  --color-border: #d1d1d1;
  --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-duration-fast: 0.28s;
  --motion-duration-medium: 0.46s;
  --motion-duration-slow: 0.68s;
  --motion-duration-glacial: 0.9s;

  --header-height: 80px;
  --sidebar-width: 15px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-white: #111;
    --color-black: #fff;
    --color-gray-100: #333;
    --color-gray-200: #444;
    --color-gray-300: #666;
    --color-gray-400: #888;
    --color-gray-500: #aaa;
    color: var(--color-white) !important;
    --color-gray-700: #ccc;
  }

  /* Protect homepage header from dark mode background inversion */
  .global-header:not(.scrolled) {
    background: transparent !important;
  }
}

.profile-container {
  top: var(--header-height);
  display: grid;
  grid-template-columns: 15vw 1fr 1fr 1fr 15vw;
  min-height: 100vh;
}

border: 1px solid var(--color-border);

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  box-sizing: border-box;
  height: 100vh;
  width: 15vw;
  min-width: 180px;
  color: var(--color-black);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: transparent;
  border-right: none;
  overflow: hidden;
  /* removed duplicate color property */
  padding-top: calc(var(--header-height) + 18px);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
  color: var(--color-dark-gray);

  .sidebar::-webkit-scrollbar-thumb {
    background: var(--color-gray-300);
    border-radius: 3px;
  }

  .sidebar::-webkit-scrollbar-thumb:hover {
    color: var(--color-dark-gray);
    background: var(--color-light-gray);

    .profile-header {
      margin-top: 0;
      color: var(--color-dark-gray);
      text-align: center;
      border-bottom: none;
      background: var(--color-light-gray);

      .profile-image,
      .profile-image img {
        color: var(--color-dark-gray);
        height: 140px;
        border-radius: 0 !important;
        object-fit: cover;
        background: var(--color-light-gray);
        margin: 0 auto 10px;
        border: 1px solid var(--color-black);
        transition: border-color var(--motion-duration-fast) var(--motion-ease-out);
        will-change: border-color;
      }

      .artist-details {
        text-align: stretch;
      }

      .artist-name {
        font-size: 1.2rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        margin-bottom: 1px;
        color: var(--color-black);
        text-transform: uppercase;
        white-space: nowrap;
      }

      .artist-title {
        font-size: 0.8125rem;
        font-weight: 400;
        letter-spacing: 0.08em;
        color: var(--color-gray-500);
        text-transform: uppercase;
      }

      /* === NAVIGATION === */

      .profile-nav {
        flex: 1;
        padding: 12px 0;
      }

      .profile-nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
      }

      .profile-nav li {
        margin: 0;
      }

      /* Refined nav link styling with smooth underline */
      .nav-link {
        position: relative;
        display: block;
        padding: 16px 32px;
        font-size: 0.9375rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        color: var(--color-gray-600);
        text-decoration: none;
        transition: all var(--motion-duration-fast) var(--motion-ease-out);
        border-left: none;
        text-transform: uppercase;
        will-change: background, color, padding;
      }

      .nav-link::after {
        content: '';
        position: absolute;
        left: 32px;
        right: 32px;
        bottom: 12px;
        height: 1px;
        background: var(--color-black);
        opacity: 0;
        transform: scaleX(0);
        transition: transform var(--motion-duration-medium) var(--motion-ease-out),
          opacity var(--motion-duration-medium) var(--motion-ease-out);
      }

      .nav-link:hover {
        color: var(--color-black);
        background: var(--color-gray-100);
      }

      .nav-link:hover::after,
      .nav-link:focus::after {
        opacity: 0.3;
        transform: scaleX(1);
      }

      .nav-link.active {
        color: var(--color-black);
        font-weight: 500;
        border-left-color: var(--color-black);
        background: var(--gradient-subtle);
      }

      .nav-link.active::after {
        opacity: 1;
        transform: scaleX(1);
      }

      .instagram-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 20px 32px;
        font-size: 0.875rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        color: var(--color-gray-600);
        text-decoration: none;
        transition: all var(--motion-duration-fast) var(--motion-ease-out);
        border: none;
        margin-top: auto;
        will-change: background, color;
      }

      .instagram-link:hover {
        color: var(--color-black);
        background: var(--color-gray-100);
      }

      .instagram-username {
        font-size: 0.8125rem;
      }

      /* === GALLERY SECTION === */
      .gallery-section {
        margin-top: calc(var(--header-height) + 18px);
        grid-column: 2 / 6;
        padding: 20px;
        max-width: 70vw;
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
        /* No header offset here; handled by .masonry-grid for universal application */
      }

      .masonry-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        width: 100%;
        margin: 0;
        box-sizing: border-box;
        padding: 0 18px 18px 18px;
        /* No top property, padding handled by .gallery-container */
      }

      @media (min-width: 768px) {
        .masonry-grid {
          grid-template-columns: repeat(3, 1fr);
          gap: 20px;
          padding: 0 20px 40px 20px;
        }
      }

      /* === GALLERY ITEMS === */
      gallery-item {
        position: relative;
        opacity: 1;
        transform: scale(1);
        transition: opacity var(--motion-duration-slow) var(--motion-ease-soft),
          transform var(--motion-duration-slow) var(--motion-ease-soft);
        will-change: transform, opacity;
      }

      .gallery-item.hidden {
        opacity: 0;
        transform: scale(0.95);
        pointer-events: none;
        position: absolute;
        visibility: hidden;
      }

      .gallery-item .img-wrapper {
        position: relative;
        width: 100%;
        height: auto;
        overflow: hidden;
        border-radius: 0;
        cursor: pointer;
        background: var(--color-gray-100);
      }

      .gallery-item .img-mask {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
        background: transparent;
        border: 1px solid var(--color-black);
        will-change: border-color;
      }

      .gallery-item .img-mask::before {
        content: '';
        position: absolute;
        inset: 0;
        background: var(--gradient-overlay);
        opacity: 0;
        transition: opacity var(--motion-duration-slow) var(--motion-ease-soft);
        z-index: 1;
        pointer-events: none;
        will-change: opacity;
      }

      .gallery-item:hover .img-mask::before {
        opacity: 0.05;
      }

      .gallery-item img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 0 !important;
        transition: transform var(--motion-duration-glacial) var(--motion-ease-soft),
          filter var(--motion-duration-medium) var(--motion-ease-out);
        will-change: transform, filter;
      }

      /* Hover and touch-active effect for gallery images */
      .gallery-item:hover img,
      .gallery-item.touch-active img {
        transform: scale(1.05);
        filter: brightness(1.1) contrast(1.1);
      }

      /* Video thumbnail orientation helpers ---------------------------------- */
      .gallery-video-thumbnail {
        position: relative;
        overflow: hidden;
        display: block;
      }

      .gallery-video-thumbnail .gallery-video-poster,
      .gallery-video-thumbnail .img {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
        /* crop to fill the thumbnail container */
        object-position: center center;
      }

      /* Orientation hints: set expected aspect ratio for the thumbnail container
   so CSS Grid / Masonry can size/crop consistently. These can be tuned. */
      .gallery-video-thumbnail.is-portrait {
        aspect-ratio: 3 / 4;
        /* tall */
      }

      .gallery-video-thumbnail.is-landscape {
        aspect-ratio: 16 / 9;
        /* wide */
      }

      .gallery-video-thumbnail.is-square {
        aspect-ratio: 1 / 1;
      }

      /* Ensure poster img sits behind the preview video element so transition is smooth */
      .gallery-video-thumbnail video.img {
        position: relative;
        z-index: 2;
      }

      .gallery-video-thumbnail .gallery-video-poster {
        position: absolute;
        inset: 0;
        z-index: 1;
      }

      .gallery-item img[data-full] {
        cursor: pointer;
      }

      /* Subtle highlight overlay for realism */
      .gallery-item:hover .img-mask::before,
      .gallery-item.touch-active .img-mask::before {
        opacity: 0.05;
        background: var(--gradient-overlay);
      }

      /* Force all gallery images to 4/5 aspect ratio, even if .img-portrait or .img-landscape is present */
      .gallery-item img,
      .gallery-item .img-portrait,
      .gallery-item .img-landscape {
        aspect-ratio: 4 / 5 !important;
        object-fit: cover !important;
        border-radius: 0 !important;
      }

      /* === VIDEO THUMBNAILS === */

      .gallery-video-thumbnail {
        position: relative;
        width: 100%;
        aspect-ratio: 4 / 5;
        height: auto;
        display: block;
        background: transparent;
        cursor: pointer;
        overflow: hidden;
        will-change: transform, opacity;
      }

      .gallery-video-thumbnail img,
      .gallery-video-thumbnail video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
      }

      .gallery-video-thumbnail .gallery-video-poster {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        z-index: 1;
        transition: opacity var(--motion-duration-fast) var(--motion-ease-out);
        will-change: opacity;
      }

      .gallery-video-thumbnail video {
        position: relative;
        z-index: 0;
        transition: opacity var(--motion-duration-fast) var(--motion-ease-out);
      }

      .gallery-video-thumbnail.preview-ready .gallery-video-poster {
        opacity: 0;
        visibility: hidden;
      }

      .gallery-video-thumbnail.preview-ready video {
        opacity: 1 !important;
        visibility: visible !important;
      }

      .gallery-video-thumbnail::after {
        content: none;
      }

      .gallery-video-thumbnail:hover::after {
        content: none;
      }

      /* === FOOTER === */
      .portfolio-footer {
        padding: clamp(40px, 6vh, 60px) clamp(20px, 5vw, 60px);
        text-align: center;
        border-top: 1px solid var(--color-gray-200);
        background: var(--color-white);
      }

      .footer-content {
        max-width: 800px;
        margin: 0 auto;
      }

      .footer-text {
        font-size: 0.875rem;
        font-weight: 400;
        letter-spacing: 0.1em;
        color: var(--color-gray-500);
        text-transform: uppercase;
        margin-bottom: 1.5rem;
      }

      .social-links {
        display: flex;
        justify-content: center;
        gap: 24px;
      }

      .social-links a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        color: var(--color-gray-600);
        font-size: 1.25rem;
        transition: all var(--motion-duration-fast) var(--motion-ease-out);
        border: none;
        border-radius: 50%;
        will-change: transform, color;
      }

      .social-links a:hover {
        color: var(--color-black);
        /* no border to color */
        transform: translateY(-2px);
      }

      /* === RESPONSIVE === */
      @media (max-width: 768px) {
        .gallery-container {
          margin-left: 0;
          max-width: 100vw;
          padding: 0;
        }

        .masonry-grid {
          grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
          gap: 8px;
          padding: var(--header-height) 8px 12px 8px;
        }
      }

      /* Anchor target utility for offset anchor scrolls by header height */
      .anchor-target {
        display: block;
        height: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        pointer-events: none;
        visibility: hidden;
      }

      /* === ANIMATIONS === */
      @keyframes fadeInUp {
        from {
          opacity: 0;
          transform: translateY(20px);
        }

        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .gallery-item {
        animation: fadeInUp var(--motion-duration-slow) var(--motion-ease-soft) backwards;
      }

      .gallery-item:nth-child(1) {
        animation-delay: 0.05s;
      }

      .gallery-item:nth-child(2) {
        animation-delay: 0.1s;
      }

      .gallery-item:nth-child(3) {
        animation-delay: 0.15s;
      }

      .gallery-item:nth-child(4) {
        animation-delay: 0.2s;
      }

      .gallery-item:nth-child(5) {
        animation-delay: 0.25s;
      }

      .gallery-item:nth-child(6) {
        animation-delay: 0.3s;
      }

      .gallery-item:nth-child(7) {
        animation-delay: 0.35s;
      }

      @media (prefers-reduced-motion: reduce) {

        .gallery-item,
        .gallery-item img,
        .gallery-video-thumbnail,
        .nav-link,
        .instagram-link,
        .profile-image,
        .social-links a {
          animation-duration: 0.01ms !important;
          animation-iteration-count: 1 !important;
          transition-duration: 0.01ms !important;
          transition-delay: 0ms !important;
        }
      }

      .gallery-item:nth-child(8) {
        animation-delay: 0.4s;
      }

      /* =======================================
   MOBILE & TABLET RESPONSIVE GALLERY
   ======================================= */

      /* Default layout (desktop-first) */
      .masonry-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 0 20px 40px;
        width: 100%;
        box-sizing: border-box;
      }

      /* Tablets and small laptops (≤900px) */
      @media (max-width: 900px) {
        .profile-container {
          display: flex;
          flex-direction: column;
          align-items: stretch;
          width: 100%;
          max-width: 100%;
          margin: 0;
          padding: 0;
        }

        .sidebar {
          position: static;
          width: 100%;
          height: auto;
          border-right: none;
          border-bottom: 1px solid var(--color-gray-200);
          background: var(--color-white);
          box-shadow: none;
          padding: 8px 0 12px;
          text-align: center;
        }

        .profile-header,
        .artist-details {
          text-align: center;
        }

        .profile-nav {
          flex-direction: row;
          flex-wrap: wrap;
          justify-content: center;
          padding: 12px 0;
          gap: 8px;
        }

        .nav-link {
          font-size: 0.8rem;
          padding: 8px 12px;
        }

        .gallery-section {
          margin: 0 auto;
          padding: 12px;
          width: 100%;
          max-width: 100%;
        }

        .masonry-grid {
          grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
          gap: 10px;
          padding: 12px;
        }

        .gallery-item img {
          aspect-ratio: auto;
          width: 100%;
          height: auto;
          border-radius: 0;
        }
      }

      /* Mobile phones (≤600px) */
      @media (max-width: 600px) {
        .masonry-grid {
          display: block;
          width: 100%;
          padding: 0;
          margin: 0 auto;
        }

        .gallery-item {
          width: 100%;
          margin-bottom: 16px;
          box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
          border-radius: 4px;
        }

        .gallery-item img,
        .gallery-video-thumbnail {
          width: 100%;
          height: auto;
          object-fit: cover;
        }

        .sidebar {
          display: block;
          width: 100vw;
          max-width: 100vw;
          min-width: 0;
          position: relative;
          float: none;
          border-right: none;
          border-bottom: 1px solid var(--color-gray-200);
          box-shadow: none;
          z-index: auto;
          padding: 0;
          background: var(--color-white);
        }

        .profile-nav {
          display: none;
        }

        body,
        html {
          width: 100%;
          overflow-x: hidden;
          margin: 0;
          padding: 0;
        }
      }

      /* Small screens - ensure sidebar doesn't overlap with header */
      @media (max-width: 768px) {
        .sidebar {
          margin-top: 60px !important;
          padding-top: 15px !important;
        }

        .profile-container {
          padding-top: 60px !important;
        }
      }

      @media (max-width: 480px) {
        .sidebar {
          margin-top: 50px !important;
          padding-top: 10px !important;
        }

        .profile-container {
          padding-top: 50px !important;
        }
      }