@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg:       #181C14;
  --bg-alt:   #3C3D37;
  --bg-card:  #697565;
  --muted:    #ECDFCC;
  --accent:   #FF4C29;
  --text:     #DFD0B8;
  --border:   #222831;
  --gap:      10px;
  --transition: 0.35s ease;
}

/* ─── Reset ─── */

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

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) var(--bg);
  background: var(--bg);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--muted); color: #fff; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 32px; }

/* ─── Navigation ─── */

nav {
  position: fixed; top: 0; left: 0; width: 100%;
  z-index: 1000; padding: 20px 0;
  transition: var(--transition);
}
nav.scrolled {
  background: #3C3D37cc;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.nav-inner { display: flex; justify-content: flex-end; align-items: center; }
.nav-links { display: flex; gap: 36px; list-style: none; align-items: center; }
.nav-links > li { position: relative; }
.nav-links > li > a {
  font-size: 0.75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 2px;
  color: var(--muted); transition: var(--transition); padding: 8px 0;
}
.nav-links > li > a:hover,
.nav-links > li > a.active { color: #fff; }

/* Dropdown */
.nav-links > li.dropdown-li::after {
  content: ''; position: absolute; top: 100%; left: 0; width: 100%; height: 12px;
}
.dropdown {
  position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%);
  min-width: 170px; background: var(--bg-card); border: 1px solid var(--bg);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}
.dropdown-li:hover .dropdown { opacity: 1; visibility: visible; pointer-events: auto; }
.dropdown a {
  display: block; padding: 10px 24px;
  font-size: 0.72rem; font-weight: 400; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px;
  transition: var(--transition); border-left: 2px solid transparent;
}
.dropdown a:hover { color: #fff; border-left-color: var(--accent); background: rgba(255,255,255,0.02); }

.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text); }
.menu-toggle svg { width: 22px; height: 22px; }

/* ─── Hero ─── */

.hero {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; text-align: center;
  position: relative; padding: 120px 32px 80px;
}
.hero-content { max-width: 720px; }
.hero-content .label {
  font-size: 0.7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 3px; color: var(--muted); margin-bottom: 16px;
}
.hero-content h1 {
  font-size: clamp(2.4rem, 7vw, 4.2rem); font-weight: 600;
  line-height: 1.1; margin-bottom: 8px; letter-spacing: -0.02em; color: #fff;
}

/* Category buttons */
.cat-buttons { display: flex; flex-wrap: wrap; gap: 4px 28px; justify-content: center; margin-top: 40px; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 12px;
  background: none; border: none; padding: 6px 0;
  color: var(--muted); font-family: 'Inter', sans-serif;
  font-size: 0.8rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 2.5px; cursor: pointer; transition: var(--transition);
}
.cat-btn::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  transition: transform 0.3s, background 0.3s;
}
.cat-btn:hover { color: #fff; }
.cat-btn:hover::before { transform: scale(1.5); }

/* ─── Sections ─── */

.section { padding: 100px 0; }
.section-header { margin-bottom: 48px; }
.section-header h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 600;
  color: #fff; letter-spacing: -0.02em;
}

/* ─── Project Rows ─── */
/*
  .p-row           — wrapper; no fixed height, height comes from children's aspect-ratios
  .p-row.split     — two-panel row; grid columns set inline from JS (e.g. "60fr 40fr")
  .p-row.duo       — two equal main panels side-by-side (portrait projects)

  .p-main          — clickable main image panel
  .p-main.contain  — object-fit: contain instead of cover
  .thumbs          — thumb grid panel
  .thumbs.stack    — mosaic layout (first thumb spans 2 rows)
  .thumb           — individual thumbnail cell
*/

.project-rows { display: flex; flex-direction: column; gap: var(--gap); }

/* Base row: block, children flow naturally */
.p-row {
  display: grid;
  gap: var(--gap);
}

