/* --- Global Resets & Typography --- */
:root {
  --bg-color: #ffffff;
  --text-color: #111111;
  --text-light: #666666;
  --header-height: 70px;
  
  /* Standard Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-size-base: 1.05rem;
  --font-size-h1: 2rem;
  --font-size-small: 0.85rem;
  --line-height-base: 1.75;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Accessibility: Hidden but available for Screen Readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Global Outline Refinement for Keyboard Navigation */
:focus-visible {
  outline: 2px solid var(--text-color);
  outline-offset: 4px;
}

/* --- Header Layout --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-left {
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.header-center {
  display: flex;
  gap: 3rem;
}

.header a {
  text-decoration: none;
  color: var(--text-light);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.3s ease;
  position: relative;
}

.header a:hover, .header a.active {
  color: var(--text-color);
}

/* --- Content Areas --- */
main, section {
  margin-top: calc(var(--header-height) + 2rem);
  min-height: calc(100vh - var(--header-height));
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Section Switching Animations */
.section-fade-in {
  animation: sectionFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Asymmetrical Project Grid --- */
.grid-container {
  padding: 2rem 4vw 6rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 3vw;
  transition: opacity 0.4s ease;
}

/* Base item structure outside zoom */
.project-card {
  position: relative;
  display: block;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
  opacity: 1;
}

.project-card.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

/* Generates asymmetrical feel by slightly shifting rows randomly in app.js or using arbitrary margins here, 
   but we'll just use flex wrap with variable widths for the organic, frameless look. */

.project-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background-color: #f5f5f5;
  transition: filter 0.4s ease;
}

/* Asymmetry overrides */
.project-card.portrait img { aspect-ratio: 3 / 4; }
.project-card.landscape img { aspect-ratio: 4 / 3; }
.project-card.square img { aspect-ratio: 1 / 1; }

.project-card:nth-child(even) {
  margin-top: 4vw; /* Offset evens to break the grid */
}
.project-card:nth-child(3n) {
  margin-bottom: 2vw;
}

/* --- Zoom Levels via Data Attribute --- */
/* The slider manipulates the data-zoom attr, altering the flex-basis calculation to change density */
.grid-container[data-zoom="1"] .project-card { width: 70vw; } /* 1 Column */
.grid-container[data-zoom="2"] .project-card { width: 42vw; } /* 2 Columns */
.grid-container[data-zoom="3"] .project-card { width: 28vw; } /* 3 Columns */
.grid-container[data-zoom="4"] .project-card { width: 20vw; } /* 4 Columns */
.grid-container[data-zoom="5"] .project-card { width: 14vw; } /* Very Dense */

/* --- Interactions & Hover Effects --- */
.overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease, background 0.4s ease;
}

.project-card:hover .overlay {
  opacity: 1;
}

.project-card:hover {
  transform: scale(1.02); /* Very subtle scale for tactile feel */
}

.project-card:hover img {
  filter: grayscale(15%) brightness(0.95);
}

.overlay h2 {
  color: white;
  font-weight: 300;
  font-size: 1.4rem;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 1.5rem;
  transform: translateY(10px);
  transition: transform 0.4s ease;
}

.project-card:hover .overlay h2 {
  transform: translateY(0);
}

/* --- CV / Contact Section --- */
.cv-container {
  max-width: 800px;
  margin: 6rem auto;
  padding: 0 2rem;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-color);
  animation: fadeIn 0.5s ease;
}

.cv-container a {
  color: #000;
}

.cv-content strong {
  display: block;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.cv-content strong:first-child {
  margin-top: 0;
}

/* --- Modal --- */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
  animation: modalFadeIn 0.3s ease forwards;
}

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
}

.modal-content {
  position: relative;
  width: 90vw;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  background: transparent;
  z-index: 10;
  padding: 2rem;
}

.modal-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin: 0;
}

.modal-inner-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  margin-top: 2rem;
}

.modal-header {
  font-weight: 400;
  font-size: var(--font-size-h1);
  margin-bottom: 0.5rem;
}

.modal-subtitle {
  color: var(--text-light);
  font-size: var(--font-size-small);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.modal-text {
  margin-top: 1rem;
}

/* --- Modal Carousel --- */
.carousel-container {
  position: relative;
  width: 100%;
  height: 60vh; /* Fixed height to prevent jumping */
  margin: 2rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fcfcfc;
  overflow: hidden;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.7);
  border: none;
  font-size: 2rem;
  color: #333;
  cursor: pointer;
  padding: 0.5rem 1rem;
  z-index: 5;
  transition: background 0.3s ease, color 0.3s ease;
  border-radius: 4px;
}
.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
}
.prev-btn { left: 10px; }
.next-btn { right: 10px; }
.carousel-dots {
  position: absolute;
  bottom: 10px;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 5;
}
.dot {
  width: 10px;
  height: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
}
.dot.active, .dot:hover {
  background: rgba(0, 0, 0, 0.8);
}

.modal .close-btn {
  position: fixed;
  top: 2rem;
  right: 3rem;
  background: none;
  border: none;
  font-size: 3rem;
  font-weight: 300;
  cursor: pointer;
  color: #000;
  z-index: 20;
}

/* --- Footer --- */
.footer {
  width: 100%;
  padding: 4rem 2rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.footer-link {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: 0.5rem 1rem;
  transition: color 0.3s ease;
}

.footer-link:hover {
  color: var(--text-color);
}

/* --- Animations & Responsiveness --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 900px) {
  .header { padding: 0 1.5rem; justify-content: center; flex-wrap: wrap; height: auto; padding-top: 1rem; padding-bottom: 1rem; gap: 1rem;}
  .header-left, .header-right { width: 100%; text-align: center; }
  .header-center { width: 100%; justify-content: center; gap: 1.5rem; }
  .grid-container[data-zoom] .project-card { width: 100% !important; margin-top: 2rem !important; }
}
