/* ============================================================
   MELVIN CRABTREE — PORTFOLIO
   Theme: Clean Craft
   ============================================================ */

/* --- RESET & BASE ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:        #F5F0EA;
  --bg-dark:   #1C1C1C;
  --text:      #1C1C1C;
  --text-muted:#6B6260;
  --accent:    #7B4F2E;
  --accent-lt: #C4A882;
  --white:     #FFFFFF;
  --border:    #E0D8CE;

  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --nav-h:     68px;
  --section-pad: 100px;
  --max-w:     1200px;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* --- TYPOGRAPHY -------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.2;
}

h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(2rem, 3.5vw, 2.8rem);
  font-weight: 600;
}

h4 {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* --- LAYOUT HELPERS ---------------------------------------- */
.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--section-pad) 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-sub {
  margin-top: 0.75rem;
  font-size: 1.05rem;
  color: var(--text-muted);
}

/* --- NAV --------------------------------------------------- */
#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  transition: background 0.3s, box-shadow 0.3s;
}

#nav.scrolled {
  background: rgba(245, 240, 234, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--white);
  transition: color 0.3s;
}

#nav.scrolled .nav-logo {
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 2.5rem;
  align-items: center;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.85);
  transition: color 0.2s;
}

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

#nav.scrolled .nav-links a {
  color: var(--text-muted);
}

#nav.scrolled .nav-links a:hover {
  color: var(--accent);
}

/* hamburger */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: background 0.3s, transform 0.3s, opacity 0.3s;
}

#nav.scrolled .nav-hamburger span {
  background: var(--text);
}

/* mobile open state */
#nav.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
#nav.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- HERO -------------------------------------------------- */
#hero {
  position: relative;
  height: 100vh;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #4a3728; /* fallback when image missing */
  transform: scale(1.05);
  transition: transform 0.1s linear;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.35) 0%,
    rgba(0,0,0,0.55) 60%,
    rgba(0,0,0,0.7) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  color: var(--white);
  padding: 0 1.5rem;
}

.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-lt);
  margin-bottom: 1rem;
}

.hero-content h1 {
  color: var(--white);
  margin-bottom: 0.75rem;
}

.hero-tagline {
  font-family: var(--font-head);
  font-style: italic;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: rgba(255,255,255,0.75);
}

.hero-scroll {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255,255,255,0.6);
  transition: color 0.2s, transform 0.3s;
  animation: bounce 2.5s ease-in-out infinite;
}

.hero-scroll svg {
  width: 28px;
  height: 28px;
}

.hero-scroll:hover {
  color: var(--white);
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(6px); }
}

/* placeholder state (when hero.jpg missing) */
.hero-bg[style*="hero.jpg"]::after {
  content: '';
}

/* --- PORTFOLIO SECTION ------------------------------------- */
#portfolio {
  background: var(--bg);
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 3rem;
}

.filter-btn {
  padding: 0.45rem 1.25rem;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 100px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

/* Gallery grid — CSS masonry via columns */
.gallery {
  columns: 3;
  column-gap: 1.25rem;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 1.25rem;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
}

.gallery-item.hidden {
  display: none;
}

.gallery-img-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--accent-lt);
}

/* Placeholder aspect ratio when image is missing */
.gallery-img-wrap::before {
  content: '';
  display: block;
  padding-top: 75%;
}

.gallery-img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

/* Override aspect ratio trick once image loads */
.gallery-img-wrap img[src] {
  position: absolute;
}

.gallery-item:hover .gallery-img-wrap img {
  transform: scale(1.04);
}

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 1rem 0.75rem;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s, transform 0.25s;
}

.gallery-item:hover .gallery-caption {
  opacity: 1;
  transform: translateY(0);
}

/* --- ABOUT ------------------------------------------------- */
#about {
  background: var(--white);
}

.about-inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 5rem;
  align-items: start;
}

.about-photo {
  position: sticky;
  top: calc(var(--nav-h) + 2rem);
  border-radius: 4px;
  overflow: hidden;
  background: var(--accent-lt);
  aspect-ratio: 3/4;
}

.about-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-text h2 {
  margin-bottom: 1.5rem;
}

.about-text p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
}

.skills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.skill-group h4 {
  margin-bottom: 0.75rem;
}

.skill-group ul li {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.2rem 0;
}

/* --- CONTACT ----------------------------------------------- */
#contact {
  background: var(--bg);
}

.contact-inner {
  max-width: 760px;
  text-align: center;
}

.contact-inner h2 {
  margin-bottom: 0.75rem;
}

.contact-inner .section-sub {
  margin-bottom: 3rem;
}

.contact-form {
  text-align: left;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.2s;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #bbb;
}

.btn-submit {
  display: inline-block;
  padding: 0.85rem 2.5rem;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-submit:hover {
  background: #6a4126;
  transform: translateY(-1px);
}

.btn-submit:active {
  transform: translateY(0);
}

/* --- FOOTER ------------------------------------------------ */
footer {
  background: var(--bg-dark);
  color: rgba(255,255,255,0.5);
  padding: 2rem 2rem;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-name {
  font-family: var(--font-head);
  font-size: 1rem;
  color: rgba(255,255,255,0.75);
}

.footer-nav {
  display: flex;
  gap: 2rem;
}

.footer-nav a {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--accent-lt);
}

.footer-copy {
  font-size: 0.8rem;
}

/* --- LIGHTBOX ---------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

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

.lightbox-img-wrap {
  max-width: 90vw;
  max-height: 88vh;
  text-align: center;
}

.lightbox-img-wrap img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 3px;
}

.lightbox-caption {
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  margin-top: 1rem;
  font-style: italic;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.lightbox-close:hover { color: var(--white); }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 1rem;
  transition: color 0.2s;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-prev:hover,
.lightbox-next:hover { color: var(--white); }

/* --- RESPONSIVE -------------------------------------------- */
@media (max-width: 900px) {
  .gallery { columns: 2; }

  .about-inner {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .about-photo {
    position: static;
    aspect-ratio: 4/3;
    max-width: 500px;
  }

  .skills {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  :root { --section-pad: 64px; }

  .gallery { columns: 1; }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: rgba(245, 240, 234, 0.98);
    backdrop-filter: blur(8px);
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0 1.5rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-top: 1px solid var(--border);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.85rem 2rem;
    color: var(--text) !important;
    font-size: 1rem;
  }

  .nav-hamburger {
    display: flex;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .skills {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