/* Single panel (main only) — exclude col since it has its own rule */
.p-row:not(.split):not(.duo):not(.col) {
  grid-template-columns: 1fr;
}

/* Duo: two portrait panels equal width (side by side) */
.p-row.duo {
  grid-template-columns: 1fr 1fr;
}

/* Col: two projects side by side (two columns) */
.p-row.col {
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

/* Inner split row inside a col group */
.col-inner.split {
  display: grid;
  gap: var(--gap);
  /* grid-template-columns set inline */
}

/* Split rows: columns set by inline style from JS */
/* .p-row.split — no extra rule needed, inline style handles it */

/* ── Main panel ── */
.p-main {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  /* aspect-ratio set inline when mainAspect is defined */
}

/* When no aspect-ratio is set and the row has a rowHeight, main fills the row.
   We achieve this by making the img absolute only when there IS an aspect-ratio
   (so the panel size is driven by the ratio), otherwise the img is static. */

.p-main img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--img-pos, center);
  transition: transform 0.8s ease;
  display: block;
}

/* When a mainAspect is set the panel has a definite height via aspect-ratio;
   absolute positioning then fills it cleanly. */
.p-main[style*="aspect-ratio"] img {
  position: absolute;
  inset: 0;
}

.p-main.contain img { object-fit: contain; background: var(--bg); }
.p-main:hover img   { transform: scale(1.03); }

/* Placeholder div (no image) */
.p-main .ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.06); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 2px;
  position: absolute; inset: 0;
}
.p-main:not([style*="aspect-ratio"]) .ph {
  position: relative; min-height: 300px;
}

