:root{
  --header-h: 64px;
  --bg-light: #f9fafb;
  --bg-dark: #222;
  --text-light: #333;
  --text-dark: #ddd;
  --card-shadow: 0 6px 16px rgba(0,0,0,0.12);
  --card-shadow-strong: 0 12px 28px rgba(0,0,0,0.15);
  --gap-h: 4rem;  
  --gap-v: 1.2rem;
  --side-padding: 3rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  font-family: 'Montserrat', sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .35s, color .35s;
}
body.dark { background: var(--bg-dark); color: var(--text-dark); }

main { flex: 1; }

#mode-btn{
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  z-index: 50;
  filter: grayscale(1);
}

#hero{
  margin-top: 2rem;
  padding-block: 2rem;
  padding-inline: var(--side-padding);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 30vh;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.hero-left { display: flex; align-items: center; gap: 1.25rem; }
.profile-pic{ width: 140px; height: 140px; border-radius: 12px; object-fit: cover; box-shadow: var(--card-shadow); }
.hero-text{ display: flex; flex-direction: column; }
.hero-name{ font-family: 'Fredoka One', cursive; font-size: 2.75rem; line-height: 1.1; }
.hero-desc{ font-size: 1rem; margin-top: 0.25rem; opacity: 0.85; }
.hero-right {
  max-width: 800px;     /* reasonable desktop limit */
  width: 90%;           /* takes up most of phone width */
  margin: 2rem auto;    /* centers horizontally * /* breathing room */
  text-align: center;
  line-height: 1.6;
  font-size: 1rem;
  opacity: 0.9;
}


section{
  max-width: 1200px;
  padding-block: 2rem;
  padding-inline: var(--side-padding);
  margin-left: auto;
  margin-right: auto;
}
h2{ font-size: 2rem; text-align: left; margin-bottom: 2rem; }

/* -------------------------
   Top Projects Grid
------------------------- */

body.dark .top-card {
  background-color: #333;
}

.top-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem; /* space between tiles */
}

/* Top cards as flex column */
.top-card {
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: white;
  box-shadow: var(--card-shadow);
  padding: 1.25rem;
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
  flex: 1 1 calc(50% - 0.75rem);
}

.top-card.first-card {
  flex: 1 1 100%;
}

/* New container for content above tools */
.top-card .card-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* takes all available space above tools */
  gap: 0.5rem;
}

/* Summary text */
.top-card .tile-desc {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* Media elements */
.top-card img,
.top-card iframe,
.top-card video {
  width: 100%;
  border-radius: 12px;
}

/* Tools at the bottom */
.top-card .tile-tools {
  display: flex;
  flex-wrap: nowrap; /* keep on one line */
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem; /* small gap from content */
}


/* Tool icons */
.top-card .tile-tools img {
  width: 24px;
  height: 24px;
}

/* Link/Button style */
.top-card a {
  display: inline-block;
  padding: 6px 12px;
  background: #007bff;
  color: #fff;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  width: fit-content;
  margin-top: 0.6rem;
  transition: background 0.2s ease, transform 0.15s ease;
}

.top-card a:hover {
  background: #0056b3;
  transform: translateY(-2px);
}

/* Grid spacing */
.top-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem; /* keeps spacing consistent */
}

/* Lock width for second-row cards */
.top-card:not(.first-card) {
  flex: 1 1 48%;
  max-width: 48%;
}

@media (max-width: 800px) {
  html {
    font-size: clamp(14px, 4vw, 16px);
  }

  body {
    padding-inline: 1rem;
  }

  section {
    padding-inline: 1rem;
  }

  /* Center section titles like "Top Projects" */
  h2, #tp-title {
    font-size: clamp(1.3rem, 5vw, 1.6rem);
    text-align: center;
    margin-bottom: 1.5rem;
  }

  /* Hero layout */
  #hero {
    flex-direction: column;
    align-items: flex-start; /* left-align all content */
    padding-inline: 1rem;    /* small padding */
    gap: 1rem;               /* space between hero-left and hero-right */
  }

  .hero-left {
    flex-direction: row;
    justify-content: left;
    gap: 1rem;
  }

  .my_intro {
    width: 200vw;
    margin-left: -53vw;
    padding: 1rem 0;
    box-sizing: border-box;
  }

  .hero-right {
    width: 100%;
    padding: 0 2rem 0.5rem 2rem;
    font-size: clamp(0.9rem, 3.5vw, 1rem);
    text-align: center;
  }

  .hero-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .hero-name {
    font-size: clamp(1.6rem, 6vw, 2rem);
  }

  .hero-desc {
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    text-align: center;
    margin-top: 1rem;
  }

  .hero-right p {
    margin-bottom: 2rem;
  }

  .profile-pic {
    width: clamp(90px, 30vw, 140px);
    height: clamp(90px, 30vw, 140px);
  }

  /* Top Projects stacked */
  .top-grid {
    flex-direction: column;
    gap: 1.5rem;
  }

  .top-card {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .tile-title {
    font-size: clamp(1rem, 4vw, 1.2rem);
  }

  .tile-desc {
    font-size: clamp(0.85rem, 3vw, 1rem);
    line-height: 1.6;
  }

  /* Brick River full width, no fade */
  .flow-row {
    width: 100%;
    margin-left: 0;
    left: 0;
    padding-inline: 0;
    -webkit-mask-image: none;
    mask-image: none;
  }

}

