:root {
  --bg: #f9f9f8;    /* pale sand, neutral */
  --text: #2f3331;  /* dark wet stone */
  --muted: #878885; /* dry rock grey */
  --line: #e5e5e2;
  --viewer-edge: #c6c6bf; /* behind an open photo: the page colour around it, deepening to this at the edges */
  --accent: #5d8752; /* soft moss green, a touch cool */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --sidebar: 300px;
  --gap: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-y: scroll; scrollbar-gutter: stable; } /* always keep the scrollbar so the page width never jumps between filters */
html:has(.lightbox.open) { overflow: hidden; } /* while a photo is open the page underneath can't scroll (the gutter keeps the width the same) */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Photos can't be dragged out, selected, or saved with a long press on phones (see script.js) */
img {
  display: block; width: 100%; height: auto;
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; background: none; border: 0; color: inherit; cursor: pointer; }
h2 { font-weight: 300; font-size: 40px; line-height: 1.1; margin-bottom: 20px; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  padding: 56px 40px;
  display: flex; flex-direction: column; gap: 56px;
  background: var(--bg);
  z-index: 50;
}
.logo { display: block; position: relative; isolation: isolate; width: fit-content; }
.logo span { display: block; font-size: 38px; line-height: 1; letter-spacing: 0.01em; }
/* The hand signature, faint, behind the name (the white PNG is used as a mask so it can take any colour) */
.logo::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: -14px; top: -26px; height: 104px; aspect-ratio: 1061 / 1001;
  background: var(--muted); opacity: 0.22;
  -webkit-mask: url(images/signature.png) center / contain no-repeat;
          mask: url(images/signature.png) center / contain no-repeat;
}
/* A single green rake stroke under the name, as long as the WORK label below it */
.logo-line { display: block; width: 43px; height: 1.5px; margin-top: 16px; background: var(--accent); }
.menu-toggle { display: none; width: 28px; height: 20px; position: relative; }
.menu-toggle span { position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor; transition: transform 0.3s; }
.menu-toggle span:first-child { top: 5px; }
.menu-toggle span:last-child { bottom: 5px; }

.nav { display: flex; flex-direction: column; gap: 32px; }
.nav-group { display: flex; flex-direction: column; gap: 6px; }
.nav-label {
  font-family: var(--sans); font-size: 12.1px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text); margin-bottom: 6px;
}
/* The open section's word grows 10%. It grows its real text size (not a stretch) so it stays
   crisp the whole way and doesn't twitch when it comes to rest; the line height stays fixed
   so the words below don't move */
.nav a { --size: 26px; position: relative; font-size: var(--size); line-height: calc(var(--size) * 1.25); width: fit-content; transition: color 0.2s, font-size 0.35s ease; }
.nav a:hover { color: var(--muted); }
.nav .filter { color: var(--muted); }
.nav .filter:hover { color: var(--text); }
.nav a.active, .nav a.active:hover { font-size: calc(var(--size) * 1.1); color: var(--accent); }
/* Underline that slides out under the selected section */
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 1px; height: 1px;
  background: var(--muted); transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.nav a:hover::after { transform: scaleX(1); }
.nav a.active::after { transform: scaleX(1); background: var(--accent); }
/* While About or Contact is on screen, the photo filter steps back */
.nav.on-section .filter.active { font-size: var(--size); color: var(--muted); }
.nav.on-section .filter.active::after { transform: scaleX(0); }

.socials { display: flex; gap: 18px; margin-top: auto; }
.socials svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.socials .dot { fill: currentColor; stroke: none; }
.socials a { color: var(--accent); transition: opacity 0.2s; }
.socials a:hover { opacity: 0.6; }

/* Main column */
main { margin-left: var(--sidebar); padding: 56px 40px 0; max-width: calc(var(--sidebar) + 1320px); }

/* Photos sit side by side in rows of equal height. Each photo's width follows its own
   shape (--ar = width / height, read from the image by script.js), so any mix of
   3:4, 4:3, 3:2 and 16:9 fills each row edge to edge. --row is the rough row height. */
