/* base CSS */
:root {
  /* Material 3 Light Colors (Max Contrast Focus) */
  --md-sys-color-background: #FDFBFF;
  --md-sys-color-on-background: #000000;
  --md-sys-color-surface: #FFFFFF;
  --md-sys-color-surface-container: #EADEF2;
  --md-sys-color-surface-container-high: #DFCEE9;
  --md-sys-color-surface-container-highest: #D2BEDE;
  --md-sys-color-on-surface: #000000;
  --md-sys-color-on-surface-variant: #1F1C25;

  --md-sys-color-primary: #593AB7;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #D1BFF9;
  --md-sys-color-on-primary-container: #170044;

  /* Material 3 Emphasized Decelerate Easing */
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0.0, 0, 1.0);
  --md-sys-motion-duration-long: 500ms;
  --trans-smooth: var(--md-sys-motion-duration-long) var(--md-sys-motion-easing-emphasized);
}

[data-theme="dark"] {
  /* Material 3 Dark Colors */
  --md-sys-color-background: #141218;
  --md-sys-color-on-background: #E6E0E9;
  --md-sys-color-surface: #141218;
  --md-sys-color-surface-container: #211F26;
  --md-sys-color-surface-container-high: #2B2930;
  --md-sys-color-surface-container-highest: #36343B;
  --md-sys-color-on-surface: #E6E0E9;
  --md-sys-color-on-surface-variant: #CAC4D0;

  --md-sys-color-primary: #D0BCFF;
  --md-sys-color-on-primary: #381E72;
  --md-sys-color-primary-container: #4F378B;
  --md-sys-color-on-primary-container: #EADDFF;
}

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

/* -----------------------------
   Page Loading Animation
   ----------------------------- */
body.loading {
  opacity: 0;
  visibility: hidden;
}

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  opacity: 1;
  visibility: visible;
  /* Smooth theme transitions */
  transition: background-color 0.3s ease, color 0.3s ease;
  /* Intro animation for the entire document */
  animation: pageLoad 0.8s var(--md-sys-motion-easing-emphasized) forwards;
}

@keyframes pageLoad {
  0% {
    opacity: 0;
    transform: scale(0.97) translateY(15px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* -----------------------------
   Navbar Styling
   ----------------------------- */
.navbar {
  width: 100%;
  height: 70px;
  flex: 0 0 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4vw;
  background-color: var(--md-sys-color-surface);
  z-index: 100;
  position: relative;
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  letter-spacing: -0.5px;
}

.menu-toggle {
  display: none;
  font-size: 1.5rem;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  padding: 0.5rem;
}

.nav-links {
  display: flex;
  gap: 2vw;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: color 0.3s ease;
  position: relative;
  padding: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
  color: var(--md-sys-color-primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--md-sys-color-primary);
  border-radius: 2px;
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  color: var(--md-sys-color-primary);
  transform: rotate(15deg);
}

/* Mobile Navbar Dropdown */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
    z-index: 120;
    position: relative;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--md-sys-color-surface-container);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    gap: 3rem;
    z-index: 105;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .nav-links.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-link {
    font-size: 2rem;
  }

  /* Feature: Stop aggressive width expansion to avoid flex-wrap line-break glitches on touch */
  .social-icon {
    width: 60px !important;
    height: 60px !important;
    border-radius: 60px !important;
    padding: 0 !important;
    justify-content: center !important;
  }
  .social-icon .icon-wrapper {
    width: 60px !important;
    height: 60px !important;
    font-size: 1.6rem !important;
    margin: 0 !important;
  }
  .social-icon:hover,
  .social-icon:focus,
  .social-icon:active {
    width: 60px !important;
  }
  .social-handle {
    display: none !important;
  }
  .social-links {
    display: grid !important;
    grid-template-columns: repeat(3, max-content) !important;
    justify-content: center !important;
    gap: 1.5rem 1rem !important;
  }

  .tree-container {
    padding: 0 1.5rem;
  }

  .name {
    font-size: 2.5rem;
  }

  .bio {
    font-size: 1rem;
  }
}

/* -----------------------------
   SPA Container & Routing
   ----------------------------- */
.app-container {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  /* Only the active section will dictate scrolling if needed */
}

/* Each virtual page is stacked */
.page-section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(15px) scale(0.98);
  /* Visibility is specifically delayed so it safely finishes computing transparency before literally hiding from the DOM layout */
  transition: opacity 0.5s var(--md-sys-motion-easing-emphasized), transform 0.5s var(--md-sys-motion-easing-emphasized), visibility 0s 0.5s;
  /* Default scrolling allowed for inner sections like Gallery */
  overflow-y: auto;
  overflow-x: hidden;
}

