/* ============================================
   Miklós Ferencz Design – Graphics Portfolio
   ============================================ */

:root {
  --bg: #ffffff;
  --text: #212121;
  --tile-bg: #a8f0e0;
  --tile-bg-2: #b8f5e8;
  --tile-hover: #7ee8d0;
  --label-color: #0a0a0a;
  --header-height: 64px;
  --gap: 12px;
  --cols: 5;
  --font-display: "Outfit", sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

html {
  font-size: 18px;/* Content links */
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: var(--bg);
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}

#header.scrolled {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

.logo a {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

/* ── HAMBURGER ── */
.menu-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
}

.menu-toggle .bar {
  display: block;
  width: 28px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}

/* ── NAV OVERLAY ── */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: start;
  padding-top: 80px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.nav-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.nav-links {
  list-style: none;
  text-align: center;
}

.nav-links li {
  margin: 16px 0;
}

.nav-links a {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--tile-hover);
}

.nav-close {
  position: absolute;
  top: 20px;
  right: 28px;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
  padding: 8px;
}

/* ── MAIN CONTENT ── */
#content {
  padding-top: var(--header-height);
  flex: 1 0 auto;
}

/* ── GRID (uniform tiles, exact 12px gap both directions) ── */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  padding: var(--gap) 26px;
}

.masonry-item {
  display: block;
  aspect-ratio: 4 / 5;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  -webkit-animation: fadeUp 0.5s ease both;
          animation: fadeUp 0.5s ease both;
}

.tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
}

.tile-inner img {
  display: block;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.tile-placeholder {
  width: 100%;
  height: 100%;
  background: var(--tile-bg);
}

.tile-label {
  position: absolute;
  z-index: 10;
  padding: 16px;
  width: 100%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.masonry-item:not(:has(img)) .tile-label {
  bottom: 20px;
  left: 20px;
  text-align: left;
}

.masonry-item:hover .tile-label,
.masonry-item.is-touched .tile-label {
  opacity: 1;
}

.tile-label span {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  color: #3a3a3a;
}

/* ── PROJECT PAGE ── */
.project-page {
  display: grid;
  grid-template-columns: 1fr;
  padding-top: 16px;
}

.project-header {
  max-width: 900px;
  margin: 16px 26px;
  text-align: left;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  opacity: 0.5;
  margin-bottom: 2px;
}

.project-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.0;
  margin-top: 0;
}

/* ── PROJECT BODY ── */
.project-body {
  padding-bottom: 80px;
}

/* Intro paragraph – left aligned, normal size */
.project-body > p:first-of-type {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  text-align: left;
  max-width: 600px;
  margin: 1.5rem 0 2rem;
}

/* Secondary text – centered, smaller */
.project-body > p {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5rem;
  color: var(--text);
  text-align: left;
  max-width: 900px;
  margin: 0.75rem auto;
  padding: 0 26px;
}

/* Content links */
.project-body a:not(.back-link) {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease, opacity 0.2s ease;
}

.project-body a:not(.back-link):hover {
  color: var(--tile-hover);
  text-decoration-color: var(--tile-hover);
}

/* Images – break out of paragraph padding, full 900px */
.project-body p img {
  display: block;
  width: calc(100% + 52px);
  margin: 2rem -26px;
  height: auto;
  cursor: zoom-in;
}

/* Video embed – centered */
.project-body .video-item,
.video-item {
  position: relative;
  max-width: 900px;
  margin: 2rem auto;
  aspect-ratio: 16 / 9;
}

.video-item iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── FOOTER ── */
#footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: rgba(10, 10, 10, 0.35);
  font-family: var(--font-body);
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) { :root { --cols: 4; } }
@media (max-width: 900px)  { :root { --cols: 3; } }

@media (max-width: 600px) {
  :root {
    --cols: 2;
    --gap: 6px;
  }

  .masonry-grid {
    padding: 6px 6px;
  }

  #header {
    padding: 0 12px;
  }

  .logo a {
    font-size: 0.875rem;
  }

  .project-header {
    margin: 16px 26px;
  }

  .project-body > p:first-of-type {
    margin: 1rem 12px 1.5rem;
  }

  .project-body > p {
    padding: 0 12px;
  }

  .project-body p img {
    width: calc(100% + 24px);
    margin: 1.5rem -12px;
  }
}

/* Hover and touch effects for tiles */
.masonry-item:hover .tile-inner img,
.masonry-item.is-touched .tile-inner img {
  transform: scale(1.05);
  opacity: 0.1;
}

@media (max-width: 400px) { :root { --cols: 1; } }

/* ── ENTRANCE ANIMATION ── */
.masonry-item:nth-child(1)  { -webkit-animation-delay: 0.05s; animation-delay: 0.05s; }
.masonry-item:nth-child(2)  { -webkit-animation-delay: 0.08s; animation-delay: 0.08s; }
.masonry-item:nth-child(3)  { -webkit-animation-delay: 0.11s; animation-delay: 0.11s; }
.masonry-item:nth-child(4)  { -webkit-animation-delay: 0.14s; animation-delay: 0.14s; }
.masonry-item:nth-child(5)  { -webkit-animation-delay: 0.17s; animation-delay: 0.17s; }
.masonry-item:nth-child(6)  { -webkit-animation-delay: 0.20s; animation-delay: 0.20s; }
.masonry-item:nth-child(7)  { -webkit-animation-delay: 0.23s; animation-delay: 0.23s; }
.masonry-item:nth-child(8)  { -webkit-animation-delay: 0.26s; animation-delay: 0.26s; }
.masonry-item:nth-child(9)  { -webkit-animation-delay: 0.29s; animation-delay: 0.29s; }
.masonry-item:nth-child(10) { -webkit-animation-delay: 0.32s; animation-delay: 0.32s; }
.masonry-item:nth-child(11) { -webkit-animation-delay: 0.35s; animation-delay: 0.35s; }
.masonry-item:nth-child(12) { -webkit-animation-delay: 0.38s; animation-delay: 0.38s; }

@-webkit-keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── LIGHTBOX ── */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

#lightbox.active {
  visibility: visible;
  opacity: 1;
  pointer-events: all;
}

/* Isolate lightbox img from ALL page image styles */
#lightbox > img {
  display: block !important;
  max-width: 88vw !important;
  max-height: 90vh !important;
  width: auto !important;
  height: auto !important;
  -o-object-fit: contain !important;
     object-fit: contain !important;
  position: static !important;
  left: auto !important;
  margin: 0 !important;
  cursor: default !important;
  flex-shrink: 0;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 28px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 4rem;
  line-height: 1;
  cursor: pointer;
  padding: 12px 20px;
  opacity: 0.5;
  transition: opacity 0.2s;
  z-index: 10;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-prev:hover,
.lightbox-next:hover { opacity: 1; }

.lightbox-prev.hidden,
.lightbox-next.hidden { display: none; }