/* ─── Custom properties ─────────────────────────────────────────────────────── */

:root {
  /* Palette */
  --color-bg:       #0E1723;
  --color-surface:  #162234;
  --color-headline: #E8E2D6;
  --color-body:     #B8B0A4;
  --color-meta:     #8B857B;
  --color-border:   #2A3445;
  --color-low:      #5A554E;
  --color-accent:   #FBCB1E;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Source Sans 3', system-ui, sans-serif;

  /* Layout */
  --max-width:    1280px;
  --side-pad:     clamp(24px, 5vw, 80px);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

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

img, picture { display: block; max-width: 100%; }

a { color: inherit; }

ul { list-style: none; margin: 0; padding: 0; }

h1, h2, h3, p { margin: 0; }

/* ─── Page load fade-in ─────────────────────────────────────────────────────── */

@keyframes body-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

body {
  animation: body-fade-in 400ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

/* ─── Typography tokens ─────────────────────────────────────────────────────── */

.display-headline {
  font-family: var(--font-display);
  font-weight: 300;
  font-variation-settings: 'opsz' 144, 'SOFT' 50, 'WONK' 0;
  font-size: clamp(2.4rem, 4.5vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--color-headline);
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* ─── Navigation ────────────────────────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--color-border);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px var(--side-pad);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: 'opsz' 36, 'SOFT' 30, 'WONK' 1;
  font-size: 1.1rem;
  color: var(--color-headline);
  text-decoration: none;
  transition: color 200ms ease;
}

.wordmark:hover {
  color: var(--color-accent);
}

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

.site-nav ul a {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: 'opsz' 36, 'SOFT' 30, 'WONK' 1;
  font-size: 1.0625rem;
  color: var(--color-meta);
  text-decoration: none;
  transition: color 200ms ease;
}

.site-nav ul a:hover {
  color: var(--color-accent);
}

.site-nav ul a.nav-active {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .wordmark,
  .site-nav ul a {
    transition: none;
  }
}

/* ─── Home page ─────────────────────────────────────────────────────────────── */

.home {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 72px var(--side-pad) 100px;
}

.home-intro {
  margin-bottom: 64px;
}

.home-intro .eyebrow {
  margin-bottom: 18px;
}

.home-intro .display-headline {
  max-width: 62ch;
}

.home-body {
  display: grid;
  grid-template-columns: 46% 1fr;
  gap: 56px;
  align-items: start;
}

.home-body--no-portrait {
  grid-template-columns: 1fr;
}

.home-body--no-portrait .body-col {
  max-width: 62ch;
}

.portrait-col {
  align-self: start;
  margin-top: 0;
}

.portrait-col picture,
.portrait-col img {
  width: 100%;
  height: auto;
  display: block;
}

.portrait-caption {
  font-family: var(--font-display);
  font-style: italic;
  font-variation-settings: 'opsz' 36;
  font-weight: 400;
  font-size: 13px;
  color: var(--color-meta);
  margin-top: 12px;
}

.body-col {
  max-width: 62ch;
}

.body-col p {
  margin-bottom: 1.4em;
  color: var(--color-body);
}

.body-col p:last-child { margin-bottom: 0; }

.body-col em   { font-style: italic; }
.body-col strong { font-weight: 600; color: var(--color-headline); }

.body-col a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* ─── Projects listing ──────────────────────────────────────────────────────── */

.projects-listing {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 72px var(--side-pad) 100px;
}

.projects-header {
  margin-bottom: 56px;
}

.projects-header .eyebrow {
  margin-bottom: 16px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
}

.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.project-card-thumb {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--color-surface);
  margin-bottom: 14px;
}

.project-card-thumb picture {
  width: 100%;
  height: 100%;
  display: block;
}

.project-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: filter 200ms ease;
}

.project-card:hover .project-card-thumb img {
  filter: brightness(1.05);
}

.project-card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: 'opsz' 36, 'SOFT' 30, 'WONK' 1;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--color-headline);
  margin-bottom: 5px;
  transition: color 200ms ease;
}

.project-card:hover .project-card-title {
  color: var(--color-accent);
}

.project-card-subtitle {
  font-size: 13px;
  color: var(--color-meta);
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .project-card-thumb img,
  .project-card-title {
    transition: none;
  }
}

/* ─── Project detail ────────────────────────────────────────────────────────── */

.project-detail {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 72px var(--side-pad) 100px;
}

.project-detail .eyebrow {
  margin-bottom: 18px;
}

.project-detail .display-headline {
  margin-bottom: 48px;
}

.project-body {
  max-width: 66%;
  margin-bottom: 72px;
}

.project-body p {
  margin-bottom: 1.4em;
  color: var(--color-body);
}

.project-body p:last-child { margin-bottom: 0; }

.project-body em     { font-style: italic; }
.project-body strong { font-weight: 600; color: var(--color-headline); }

.project-body a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Masonry gallery — CSS columns */
.project-gallery {
  column-count: 3;
  column-gap: 16px;
}

.project-gallery figure {
  break-inside: avoid;
  margin: 0 0 16px;
  padding: 0;
}

.project-gallery figure picture {
  display: block;
  width: 100%;
}

.project-gallery figure img {
  width: 100%;
  height: auto;
}

/* Scroll-reveal — applied only when JS adds .is-visible */
@media (prefers-reduced-motion: no-preference) {
  .project-gallery figure {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
  }

  .project-gallery figure.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

.back-link {
  display: inline-block;
  margin-top: 56px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--color-meta);
  text-decoration: none;
  transition: color 200ms ease;
}

.back-link:hover { color: var(--color-body); }

@media (prefers-reduced-motion: reduce) {
  .back-link { transition: none; }
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--color-border);
}

.site-footer > * {
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--side-pad);
  padding-right: var(--side-pad);
}

.site-footer .eyebrow {
  padding-top: 64px;
  margin-bottom: 20px;
}

.footer-links {
  display: flex;
  gap: 40px;
  padding-bottom: 72px;
}

.footer-links a {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: 'opsz' 36, 'SOFT' 30, 'WONK' 1;
  font-size: 1.0625rem;
  color: var(--color-headline);
  text-decoration: none;
  transition: color 200ms ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .footer-links a { transition: none; }
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 1024px) {
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-gallery {
    column-count: 2;
  }

  .home-body {
    grid-template-columns: 42% 1fr;
    gap: 40px;
  }
}

/* Mobile */
@media (max-width: 639px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .project-gallery {
    column-count: 1;
  }

  .home-body {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .home-intro .display-headline {
    max-width: none;
  }

  .site-nav ul {
    gap: 20px;
  }

  .project-body {
    max-width: none;
  }
}
