/* ============================================================
   Fotograf Peter Westrup — Shared Stylesheet v2
   Palette: --bg #f0f0f0  --ink #181818  --mid #888  --green #5c7c38
   Fonts: Playfair Display (nav, captions, headings) + Montserrat (body)
   ============================================================ */

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

:root {
  --bg:     #f0f0f0;
  --ink:    #181818;
  --mid:    #444444;
  --green:  #5c7c38;   /* active nav colour — edit this to adjust */
  --font-display: 'Cormorant Garamond', serif;
  --border: rgba(24,24,24,0.08);
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Montserrat', sans-serif;
  font-weight: 300;
  letter-spacing: 0.02em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────────────── */
/* Matches archive.peterwestrup.se exactly: 28px top, 32px sides */
header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 32px 0;
}

.site-logo { display: block; flex-shrink: 0; }
.site-logo img {
  height: 120px;       /* same as archive page */
  width: auto;
  display: block;
  opacity: 0.85;       /* same as archive page */
  transition: opacity 0.2s;
}
.site-logo:hover img { opacity: 1; }

/* ── NAV ─────────────────────────────────────────────────── */
nav {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  padding-top: 6px;    /* matches archive .header-right padding-top */
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav a {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  color: var(--mid);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

nav a:hover           { color: var(--ink); }
nav a[aria-current]   { color: var(--green); }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 1px;
  background: var(--ink);
}

@media (max-width: 740px) {
  /* Header scrolls away normally */
  header { padding: 16px 20px 12px; flex-wrap: wrap; }
  .site-logo img { height: 64px; }

  /* Hamburger: fixed, floats over content */
  .nav-toggle {
    display: flex;
    position: fixed;
    top: 16px;
    right: 18px;
    z-index: 400;
    padding: 10px;
    background: none;
  }
  .nav-toggle span {
    width: 24px;
    height: 2px; /* thicker strokes */
  }

  /* Nav: fixed full-screen overlay when open */
  nav {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 350;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: var(--bg);
  }
  nav.is-open { display: flex; }
  nav a { padding: 16px 0; font-size: 1.6rem; width: 100%; text-align: center; }
}

/* ── MAIN ────────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 32px 32px 100px;  /* side padding matches header */
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 740px) { main { padding: 24px 20px 64px; } }

/* ============================================================
   MOBILE OVERRIDES
   ============================================================ */
@media (max-width: 740px) {

  /* Commissions cover grid: 2-column masonry */
  #main-grid {
    display: block;
    columns: 2;
    column-gap: 10px;
    margin-top: 20px;
  }
  #main-grid .masonry-item {
    break-inside: avoid;
    margin-bottom: 8px;
  }
  .masonry-caption { font-size: 0.62rem; margin-top: 3px; line-height: 1.3; }

  /* Detail view: full-width stacked, no lightbox */
  .detail-grid {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }
  .detail-item {
    cursor: default;
    width: 100%;
  }
  .detail-item img {
    height: auto !important;
    width: 100% !important;
  }

  /* Landscapes / observations: single column, full width, no lightbox */
  .photo-grid {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }
  .photo-item {
    width: 100%;
  }
  .photo-item img {
    height: auto !important;
    width: 100% !important;
  }

  /* About: bild centrerad, text vänsterställd */
  .about-layout {
    margin-left: 0 !important;
    text-align: left;
    justify-items: stretch;
  }
  .about-body { max-width: 100%; text-align: left; }
  .about-photo { display: flex; justify-content: center; }
  .about-photo img { margin: 0 auto; }
}

/* ── FOOTER ──────────────────────────────────────────────── */
footer {
  padding: 24px 36px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--mid);
  text-align: center;
}
footer a { color: var(--mid); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--ink); }

/* ── PAGE TITLE ──────────────────────────────────────────── */
.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-bottom: 36px;
  letter-spacing: 0.01em;
}

/* ── VISUALLY HIDDEN (accessible, not visible) ───────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── LOADING STATE ───────────────────────────────────────── */
#main-grid, #gallery {
  opacity: 0;
  transition: opacity 0.4s ease;
}
#main-grid.loaded, #gallery.loaded { opacity: 1; }