.feed { --row: clamp(240px, 46vh, 540px); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); max-width: 1240px; }
/* Limits on how far a photo stretches (on computers; phones show one photo per row anyway).
   No photo grows taller than 90% of the screen, and a vertical photo (.tall, set by
   script.js) only to 1.8 times the usual row height. So a vertical photo left alone in a
   row (say, beside a wide panorama) stays a sensible size, centred, while landscapes still
   reach edge to edge */
@media (min-width: 801px) {
  .feed figure { max-width: calc(90vh * var(--ar, 1.5)); }
  .feed figure.tall { max-width: calc(var(--row) * var(--ar) * 1.8); }
}
.feed::after { content: ""; flex-grow: 999; } /* keeps the last row from stretching (script.js sizes it) */
.feed figure {
  position: relative; cursor: zoom-in; background: var(--line);
  flex: var(--ar, 1.5) 1 calc(var(--row) * var(--ar, 1.5)); aspect-ratio: var(--ar, 1.5);
  opacity: 0; transition: opacity 0.9s ease, transform 0.35s ease;
}
.feed figure img { height: 100%; object-fit: cover; }
.feed figure.visible { opacity: 1; }
.feed figure.hidden { display: none; }
.feed figure:hover { transform: scale(1.008); z-index: 1; }
.feed figure.landing { transform: none; transition: none; } /* holds still while the open photo returns */
/* Rake line: a soft hand-drawn line raked under the photo on hover (drawn by script.js) */
.rake-line {
  position: absolute; pointer-events: none; overflow: visible;
  fill: none; stroke: var(--muted); stroke-opacity: 0.75; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round;
  transition: opacity 0.4s ease-in;
}
.rake-line path { transition: stroke-dashoffset 1s cubic-bezier(0.45, 0.05, 0.25, 1); }
@media (prefers-reduced-motion: reduce) { .rake-line path { transition: none; } }
.feed figcaption {
  position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; background: var(--bg);
  font-family: var(--sans); font-size: 12px; color: var(--text); letter-spacing: 0.02em;
  opacity: 0; transition: opacity 0.3s;
}
.feed figure:hover figcaption { opacity: 1; }
.feed figcaption .ratio { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed figcaption .ratio:not(:first-child) { margin-left: 10px; }

/* Only one page shows at a time (script.js hides the others), and empty menu groups hide too */
[hidden] { display: none !important; }

/* Switching sections: a quick fade out, then the new content fades in a little slower,
   rising 6px and coming into focus, on the same 0.3s curve as the menu underline */
main { transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out), filter 0.3s var(--ease-out); }
main.is-leaving { opacity: 0; transition: opacity 0.15s ease-in; }
main.is-entering { opacity: 0; transform: translateY(6px); filter: blur(3px); transition: none; }