.page-section.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.5s var(--md-sys-motion-easing-emphasized), transform 0.5s var(--md-sys-motion-easing-emphasized), visibility 0s;
  z-index: 10;
}

/* -----------------------------
   Home Section Specific
   ----------------------------- */
#home-section {
  overflow-x: hidden;
  overflow-y: auto;
  display: block;
}

/* Home Layout container */
.tree-container {
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 70px);
  min-height: calc(100vh - 70px);
  margin: 0 auto;
  padding: 3vh 4vw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ============================
   Profile Section (Hero)
   ============================ */
.profile-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative;
  margin-bottom: 2vh;
}

.profile-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.profile-image-wrapper {
  position: absolute;
  top: 0;
  right: 0;
  width: 65%;
  height: 100%;
  border-radius: 40px;
  -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 35%);
  mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 35%);
  will-change: transform;
  transform: translateZ(0);
}

.profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center right;
}

.profile-info {
  position: relative;
  width: 50%;
  z-index: 2;
  padding-left: 2vw;
}

.profile-info .name {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 500;
  margin-bottom: 1vh;
  color: var(--md-sys-color-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.profile-info .bio {
  font-size: clamp(1rem, 2vw, 1.3rem);
  color: var(--md-sys-color-on-surface-variant);
  max-width: 90%;
  line-height: 1.5;
  font-weight: 300;
}

/* ============================
   Social Links Section
   ============================ */
.links-section {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  justify-content: center;
  max-height: 20vh;
}

.social-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
}

.social-icon {
  text-decoration: none;
  background-color: var(--md-sys-color-surface-container);
  border: none;
  border-radius: 40px;
  width: clamp(60px, 8vh, 80px);
  height: clamp(60px, 8vh, 80px);
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  will-change: width, background-color, box-shadow;
  transform: translateZ(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: width var(--trans-smooth), background-color 0.2s ease, box-shadow var(--trans-smooth);
}

.icon-wrapper {
  min-width: clamp(60px, 8vh, 80px);
  width: clamp(60px, 8vh, 80px);
  height: clamp(60px, 8vh, 80px);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.2rem, 3vh, 1.75rem);
  color: var(--md-sys-color-on-surface);
  transition: transform var(--trans-smooth), color 0.2s ease;
}

.social-handle {
  opacity: 0;
  color: var(--md-sys-color-on-primary-container);
  font-weight: 500;
  font-size: clamp(0.9rem, 2vh, 1.1rem);
  white-space: nowrap;
  padding-right: 32px;
  transform: translateX(-20px);
  transition: opacity var(--trans-smooth), transform var(--trans-smooth);
}

.social-icon:hover {
  width: clamp(180px, 25vw, 220px);
  background-color: var(--md-sys-color-primary-container);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.social-icon:hover .social-handle {
  opacity: 1;
  transform: translateX(0);
  color: #FFFFFF !important;
}

.social-icon:hover .icon-wrapper {
  color: #FFFFFF !important;
  transform: scale(1.05);
}

/* ============================
   Generic Inner Sections (Gallery, Commission)
   ============================ */
.inner-content {
  padding: 4vw;
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  color: var(--md-sys-color-primary);
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.section-text {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 20px;
  height: 250px;
  /* generic placeholder for image */
  background-image: linear-gradient(135deg, var(--md-sys-color-surface-container) 0%, var(--md-sys-color-surface-container-high) 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Responsiveness */
@media (max-width: 1024px) {
  .profile-image-wrapper {
    width: 60%;
  }

  .profile-info {
    width: 60%;
  }
}

@media (max-width: 768px) {
  .tree-container {
    padding: 2vh 4vw;
  }

  .profile-container {
    flex-direction: column;
    justify-content: flex-end;
  }

  .profile-image-wrapper {
    width: 100%;
    height: 65%;
    left: 0;
    top: 0;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 50%, rgba(0, 0, 0, 0) 100%);
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 50%, rgba(0, 0, 0, 0) 100%);
    border-radius: 30px;
    object-position: center top;
  }

  .profile-info {
    width: 100%;
    height: 35%;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .profile-info {
    width: 100%;
    margin-top: 1rem;
  }

  .social-links {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    justify-content: center;
    gap: 1.5rem 1rem;
  }
}

@media (max-width: 480px) {
  .social-icon:hover {
    width: clamp(160px, 45vw, 200px);
  }

  .section-title {
    font-size: 2rem;
  }
}

/* ============================
   Multi-select Checkmarks & M3 Dropdown
   ============================ */

/* Tag Checkbox Layout */
.tags-list li,
.m3-dropdown-list li {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.tag-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.tag-checkbox i {
  font-size: 10px;
  color: var(--md-sys-color-on-primary);
  opacity: 0;
  transition: opacity 0.2s;
}

li.active .tag-checkbox {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

li.active .tag-checkbox i {
  opacity: 1;
}

/* Custom M3 Dropdown container (Mobile) */
.m3-dropdown {
  position: relative;
  width: 100%;
}

.m3-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-surface-container-high);
  border-radius: 12px;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.m3-dropdown-header:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.m3-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 0.5rem;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: 12px;
  list-style: none;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  max-height: 250px;
  overflow-y: auto;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.m3-dropdown-list.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
}

.m3-dropdown-list li {
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--md-sys-color-on-surface-variant);
}

.m3-dropdown-list li:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.m3-dropdown-list li.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 500;
}

/* ============================
   Gallery & Modal CSS
   ============================ */
.gallery-wrapper {
  display: flex;
  height: 100%;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-sidebar {
  flex: 0 0 250px;
  padding: 2rem;
  border-right: 1px solid var(--md-sys-color-surface-container-high);
  overflow-y: auto;
}

.gallery-sidebar h3 {
  color: var(--md-sys-color-primary);
  margin-bottom: 1rem;
}

.tags-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tags-list li {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  color: var(--md-sys-color-on-surface-variant);
}

.tags-list li:hover {
  background-color: var(--md-sys-color-surface-container);
}

.tags-list li.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 500;
}

.social-icon.instagram:hover {
  background-color: #E1306C;
  border-color: transparent;
  color: #fff;
}

.social-icon.telegram:hover {
  background-color: #0088cc;
  border-color: transparent;
  color: #fff;
}

.social-icon.discord:hover {
  background-color: #5865F2;
  border-color: transparent;
  color: #fff;
}

.social-icon.furaffinity:hover {
  background-color: #2E3B46;
  border-color: transparent;
  color: #fff;
}

.social-icon.steam:hover {
  background-color: #1b2838;
  border-color: transparent;
  color: #fff;
}

.social-icon.osu:hover {
  background-color: #ff66aa;
  border-color: transparent;
  color: #fff;
}

.gallery-main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  position: relative;
  border-radius: 16px;
  height: 250px;
  background-size: cover;
  background-position: center;
  background-color: var(--md-sys-color-surface-container);
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.3s cubic-bezier(0.2, 0, 0, 1);
  /* Use simple 3D transform force to allocate a lightweight GPU layer instead of will-change */
  transform: translateZ(0); 
}

.gallery-item:hover {
  transform: translateY(-4px) scale(1.02) translateZ(0);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.gallery-item-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}

.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 1.5rem 1rem 1rem;
  color: #fff;
}