/* ============================================================
   MASONRY GRID (commissions cover, landscapes, observations)
   ============================================================ */
.masonry {
  columns: 3 260px;
  column-gap: 56px;
  margin-top: 44px;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 72px;   /* generous vertical space between items */
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.masonry-item img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity 0.3s;
  background: #d8d8d8;
}
.masonry-item:hover img { opacity: 0.82; }

/* ============================================================
   PHOTO ROW GRID (landscapes, observations)
   Same height, natural width, flows left-to-right
   ============================================================ */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 44px;
  justify-content: center;
}

.photo-item {
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.photo-item img {
  display: block;
  height: 420px;
  width: auto;
  transition: opacity 0.3s;
  background: #d8d8d8;
}

.photo-item:hover img { opacity: 0.82; }

@media (max-width: 740px) {
  .photo-grid { gap: 12px; }
  .photo-item img { height: 180px; }
}

/* Caption below each grid item — Playfair Display */
.masonry-caption {
  margin-top: 10px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--ink);
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.masonry-caption .caption-client {
  display: inline;
  font-size: inherit;
  color: inherit;
  font-style: normal;
}

/* ============================================================
   COMMISSION DETAIL VIEW
   (the grid of images within one commission)
   ============================================================ */
.detail-view { display: none; }
.detail-view.is-visible { display: block; }

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 28px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.82rem;
  color: var(--mid);
  padding: 0;
  transition: color 0.15s;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-back:hover { color: var(--ink); }
.btn-back::before { content: '←'; font-style: normal; }

.detail-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.detail-client-name {
  display: none;
}

/* Detail image grid: same height, natural width (no crop) */
.detail-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 28px;
  justify-content: center;
}

.detail-item {
  flex: 0 0 auto;
  cursor: pointer;
}

.detail-item img {
  display: block;
  height: 420px;
  width: auto;
  transition: opacity 0.25s;
  background: #d8d8d8;
}
.detail-item:hover img { opacity: 0.82; }

/* ============================================================
   LIGHTBOX — light background
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lightbox.is-open { display: flex; }

.lb-img {
  max-width: min(90vw, 1200px);
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.35s;
}
.lb-img.loaded { opacity: 1; }

.lb-caption-text {
  margin-top: 16px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 300;
  color: var(--mid);
  letter-spacing: 0.02em;
  min-height: 1.4em;
}

/* Nav buttons */
.lb-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(24,24,24,0.3);
  font-family: 'Cormorant Garamond', serif;
  font-size: 3rem;
  font-weight: 300;
  cursor: pointer;
  padding: 20px 28px;
  transition: color 0.15s;
  line-height: 1;
  z-index: 1001;
}
.lb-btn:hover { color: var(--ink); }
.lb-prev { left: 0; }
.lb-next { right: 0; }

.lb-close {
  position: fixed;
  top: 22px;
  right: 28px;
  background: none;
  border: none;
  color: rgba(24,24,24,0.3);
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 300;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  transition: color 0.15s;
  z-index: 1001;
}
.lb-close:hover { color: var(--ink); }

.lb-counter {
  position: fixed;
  bottom: 22px;
  right: 28px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.6rem;
  color: var(--mid);
  letter-spacing: 0.1em;
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.about-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 72px;
  align-items: start;
  max-width: 900px;
  margin-top: 44px;
  margin-left: 80px;
}

.about-body {
  max-width: 480px;
}

.about-photo img {
  display: block;
  width: 280px;
  height: auto;
}

@media (max-width: 700px) {
  .about-layout {
    grid-template-columns: 1fr;
    gap: 36px;
  }
  .about-photo { order: -1; }
  .about-photo img { width: 100%; max-width: 320px; }
}
.about-body h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 32px;
  letter-spacing: 0.01em;
}
.about-body p {
  font-size: 0.88rem;
  line-height: 1.85;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
  color: var(--ink);
}
.about-body p:last-child { margin-bottom: 0; }
.about-contact-link {
  display: block;
  margin-top: 20px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.82rem;
  color: var(--ink);
  text-decoration: none;
}
.about-contact-link:hover { color: var(--mid); }