.about p, .contact p { max-width: 48ch; margin-bottom: 14px; color: var(--text); }
/* About: a quiet clearing. One photo, a few words, and plenty of open space around them */
.about {
  display: flex; flex-direction: column; align-items: center; gap: 56px;
  max-width: 920px; margin-inline: auto; padding: 10vh 0 6vh; text-align: center;
}
.about img { width: min(340px, 100%); }
.about h2 {
  font-family: var(--sans); font-size: 12.1px; letter-spacing: 0.18em; text-transform: uppercase;
  line-height: 1; margin-bottom: 28px;
}
.about p { max-width: 36ch; margin-inline: auto; }
.about p + p { margin-top: 32px; font-family: var(--sans); font-size: 15.5px; letter-spacing: 0.02em; color: #4a4d4a; }

.contact { max-width: 920px; }
.email { font-size: 28px; font-style: italic; border-bottom: 1px solid var(--line); transition: border-color 0.3s; }
.email:hover { border-color: var(--text); }

.site-footer { max-width: 920px; margin-top: 96px; padding: 24px 0 40px; font-family: var(--sans); font-size: 12px; color: var(--muted); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  visibility: hidden; pointer-events: none;
}
/* The page colour covers the grid at once, so the photos behind never show fading out. Then,
   slowly, the edges deepen: the page colour stays around the photo and darkens outwards */
.lightbox.open { background: var(--bg); visibility: visible; pointer-events: auto; }
.lightbox::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, var(--bg) 50%, var(--viewer-edge) 100%);
}
.lightbox.open::before { opacity: 1; transition: opacity 1.2s ease 0.1s; }
/* While closing, only the photo shows, shrinking back over the grid (script.js ends it on landing) */
.lightbox.closing { visibility: visible; }
/* The photo grows out of its spot in the grid (script.js sets the starting transform) */
.lightbox img {
  width: auto; max-width: 88vw; max-height: 82vh; object-fit: contain;
  transform-origin: 0 0; cursor: zoom-in;
  transition: transform 0.4s var(--ease-out), translate 0.4s var(--ease-out), scale 0.4s var(--ease-out), opacity 0.25s;
}
/* Clicking the open photo brings it a third closer, around the spot clicked (script.js) */
/* Zoomed: press and drag to move around it (follows the pointer exactly while dragging) */
.lightbox img.zoomed { cursor: grab; touch-action: none; }
.lightbox img.panning { cursor: grabbing; transition: none; }
/* The label settles in just after the photo; on close it goes at once with the background,
   so the photo shrinks back into the grid alone */
.lb-label {
  position: absolute; left: 32px; bottom: 26px; pointer-events: none; opacity: 0;
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.02em; line-height: 1.6;
}
.lightbox.open .lb-label { opacity: 1; transition: opacity 0.6s ease 0.2s; }
.lb-label span { display: block; }
.lb-label span:first-child { color: var(--text); }
.lb-label span:last-child { color: var(--muted); white-space: pre; font-variant-numeric: tabular-nums; }
.lightbox button { position: absolute; color: var(--text); font-size: 40px; font-weight: 300; padding: 16px; opacity: 0; transition: opacity 0.3s; }
.lightbox.open button { opacity: 0.5; }
/* Once the mouse rests, the controls and cursor fade slowly away (script.js), leaving the photo alone */
.lightbox.open.resting, .lightbox.open.resting img { cursor: none; }
.lightbox.open.resting button { opacity: 0; transition: opacity 1.2s ease; }
.lightbox.open button:hover { opacity: 1; cursor: pointer; }
.lb-close { top: 8px; right: 16px; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }

/* Smaller laptops */
@media (max-width: 1100px) {
  :root { --sidebar: 250px; }
  .sidebar { padding: 40px 28px; }
  .logo span { font-size: 32px; }
  .nav a { --size: 22px; }
  main { padding: 40px 28px 0; }
}

/* Phones and tablets: sidebar becomes a top bar */
@media (max-width: 800px) {
  .sidebar {
    position: sticky; bottom: auto; width: auto;
    padding: 16px; gap: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; }
  .logo span { font-size: 26px; }
  .logo-line { margin-top: 10px; }
  .logo::before { height: 66px; top: -14px; left: -8px; }
  .menu-toggle { display: block; }
  .nav, .socials { display: none; }
  .sidebar.menu-open { height: 100vh; }
  .sidebar.menu-open .nav { display: flex; padding: 40px 0 0; }
  .sidebar.menu-open .socials { display: flex; }
  .sidebar.menu-open .menu-toggle span:first-child { transform: translateY(4px) rotate(45deg); }
  .sidebar.menu-open .menu-toggle span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .nav a { --size: 30px; }

  main { margin-left: 0; padding: 16px 16px 0; }
  .feed { --row: 220px; gap: 8px; }
  .feed figcaption { display: none; }
  .about { gap: 36px; padding: 6vh 0 2vh; }
  .about img { width: min(280px, 100%); }
  .contact { padding-top: 16px; }
  .email { font-size: 22px; word-break: break-all; }
}