.gallery-overlay h4 {
  margin: 0 0 0.2rem 0;
  font-size: 1.1rem;
}

.gallery-overlay span {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  /* Darker backdrop */
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
}

.modal-content {
  background-color: var(--md-sys-color-surface);
  width: 95vw;
  max-width: 1600px;
  height: 95vh;
  border-radius: 20px;
  display: flex;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transition: background-color 0.4s var(--md-sys-motion-easing-emphasized), border-radius 0.4s var(--md-sys-motion-easing-emphasized);
}

.close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--md-sys-color-surface-container);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.close-modal:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.modal-left {
  flex: 6;
  background-color: black;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-image-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none; /* Crucial for pinch to zoom handling via JS */
}

.modal-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: opacity 0.2s ease, transform 0.1s ease-out; /* Smooth JS transform updates */
  transform-origin: center center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none; /* Block ghost image drag selection */
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(20, 18, 24, 0.7);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  backdrop-filter: blur(5px);
  transition: background-color 0.2s;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-nav:hover {
  background-color: rgba(20, 18, 24, 0.9);
}

/* Position strictly within the left canvas explicitly */
#modal-prev {
  left: 2rem;
}

#modal-next {
  right: 2rem;
}

.thumbnail-row {
  flex: 0 0 80px;
  height: 80px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  gap: 10px;
  padding: 10px;
  background-color: #1a1a1a;
  overflow-x: auto;
  transition: opacity 0.2s ease; /* Avoid layout transitions firing on resize */
  overflow-y: hidden;
}

.thumb-wrapper {
  flex: 0 0 60px;
  height: 60px;
  width: 60px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  overflow: hidden;
}

.thumb-wrapper:hover,
.thumb-wrapper.active {
  opacity: 1;
  border: 2px solid var(--md-sys-color-primary);
}

.modal-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-right {
  flex: 3;
  padding: 2.5rem;
  background-color: var(--md-sys-color-surface);
  overflow-y: auto;
  overflow-x: hidden;
  transition: opacity 0.2s ease, background-color 0.4s ease; /* Avoid layout transitions firing on resize */
}

/* Fullscreen Mode Overrides */
.modal.fullscreen .modal-content {
  background-color: black;
}

