/* ===========================================================
   Design tokens
   =========================================================== */
:root {
  --bg: #fafaf8;
  --ink: #111111;
  --muted: #6b6b6b;
  --line: #e5e3de;
  --surface: #ffffff;
  --header-h: 76px;
  --gap: 4px;
  --max-width: 1400px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0 0 40px;
  padding: 0 5vw;
}
.section-index {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.section-heading h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ===========================================================
   Header
   =========================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(250, 250, 248, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
}

.logo-image {
  display: block;
  height: calc(var(--header-h) * 0.5);
  max-height: 40px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  position: relative;
  padding: 4px 0;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1.5px;
  background: currentColor;
  transition: width 0.3s var(--ease);
}

.nav-links a:hover::after { width: 100%; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ink);
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===========================================================
   Hero
   =========================================================== */
.hero {
  position: relative;
  min-height: calc(90vh - var(--header-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 4vw 5vw;
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.2) 45%, rgba(0, 0, 0, 0.55) 100%);
}

.hero-heading {
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  max-width: 18ch;
}

.hero-subheading {
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  color: var(--muted);
  max-width: 42ch;
  margin: 0 0 40px;
}

.hero-scroll {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  width: fit-content;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 3px;
}

/* When a hero image is set, the text sits on top of it, so it switches to
   light text with a dark gradient scrim behind it for legibility. */
.hero-has-image .hero-heading,
.hero-has-image .hero-subheading,
.hero-has-image .hero-scroll {
  color: #fff;
}

.hero-has-image .hero-subheading {
  color: rgba(255, 255, 255, 0.85);
}

.hero-has-image .hero-scroll {
  border-bottom-color: #fff;
}

/* ===========================================================
   Square grid
   =========================================================== */
.work {
  padding: 8vw 0 10vw;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  padding: 0 var(--gap);
}

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

.grid-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--accent, #1a1a1a);
  display: block;
}

.tile-featured {
  grid-column: span 2;
  grid-row: span 2;
}

.grid-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}

.grid-tile:hover img { transform: scale(1.06); }

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.72) 100%);
  color: #fff;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

.grid-tile:hover .tile-overlay,
.grid-tile:focus-visible .tile-overlay {
  opacity: 1;
  transform: translateY(0);
}

.tile-category {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.tile-title {
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  font-weight: 600;
}

.tile-featured .tile-title { font-size: clamp(1.3rem, 2.2vw, 1.9rem); }

.empty-state {
  padding: 0 5vw;
  color: var(--muted);
}

/* Always show overlay on touch devices since :hover is unreliable */
@media (hover: none) {
  .tile-overlay {
    opacity: 1;
    transform: none;
    background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.75) 100%);
  }
}

/* ===========================================================
   About / Contact
   =========================================================== */
.about, .contact {
  padding: 6vw 5vw;
  max-width: var(--max-width);
  margin: 0 auto;
}

.about-body, .contact-body {
  max-width: 62ch;
  padding: 0 5vw;
  color: var(--muted);
  font-size: 1.05rem;
}

.about-body p, .contact-body { margin: 0 0 20px; }

.contact {
  border-top: 1px solid var(--line);
}

.contact-email {
  display: inline-block;
  margin: 12px 0 0 5vw;
  padding-left: calc(0px);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 700;
  border-bottom: 2px solid var(--ink);
}

/* ===========================================================
   Project detail page
   =========================================================== */
.project-detail {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 6vw 5vw 4vw;
}

.back-link {
  display: inline-block;
  margin-bottom: 32px;
  font-size: 0.9rem;
  color: var(--muted);
}

.project-detail-header h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  margin: 8px 0 16px;
  letter-spacing: -0.01em;
}

.project-summary {
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.15rem;
}

.project-hero-image {
  margin: 40px 0;
  background: var(--accent, #1a1a1a);
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.project-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-description {
  max-width: 68ch;
  font-size: 1.05rem;
}

.project-description p { margin: 0 0 20px; }

.more-work {
  padding: 4vw 0 8vw;
  border-top: 1px solid var(--line);
  margin-top: 4vw;
}

/* ===========================================================
   Footer
   =========================================================== */
.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 5vw;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-social {
  display: flex;
  gap: 20px;
}

.footer-social a:hover { color: var(--ink); }

.back-to-top { font-weight: 600; }

/* ===========================================================
   404
   =========================================================== */
.not-found {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.not-found h1 { font-size: 5rem; margin: 0; }

/* ===========================================================
   Responsive
   =========================================================== */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid-small { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  :root { --header-h: 64px; }

  .nav-toggle { display: flex; }

  .nav-links {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s var(--ease);
  }

  .nav-links.open { max-height: 320px; }

  .nav-links a {
    padding: 16px 5vw;
    border-bottom: 1px solid var(--line);
    width: 100%;
  }

  .nav-links a::after { display: none; }

  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid-small { grid-template-columns: repeat(2, 1fr); }
  .tile-featured { grid-column: span 2; grid-row: span 2; }

  .about-body, .contact-body { padding: 0; }
  .contact-email { margin-left: 0; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(1, 1fr); }
  .grid-small { grid-template-columns: repeat(1, 1fr); }
  .tile-featured { grid-column: span 1; grid-row: span 1; }
}