/* Info overlay */
.p-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 40px 28px 24px;
  background: linear-gradient(to top, rgba(8,32,50,0.9) 0%, transparent 100%);
  pointer-events: none;
}
.p-info h3 { font-size: 1.15rem; font-weight: 500; color: #fff; }
.p-info span { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }

/* ── Thumb panel ── */
/*
  In a split row the thumbs panel fills the grid cell whose height is
  determined by the adjacent main panel's aspect-ratio.
  --cols  = number of columns  (set inline from JS)
  --rows  = number of rows     (set inline from JS, = ceil(count/cols))
  Both are always set by JS so the grid divides the available space exactly.
*/
.thumbs {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  grid-template-rows:    repeat(var(--rows, 1), 1fr);
  /* Fill the height of the grid cell (= main panel height in split rows).
     In standalone / col rows there's no external height so auto rows apply. */
  height: 100%;
  overflow: hidden;
}

/* Thumb cell always fills its grid track */
.thumb {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  cursor: pointer;
  min-height: 0; /* allow grid shrink */
}

/* Image always covers its cell — cell size is controlled by grid-template-rows */
.thumb img,
.thumb video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

/* Individual thumb aspect-ratio override (standalone / col rows only —
   in split rows the grid tracks control height so aspect-ratio is ignored
   by the browser in favour of the grid constraint, which is what we want) */
.thumb[style*="aspect-ratio"] {
  /* aspect-ratio only has effect when height is not externally constrained */
}

.thumb:hover img { transform: scale(1.05); }

/* Mosaic / stack layout */
.thumbs.stack {
  grid-template-columns: 1.3fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.thumbs.stack .thumb:first-child { grid-row: span 2; }

/* ─── Project Detail Overlay ─── */

.project-detail {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(8,32,50,0.95);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 48px 32px; overflow-y: auto;
}
.project-detail.open { display: block; }
.detail-inner { max-width: 900px; margin: 40px auto; }
.detail-close {
  position: fixed; top: 28px; right: 28px; width: 40px; height: 40px;
  background: transparent; border: 1px solid var(--muted);
  color: var(--text); font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.detail-close:hover { border-color: var(--accent); color: var(--accent); }
.detail-inner h2 { font-size: 1.8rem; font-weight: 500; margin-bottom: 6px; letter-spacing: -0.02em; color: #fff; }
.detail-inner .meta { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin-bottom: 32px; }
.detail-grid { display: flex; flex-direction: column; gap: 8px; }
.detail-grid img,
.detail-grid video { width: 100%; height: auto; display: block; }
.empty-detail { padding: 60px 0; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ─── Contact ─── */

#contact { background: var(--bg-alt); }
.contact-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: start; }
.contact-text h3 { font-size: 1.4rem; font-weight: 500; line-height: 1.3; margin-bottom: 12px; color: #fff; letter-spacing: -0.02em; }
.contact-text p  { color: var(--muted); font-size: 0.85rem; line-height: 1.8; margin-bottom: 28px; }
.contact-line { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; font-size: 0.85rem; }
.contact-line .icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); font-size: 0.75rem; color: var(--muted);
  flex-shrink: 0; transition: var(--transition);
}
.contact-line:hover .icon { border-color: var(--accent); color: var(--accent); }
.contact-line .label { display: block; font-size: 0.55rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 2px; font-weight: 600; }
.social { display: flex; gap: 8px; margin-top: 24px; }
.social a {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); font-size: 0.65rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; transition: var(--transition);
}
.social a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.contact-form { display: grid; gap: 14px; }
.contact-form input,
.contact-form textarea {
  width: 100%; padding: 14px 18px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 0.85rem; outline: none; transition: var(--transition);
}
.contact-form input:focus,
.contact-form textarea:focus { border-color: var(--muted); }
.contact-form textarea { min-height: 110px; resize: vertical; }
.contact-form button { justify-self: start; }

/* ─── Footer ─── */

footer { padding: 32px 0; border-top: 1px solid var(--border); text-align: center; font-size: 0.7rem; color: var(--muted); }
footer span { color: var(--accent); }

/* ─── Misc ─── */
.empty { color: var(--muted); font-size: 0.85rem; }

/* ─── Responsive ─── */

@media (max-width: 900px) {
  .p-row.split,
  .p-row.duo,
  .p-row.col {
    grid-template-columns: 1fr !important;
  }
  /* On mobile, thumbs panel height is no longer constrained by the main panel
     (they stack), so let rows be auto-sized again */
  .p-row.split > .thumbs,
  .p-row.duo   > .thumbs {
    height: auto;
    grid-template-rows: auto;
  }
  /* Give panels a fallback height on mobile when they have no aspect-ratio */
  .p-main:not([style*="aspect-ratio"]) { min-height: 260px; }
  .thumbs.stack {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }
  .thumbs.stack .thumb:first-child { grid-row: span 1; }
  .contact-wrap { grid-template-columns: 1fr; gap: 40px; }
}

@media (max-width: 768px) {
  .container { padding: 0 20px; }
  .nav-inner { justify-content: flex-start; }
  .nav-links {
    position: fixed; top: 0; right: -100%; width: 240px; height: 100vh;
    background: var(--bg-card); flex-direction: column;
    padding: 80px 36px 40px; gap: 28px;
    transition: var(--transition); border-left: 1px solid var(--border);
    align-items: flex-start; z-index: 999;
  }
  .nav-links.open { right: 0; }
  .dropdown { position: static; transform: none; opacity: 1; visibility: visible; pointer-events: auto; background: transparent; border: none; padding: 8px 0 0 16px; min-width: auto; display: none; }
  .dropdown-li:hover .dropdown { display: none; }
  .dropdown-li.dropdown-open .dropdown { display: block; }
  .dropdown a { padding: 8px 16px; }
  .menu-toggle { display: block; }
  .mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; display: none; }
  .mobile-overlay.open { display: block; }
  .cat-btn { font-size: 0.72rem; }
  .cat-btn::before { width: 6px; height: 6px; }
  .cat-buttons { gap: 4px 20px; }
  .section { padding: 64px 0; }
  .project-detail { padding: 32px 20px; }
  .detail-inner h2 { font-size: 1.4rem; }
}