.modal.fullscreen .modal-right {
  flex: 0 0 0px;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  /* Delay structural collapse until AFTER opacity completes */
  transition: opacity 0.15s ease, flex 0.4s ease 0.15s, padding 0.4s ease 0.15s;
}

.modal.fullscreen .thumbnail-row {
  flex: 0 0 0px;
  height: 0;
  padding: 0;
  opacity: 0;
  /* Delay structural collapse until AFTER opacity completes */
  transition: opacity 0.15s ease, flex 0.4s ease 0.15s, height 0.4s ease 0.15s, padding 0.4s ease 0.15s;
}

.modal.fullscreen .close-modal {
  background-color: rgba(255,255,255,0.1);
  color: white;
  backdrop-filter: blur(10px);
}

.modal.fullscreen .modal-image-container img {
  cursor: zoom-out;
}

#modal-title {
  color: var(--md-sys-color-primary);
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

#modal-description {
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .project-card {
    flex-direction: column;
    margin-bottom: 2.5rem;
  }

  .gallery-wrapper {
    flex-direction: column;
    height: auto; /* Allow expanding beyond 100% strictly for mobile continuous scroll */
  }

  .gallery-main {
    overflow-y: visible; /* Push mobile scroll boundaries to window level */
    padding: 1rem;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }

  .gallery-sidebar {
    flex: none;
    border: none;
    padding: 1rem;
    border-bottom: 1px solid var(--md-sys-color-surface-container-high);
    overflow-y: visible; /* Push mobile scroll boundary to window */
  }

  .gallery-mobile-filter {
    margin-bottom: 1.5rem;
    width: 100%;
  }

  .tags-dropdown {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 1rem;
  }

  .modal-content {
    flex-direction: column;
    height: 100vh;
    border-radius: 0; /* Consume whole mobile screen */
  }

  .modal-left {
    flex: 1; /* Consume remaining space */
    height: auto;
  }

  .modal-right {
    flex: none;
    height: auto;
    min-height: max-content;
    max-height: 40vh; /* Don't eat the image space */
    padding: 1.5rem;
  }
}

/* ============================
   Scroll/More UI Polish
   ============================ */

.btn-more {
  margin-top: 1.5rem;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 40px;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-more:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.more-content-section {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  background-color: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-surface-container-high);
}

/* Scroll To Top Button */
.scroll-top-btn {
  position: fixed;
  top: 80px;
  /* Appear at top as requested */
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.scroll-top-btn:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

/* Animated Hamburger Icon */
.hamburger {
  width: 24px;
  height: 18px;
  display: block;
  position: relative;
  cursor: pointer;
  z-index: 120;
}

.hamburger span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background-color: var(--md-sys-color-on-surface);
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

.hamburger span:nth-child(1) {
  top: 0px;
}

.hamburger span:nth-child(2) {
  top: 8px;
}

.hamburger span:nth-child(3) {
  top: 16px;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ============================
   Projects Layout
   ============================ */

.projects-area {
  padding: 4vw 0;
  background-color: var(--md-sys-color-background);
}

.project-card {
  display: flex;
  gap: 2rem;
  margin-bottom: 4rem;
  background-color: var(--md-sys-color-surface-container);
  border-radius: 24px;
  overflow: hidden;
}

/* Removed row-reverse so all project photos are left-aligned */

.project-image {
  flex: 1;
  min-height: 300px;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-text {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.project-text h3 {
  color: var(--md-sys-color-primary);
  font-size: 2rem;
  margin-bottom: 1rem;
}

.project-text p {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.project-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-m3 {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 40px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-m3:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}



/* ============================
   Skeleton UI
   ============================ */

/* ============================
   Fancy Skeleton Loader
   ============================ */

.skeleton {
  position: relative;
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container);
}

.skeleton::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 100%
  );
  transform: translateX(-100%) translateZ(0);
  animation: shimmer-gpu 1.6s infinite linear;
}

@keyframes shimmer-gpu {
  0% {
    transform: translateX(-100%) translateZ(0);
  }
  100% {
    transform: translateX(100%) translateZ(0);
  }
}

.skeleton::after {
  content: '\f03e'; /* FontAwesome image icon */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.15;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.15; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.25; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.15; }
}

.skeleton img,
.skeleton .gallery-overlay {
  opacity: 0;
}

/* Ensure all images fade in smoothly once their parent's skeleton loader is removed */
img {
  transition: opacity 0.5s ease;
}

/* ============================
   Custom Scrollbar (Material 3)
   ============================ */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--md-sys-color-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: 10px;
  border: 3px solid var(--md-sys-color-surface);
  /* Creates a padded pill effect */
}

::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-on-surface-variant);
}


/* Explicit fade-in classes for reliable image loading */
img.fade-in {
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

img.fade-in.loaded {
  opacity: 1;
}