@media (min-width: 481px) and (max-width: 820px) {
  html {
    font-size: clamp(15px, 2vw, 17px);
  }

  body {
    padding-inline: 2rem;
  }

  section {
    padding-inline: 2rem;
  }

  h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    text-align: left;
    margin-bottom: 2rem;
  }

  .hero-left {
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
  }

  .hero-right {
    padding-left: 1rem;
    max-width: 50%;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  }

  .hero-name {
    font-size: clamp(1.8rem, 5vw, 2.4rem);
  }

  .hero-desc {
    font-size: clamp(0.9rem, 3vw, 1rem);
  }

  .profile-pic {
    width: clamp(100px, 20vw, 120px);
    height: clamp(100px, 20vw, 120px);
  }

  .top-card {
    flex: 1 1 100%;
    max-width: 100%;
    padding: 1.25rem;
    margin-bottom: 2rem;
  }

  .tile {
    width: 100%;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .tile-title {
    font-size: clamp(1rem, 3.5vw, 1.3rem);
  }

  .tile-desc {
    font-size: clamp(0.9rem, 3vw, 1rem);
  }

  .flow-row {
    width: 100%;
    margin-left: 0;
    left: 0;
    padding-inline: 1rem;
    -webkit-mask-image: linear-gradient(to right, transparent 0, black 2rem, black calc(100% - 2rem), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, black 2rem, black calc(100% - 2rem), transparent 100%);
  }
}






/* All Projects spacing */
#projects { padding-bottom: 1rem; }
#flowing-projects-container { margin-top: 1rem; padding-bottom: 2rem; }

.flow-row {
  position: relative;
  overflow: hidden;
  margin-block: var(--gap-v);
  width: 65vw;
  left: 50%;
  margin-left: -30vw;
  padding-inline: 1rem; /* small margin on both sides */
  
  /* keep the fade at edges */
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 2rem, black calc(100% - 2rem), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 2rem, black calc(100% - 2rem), transparent 100%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}


.flow-track {
  display: flex;
  gap: var(--gap-h);
  width: max-content;
  will-change: transform;
  pointer-events: auto;
}

.tile{
  flex: 0 0 auto;
  width: 340px;
  min-height: 140px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 1rem;
  text-align: left;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(0,0,0,0.05);
  transition: transform .18s ease, box-shadow .18s ease;
  pointer-events: auto;
}
.tile:hover{ transform: scale(1.06); box-shadow: 0 10px 20px rgba(0,0,0,0.12); }
body.dark .tile{ background: #333; color: var(--text-dark); }

.tile-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.tile-desc {
  font-weight: 400;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
  opacity: 0.85;
}

.tile-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tile-tools .tool-icon {
  width: 24px;
  height: 24px;
}

.tile-active { border: 2px solid #0077ff; }

/* Popup Overlay and other styles remain unchanged... (everything from your original CSS is still included here) */


@keyframes scroll-ltr{ from{ transform: translateX(-50%); } to{ transform: translateX(0%); } }
@keyframes scroll-rtl{ from{ transform: translateX(0%); } to{ transform: translateX(-50%); } }

#test-3d .test-3d-window{
  height: 400px;
  background: #f4f4f4;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-top: 1rem;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
}

/* -------------------------
   Popup Overlay
------------------------- */
#popup-overlay {
  position: fixed;
  top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.7);
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
}

#popup-overlay > div {
  background: white;
  border-radius: 14px;
  padding: 24px;
  max-width: 800px;
  width: 90%;
  max-height: 85%;
  overflow-y: auto;
  box-shadow: var(--card-shadow-strong);
  font-family: 'Montserrat', sans-serif;
  transition: transform .25s ease;
}

body.dark #popup-overlay > div { background: #333; color: var(--text-dark); }

#popup-overlay h2 { font-family: 'Fredoka One', cursive; font-size: 1.8rem; margin-bottom: 1rem; }
#popup-overlay img, #popup-overlay video { width: 100%; border-radius: 12px; margin-bottom: 1rem; }
#popup-overlay a {
  display:inline-block; padding:10px 16px; background:#007bff; color:#fff; border-radius:8px; text-decoration:none; font-weight:500;
}
#popup-overlay a:hover { background:#0056b3; }

/* ------------------------- POPUP STYLES FOR NEW JSON STRUCTURE ------------------------- */

/* Popup Overlay & Container */
#popup-overlay {
  position: fixed;
  top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.7);
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
}

#popup-overlay > div {
  background: white;
  border-radius: 14px;
  padding: 24px;
  max-width: 800px;
  width: 90%;
  max-height: 85%;
  overflow-y: auto;
  box-shadow: var(--card-shadow-strong);
  font-family: 'Montserrat', sans-serif;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

body.dark #popup-overlay > div { background: #333; color: var(--text-dark); }

/* Popup text and subheading */
#popup-overlay h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  margin-bottom: 0.2rem;
}
#popup-overlay h3 {
  font-weight: 500;
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  opacity: 0.85;
}
#popup-overlay p {
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 0.6rem;
}

/* Popup media */
#popup-overlay img,
#popup-overlay video,
#popup-overlay iframe {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 1rem;
}
#popup-overlay iframe {
  height: 400px;
  border: none;
}


/* External link button */
#popup-overlay a {
  display:inline-block;
  padding:10px 16px;
  background:#007bff;
  color:#fff;
  border-radius:8px;
  text-decoration:none;
  font-weight:500;
}
#popup-overlay a:hover { background:#0056b3; }

/* ------------------------- VIDEO STYLES POPUP ------------------------- */

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

/* ------------------------- 3D Model Styles ------------------------- */

.stl-container model-viewer {
  width: 100%;
  height: 300px; /* adjust as needed */
  border-radius: 12px;
  position: relative;
}

.drag-indicator {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.5s ease;
}



body.dark #footer {
  color: var(--text-dark);
}


#footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
  opacity: 0.7;
  flex-shrink: 0;
}